pause: more cleanup

This commit is contained in:
somewhatlurker
2019-10-23 06:02:34 +11:00
parent 421a5e4d4f
commit e6ad288288
2 changed files with 61 additions and 50 deletions
@@ -64,9 +64,7 @@ namespace TLAC::Components
int squareAet;
int crossAet;
int circleAet;
static std::chrono::time_point<std::chrono::high_resolution_clock> menuItemMoveTime; // used for animation
enum menusets
{
MENUSET_MAIN = 0,
@@ -94,59 +92,25 @@ namespace TLAC::Components
};
static int curMenuPos;
static int mainMenuPos; // syncs to menuPos when menuSet == menuset_main (used for restoring on back)
static int mainMenuPos; // syncs to curMenuPos when curMenuSet == MENUSET_MAIN (used for restoring on back)
static menusets curMenuSet;
static void mainmenu() { curMenuSet = MENUSET_MAIN; curMenuPos = mainMenuPos; menuItemMoveTime = std::chrono::high_resolution_clock::now(); };
static std::chrono::time_point<std::chrono::high_resolution_clock> menuItemMoveTime; // used for animation
static void mainmenu() { setMenuPos(MENUSET_MAIN, mainMenuPos); };
static void unpause() { pause = false; };
//static void restart() { *(uint8_t*)0x140d0b538 = 1; unpause(); }
static void giveup() { giveUp = true; };
static void sevolmenu() { curMenuSet = MENUSET_SEVOL; curMenuPos = 1; menuItemMoveTime = std::chrono::high_resolution_clock::now(); };
static void sevolmenu() { setMenuPos(MENUSET_SEVOL, 1); };
static void sevolplus() { setSEVolume(10); };
static void sevolminus() { setSEVolume(-10); };
// contents are in Pause.cpp because they can't be inline here for a static (const) array/vec
static std::vector<menuSet> menu;
// defined as an array now so submenus could be added
// not sure how to make this static for consistency so whatever
menuSet menu[2] = {
{
"PAUSED",
{
{ "RESUME", unpause, false },
//{ "RESTART", restart, false },
{ "SE VOLUME", sevolmenu, false },
{ "GIVE UP", giveup, false },
}
},
{
"SE VOLUME",
{
{ "+", sevolplus, true },
{ "XX", mainmenu, false },
{ "-", sevolminus, true },
}
},
};
static void setMenuPos(menusets set, int pos);
void setMenuPos(menusets set, int pos)
{
if (set >= 0 && set < _countof(menu))
curMenuSet = set;
else
curMenuSet = MENUSET_MAIN;
if (pos < 0)
pos = menu[curMenuSet].items.size() - 1;
else if (pos >= menu[curMenuSet].items.size())
pos = 0;
curMenuPos = pos;
if (curMenuSet == MENUSET_MAIN)
mainMenuPos = curMenuPos;
menuItemMoveTime = std::chrono::high_resolution_clock::now();
}
static float getMenuAnimPos();
};
}