From 595421da3908a2d3e7a1b063605bb3f2a3adb65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Wed, 30 Sep 2020 20:02:47 +0300 Subject: Fixes, mouse AUX buttons, joystick detect menu --- src/core/Frontend.cpp | 21 ++++++++++++--- src/core/Game.cpp | 1 - src/core/Pad.h | 2 ++ src/core/config.h | 3 +++ src/core/re3.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++----- src/core/timebars.cpp | 2 +- 6 files changed, 90 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 9ead2a0a..2cb27730 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -854,6 +854,13 @@ CMenuManager::Draw() str = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[0].m_EntryName); break; default: +#ifdef CUSTOM_FRONTEND_OPTIONS + if (aScreens[m_nCurrScreen].m_aEntries[0].m_SaveSlot == SAVESLOT_CFO) { + FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[0].m_TargetMenu]; + str = (wchar*)option.leftText; + } + else +#endif str = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[0].m_EntryName); break; } @@ -3443,6 +3450,7 @@ CMenuManager::LoadSettings() CFileMgr::Read(fileHandle, m_PrefsSkinFile, 256); CFileMgr::Read(fileHandle, (char*)&m_ControlMethod, 1); CFileMgr::Read(fileHandle, (char*)&m_PrefsLanguage, 1); +/* #ifdef CUSTOM_FRONTEND_OPTIONS for (int i = 0; i < numCustomFrontendOptions; i++) { FrontendOption& option = customFrontendOptions[i]; @@ -3456,6 +3464,7 @@ CMenuManager::LoadSettings() CFileMgr::Read(fileHandle, (char *)&CMenuManager::m_PrefsIslandLoading, 1); CMenuManager::m_DisplayIslandLoading = CMenuManager::m_PrefsIslandLoading; #endif +*/ } } @@ -3546,6 +3555,7 @@ CMenuManager::SaveSettings() CFileMgr::Write(fileHandle, m_PrefsSkinFile, 256); CFileMgr::Write(fileHandle, (char*)&m_ControlMethod, 1); CFileMgr::Write(fileHandle, (char*)&m_PrefsLanguage, 1); +/* #ifdef CUSTOM_FRONTEND_OPTIONS for (int i = 0; i < numCustomFrontendOptions; i++) { FrontendOption &option = customFrontendOptions[i]; @@ -3557,6 +3567,7 @@ CMenuManager::SaveSettings() #ifdef NO_ISLAND_LOADING CFileMgr::Write(fileHandle, (char *)&CMenuManager::m_PrefsIslandLoading, 1); #endif +*/ } CFileMgr::CloseFile(fileHandle); @@ -3880,7 +3891,10 @@ CMenuManager::Process(void) MouseButtonJustClicked = 4; else if (CPad::GetPad(0)->GetMouseWheelDownJustUp()) MouseButtonJustClicked = 5; - // TODO two more buttons + else if (CPad::GetPad(0)->GetMouseX1JustUp()) + MouseButtonJustClicked = 6; + else if (CPad::GetPad(0)->GetMouseX2JustUp()) + MouseButtonJustClicked = 7; JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown(); @@ -5106,7 +5120,8 @@ CMenuManager::ProcessButtonPresses(void) *option.value = option.lastSavedValue = option.displayedValue; } else if (option.type == FEOPTION_DYNAMIC) { - option.buttonPressFunc(FEOPTION_ACTION_SELECT); + if (option.buttonPressFunc) + option.buttonPressFunc(FEOPTION_ACTION_SELECT); } else if (option.type == FEOPTION_REDIRECT) { ChangeScreen(option.to, option.option, true, option.fadeIn); } else if (option.type == FEOPTION_GOBACK) { @@ -5349,7 +5364,7 @@ CMenuManager::ProcessButtonPresses(void) option.changeFunc(option.displayedValue); *option.value = option.lastSavedValue = option.displayedValue; } - } else if (option.type == FEOPTION_DYNAMIC) { + } else if (option.type == FEOPTION_DYNAMIC && option.buttonPressFunc) { option.buttonPressFunc(changeValueBy > 0 ? FEOPTION_ACTION_RIGHT : FEOPTION_ACTION_LEFT); } DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); diff --git a/src/core/Game.cpp b/src/core/Game.cpp index e944512a..bb9df1a2 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -297,7 +297,6 @@ bool CGame::InitialiseOnceAfterRW(void) #ifdef CUSTOM_FRONTEND_OPTIONS if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) { CustomFrontendOptionsPopulate(); - FrontEndMenuManager.LoadSettings(); } #endif return true; diff --git a/src/core/Pad.h b/src/core/Pad.h index 8c3bc752..8c5d7ba3 100644 --- a/src/core/Pad.h +++ b/src/core/Pad.h @@ -277,6 +277,8 @@ public: bool GetMiddleMouseJustUp() { return !!(!NewMouseControllerState.MMB && OldMouseControllerState.MMB); } bool GetMouseWheelUpJustUp() { return !!(!NewMouseControllerState.WHEELUP && OldMouseControllerState.WHEELUP); } bool GetMouseWheelDownJustUp() { return !!(!NewMouseControllerState.WHEELDN && OldMouseControllerState.WHEELDN); } + bool GetMouseX1JustUp() { return !!(!NewMouseControllerState.MXB1 && OldMouseControllerState.MXB1); } + bool GetMouseX2JustUp() { return !!(!NewMouseControllerState.MXB2 && OldMouseControllerState.MXB2); } bool GetLeftMouse() { return NewMouseControllerState.LMB; } bool GetRightMouse() { return NewMouseControllerState.RMB; } diff --git a/src/core/config.h b/src/core/config.h index e8e15ebe..0f3cb2ef 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -226,6 +226,9 @@ enum Config { #if !defined(RW_GL3) && defined(_WIN32) #define XINPUT #endif +#if defined(RW_GL3) && !defined(__SWITCH__) // TODO +#define DONT_TRUST_RECOGNIZED_JOYSTICKS // Then we'll only rely on GLFW gamepad DB, and want user to enter Cpntroller->Detect joysticks if his joystick isn't on that list. +#endif #define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m #define KANGAROO_CHEAT #define ALLCARSHELI_CHEAT diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 13cb6283..b892ca36 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -32,6 +32,7 @@ #include "MBlur.h" #include "postfx.h" #include "custompipes.h" +#include "ControllerConfig.h" #ifndef _WIN32 #include "assert.h" @@ -195,6 +196,7 @@ wchar* MultiSamplingDraw(bool *disabled, bool userHovering) { return unicodeTemp; } } +char* multisamplingKey = "MultiSampling"; #endif #ifdef MORE_LANGUAGES @@ -247,6 +249,8 @@ void FreeCamChange(int8 displayedValue) TheCamera.bFreeCam = !!displayedValue; FrontEndMenuManager.SaveSettings(); } +const wchar* freeCamText = (wchar*)L"FREE CAM"; +char* freeCamKey = "FreeCam"; #endif #ifdef CUTSCENE_BORDERS_SWITCH @@ -255,6 +259,7 @@ void BorderModeChange(int8 displayedValue) CMenuManager::m_PrefsCutsceneBorders = !!displayedValue; FrontEndMenuManager.SaveSettings(); } +char* cutsceneBordersKey = "CutsceneBorders"; #endif #ifdef PS2_ALPHA_TEST @@ -263,11 +268,52 @@ void PS2AlphaTestChange(int8 displayedValue) gPS2alphaTest = !!displayedValue; FrontEndMenuManager.SaveSettings(); } +char* ps2alphaKey = "PS2AlphaTest"; #endif +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +const wchar* detectJoystickText = (wchar*)L"Detect Joystick"; +const wchar* detectJoystickExplanation = (wchar*)L"Press any key on your preferred joystick that you would like to use on the game."; +const wchar* detectedJoystickText = (wchar*)L"Detected Joystick"; +wchar selectedJoystickUnicode[128]; + +wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { + int numButtons; + int found = -1; + const char *joyname; + if (userHovering) { + for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) { + if (joyname = glfwGetJoystickName(i)) { + const uint8* buttons = glfwGetJoystickButtons(i, &numButtons); + for (int j = 0; j < numButtons; j++) { + if (buttons[j]) { + strcpy(gSelectedJoystickName, joyname); + found = i; + break; + } + } + if (found != -1) + break; + } + } + + if (found != -1 && PSGLOBAL(joy1id) != found) { + if (PSGLOBAL(joy1id) != -1 && PSGLOBAL(joy1id) != found) + PSGLOBAL(joy2id) = PSGLOBAL(joy1id); + else + PSGLOBAL(joy2id) = -1; + + PSGLOBAL(joy1id) = found; + } + } + AsciiToUnicode(gSelectedJoystickName, selectedJoystickUnicode); + + return selectedJoystickUnicode; +} +#endif // Important: Make sure to read the warnings/informations in frontendoption.h!! -// For texts: Either use TheText.Get, or use wcsdup(wchar version of strdup) +// If you won't use GXT entry as text, you may want to declare them globally, to not alloc them on each reload. (static declared texts has some problems on Linux etc.) void CustomFrontendOptionsPopulate(void) { @@ -342,14 +388,14 @@ CustomFrontendOptionsPopulate(void) #ifdef MULTISAMPLING SWITCH_TO_GRAPHICS_MENU - FrontendOptionAddDynamic(TheText.Get("FED_AAS"), MultiSamplingDraw, (int8*)&FrontEndMenuManager.m_nPrefsMSAALevel, MultiSamplingButtonPress, MultiSamplingGoBack, true); + FrontendOptionAddDynamic(TheText.Get("FED_AAS"), MultiSamplingDraw, (int8*)&FrontEndMenuManager.m_nPrefsMSAALevel, MultiSamplingButtonPress, MultiSamplingGoBack, multisamplingKey); #endif CLONE_OPTION(TheText.Get("FED_TRA"), MENUACTION_TRAILS, nil, nil); #ifdef PS2_ALPHA_TEST SWITCH_TO_GRAPHICS_MENU - FrontendOptionAddSelect(TheText.Get("FEM_2PR"), off_on, 2, (int8*)&gPS2alphaTest, false, PS2AlphaTestChange, nil, true); + FrontendOptionAddSelect(TheText.Get("FEM_2PR"), off_on, 2, (int8*)&gPS2alphaTest, false, PS2AlphaTestChange, nil, ps2alphaKey); #endif ADD_RESTORE_DEFAULTS(RestoreDefGraphics) @@ -365,13 +411,12 @@ CustomFrontendOptionsPopulate(void) #ifdef CUTSCENE_BORDERS_SWITCH SWITCH_TO_DISPLAY_MENU - FrontendOptionAddSelect(TheText.Get("FEM_CSB"), off_on, 2, (int8 *)&CMenuManager::m_PrefsCutsceneBorders, false, BorderModeChange, nil, true); + FrontendOptionAddSelect(TheText.Get("FEM_CSB"), off_on, 2, (int8 *)&CMenuManager::m_PrefsCutsceneBorders, false, BorderModeChange, nil, cutsceneBordersKey); #endif #ifdef FREE_CAM SWITCH_TO_DISPLAY_MENU - static const wchar* text = (wchar*)wcsdup(L"FREE CAM"); - FrontendOptionAddSelect(text, off_on, 2, (int8*)&TheCamera.bFreeCam, false, FreeCamChange, nil, true); + FrontendOptionAddSelect(freeCamText, off_on, 2, (int8*)&TheCamera.bFreeCam, false, FreeCamChange, nil, freeCamKey); #endif CLONE_OPTION(TheText.Get("FED_SUB"), MENUACTION_SUBTITLES, nil, nil); @@ -388,7 +433,21 @@ CustomFrontendOptionsPopulate(void) #endif ADD_RESTORE_DEFAULTS(RestoreDefDisplay) - ADD_BACK + ADD_BACK + +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS + int detectJoystickMenu = FrontendScreenAdd("FET_CON", MENUSPRITE_MAINMENU, MENUPAGE_CONTROLLER_PC, 50, 60, 20, + FONT_BANK, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE, FESCREEN_LEFT_ALIGN, false); + + FrontendOptionSetCursor(detectJoystickMenu, 0); + + FrontendOptionAddBuiltinAction(detectJoystickExplanation, MENUACTION_LABEL, nil, nil); + FrontendOptionAddDynamic(detectedJoystickText, DetectJoystickDraw, nil, nil, nil); + FrontendOptionAddBackButton(TheText.Get("FEDS_TB")); + + FrontendOptionSetCursor(MENUPAGE_CONTROLLER_PC, 2); + FrontendOptionAddRedirect(detectJoystickText, detectJoystickMenu, 1); +#endif } #endif diff --git a/src/core/timebars.cpp b/src/core/timebars.cpp index 5ac5565d..94051b25 100644 --- a/src/core/timebars.cpp +++ b/src/core/timebars.cpp @@ -89,7 +89,7 @@ void tbDisplay() CFont::SetScale(0.48f, 1.12f); CFont::SetCentreOff(); CFont::SetJustifyOff(); - CFont::SetWrapx(640.0f); + CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); CFont::SetRightJustifyOff(); CFont::SetPropOn(); CFont::SetFontStyle(FONT_BANK); -- cgit v1.2.3 From 3bd333022778cee8dd95b58b02a7263870546c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Fri, 2 Oct 2020 17:36:56 +0300 Subject: Load and write our settings in re3.ini & fixes --- src/core/Frontend.cpp | 37 ++++------------- src/core/Game.cpp | 5 +++ src/core/common.h | 4 +- src/core/config.h | 7 ++-- src/core/main.h | 5 +++ src/core/re3.cpp | 113 ++++++++++++++++++++++++++++++++++++++++---------- 6 files changed, 116 insertions(+), 55 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 2cb27730..db3774a7 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3450,21 +3450,6 @@ CMenuManager::LoadSettings() CFileMgr::Read(fileHandle, m_PrefsSkinFile, 256); CFileMgr::Read(fileHandle, (char*)&m_ControlMethod, 1); CFileMgr::Read(fileHandle, (char*)&m_PrefsLanguage, 1); -/* -#ifdef CUSTOM_FRONTEND_OPTIONS - for (int i = 0; i < numCustomFrontendOptions; i++) { - FrontendOption& option = customFrontendOptions[i]; - if (option.save) { - CFileMgr::Read(fileHandle, (char*)option.value, 1); - option.lastSavedValue = option.displayedValue = *option.value; - } - } -#endif -#ifdef NO_ISLAND_LOADING - CFileMgr::Read(fileHandle, (char *)&CMenuManager::m_PrefsIslandLoading, 1); - CMenuManager::m_DisplayIslandLoading = CMenuManager::m_PrefsIslandLoading; -#endif -*/ } } @@ -3481,8 +3466,11 @@ CMenuManager::LoadSettings() m_bLanguageLoaded = false; else { m_bLanguageLoaded = true; + // Already called in InitialiseChangedLanguageSettings + /* TheText.Unload(); TheText.Load(); + */ m_bFrontEnd_ReloadObrTxtGxt = true; InitialiseChangedLanguageSettings(); @@ -3555,23 +3543,14 @@ CMenuManager::SaveSettings() CFileMgr::Write(fileHandle, m_PrefsSkinFile, 256); CFileMgr::Write(fileHandle, (char*)&m_ControlMethod, 1); CFileMgr::Write(fileHandle, (char*)&m_PrefsLanguage, 1); -/* -#ifdef CUSTOM_FRONTEND_OPTIONS - for (int i = 0; i < numCustomFrontendOptions; i++) { - FrontendOption &option = customFrontendOptions[i]; - if (option.save) { - CFileMgr::Write(fileHandle, (char*)option.value, 1); - } - } -#endif -#ifdef NO_ISLAND_LOADING - CFileMgr::Write(fileHandle, (char *)&CMenuManager::m_PrefsIslandLoading, 1); -#endif -*/ } CFileMgr::CloseFile(fileHandle); CFileMgr::SetDir(""); + +#ifdef LOAD_INI_SETTINGS + SaveINISettings(); +#endif } bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); @@ -6332,4 +6311,4 @@ CMenuManager::ConstructStatLine(int rowIdx) #undef GetBackJustDown #undef ChangeScreen -#endif \ No newline at end of file +#endif diff --git a/src/core/Game.cpp b/src/core/Game.cpp index bb9df1a2..93f0d1b0 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -295,9 +295,14 @@ bool CGame::InitialiseOnceAfterRW(void) CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile); #ifdef CUSTOM_FRONTEND_OPTIONS + // Apparently this func. can be run multiple times at the start. if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) { + // needs stored language and TheText to be loaded, and last TheText reload is at the start of here CustomFrontendOptionsPopulate(); } +#endif +#ifdef LOAD_INI_SETTINGS + LoadINISettings(); // needs frontend options to be loaded #endif return true; } diff --git a/src/core/common.h b/src/core/common.h index 9b5c2369..ef3da265 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -219,6 +219,8 @@ public: extern int strcasecmp(const char *str1, const char *str2); #endif +extern wchar *AllocUnicode(const char*src); + #define clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v)) inline float sq(float x) { return x*x; } @@ -444,4 +446,4 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value) assert(ReadSaveBuf(buf) == size); -void cprintf(char*, ...); \ No newline at end of file +void cprintf(char*, ...); diff --git a/src/core/config.h b/src/core/config.h index 0f3cb2ef..171c6be9 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -198,6 +198,7 @@ enum Config { #define FIX_BUGS // fixes bugs that we've came across during reversing, TODO: use this more #define MORE_LANGUAGES // Add more translations to the game #define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible +#define LOAD_INI_SETTINGS // Rendering/display #define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios @@ -226,8 +227,8 @@ enum Config { #if !defined(RW_GL3) && defined(_WIN32) #define XINPUT #endif -#if defined(RW_GL3) && !defined(__SWITCH__) // TODO -#define DONT_TRUST_RECOGNIZED_JOYSTICKS // Then we'll only rely on GLFW gamepad DB, and want user to enter Cpntroller->Detect joysticks if his joystick isn't on that list. +#if !defined(_WIN32) && !defined(__SWITCH__) +#define DONT_TRUST_RECOGNIZED_JOYSTICKS // Then we'll only rely on GLFW gamepad DB, and expect user to enter Controller->Detect joysticks if his joystick isn't on that list. #endif #define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m #define KANGAROO_CHEAT @@ -309,4 +310,4 @@ enum Config { #undef NO_ISLAND_LOADING #define PC_PARTICLE #define VC_PED_PORTS // To not process collisions always. But should be tested if that's really beneficial -#endif \ No newline at end of file +#endif diff --git a/src/core/main.h b/src/core/main.h index 96fbef05..7eb080cb 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -36,3 +36,8 @@ void ResetLoadingScreenBar(void); #ifndef MASTER void TheModelViewer(void); #endif + +#ifdef LOAD_INI_SETTINGS +void LoadINISettings(); +void SaveINISettings(); +#endif diff --git a/src/core/re3.cpp b/src/core/re3.cpp index b892ca36..069320ec 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1,6 +1,7 @@ #include #define WITHWINDOWS #include "common.h" +#include "platform.h" #include "crossplatform.h" #include "Renderer.h" #include "Credits.h" @@ -16,7 +17,6 @@ #include "Heli.h" #include "Automobile.h" #include "Ped.h" -#include "Particle.h" #include "Console.h" #include "Debug.h" #include "Hud.h" @@ -32,15 +32,12 @@ #include "MBlur.h" #include "postfx.h" #include "custompipes.h" -#include "ControllerConfig.h" #ifndef _WIN32 #include "assert.h" #include #endif -#include - #ifdef RWLIBS extern "C" int vsprintf(char* const _Buffer, char const* const _Format, va_list _ArgList); #endif @@ -74,7 +71,6 @@ mysrand(unsigned int seed) #ifdef CUSTOM_FRONTEND_OPTIONS #include "frontendoption.h" -#include "platform.h" #include "Font.h" void ReloadFrontendOptions(void) @@ -196,7 +192,7 @@ wchar* MultiSamplingDraw(bool *disabled, bool userHovering) { return unicodeTemp; } } -char* multisamplingKey = "MultiSampling"; +const char* multisamplingKey = "MultiSampling"; #endif #ifdef MORE_LANGUAGES @@ -249,8 +245,7 @@ void FreeCamChange(int8 displayedValue) TheCamera.bFreeCam = !!displayedValue; FrontEndMenuManager.SaveSettings(); } -const wchar* freeCamText = (wchar*)L"FREE CAM"; -char* freeCamKey = "FreeCam"; +const char* freeCamKey = "FreeCam"; #endif #ifdef CUTSCENE_BORDERS_SWITCH @@ -259,7 +254,7 @@ void BorderModeChange(int8 displayedValue) CMenuManager::m_PrefsCutsceneBorders = !!displayedValue; FrontEndMenuManager.SaveSettings(); } -char* cutsceneBordersKey = "CutsceneBorders"; +const char* cutsceneBordersKey = "CutsceneBorders"; #endif #ifdef PS2_ALPHA_TEST @@ -268,13 +263,10 @@ void PS2AlphaTestChange(int8 displayedValue) gPS2alphaTest = !!displayedValue; FrontEndMenuManager.SaveSettings(); } -char* ps2alphaKey = "PS2AlphaTest"; +const char* ps2alphaKey = "PS2AlphaTest"; #endif #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS -const wchar* detectJoystickText = (wchar*)L"Detect Joystick"; -const wchar* detectJoystickExplanation = (wchar*)L"Press any key on your preferred joystick that you would like to use on the game."; -const wchar* detectedJoystickText = (wchar*)L"Detected Joystick"; wchar selectedJoystickUnicode[128]; wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { @@ -287,7 +279,6 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { const uint8* buttons = glfwGetJoystickButtons(i, &numButtons); for (int j = 0; j < numButtons; j++) { if (buttons[j]) { - strcpy(gSelectedJoystickName, joyname); found = i; break; } @@ -303,17 +294,21 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { else PSGLOBAL(joy2id) = -1; + strcpy(gSelectedJoystickName, joyname); PSGLOBAL(joy1id) = found; } } - AsciiToUnicode(gSelectedJoystickName, selectedJoystickUnicode); + if (PSGLOBAL(joy1id) == -1) + AsciiToUnicode("Not found", selectedJoystickUnicode); + else + AsciiToUnicode(gSelectedJoystickName, selectedJoystickUnicode); return selectedJoystickUnicode; } #endif // Important: Make sure to read the warnings/informations in frontendoption.h!! -// If you won't use GXT entry as text, you may want to declare them globally, to not alloc them on each reload. (static declared texts has some problems on Linux etc.) +// If you will hardcode any text, please use AllocUnicode! wchar_t size differs between platforms void CustomFrontendOptionsPopulate(void) { @@ -416,7 +411,7 @@ CustomFrontendOptionsPopulate(void) #ifdef FREE_CAM SWITCH_TO_DISPLAY_MENU - FrontendOptionAddSelect(freeCamText, off_on, 2, (int8*)&TheCamera.bFreeCam, false, FreeCamChange, nil, freeCamKey); + FrontendOptionAddSelect(TheText.Get("FEC_FRC"), off_on, 2, (int8*)&TheCamera.bFreeCam, false, FreeCamChange, nil, freeCamKey); #endif CLONE_OPTION(TheText.Get("FED_SUB"), MENUACTION_SUBTITLES, nil, nil); @@ -433,24 +428,96 @@ CustomFrontendOptionsPopulate(void) #endif ADD_RESTORE_DEFAULTS(RestoreDefDisplay) - ADD_BACK + ADD_BACK #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS - int detectJoystickMenu = FrontendScreenAdd("FET_CON", MENUSPRITE_MAINMENU, MENUPAGE_CONTROLLER_PC, 50, 60, 20, + int detectJoystickMenu = FrontendScreenAdd("FEC_JOD", MENUSPRITE_MAINMENU, MENUPAGE_CONTROLLER_PC, 40, 60, 20, FONT_BANK, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE, FESCREEN_LEFT_ALIGN, false); FrontendOptionSetCursor(detectJoystickMenu, 0); - FrontendOptionAddBuiltinAction(detectJoystickExplanation, MENUACTION_LABEL, nil, nil); - FrontendOptionAddDynamic(detectedJoystickText, DetectJoystickDraw, nil, nil, nil); + FrontendOptionAddBuiltinAction(TheText.Get("FEC_JPR"), MENUACTION_LABEL, nil, nil); + FrontendOptionAddDynamic(TheText.Get("FEC_JDE"), DetectJoystickDraw, nil, nil, nil); FrontendOptionAddBackButton(TheText.Get("FEDS_TB")); FrontendOptionSetCursor(MENUPAGE_CONTROLLER_PC, 2); - FrontendOptionAddRedirect(detectJoystickText, detectJoystickMenu, 1); + FrontendOptionAddRedirect(TheText.Get("FEC_JOD"), detectJoystickMenu, 1); #endif } #endif +#ifdef LOAD_INI_SETTINGS +#include "ini_parser.hpp" +void LoadINISettings() +{ + linb::ini cfg; + cfg.load_file("re3.ini"); + char defaultStr[4]; + +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS + strcpy(gSelectedJoystickName, cfg.get("DetectJoystick", "JoystickName", "").c_str()); + _InputInitialiseJoys(); +#endif + +#ifdef CUSTOM_FRONTEND_OPTIONS + for (int i = 0; i < numCustomFrontendOptions; i++) { + FrontendOption& option = customFrontendOptions[i]; + if (option.save) { + // CFO only supports saving uint8 right now + sprintf(defaultStr, "%u", *option.value); + option.lastSavedValue = option.displayedValue = *option.value = atoi(cfg.get("FrontendOptions", option.save, defaultStr).c_str()); + } + } +#endif + +#ifdef NO_ISLAND_LOADING + sprintf(defaultStr, "%u", CMenuManager::m_PrefsIslandLoading); + CMenuManager::m_PrefsIslandLoading = atoi(cfg.get("FrontendOptions", "NoIslandLoading", defaultStr).c_str()); + CMenuManager::m_DisplayIslandLoading = CMenuManager::m_PrefsIslandLoading; +#endif + +} + +void SaveINISettings() +{ + linb::ini cfg; + cfg.load_file("re3.ini"); + bool changed = false; + char temp[4]; + +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS + if (strncmp(cfg.get("DetectJoystick", "JoystickName", "").c_str(), gSelectedJoystickName, strlen(gSelectedJoystickName)) != 0) { + changed = true; + cfg.set("DetectJoystick", "JoystickName", gSelectedJoystickName); + } +#endif +#ifdef CUSTOM_FRONTEND_OPTIONS + for (int i = 0; i < numCustomFrontendOptions; i++) { + FrontendOption &option = customFrontendOptions[i]; + if (option.save) { + if (atoi(cfg.get("FrontendOptions", option.save, "xxx").c_str()) != *option.value) { // if .ini doesn't have that key compare with xxx, so we can add it + changed = true; + sprintf(temp, "%u", *option.value); + cfg.set("FrontendOptions", option.save, temp); + } + } + } +#endif +#ifdef NO_ISLAND_LOADING + if (atoi(cfg.get("FrontendOptions", "NoIslandLoading", "xxx").c_str()) != CMenuManager::m_PrefsIslandLoading) { + changed = true; + sprintf(temp, "%u", CMenuManager::m_PrefsIslandLoading); + cfg.set("FrontendOptions", "NoIslandLoading", temp); + } +#endif + + if (changed) + cfg.write_file("re3.ini"); +} + +#endif + + #ifdef DEBUGMENU void WeaponCheat(); void HealthCheat(); @@ -598,6 +665,8 @@ static const char *carnames[] = { "yankee", "escape", "borgnine", "toyz", "ghost", }; +//#include + static CTweakVar** TweakVarsList; static int TweakVarsListSize = -1; static bool bAddTweakVarsNow = false; -- cgit v1.2.3