diff options
author | erorcun <erayorcunus@gmail.com> | 2020-10-04 21:18:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-04 21:18:33 +0200 |
commit | ea4007a13c844007b5b5ad06b6e01941cbd66e10 (patch) | |
tree | 32195602f9ba72f90ff2dbe4a2a1447f339012e1 /src/core/re3.cpp | |
parent | small fix (diff) | |
parent | Merge branch 'master' into master (diff) | |
download | re3-ea4007a13c844007b5b5ad06b6e01941cbd66e10.tar re3-ea4007a13c844007b5b5ad06b6e01941cbd66e10.tar.gz re3-ea4007a13c844007b5b5ad06b6e01941cbd66e10.tar.bz2 re3-ea4007a13c844007b5b5ad06b6e01941cbd66e10.tar.lz re3-ea4007a13c844007b5b5ad06b6e01941cbd66e10.tar.xz re3-ea4007a13c844007b5b5ad06b6e01941cbd66e10.tar.zst re3-ea4007a13c844007b5b5ad06b6e01941cbd66e10.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/re3.cpp | 148 |
1 files changed, 138 insertions, 10 deletions
diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 13cb6283..069320ec 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1,6 +1,7 @@ #include <csignal> #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" @@ -38,8 +38,6 @@ #include <stdarg.h> #endif -#include <list> - #ifdef RWLIBS extern "C" int vsprintf(char* const _Buffer, char const* const _Format, va_list _ArgList); #endif @@ -73,7 +71,6 @@ mysrand(unsigned int seed) #ifdef CUSTOM_FRONTEND_OPTIONS #include "frontendoption.h" -#include "platform.h" #include "Font.h" void ReloadFrontendOptions(void) @@ -195,6 +192,7 @@ wchar* MultiSamplingDraw(bool *disabled, bool userHovering) { return unicodeTemp; } } +const char* multisamplingKey = "MultiSampling"; #endif #ifdef MORE_LANGUAGES @@ -247,6 +245,7 @@ void FreeCamChange(int8 displayedValue) TheCamera.bFreeCam = !!displayedValue; FrontEndMenuManager.SaveSettings(); } +const char* freeCamKey = "FreeCam"; #endif #ifdef CUTSCENE_BORDERS_SWITCH @@ -255,6 +254,7 @@ void BorderModeChange(int8 displayedValue) CMenuManager::m_PrefsCutsceneBorders = !!displayedValue; FrontEndMenuManager.SaveSettings(); } +const char* cutsceneBordersKey = "CutsceneBorders"; #endif #ifdef PS2_ALPHA_TEST @@ -263,11 +263,52 @@ void PS2AlphaTestChange(int8 displayedValue) gPS2alphaTest = !!displayedValue; FrontEndMenuManager.SaveSettings(); } +const char* ps2alphaKey = "PS2AlphaTest"; #endif +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +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]) { + 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; + + strcpy(gSelectedJoystickName, joyname); + PSGLOBAL(joy1id) = found; + } + } + 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!! -// For texts: Either use TheText.Get, or use wcsdup(wchar version of strdup) +// If you will hardcode any text, please use AllocUnicode! wchar_t size differs between platforms void CustomFrontendOptionsPopulate(void) { @@ -342,14 +383,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 +406,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(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); @@ -389,9 +429,95 @@ CustomFrontendOptionsPopulate(void) ADD_RESTORE_DEFAULTS(RestoreDefDisplay) ADD_BACK + +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS + 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(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(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(); @@ -539,6 +665,8 @@ static const char *carnames[] = { "yankee", "escape", "borgnine", "toyz", "ghost", }; +//#include <list> + static CTweakVar** TweakVarsList; static int TweakVarsListSize = -1; static bool bAddTweakVarsNow = false; |