Removed macros from Pad.cpp:

- Turned them in functions.
This commit is contained in:
_AG 2019-07-02 21:22:16 +02:00
parent 6c693e3bbf
commit 5afa330e7d
2 changed files with 136 additions and 35 deletions

View File

@ -66,6 +66,21 @@ int8 DisplayComboButtonErrMsg;
bool MouseButtonJustClicked; bool MouseButtonJustClicked;
bool JoyButtonJustClicked; bool JoyButtonJustClicked;
// Frontend inputs.
bool GetPadBack();
bool GetPadForward();
bool GetPadMoveUp();
bool GetPadMoveDown();
bool GetPadMoveLeft();
bool GetPadMoveRight();
bool GetMouseForward();
bool GetMouseBack();
bool GetMousePos();
bool GetMouseMoveLeft();
bool GetMouseMoveRight();
bool GetPadInput();
bool GetMouseInput();
char *FrontendFilenames[] = { char *FrontendFilenames[] = {
"fe2_mainpanel_ul", "fe2_mainpanel_ul",
"fe2_mainpanel_ur", "fe2_mainpanel_ur",
@ -697,12 +712,15 @@ void CMenuManager::Draw()
} }
// Mouse support. // Mouse support.
if (m_nCurrScreen == MENUPAGE_SKIN_SELECT || m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { // TODO: inputs for these pages.
//TODO: inputs for these pages. if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) {
}
else if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) {
} }
else { else {
static bool bIsMouseInPosition = false; static bool bIsMouseInPosition = false;
if (m_nMenuFadeAlpha >= 255 && MOUSE_INPUT) { if (m_nMenuFadeAlpha >= 255 && GetMouseInput()) {
CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) }; CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) };
if (m_bShowMouse && if (m_bShowMouse &&
((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f))))) ((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f)))))
@ -718,7 +736,7 @@ void CMenuManager::Draw()
m_nPrevOption = m_nCurrOption; m_nPrevOption = m_nCurrOption;
if (MOUSE_LMB) if (GetMouseForward())
m_nHoverOption = IGNORE_OPTION; m_nHoverOption = IGNORE_OPTION;
else else
m_nHoverOption = ACTIVATE_OPTION; m_nHoverOption = ACTIVATE_OPTION;
@ -1360,7 +1378,7 @@ void CMenuManager::Process(void)
m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode();
} }
else { else {
if (PAD_ESC) if (GetPadBack())
RequestFrontEndStartUp(); RequestFrontEndStartUp();
UnloadTextures(); UnloadTextures();
@ -1394,16 +1412,16 @@ void CMenuManager::ProcessButtonPresses()
m_nMousePosY = SCREEN_HEIGHT; m_nMousePosY = SCREEN_HEIGHT;
// Show/hide mouse cursor. // Show/hide mouse cursor.
if (MOUSE_INPUT) if (GetMouseInput())
m_bShowMouse = true; m_bShowMouse = true;
else if (PAD_INPUT) else if (GetPadInput())
m_bShowMouse = false; m_bShowMouse = false;
// Get number of menu options. // Get number of menu options.
uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); uint8 NumberOfMenuOptions = GetNumberOfMenuOptions();
// Select next/previous option with pad. Mouse is done in drawing function. // Select next/previous option with pad. Mouse is done in drawing function.
if (PAD_UP) { if (GetPadMoveUp()) {
m_nPrevOption = m_nCurrOption; m_nPrevOption = m_nCurrOption;
m_nCurrOption -= 1; m_nCurrOption -= 1;
@ -1418,7 +1436,7 @@ void CMenuManager::ProcessButtonPresses()
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0);
} }
else if (PAD_DOWN) { else if (GetPadMoveDown()) {
m_nPrevOption = m_nCurrOption; m_nPrevOption = m_nCurrOption;
m_nCurrOption += 1; m_nCurrOption += 1;
@ -1435,7 +1453,7 @@ void CMenuManager::ProcessButtonPresses()
} }
// Set what happens if ESC is pressed. // Set what happens if ESC is pressed.
if (PAD_ESC) { if (GetPadBack()) {
bool PlayEscSound = false; bool PlayEscSound = false;
switch (m_nCurrScreen) { switch (m_nCurrScreen) {
case MENUPAGE_START_MENU: case MENUPAGE_START_MENU:
@ -1457,7 +1475,7 @@ void CMenuManager::ProcessButtonPresses()
// TODO: finish hover options. // TODO: finish hover options.
// Set mouse buttons. // Set mouse buttons.
if (MOUSE_LMB) { if (GetMouseForward()) {
switch (m_nHoverOption) { switch (m_nHoverOption) {
case ACTIVATE_OPTION: case ACTIVATE_OPTION:
if (m_nCurrOption || m_nCurrScreen != MENUPAGE_PAUSE_MENU) if (m_nCurrOption || m_nCurrScreen != MENUPAGE_PAUSE_MENU)
@ -1472,8 +1490,8 @@ void CMenuManager::ProcessButtonPresses()
// Process all menu options here, but first check if it's an option or a redirect. // Process all menu options here, but first check if it's an option or a redirect.
int32 CurrAction = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; int32 CurrAction = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action;
if ((PAD_ENTER || MOUSE_LMB) || if ((GetPadForward() || GetMouseForward()) ||
((PAD_LEFT || MOUSE_WHU) || (PAD_RIGHT || MOUSE_WHD)) && ((GetPadMoveLeft() || GetMouseMoveRight()) || (GetPadMoveRight() || GetMouseMoveLeft())) &&
(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu == m_nCurrScreen && (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu == m_nCurrScreen &&
CurrAction != MENUACTION_CHANGEMENU && CurrAction != MENUACTION_CHANGEMENU &&
CurrAction != MENUACTION_LOADRADIO && CurrAction != MENUACTION_LOADRADIO &&
@ -1520,8 +1538,8 @@ WRAPPER void CMenuManager::ProcessOnOffMenuOptions() { EAXJMP(0x48AE60); }
#else #else
void CMenuManager::ProcessOnOffMenuOptions() void CMenuManager::ProcessOnOffMenuOptions()
{ {
int8 InputDirection = (PAD_LEFT || MOUSE_WHD) && (!PAD_ENTER && !MOUSE_LMB) ? -1 : 1; int8 InputDirection = (GetPadMoveLeft() || GetMouseMoveLeft()) && (!GetPadForward() && !GetMouseForward()) ? -1 : 1;
int8 InputEnter = PAD_ENTER; int8 InputEnter = GetPadForward();
uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); uint8 NumberOfMenuOptions = GetNumberOfMenuOptions();
@ -2078,7 +2096,7 @@ WRAPPER void CMenuManager::SwitchMenuOnAndOff() { EAXJMP(0x488790); }
void CMenuManager::SwitchMenuOnAndOff() void CMenuManager::SwitchMenuOnAndOff()
{ {
// Just what the function name says. // Just what the function name says.
if (PAD_START || m_bShutDownFrontEndRequested || m_bStartUpFrontEndRequested) { if (m_bShutDownFrontEndRequested || m_bStartUpFrontEndRequested) {
if (!m_bMenuActive) if (!m_bMenuActive)
m_bMenuActive = true; m_bMenuActive = true;
@ -2154,7 +2172,7 @@ void CMenuManager::WaitForUserCD()
CPad::UpdatePads(); CPad::UpdatePads();
MessageScreen("NO_PCCD"); MessageScreen("NO_PCCD");
if (PAD_ESC) { if (GetPadBack()) {
m_bQuitGameNoCD = true; m_bQuitGameNoCD = true;
RsEventHandler(rsQUITAPP, 0); RsEventHandler(rsQUITAPP, 0);
} }
@ -2270,6 +2288,106 @@ void CMenuManager::SetDefaultPreferences(int8 screen)
}; };
} }
// Frontend inputs.
bool GetPadBack()
{
return
(CPad::GetPad(0)->NewKeyState.ESC && !CPad::GetPad(0)->OldKeyState.ESC) ||
(CPad::GetPad(0)->NewState.Start && !CPad::GetPad(0)->OldState.Start) ||
(CPad::GetPad(0)->NewState.Triangle && !CPad::GetPad(0)->OldState.Triangle);
}
bool GetPadForward()
{
return
(CPad::GetPad(0)->NewKeyState.EXTENTER && !CPad::GetPad(0)->OldKeyState.EXTENTER) ||
(CPad::GetPad(0)->NewKeyState.ENTER && !CPad::GetPad(0)->OldKeyState.ENTER) ||
(CPad::GetPad(0)->NewState.Cross && !CPad::GetPad(0)->OldState.Cross);
}
bool GetPadMoveUp()
{
return
(CPad::GetPad(0)->NewState.DPadUp && !CPad::GetPad(0)->OldState.DPadUp) ||
(CPad::GetPad(0)->NewKeyState.UP && !CPad::GetPad(0)->OldKeyState.UP) ||
(CPad::GetPad(0)->NewState.LeftStickY < 0 && !CPad::GetPad(0)->OldState.LeftStickY < 0);
}
bool GetPadMoveDown()
{
return
(CPad::GetPad(0)->NewState.DPadDown && !CPad::GetPad(0)->OldState.DPadDown) ||
(CPad::GetPad(0)->NewKeyState.DOWN && !CPad::GetPad(0)->OldKeyState.DOWN) ||
(CPad::GetPad(0)->NewState.LeftStickY > 0 && !CPad::GetPad(0)->OldState.LeftStickY > 0);
}
bool GetPadMoveLeft()
{
return
(CPad::GetPad(0)->NewState.DPadLeft && !CPad::GetPad(0)->OldState.DPadLeft) ||
(CPad::GetPad(0)->NewKeyState.LEFT && !CPad::GetPad(0)->OldKeyState.LEFT) ||
(CPad::GetPad(0)->NewState.LeftStickX < 0 && !CPad::GetPad(0)->OldState.LeftStickX < 0);
}
bool GetPadMoveRight()
{
return
(CPad::GetPad(0)->NewState.DPadRight && !CPad::GetPad(0)->OldState.DPadRight) ||
(CPad::GetPad(0)->NewKeyState.RIGHT && !CPad::GetPad(0)->OldKeyState.RIGHT) ||
(CPad::GetPad(0)->NewState.LeftStickX > 0 && !CPad::GetPad(0)->OldState.LeftStickX > 0);
}
bool GetMouseForward()
{
return
(CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB);
}
bool GetMouseBack()
{
return
(CPad::GetPad(0)->NewMouseControllerState.RMB && !CPad::GetPad(0)->OldMouseControllerState.RMB);
}
bool GetMousePos()
{
return
(CPad::GetPad(0)->NewMouseControllerState.x != 0.0f || CPad::GetPad(0)->OldMouseControllerState.y != 0.0f);
}
bool GetMouseMoveLeft()
{
return
(CPad::GetPad(0)->NewMouseControllerState.WHEELDN && !CPad::GetPad(0)->OldMouseControllerState.WHEELDN != 0.0f);
}
bool GetMouseMoveRight()
{
return
(CPad::GetPad(0)->NewMouseControllerState.WHEELUP && !CPad::GetPad(0)->OldMouseControllerState.WHEELUP != 0.0f);
}
bool GetPadInput()
{
return
GetPadBack() ||
GetPadForward() ||
GetPadMoveUp() ||
GetPadMoveDown() ||
GetPadMoveLeft() ||
GetPadMoveRight();
}
bool GetMouseInput()
{
return
GetMouseForward() ||
GetMouseBack() ||
GetMousePos() ||
GetMouseMoveLeft() ||
GetMouseMoveRight();
}
STARTPATCHES STARTPATCHES
InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP); InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP);
InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP); InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP);

View File

@ -1,22 +1,5 @@
#pragma once #pragma once
// Some macros for frontend stuff.
#define PAD_START (CPad::GetPad(0)->NewState.Start && !CPad::GetPad(0)->NewState.Start)
#define PAD_ESC (CPad::GetPad(0)->NewKeyState.ESC && !CPad::GetPad(0)->OldKeyState.ESC) || (CPad::GetPad(0)->NewState.Triangle && !CPad::GetPad(0)->NewState.Triangle)
#define PAD_ENTER (CPad::GetPad(0)->NewKeyState.EXTENTER && !CPad::GetPad(0)->OldKeyState.EXTENTER) || (CPad::GetPad(0)->NewKeyState.ENTER && !CPad::GetPad(0)->OldKeyState.ENTER) || (CPad::GetPad(0)->NewState.Cross && !CPad::GetPad(0)->NewState.Cross)
#define PAD_UP (CPad::GetPad(0)->NewState.DPadUp && !CPad::GetPad(0)->OldState.DPadUp) || (CPad::GetPad(0)->NewKeyState.UP && !CPad::GetPad(0)->OldKeyState.UP) || (CPad::GetPad(0)->NewState.LeftStickY < 0 && !CPad::GetPad(0)->OldState.LeftStickY < 0)
#define PAD_DOWN (CPad::GetPad(0)->NewState.DPadDown && !CPad::GetPad(0)->OldState.DPadDown) || (CPad::GetPad(0)->NewKeyState.DOWN && !CPad::GetPad(0)->OldKeyState.DOWN) || (CPad::GetPad(0)->NewState.LeftStickY > 0 && !CPad::GetPad(0)->OldState.LeftStickY > 0)
#define PAD_LEFT (CPad::GetPad(0)->NewState.DPadLeft && !CPad::GetPad(0)->OldState.DPadLeft) || (CPad::GetPad(0)->NewKeyState.LEFT && !CPad::GetPad(0)->OldKeyState.LEFT) || (CPad::GetPad(0)->NewState.LeftStickX < 0 && !CPad::GetPad(0)->OldState.LeftStickX < 0)
#define PAD_RIGHT (CPad::GetPad(0)->NewState.DPadRight && !CPad::GetPad(0)->OldState.DPadRight) || (CPad::GetPad(0)->NewKeyState.RIGHT && !CPad::GetPad(0)->OldKeyState.RIGHT) || (CPad::GetPad(0)->NewState.LeftStickX > 0 && !CPad::GetPad(0)->OldState.LeftStickX > 0)
#define MOUSE_LMB (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB)
#define MOUSE_RMB (CPad::GetPad(0)->NewMouseControllerState.RMB && !CPad::GetPad(0)->OldMouseControllerState.RMB)
#define MOUSE_POS (CPad::GetPad(0)->NewMouseControllerState.x != 0.0f || CPad::GetPad(0)->NewMouseControllerState.y != 0.0f)
#define MOUSE_WHU (CPad::GetPad(0)->NewMouseControllerState.WHEELUP && !CPad::GetPad(0)->OldMouseControllerState.WHEELUP != 0.0f)
#define MOUSE_WHD (CPad::GetPad(0)->NewMouseControllerState.WHEELDN && !CPad::GetPad(0)->OldMouseControllerState.WHEELDN != 0.0f)
#define PAD_INPUT (PAD_ESC || PAD_ENTER || PAD_UP || PAD_DOWN || PAD_LEFT || PAD_RIGHT)
#define MOUSE_INPUT (MOUSE_LMB || MOUSE_RMB || MOUSE_POS || MOUSE_WHU || MOUSE_WHD)
// same as RW skeleton // same as RW skeleton
/* /*
enum Key enum Key