pause: more cleanup
This commit is contained in:
@@ -27,6 +27,25 @@ namespace TLAC::Components
|
|||||||
InputState* Pause::inputState;
|
InputState* Pause::inputState;
|
||||||
PlayerData* Pause::playerData;
|
PlayerData* Pause::playerData;
|
||||||
JvsButtons Pause::filteredButtons;
|
JvsButtons Pause::filteredButtons;
|
||||||
|
std::vector<Pause::menuSet> Pause::menu = {
|
||||||
|
{
|
||||||
|
"PAUSED",
|
||||||
|
{
|
||||||
|
{ "RESUME", unpause, false },
|
||||||
|
//{ "RESTART", restart, false },
|
||||||
|
{ "SE VOLUME", sevolmenu, false },
|
||||||
|
{ "GIVE UP", giveup, false },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"SE VOLUME",
|
||||||
|
{
|
||||||
|
{ "+", sevolplus, true },
|
||||||
|
{ "XX", mainmenu, false },
|
||||||
|
{ "-", sevolminus, true },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
Pause::Pause()
|
Pause::Pause()
|
||||||
{
|
{
|
||||||
@@ -113,7 +132,11 @@ namespace TLAC::Components
|
|||||||
if (inputState->Tapped.Buttons & JVS_SQUARE)
|
if (inputState->Tapped.Buttons & JVS_SQUARE)
|
||||||
{
|
{
|
||||||
showUI = !showUI;
|
showUI = !showUI;
|
||||||
if (!showUI)
|
if (showUI)
|
||||||
|
{
|
||||||
|
menuItemMoveTime = std::chrono::high_resolution_clock::now(); // restart animations
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// clear these from the screen too
|
// clear these from the screen too
|
||||||
destroyAetLayer(triangleAet);
|
destroyAetLayer(triangleAet);
|
||||||
@@ -278,9 +301,7 @@ namespace TLAC::Components
|
|||||||
|
|
||||||
if (i == curMenuPos)
|
if (i == curMenuPos)
|
||||||
{
|
{
|
||||||
const int duration = 1500000000; // 1.5s
|
uint8_t alpha = (cosf(getMenuAnimPos() * 6.283185f) * 0.15 + 0.85) * 255;
|
||||||
std::chrono::nanoseconds cyclePos = (std::chrono::high_resolution_clock::now() - menuItemMoveTime) % std::chrono::nanoseconds(duration);
|
|
||||||
uint8_t alpha = (cosf(cyclePos.count() * 6.283185f / duration) * 0.15 + 0.85) * 255;
|
|
||||||
dtParams.colour = 0x00ffff00 | (alpha << 24);
|
dtParams.colour = 0x00ffff00 | (alpha << 24);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -368,6 +389,32 @@ namespace TLAC::Components
|
|||||||
playerData->act_slide_vol = playerData->act_vol;
|
playerData->act_slide_vol = playerData->act_vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Pause::setMenuPos(menusets set, int pos)
|
||||||
|
{
|
||||||
|
if (set >= 0 && set < menu.size())
|
||||||
|
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(); // restart animations
|
||||||
|
}
|
||||||
|
|
||||||
|
float Pause::getMenuAnimPos()
|
||||||
|
{
|
||||||
|
const int duration = 1500000000; // 1.5s
|
||||||
|
return (float)((std::chrono::high_resolution_clock::now() - menuItemMoveTime) % std::chrono::nanoseconds(duration)).count() / (float)duration;
|
||||||
|
}
|
||||||
|
|
||||||
void Pause::InjectCode(void* address, const std::vector<uint8_t> data)
|
void Pause::InjectCode(void* address, const std::vector<uint8_t> data)
|
||||||
{
|
{
|
||||||
const size_t byteCount = data.size() * sizeof(uint8_t);
|
const size_t byteCount = data.size() * sizeof(uint8_t);
|
||||||
|
|||||||
@@ -64,9 +64,7 @@ namespace TLAC::Components
|
|||||||
int squareAet;
|
int squareAet;
|
||||||
int crossAet;
|
int crossAet;
|
||||||
int circleAet;
|
int circleAet;
|
||||||
|
|
||||||
static std::chrono::time_point<std::chrono::high_resolution_clock> menuItemMoveTime; // used for animation
|
|
||||||
|
|
||||||
enum menusets
|
enum menusets
|
||||||
{
|
{
|
||||||
MENUSET_MAIN = 0,
|
MENUSET_MAIN = 0,
|
||||||
@@ -94,59 +92,25 @@ namespace TLAC::Components
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int curMenuPos;
|
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 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 unpause() { pause = false; };
|
||||||
//static void restart() { *(uint8_t*)0x140d0b538 = 1; unpause(); }
|
//static void restart() { *(uint8_t*)0x140d0b538 = 1; unpause(); }
|
||||||
static void giveup() { giveUp = true; };
|
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 sevolplus() { setSEVolume(10); };
|
||||||
static void sevolminus() { 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
|
static void setMenuPos(menusets set, int pos);
|
||||||
// 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 },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
void setMenuPos(menusets set, int pos)
|
static float getMenuAnimPos();
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user