pause: add SE volume submenu, improve some state management
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "../Constants.h"
|
||||
#include "EmulatorComponent.h"
|
||||
#include "PlayerData.h"
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
|
||||
@@ -19,15 +20,16 @@ namespace TLAC::Components
|
||||
virtual void UpdatePostInput() override;
|
||||
virtual void UpdateDrawSprites() override;
|
||||
|
||||
static bool isPaused;
|
||||
static bool giveUp;
|
||||
static void setPaused(bool pause);
|
||||
static bool pause; // set pause to change pause state
|
||||
static bool giveUp; // set give up to end current song
|
||||
private:
|
||||
// this is a mess of static so that menuItems can work
|
||||
static bool isPauseKeyTapped();
|
||||
static std::vector<bool> streamPlayStates;
|
||||
static void InjectCode(void* address, const std::vector<uint8_t> data);
|
||||
|
||||
static bool isPaused; // tracks internal state
|
||||
|
||||
static std::vector<uint8_t> origAetMovOp;
|
||||
static constexpr uint8_t* aetMovPatchAddress = (uint8_t*)0x1401703b3;
|
||||
|
||||
@@ -36,6 +38,8 @@ namespace TLAC::Components
|
||||
|
||||
static bool hookedGiveUpFunc(void* cls);
|
||||
|
||||
static void setSEVolume(int amount);
|
||||
|
||||
static const int menuX = 640;
|
||||
static const int menuY = 360;
|
||||
static const int menuItemHeight = 36;
|
||||
@@ -43,15 +47,38 @@ namespace TLAC::Components
|
||||
|
||||
static bool showUI;
|
||||
static unsigned int menuPos;
|
||||
static unsigned int mainMenuPos; // syncs to menuPos when menuSet == menuset_main (used for restoring on back)
|
||||
static unsigned int menuSet;
|
||||
|
||||
static std::chrono::time_point<std::chrono::high_resolution_clock> menuItemSelectTime;
|
||||
|
||||
static void unpause() { setPaused(false); };
|
||||
enum menusets
|
||||
{
|
||||
menuset_main = 0,
|
||||
menuset_sevol = 1,
|
||||
};
|
||||
|
||||
static void mainmenu() { menuSet = menuset_main; menuPos = mainMenuPos; menuItemSelectTime = std::chrono::high_resolution_clock::now(); };
|
||||
static void unpause() { pause = false; };
|
||||
static void giveup() { giveUp = true; };
|
||||
|
||||
std::vector<std::pair<std::string, void(*)()>> menuItems = {
|
||||
std::pair<std::string, void(*)()>(std::string("RESUME"), &unpause),
|
||||
std::pair<std::string, void(*)()>(std::string("GIVE UP"), &giveup),
|
||||
static void sevolmenu() { menuSet = menuset_sevol; menuPos = 1; menuItemSelectTime = std::chrono::high_resolution_clock::now(); };
|
||||
static void sevolplus() { setSEVolume(10); };
|
||||
static void sevolminus() { setSEVolume(-10); };
|
||||
|
||||
|
||||
// defined as an array now so submenus could be added
|
||||
std::vector<std::pair<std::string, void(*)()>> menuItems[2] = {
|
||||
{
|
||||
std::pair<std::string, void(*)()>(std::string("RESUME"), &unpause),
|
||||
std::pair<std::string, void(*)()>(std::string("SE VOLUME"), &sevolmenu),
|
||||
std::pair<std::string, void(*)()>(std::string("GIVE UP"), &giveup),
|
||||
},
|
||||
{
|
||||
std::pair<std::string, void(*)()>(std::string("+"), &sevolplus),
|
||||
std::pair<std::string, void(*)()>(std::string("XX"), &mainmenu),
|
||||
std::pair<std::string, void(*)()>(std::string("-"), &sevolminus),
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user