summaryrefslogtreecommitdiffstats
path: root/src/core/Frontend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/Frontend.cpp')
-rw-r--r--src/core/Frontend.cpp147
1 files changed, 49 insertions, 98 deletions
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 7d378e7f..7ff80697 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -899,29 +899,29 @@ CMenuManager::CheckSliderMovement(int value)
switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) {
case MENUACTION_BRIGHTNESS:
m_PrefsBrightness += value * (512/16);
- m_PrefsBrightness = clamp(m_PrefsBrightness, 0, 511);
+ m_PrefsBrightness = Clamp(m_PrefsBrightness, 0, 511);
break;
case MENUACTION_DRAWDIST:
if(value > 0)
m_PrefsLOD += ((1.8f - 0.8f) / 16.0f);
else
m_PrefsLOD -= ((1.8f - 0.8f) / 16.0f);
- m_PrefsLOD = clamp(m_PrefsLOD, 0.8f, 1.8f);
+ m_PrefsLOD = Clamp(m_PrefsLOD, 0.8f, 1.8f);
CRenderer::ms_lodDistScale = m_PrefsLOD;
break;
case MENUACTION_MUSICVOLUME:
m_PrefsMusicVolume += value * (128/16);
- m_PrefsMusicVolume = clamp(m_PrefsMusicVolume, 0, 127);
+ m_PrefsMusicVolume = Clamp(m_PrefsMusicVolume, 0, 127);
DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume);
break;
case MENUACTION_SFXVOLUME:
m_PrefsSfxVolume += value * (128/16);
- m_PrefsSfxVolume = clamp(m_PrefsSfxVolume, 0, 127);
+ m_PrefsSfxVolume = Clamp(m_PrefsSfxVolume, 0, 127);
DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume);
break;
case MENUACTION_MOUSESENS:
TheCamera.m_fMouseAccelHorzntl += value * 1.0f/200.0f/15.0f; // ???
- TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f/3200.0f, 1.0f/200.0f);
+ TheCamera.m_fMouseAccelHorzntl = Clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f/3200.0f, 1.0f/200.0f);
#ifdef FIX_BUGS
TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f;
#else
@@ -950,12 +950,7 @@ CMenuManager::DisplayHelperText()
m_nHelperTextAlpha -= 2;
}
#else
- static float fadeAlpha = 0.0f; // To keep it precisely
- if (m_nHelperTextAlpha >= 255 && fadeAlpha < 250) fadeAlpha = m_nHelperTextAlpha;
-
- // -2 per every 33 ms (1000.f/30.f - original frame limiter fps)
- fadeAlpha -= (frameTime / 33.0f) * 2.0f;
- m_nHelperTextAlpha = fadeAlpha;
+ m_nHelperTextAlpha -= 2 * CTimer::GetLogicalFramesPassed();
#endif
if (m_nHelperTextAlpha < 1)
ResetHelperText();
@@ -2686,11 +2681,7 @@ CMenuManager::DrawFrontEndNormal()
static float fadeAlpha = 0.0f;
if (m_nMenuFadeAlpha < 255) {
- if (m_nMenuFadeAlpha == 0 && fadeAlpha > 1.0f) fadeAlpha = 0.0f;
-
- // +20 per every 33 ms (1000.f/30.f - original frame limiter fps)
- fadeAlpha += (frameTime) * 20.f / 33.f;
- m_nMenuFadeAlpha = fadeAlpha;
+ m_nMenuFadeAlpha += 20 * CTimer::GetLogicalFramesPassed();
} else {
// TODO: what is this? waiting mouse?
if(field_518 == 4){
@@ -2950,12 +2941,7 @@ CMenuManager::DrawFrontEndNormal()
// Famous transparent menu bug
#ifdef FIX_BUGS
- static float fadeAlpha = 0.0f;
- if (m_nMenuFadeAlpha == 0 && fadeAlpha > 1.0f) fadeAlpha = 0.0f;
-
- // +20 per every 33 ms (1000.f/30.f - original frame limiter fps)
- fadeAlpha += (frameTime) * 20.f / 33.f;
- m_nMenuFadeAlpha = fadeAlpha;
+ m_nMenuFadeAlpha += 20 * CTimer::GetLogicalFramesPassed();
#else
static uint32 LastFade = 0;
@@ -2986,40 +2972,11 @@ CMenuManager::DrawFrontEndNormal()
#ifdef RED_DELETE_BACKGROUND
if (m_nCurrScreen == MENUPAGE_CHOOSE_DELETE_SLOT || m_nCurrScreen == MENUPAGE_DELETE_SLOT_CONFIRM) {
- CSprite2d::Draw2DPolygon(SCREEN_STRETCH_X(18.0f), MENU_Y(8.0f),
- SCREEN_WIDTH - SCREEN_STRETCH_X(20.0f), MENU_Y(8.0f),
- SCREEN_STRETCH_X(12.0f), MENU_Y(11.0f),
- SCREEN_WIDTH - SCREEN_STRETCH_X(14.0f), MENU_Y(11.0f),
- CRGBA(150, 0, 0, 140));
-
- CSprite2d::Draw2DPolygon(SCREEN_STRETCH_X(12.0f), MENU_Y(11.0f),
- SCREEN_WIDTH - SCREEN_STRETCH_X(14.0f), MENU_Y(11.0f),
- SCREEN_STRETCH_X(10.0f), MENU_Y(16.0f),
- SCREEN_WIDTH - SCREEN_STRETCH_X(12.0f), MENU_Y(16.0f),
- CRGBA(150, 0, 0, 140));
-
- CSprite2d::Draw2DPolygon(SCREEN_STRETCH_X(10.0f), MENU_Y(16.0f),
- SCREEN_WIDTH - SCREEN_STRETCH_X(12.0f), MENU_Y(16.0f),
- SCREEN_STRETCH_X(10.0f), SCREEN_SCALE_Y(431.0f),
- SCREEN_WIDTH - SCREEN_STRETCH_X(12.0f), SCREEN_SCALE_Y(431.0f),
- CRGBA(150, 0, 0, 140));
-
- CSprite2d::Draw2DPolygon(SCREEN_STRETCH_X(10.0f), SCREEN_SCALE_Y(431.0f),
- SCREEN_WIDTH - SCREEN_STRETCH_X(12.0f), SCREEN_SCALE_Y(431.0f),
- SCREEN_STRETCH_X(12.0f), SCREEN_SCALE_Y(435.0f),
- SCREEN_WIDTH - SCREEN_STRETCH_X(14.0f), SCREEN_SCALE_Y(435.0f),
- CRGBA(150, 0, 0, 140));
-
- CSprite2d::Draw2DPolygon(SCREEN_STRETCH_X(12.0f), SCREEN_SCALE_Y(435.0f),
- SCREEN_WIDTH - SCREEN_STRETCH_X(14.0f), SCREEN_SCALE_Y(435.0f),
- SCREEN_STRETCH_X(18.0f), SCREEN_SCALE_Y(438.0f),
- SCREEN_WIDTH - SCREEN_STRETCH_X(20.0f), SCREEN_SCALE_Y(438.0f),
- CRGBA(150, 0, 0, 140));
-
- // yellow bar
- CSprite2d::DrawRect(CRect(MENU_X(13.0f), SCREEN_STRETCH_FROM_BOTTOM(96.0f),
- SCREEN_STRETCH_FROM_RIGHT(11.0f), SCREEN_STRETCH_FROM_BOTTOM(59.0f)),
- CRGBA(235, 170, 50, 255));
+ CSprite2d::Draw2DPolygon(0.0f, 0.0f,
+ SCREEN_WIDTH, 0.0f,
+ 0.0f, SCREEN_HEIGHT,
+ SCREEN_WIDTH, SCREEN_HEIGHT,
+ CRGBA(150, 0, 0, 80));
}
#endif
@@ -3542,9 +3499,15 @@ CMenuManager::InitialiseChangedLanguageSettings()
{
if (m_bFrontEnd_ReloadObrTxtGxt) {
m_bFrontEnd_ReloadObrTxtGxt = false;
+#ifdef FIX_BUGS
+ if (gGameState > GS_INIT_ONCE)
+#endif
CTimer::Stop();
TheText.Unload();
TheText.Load();
+#ifdef FIX_BUGS
+ if (gGameState > GS_INIT_ONCE)
+#endif
CTimer::Update();
CGame::frenchGame = false;
CGame::germanGame = false;
@@ -3661,7 +3624,9 @@ CMenuManager::LoadAllTextures()
#ifdef MENU_MAP
static bool menuOptionAdded = false;
for (int i = 0; i < ARRAY_SIZE(MapFilenames); i++) {
- if (!menuOptionAdded && RwTextureRead(MapFilenames[i][0], MapFilenames[i][1])) {
+ RwTexture *firstTile;
+ if (!menuOptionAdded && (firstTile = RwTextureRead(MapFilenames[i][0], MapFilenames[i][1]))) {
+ RwTextureDestroy(firstTile);
FrontendOptionSetCursor(MENUPAGE_PAUSE_MENU, 2, false);
FrontendOptionAddBuiltinAction("FEG_MAP", MENUACTION_CHANGEMENU, MENUPAGE_MAP, SAVESLOT_NONE);
menuOptionAdded = true;
@@ -3825,11 +3790,10 @@ CMenuManager::LoadSettings()
#ifdef LOAD_INI_SETTINGS
if (LoadINISettings()) {
LoadINIControllerSettings();
- } else {
- // no re3.ini, create it
- SaveINISettings();
- SaveINIControllerSettings();
}
+ // if no re3.ini, create it, or update it with new values
+ SaveINISettings();
+ SaveINIControllerSettings();
#endif
m_PrefsVsync = m_PrefsVsyncDisp;
@@ -4326,29 +4290,16 @@ CMenuManager::ProcessButtonPresses(void)
#ifdef USE_DEBUG_SCRIPT_LOADER
if (m_nCurrScreen == MENUPAGE_START_MENU || m_nCurrScreen == MENUPAGE_NEW_GAME || m_nCurrScreen == MENUPAGE_NEW_GAME_RELOAD) {
-#ifdef RW_GL3
- if (glfwGetKey(PSGLOBAL(window), GLFW_KEY_R) == GLFW_PRESS) {
+ if (CPad::GetPad(0)->GetChar('R')) {
scriptToLoad = 1;
DoSettingsBeforeStartingAGame();
return;
}
- if (glfwGetKey(PSGLOBAL(window), GLFW_KEY_D) == GLFW_PRESS) {
+ if (CPad::GetPad(0)->GetChar('D')) {
scriptToLoad = 2;
DoSettingsBeforeStartingAGame();
return;
}
-#elif defined _WIN32
- if (GetAsyncKeyState('R') & 0x8000) {
- scriptToLoad = 1;
- DoSettingsBeforeStartingAGame();
- return;
- }
- if (GetAsyncKeyState('D') & 0x8000) {
- scriptToLoad = 2;
- DoSettingsBeforeStartingAGame();
- return;
- }
-#endif
}
#endif
@@ -4423,7 +4374,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = m_nHoverOption - HOVEROPTION_RADIO_0;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
} else if (m_nHoverOption == HOVEROPTION_RANDOM_ITEM
&& aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action != MENUACTION_RESUME) {
@@ -4437,7 +4388,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = HEAD_RADIO;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
case HOVEROPTION_RADIO_1:
@@ -4445,7 +4396,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = DOUBLE_CLEF;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
case HOVEROPTION_RADIO_2:
@@ -4453,7 +4404,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = JAH_RADIO;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
case HOVEROPTION_RADIO_3:
@@ -4461,7 +4412,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = RISE_FM;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
case HOVEROPTION_RADIO_4:
@@ -4469,7 +4420,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = LIPS_106;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
case HOVEROPTION_RADIO_5:
@@ -4477,7 +4428,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = GAME_FM;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
case HOVEROPTION_RADIO_6:
@@ -4485,7 +4436,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = MSX_FM;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
case HOVEROPTION_RADIO_7:
@@ -4493,7 +4444,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = FLASHBACK;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
case HOVEROPTION_RADIO_8:
@@ -4501,7 +4452,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = CHATTERBOX;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
case HOVEROPTION_RADIO_9:
@@ -4509,7 +4460,7 @@ CMenuManager::ProcessButtonPresses(void)
m_PrefsRadioStation = USERTRACK;
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
case HOVEROPTION_RANDOM_ITEM:
@@ -4559,7 +4510,7 @@ CMenuManager::ProcessButtonPresses(void)
break;
case HOVEROPTION_INCREASE_MUSICVOLUME:
m_PrefsMusicVolume = m_PrefsMusicVolume + 8;
- m_PrefsMusicVolume = clamp(m_PrefsMusicVolume, 0, 127);
+ m_PrefsMusicVolume = Clamp(m_PrefsMusicVolume, 0, 127);
DMAudio.SetMusicMasterVolume(uchar)(m_PrefsMusicVolume);
SaveSettings();
break;
@@ -4598,7 +4549,7 @@ CMenuManager::ProcessButtonPresses(void)
break;
case HOVEROPTION_INCREASE_MOUSESENS:
TheCamera.m_fMouseAccelHorzntl += (1.0f / 3000);
- TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f / 3200, 1.0f / 200);
+ TheCamera.m_fMouseAccelHorzntl = Clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f / 3200, 1.0f / 200);
#ifdef FIX_BUGS
TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f;
#else
@@ -4608,7 +4559,7 @@ CMenuManager::ProcessButtonPresses(void)
break;
case HOVEROPTION_DECREASE_MOUSESENS:
TheCamera.m_fMouseAccelHorzntl -= (1.0f / 3000);
- TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f / 3200, 1.0f / 200);
+ TheCamera.m_fMouseAccelHorzntl = Clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f / 3200, 1.0f / 200);
#ifdef FIX_BUGS
TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f;
#else
@@ -4732,7 +4683,7 @@ CMenuManager::ProcessButtonPresses(void)
curBottomBarOption = hoveredBottomBarOption;
ChangeScreen(bbNames[curBottomBarOption].screenId, 0, true, false);
if (bbNames[curBottomBarOption].screenId == MENUPAGE_SOUND_SETTINGS)
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
return;
} else if (bottomBarActive) {
if (CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetCrossJustDown()) {
@@ -4740,7 +4691,7 @@ CMenuManager::ProcessButtonPresses(void)
bottomBarActive = false;
if (bbNames[curBottomBarOption].screenId == MENUPAGE_SOUND_SETTINGS)
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
return;
} else if (CPad::GetPad(0)->GetLeftJustDown() || CPad::GetPad(0)->GetAnaloguePadLeft() || CPad::GetPad(0)->GetDPadLeftJustDown()
@@ -4891,7 +4842,7 @@ CMenuManager::ProcessButtonPresses(void)
}
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
#endif
break;
@@ -5101,7 +5052,7 @@ CMenuManager::ProcessButtonPresses(void)
DMAudio.SetMusicMasterVolume(102);
DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume);
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
SaveSettings();
} else if (m_nCurrScreen == MENUPAGE_DISPLAY_SETTINGS) {
m_PrefsFrameLimiter = true;
@@ -5187,7 +5138,7 @@ CMenuManager::ProcessButtonPresses(void)
break;
case MENUACTION_LOADRADIO:
ChangeScreen(MENUPAGE_SOUND_SETTINGS, 0, true, true);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("STARTED PLAYING FRONTEND AUDIO TRACK");
break;
#ifdef MISSION_REPLAY
@@ -5382,7 +5333,7 @@ CMenuManager::ProcessButtonPresses(void)
}
SaveSettings();
DMAudio.SetRadioInCar(m_PrefsRadioStation);
- DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1);
+ DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE);
OutputDebugString("FRONTEND RADIO STATION CHANGED");
break;
#ifdef ASPECT_RATIO_SCALE
@@ -5424,14 +5375,14 @@ CMenuManager::ProcessButtonPresses(void)
case MENUACTION_AUDIOHW:
if (m_nPrefsAudio3DProviderIndex != -1) {
m_nPrefsAudio3DProviderIndex += changeValueBy;
- m_nPrefsAudio3DProviderIndex = clamp(m_nPrefsAudio3DProviderIndex, 0, DMAudio.GetNum3DProvidersAvailable() - 1);
+ m_nPrefsAudio3DProviderIndex = Clamp(m_nPrefsAudio3DProviderIndex, 0, DMAudio.GetNum3DProvidersAvailable() - 1);
}
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0);
break;
case MENUACTION_SPEAKERCONF:
if (m_nPrefsAudio3DProviderIndex != -1) {
m_PrefsSpeakers -= changeValueBy;
- m_PrefsSpeakers = clamp(m_PrefsSpeakers, 0, 2);
+ m_PrefsSpeakers = Clamp(m_PrefsSpeakers, 0, 2);
DMAudio.SetSpeakerConfig(m_PrefsSpeakers);
SaveSettings();
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);