Remove debug keys for changing class, spawning items, adding xp, and opening the consumables window. Fix XP progress bar so it doesn't loop the sound if the menu is closed early. Pause menu now pauses the game during gameplay. Release Build 7895.

This commit is contained in:
sigonasr2 2024-03-03 22:36:37 -06:00
parent 9a6f710201
commit 93081fe7f0
12 changed files with 43 additions and 58 deletions

View File

@ -411,34 +411,9 @@ void AiL::HandleUserInput(float fElapsedTime){
bool heldDownMovementKey=false; //Is true when a movement key has been held down.
if(KEY_MENU.Released()){
Audio::UpdateBGMVolume(); //When we open the pause menu, it forces the bgm volume to be halved. So we notify the engine that this is happening.
PauseGame();
Menu::OpenMenu(MenuType::PAUSE);
}
if(GetMouseWheel()>0){
switch(player->GetClass()){
case WARRIOR:{
ChangePlayerClass(RANGER);
}break;
case RANGER:{
ChangePlayerClass(WIZARD);
}break;
case WIZARD:{
ChangePlayerClass(WARRIOR);
}break;
}
}
if(GetMouseWheel()<0){
switch(player->GetClass()){
case WARRIOR:{
ChangePlayerClass(WIZARD);
}break;
case RANGER:{
ChangePlayerClass(WARRIOR);
}break;
case WIZARD:{
ChangePlayerClass(RANGER);
}break;
}
}
if(player->GetVelocity()==vf2d{0,0}&&player->CanMove()){
auto GetPlayerStaircaseDirection=[&](){
for(LayerTag&layer:MAP_DATA[GetCurrentLevel()].LayerData){
@ -639,16 +614,6 @@ void AiL::HandleUserInput(float fElapsedTime){
}
}
}
if(GetKey(I).bPressed){
Menu::OpenMenu(INVENTORY_CONSUMABLES);
}
if(GetKey(O).bPressed){
ItemDrop::SpawnItem(&ITEM_DATA.at("Green Slime Remains"),player->GetPos(),player->OnUpperLevel());
}
if(GetKey(L).bHeld){
game->GetPlayer()->AddXP(1);
}
}
void AiL::UpdateCamera(float fElapsedTime){
@ -3007,14 +2972,12 @@ void AiL::ReduceBossEncounterMobCount(){
}
void AiL::RenderMenu(){
if(!GamePaused()&&Menu::stack.size()>0){
if(Menu::stack.size()>0){
if(Menu::alreadyClicked){ //Do not run a click event for this round.
Menu::alreadyClicked=false;
}else{
Menu::stack.back()->Update(this);
}
}
if(Menu::stack.size()>0){
for(Menu*menu:Menu::stack){
if(menu->cover)FillRectDecal({0,0},WINDOW_SIZE,{0,0,0,uint8_t(255*0.4)});
menu->Draw(this);

View File

@ -301,7 +301,7 @@ void Audio::UpdateLoop(){
float channelVol=track.GetVolume(Self().currentAudioEvent,Self().currentLoopIndex);
Self().prevVolumes.push_back(channelVol);
Self().targetVolumes.push_back(channelVol);
Engine().SetVolume(trackID,Self().GetCalculatedVolume(channelVol));
Engine().SetVolume(trackID,Self().GetCalculatedBGMVolume(channelVol));
#pragma region Handle threaded loop indexing
Self().currentLoopIndex++;
if(Self().currentLoopIndex>=track.GetChannelIDs().size()){
@ -341,7 +341,7 @@ void Audio::Update(){
Self().fadeToTargetVolumeTime=std::max(0.f,Self().fadeToTargetVolumeTime-game->GetElapsedTime());
for(int counter=0;float&vol:Self().prevVolumes){
const BGM&currentBgm=Self().bgm[Self().currentBGM];
Engine().SetVolume(currentBgm.GetChannelIDs()[counter],util::lerp(vol,Self().GetCalculatedVolume(Self().targetVolumes[counter]),1-(Self().fadeToTargetVolumeTime/currentBgm.GetFadeTime())));
Engine().SetVolume(currentBgm.GetChannelIDs()[counter],util::lerp(vol,Self().GetCalculatedBGMVolume(Self().targetVolumes[counter]),1-(Self().fadeToTargetVolumeTime/currentBgm.GetFadeTime())));
counter++;
}
}
@ -379,12 +379,12 @@ void Audio::UpdateBGMVolume(){
BGM&track=Self().bgm[Self().playParams.sound];
for(int channelListIndex=0;int trackID:track.GetChannelIDs()){
float channelVol=track.GetVolume(Self().currentAudioEvent,channelListIndex);
Engine().SetVolume(trackID,Self().GetCalculatedVolume(channelVol));
Engine().SetVolume(trackID,Self().GetCalculatedBGMVolume(channelVol));
channelListIndex++;
}
EnvironmentalAudio::UpdateEnvironmentalAudio();
}
float Audio::GetCalculatedVolume(const float channelVol){
float Audio::GetCalculatedBGMVolume(const float channelVol){
float pauseMult=1.f;
for(Menu*menus:Menu::stack){
if(menus==Menu::menus[MenuType::PAUSE]){
@ -394,6 +394,9 @@ float Audio::GetCalculatedVolume(const float channelVol){
}
return channelVol*GetBGMVolume()*GetMuteMult()*pauseMult;
}
float Audio::GetCalculatedSFXVolume(const float vol){
return vol*GetSFXVolume()*GetMuteMult();
}
float Audio::GetMuteMult(){
if(muted)return 0.f;
return 1.f;

View File

@ -79,6 +79,8 @@ public:
static float GetMuteMult();
//This will get a prepared BGM loop iteration count which is useful for loading stages.
static int GetPrepareBGMLoopIterations(std::string_view sound);
static float GetCalculatedBGMVolume(const float channelVol);
static float GetCalculatedSFXVolume(const float vol);
private:
bool trackLoadStarted=false;
bool trackLoadComplete=false;
@ -87,7 +89,6 @@ private:
int currentLoopIndex=0;
//Set to false by PrepareBGM(). If PlayBGM() is called instead, it will set the state of this variable to true, such that the loading is performed in Audio::Update()!
bool immediatelyLoadAudio=false;
float GetCalculatedVolume(const float channelVol);
struct BGMPlayParams{
std::string sound;

View File

@ -44,6 +44,7 @@ All rights reserved.
#include "State_OverworldMap.h"
#include "ProgressBar.h"
#include "SoundEffect.h"
#include "State_LevelComplete.h"
INCLUDE_game
@ -72,6 +73,7 @@ void Menu::InitializeLevelCompleteWindow(){
Unlock::UnlockArea(State_OverworldMap::GetCurrentConnectionPoint().map);
Merchant::RandomizeTravelingMerchant();
}
State_LevelComplete::TurnOffXPSound();
GameState::ChangeState(States::OVERWORLD_MAP,0.25f);
return true;
};
@ -79,6 +81,7 @@ void Menu::InitializeLevelCompleteWindow(){
auto nextButtonAction=[](MenuFuncData data){
Unlock::UnlockArea(State_OverworldMap::GetCurrentConnectionPoint().map);
Merchant::RandomizeTravelingMerchant();
State_LevelComplete::TurnOffXPSound();
GameState::ChangeState(States::GAME_HUB,0.25f);
return true;
};

View File

@ -53,6 +53,7 @@ void Menu::InitializePauseWindow(){
pauseWindow->ADD("Resume Button",MenuComponent)(geom2d::rect<float>{{6.f,0.f},{84.f,24.f}},"Resume",[](MenuFuncData data){
Menu::CloseMenu();
game->ResumeGame();
Audio::UpdateBGMVolume(); //When we open the pause menu, it forces the bgm volume to be halved. So we notify the engine that this is happening.
return true;
},ButtonAttr::FIT_TO_LABEL)END;
@ -78,6 +79,7 @@ void Menu::InitializePauseWindow(){
}else{
Component<MenuComponent>(LEVEL_COMPLETE,"Next Button")->Disable();
}
game->ResumeGame();
GameState::ChangeState(States::LEVEL_COMPLETE,0.4f);
return true;
},ButtonAttr::FIT_TO_LABEL)END;
@ -89,10 +91,10 @@ void Menu::InitializePauseWindow(){
{ //Button Key
{game->KEY_SCROLL,{"Navigate",[](MenuType type){}}},
{game->KEY_BACK,{"Resume",[](MenuType type){
Menu::CloseMenu();
Component<MenuComponent>(type,"Resume Button")->Click();
}}},
{game->KEY_MENU,{"Resume",[](MenuType type){
Menu::CloseMenu();
Component<MenuComponent>(type,"Resume Button")->Click();
}}},
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
}

View File

@ -98,7 +98,7 @@ void SoundEffect::PlaySFX(const std::string_view eventName,const vf2d&pos){
float pitch=util::random(pitchDiff)+sfx.minPitch;
if(pos==CENTERED){
Audio::Engine().Play(operator""_SFX(sfx.filename.c_str(),sfx.filename.length()),sfx.vol*Audio::GetSFXVolume()*Audio::GetMuteMult(),0.0f,pitch);
Audio::Engine().Play(operator""_SFX(sfx.filename.c_str(),sfx.filename.length()),Audio::GetCalculatedSFXVolume(sfx.vol*Audio::GetSFXVolume()),0.0f,pitch);
}else{
const float soundActivationRange="Audio.Environmental Audio Activation Range"_F;

View File

@ -60,6 +60,8 @@ void State_LevelComplete::OnStateChange(GameState*prevState){
Component<ProgressBar>(MenuType::LEVEL_COMPLETE,"XP Bar")->ResetProgressBar(game->GetPlayer()->CurrentXP(),game->GetPlayer()->NextLevelXPRequired());
accumulatedXP=game->GetPlayer()->GetAccumulatedXP();
gainRate=(game->GetPlayer()->NextLevelXPRequired()*0.5f)/60.f;
float xpBonus=1.1f; //10% XP bonus for finishing a stage.
if(Component<MenuLabel>(LEVEL_COMPLETE,"Stage Complete Label")->GetLabel()!="Stage Summary"){ //If the label says stage summary, we didn't actually complete the level. Don't reward any stage items to the player.
for(const ItemMapData&data:game->GetCurrentMap().GetStageLoot()){
@ -99,12 +101,13 @@ void State_LevelComplete::OnUserUpdate(AiL*game){
}
}
lastXPGain-=game->GetElapsedTime();
if(accumulatedXP>0){
lastXPChangeTimer-=game->GetElapsedTime();
Audio::Engine().SetVolume(xpGainSound,0.6f);
if(lastXPChangeTimer<=0.f){
int incrementAmt=int(accumulatedXP/(1/"Interface.HUD XP Bar Tick Rate"_F))+1;
accumulatedXP-=incrementAmt;
Audio::Engine().SetVolume(xpGainSound,Audio::GetCalculatedSFXVolume(0.6f));
if(lastXPGain<=0.f){
int incrementAmt=gainRate*game->GetElapsedTime()+1;
accumulatedXP=std::max(0,accumulatedXP-incrementAmt);
auto progressBar=Component<ProgressBar>(MenuType::LEVEL_COMPLETE,"XP Bar");
progressBar->UpdateProgressBar(progressBar->GetCurrentProgress()+incrementAmt);
if(progressBar->GetCurrentProgress()>=progressBar->GetFinalProgress()){
@ -113,7 +116,7 @@ void State_LevelComplete::OnUserUpdate(AiL*game){
progressBar->ResetProgressBar(progressBar->GetCurrentProgress()-progressBar->GetFinalProgress(),game->GetPlayer()->NextLevelXPRequired());
SoundEffect::PlaySFX("Level Up",SoundEffect::CENTERED);
}
lastXPChangeTimer="Interface.HUD XP Bar Tick Rate"_F;
lastXPGain=1/60.f;
}
}else{
Audio::Engine().SetVolume(xpGainSound,0.f);
@ -127,4 +130,8 @@ void State_LevelComplete::DrawOverlay(AiL*game){
game->DrawShadowStringPropDecal(levelUpTextPos+vf2d{8.f,0.f},"Level Up!",YELLOW);
game->DrawRotatedDecal(levelUpTextPos+vf2d{2.f,1.f},GFX["overworld_arrow.png"].Decal(),-PI/2,GFX["overworld_arrow.png"].Sprite()->Size(),{1.f,1.f},BLACK);
game->DrawRotatedDecal(levelUpTextPos+vf2d{2.f,0.f},GFX["overworld_arrow.png"].Decal(),-PI/2,GFX["overworld_arrow.png"].Sprite()->Size(),{1.f,1.f},YELLOW);
}
void State_LevelComplete::TurnOffXPSound(){
Audio::Engine().SetVolume(((State_LevelComplete*)(GameState::states[States::LEVEL_COMPLETE]))->xpGainSound,0.f);
}

View File

@ -40,13 +40,16 @@ All rights reserved.
class State_LevelComplete:public GameState{
int accumulatedXP=0;
float lastXPChangeTimer=0.f;
vf2d levelUpTextPos={-100.f,-100.f};
float levelUpTimer=0.f;
float gainRate=0.f;
float lastXPGain=0.f;
size_t xpGainSound=std::numeric_limits<size_t>::max();
virtual void OnStateChange(GameState*prevState)override final;
virtual void OnUserUpdate(AiL*game)override final;
virtual void Draw(AiL*game)override final;
virtual void DrawOverlay(AiL*game)override final;
virtual void OnLevelLoad()override final;
public:
static void TurnOffXPSound();
};

View File

@ -29,3 +29,9 @@ do we need a minimap? (maybe with fog of war?) Maybe polling that once testing w
should gemstones dropp from boss stages aswell? (Maybe lower droprate?)
chasing blue slime as warrior aint no fun, nerf there move spd (-5% maybe?)
feature to lock accesoires to protect them from selling would be nice
Animations when using DPad lock up
Reset tutorials when loading a new character
When opening craft/buy/sell menu, default to the appropriate button.
Pressing back on the Select button of the equip menu causes you to exit the menu.
Funny text colors with text color override on blacksmith menu

View File

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 4
#define VERSION_PATCH 4
#define VERSION_BUILD 7889
#define VERSION_BUILD 7895
#define stringify(a) stringify_(a)
#define stringify_(a) #a

View File

@ -51,9 +51,6 @@ Interface
# How long between each reduction/addition of health.
HUD Mana Tick Rate = 0.01s
# How long between each addition to the XP bar on the level complete screen.
HUD XP Bar Tick Rate = 0.005s
# How long the timer text rises up
HUD Level Up Timer = 0.2s
}