[options] Remove duplicate string constants

* Changed the string to enum conversions to be built at runtime from
  the existing constant array rather than redefining the strings.
* Fixed an issue in the initialization of the `checkable_mi` array.
  A test had been mistakenly removed during the refactor.
* Fixed an issue where changing a bool or int option would cause an
  assertion error at runtime. Changed helper methods definitions to
  use a pointer to a variable rather than take a parameter by
  reference, clarifying the intent from the caller perspective.
* Fixed the `renderer` enum definition to properly exclude Direct3D or
  Quartz2D depending on the platform.
* Various comment fixes.
This commit is contained in:
Fabrice de Gans 2022-09-07 22:58:29 -07:00 committed by Rafael Kitover
parent c4d46a713f
commit 4a056c7720
7 changed files with 239 additions and 354 deletions

View File

@ -31,24 +31,26 @@ bool cmditem_lt(const struct cmditem& cmd1, const struct cmditem& cmd2)
return wxStrcmp(cmd1.cmd, cmd2.cmd) < 0;
}
void MainFrame::GetMenuOptionBool(const wxString& menuName, bool field)
void MainFrame::GetMenuOptionBool(const wxString& menuName, bool* field)
{
field = !field;
assert(field);
*field = !*field;
int id = wxXmlResource::GetXRCID(menuName);
for (size_t i = 0; i < checkable_mi.size(); i++) {
if (checkable_mi[i].cmd != id)
continue;
field = checkable_mi[i].mi->IsChecked();
*field = checkable_mi[i].mi->IsChecked();
break;
}
}
void MainFrame::GetMenuOptionInt(const wxString& menuName, int field, int mask)
void MainFrame::GetMenuOptionInt(const wxString& menuName, int* field, int mask)
{
assert(field);
int value = mask;
bool is_checked = ((field) & (mask)) != (value);
bool is_checked = ((*field) & (mask)) != (value);
int id = wxXmlResource::GetXRCID(menuName);
for (size_t i = 0; i < checkable_mi.size(); i++) {
@ -59,7 +61,7 @@ void MainFrame::GetMenuOptionInt(const wxString& menuName, int field, int mask)
break;
}
field = ((field) & ~(mask)) | (is_checked ? (value) : 0);
*field = ((*field) & ~(mask)) | (is_checked ? (value) : 0);
}
void MainFrame::SetMenuOption(const wxString& menuName, int value)
@ -192,8 +194,8 @@ EVT_HANDLER(RecentReset, "Reset recent ROM list")
EVT_HANDLER(RecentFreeze, "Freeze recent ROM list (toggle)")
{
bool menuPress;
GetMenuOptionBool("RecentFreeze", menuPress);
bool menuPress = false;
GetMenuOptionBool("RecentFreeze", &menuPress);
toggleBooleanVar(&menuPress, &gopts.recent_freeze);
SetMenuOption("RecentFreeze", gopts.recent_freeze ? 1 : 0);
update_opts();
@ -1471,8 +1473,8 @@ EVT_HANDLER(wxID_EXIT, "Exit")
// Emulation menu
EVT_HANDLER(Pause, "Pause (toggle)")
{
bool menuPress;
GetMenuOptionBool("Pause", menuPress);
bool menuPress = false;
GetMenuOptionBool("Pause", &menuPress);
toggleBooleanVar(&menuPress, &paused);
SetMenuOption("Pause", paused ? 1 : 0);
@ -1491,8 +1493,8 @@ EVT_HANDLER(Pause, "Pause (toggle)")
// new
EVT_HANDLER_MASK(EmulatorSpeedupToggle, "Turbo mode (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
GetMenuOptionBool("EmulatorSpeedupToggle", menuPress);
bool menuPress = false;
GetMenuOptionBool("EmulatorSpeedupToggle", &menuPress);
toggleBooleanVar(&menuPress, &turbo);
SetMenuOption("EmulatorSpeedupToggle", turbo ? 1 : 0);
}
@ -1510,156 +1512,156 @@ EVT_HANDLER(ToggleFullscreen, "Full screen (toggle)")
EVT_HANDLER(JoypadAutofireA, "Autofire A (toggle)")
{
bool menuPress;
GetMenuOptionBool("JoypadAutofireA", menuPress);
bool menuPress = false;
GetMenuOptionBool("JoypadAutofireA", &menuPress);
toggleBitVar(&menuPress, &autofire, KEYM_A);
SetMenuOption("JoypadAutofireA", menuPress ? 1 : 0);
GetMenuOptionInt("JoypadAutofireA", autofire, KEYM_A);
GetMenuOptionInt("JoypadAutofireA", &autofire, KEYM_A);
}
EVT_HANDLER(JoypadAutofireB, "Autofire B (toggle)")
{
bool menuPress;
GetMenuOptionBool("JoypadAutofireB", menuPress);
bool menuPress = false;
GetMenuOptionBool("JoypadAutofireB", &menuPress);
toggleBitVar(&menuPress, &autofire, KEYM_B);
SetMenuOption("JoypadAutofireB", menuPress ? 1 : 0);
GetMenuOptionInt("JoypadAutofireB", autofire, KEYM_B);
GetMenuOptionInt("JoypadAutofireB", &autofire, KEYM_B);
}
EVT_HANDLER(JoypadAutofireL, "Autofire L (toggle)")
{
bool menuPress;
GetMenuOptionBool("JoypadAutofireL", menuPress);
bool menuPress = false;
GetMenuOptionBool("JoypadAutofireL", &menuPress);
toggleBitVar(&menuPress, &autofire, KEYM_L);
SetMenuOption("JoypadAutofireL", menuPress ? 1 : 0);
GetMenuOptionInt("JoypadAutofireL", autofire, KEYM_L);
GetMenuOptionInt("JoypadAutofireL", &autofire, KEYM_L);
}
EVT_HANDLER(JoypadAutofireR, "Autofire R (toggle)")
{
bool menuPress;
GetMenuOptionBool("JoypadAutofireR", menuPress);
bool menuPress = false;
GetMenuOptionBool("JoypadAutofireR", &menuPress);
toggleBitVar(&menuPress, &autofire, KEYM_R);
SetMenuOption("JoypadAutofireR", menuPress ? 1 : 0);
GetMenuOptionInt("JoypadAutofireR", autofire, KEYM_R);
GetMenuOptionInt("JoypadAutofireR", &autofire, KEYM_R);
}
EVT_HANDLER(JoypadAutoholdUp, "Autohold Up (toggle)")
{
bool menuPress;
bool menuPress = false;
char keyName[] = "JoypadAutoholdUp";
int keym = KEYM_UP;
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym);
GetMenuOptionInt(keyName, &autohold, keym);
}
EVT_HANDLER(JoypadAutoholdDown, "Autohold Down (toggle)")
{
bool menuPress;
bool menuPress = false;
char keyName[] = "JoypadAutoholdDown";
int keym = KEYM_DOWN;
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym);
GetMenuOptionInt(keyName, &autohold, keym);
}
EVT_HANDLER(JoypadAutoholdLeft, "Autohold Left (toggle)")
{
bool menuPress;
bool menuPress = false;
char keyName[] = "JoypadAutoholdLeft";
int keym = KEYM_LEFT;
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym);
GetMenuOptionInt(keyName, &autohold, keym);
}
EVT_HANDLER(JoypadAutoholdRight, "Autohold Right (toggle)")
{
bool menuPress;
bool menuPress = false;
char keyName[] = "JoypadAutoholdRight";
int keym = KEYM_RIGHT;
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym);
GetMenuOptionInt(keyName, &autohold, keym);
}
EVT_HANDLER(JoypadAutoholdA, "Autohold A (toggle)")
{
bool menuPress;
bool menuPress = false;
char keyName[] = "JoypadAutoholdA";
int keym = KEYM_A;
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym);
GetMenuOptionInt(keyName, &autohold, keym);
}
EVT_HANDLER(JoypadAutoholdB, "Autohold B (toggle)")
{
bool menuPress;
bool menuPress = false;
char keyName[] = "JoypadAutoholdB";
int keym = KEYM_B;
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym);
GetMenuOptionInt(keyName, &autohold, keym);
}
EVT_HANDLER(JoypadAutoholdL, "Autohold L (toggle)")
{
bool menuPress;
bool menuPress = false;
char keyName[] = "JoypadAutoholdL";
int keym = KEYM_L;
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym);
GetMenuOptionInt(keyName, &autohold, keym);
}
EVT_HANDLER(JoypadAutoholdR, "Autohold R (toggle)")
{
bool menuPress;
bool menuPress = false;
char keyName[] = "JoypadAutoholdR";
int keym = KEYM_R;
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym);
GetMenuOptionInt(keyName, &autohold, keym);
}
EVT_HANDLER(JoypadAutoholdSelect, "Autohold Select (toggle)")
{
bool menuPress;
bool menuPress = false;
char keyName[] = "JoypadAutoholdSelect";
int keym = KEYM_SELECT;
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym);
GetMenuOptionInt(keyName, &autohold, keym);
}
EVT_HANDLER(JoypadAutoholdStart, "Autohold Start (toggle)")
{
bool menuPress;
bool menuPress = false;
char keyName[] = "JoypadAutoholdStart";
int keym = KEYM_START;
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym);
GetMenuOptionInt(keyName, &autohold, keym);
}
#include "background-input.h"
EVT_HANDLER(AllowKeyboardBackgroundInput, "Allow keyboard background input (toggle)")
{
bool menuPress;
GetMenuOptionBool("AllowKeyboardBackgroundInput", menuPress);
bool menuPress = false;
GetMenuOptionBool("AllowKeyboardBackgroundInput", &menuPress);
toggleBooleanVar(&menuPress, &allowKeyboardBackgroundInput);
SetMenuOption("AllowKeyboardBackgroundInput", allowKeyboardBackgroundInput ? 1 : 0);
@ -1676,8 +1678,8 @@ EVT_HANDLER(AllowKeyboardBackgroundInput, "Allow keyboard background input (togg
EVT_HANDLER(AllowJoystickBackgroundInput, "Allow joystick background input (toggle)")
{
bool menuPress;
GetMenuOptionBool("AllowJoystickBackgroundInput", menuPress);
bool menuPress = false;
GetMenuOptionBool("AllowJoystickBackgroundInput", &menuPress);
toggleBooleanVar(&menuPress, &allowJoystickBackgroundInput);
SetMenuOption("AllowJoystickBackgroundInput", allowJoystickBackgroundInput ? 1 : 0);
@ -1691,8 +1693,8 @@ EVT_HANDLER_MASK(LoadGameRecent, "Load most recent save", CMDEN_SAVST)
EVT_HANDLER(LoadGameAutoLoad, "Auto load most recent save (toggle)")
{
bool menuPress;
GetMenuOptionBool("LoadGameAutoLoad", menuPress);
bool menuPress = false;
GetMenuOptionBool("LoadGameAutoLoad", &menuPress);
toggleBooleanVar(&menuPress, &gopts.autoload_state);
SetMenuOption("LoadGameAutoLoad", gopts.autoload_state ? 1 : 0);
update_opts();
@ -1769,22 +1771,22 @@ EVT_HANDLER_MASK(Load, "Load state...", CMDEN_GB | CMDEN_GBA)
// new
EVT_HANDLER(KeepSaves, "Do not load battery saves (toggle)")
{
bool menuPress;
GetMenuOptionBool("KeepSaves", menuPress);
bool menuPress = false;
GetMenuOptionBool("KeepSaves", &menuPress);
toggleBitVar(&menuPress, &skipSaveGameBattery, 1);
SetMenuOption("KeepSaves", menuPress ? 1 : 0);
GetMenuOptionInt("KeepSaves", skipSaveGameBattery, 1);
GetMenuOptionInt("KeepSaves", &skipSaveGameBattery, 1);
update_opts();
}
// new
EVT_HANDLER(KeepCheats, "Do not change cheat list (toggle)")
{
bool menuPress;
GetMenuOptionBool("KeepCheats", menuPress);
bool menuPress = false;
GetMenuOptionBool("KeepCheats", &menuPress);
toggleBitVar(&menuPress, &skipSaveGameCheats, 1);
SetMenuOption("KeepCheats", menuPress ? 1 : 0);
GetMenuOptionInt("KeepCheats", skipSaveGameCheats, 1);
GetMenuOptionInt("KeepCheats", &skipSaveGameCheats, 1);
update_opts();
}
@ -1945,8 +1947,8 @@ EVT_HANDLER_MASK(CheatsSearch, "Create cheat...", CMDEN_GB | CMDEN_GBA)
// new
EVT_HANDLER(CheatsAutoSaveLoad, "Auto save/load cheats (toggle)")
{
bool menuPress;
GetMenuOptionBool("CheatsAutoSaveLoad", menuPress);
bool menuPress = false;
GetMenuOptionBool("CheatsAutoSaveLoad", &menuPress);
toggleBooleanVar(&menuPress, &gopts.autoload_cheats);
SetMenuOption("CheatsAutoSaveLoad", gopts.autoload_cheats ? 1 : 0);
update_opts();
@ -1956,18 +1958,18 @@ EVT_HANDLER(CheatsAutoSaveLoad, "Auto save/load cheats (toggle)")
// changed for convenience to match internal variable functionality
EVT_HANDLER(CheatsEnable, "Enable cheats (toggle)")
{
bool menuPress;
GetMenuOptionBool("CheatsEnable", menuPress);
bool menuPress = false;
GetMenuOptionBool("CheatsEnable", &menuPress);
toggleBitVar(&menuPress, &cheatsEnabled, 1);
SetMenuOption("CheatsEnable", menuPress ? 1 : 0);
GetMenuOptionInt("CheatsEnable", cheatsEnabled, 1);
GetMenuOptionInt("CheatsEnable", &cheatsEnabled, 1);
update_opts();
}
EVT_HANDLER(ColorizerHack, "Enable Colorizer Hack (toggle)")
{
int val = 0;
GetMenuOptionInt("ColorizerHack", val, 1);
GetMenuOptionInt("ColorizerHack", &val, 1);
if (val == 1 && useBiosFileGB == 1) {
wxLogError(_("Cannot use Colorizer Hack when GB BIOS File is enabled."));
@ -1983,96 +1985,96 @@ EVT_HANDLER(ColorizerHack, "Enable Colorizer Hack (toggle)")
// Debug menu
EVT_HANDLER_MASK(VideoLayersBG0, "Video layer BG0 (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "VideoLayersBG0";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 8));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 8));
GetMenuOptionInt(keyName, &layerSettings, (1 << 8));
layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false);
}
EVT_HANDLER_MASK(VideoLayersBG1, "Video layer BG1 (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "VideoLayersBG1";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 9));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 9));
GetMenuOptionInt(keyName, &layerSettings, (1 << 9));
layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false);
}
EVT_HANDLER_MASK(VideoLayersBG2, "Video layer BG2 (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "VideoLayersBG2";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 10));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 10));
GetMenuOptionInt(keyName, &layerSettings, (1 << 10));
layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false);
}
EVT_HANDLER_MASK(VideoLayersBG3, "Video layer BG3 (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "VideoLayersBG3";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 11));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 11));
GetMenuOptionInt(keyName, &layerSettings, (1 << 11));
layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false);
}
EVT_HANDLER_MASK(VideoLayersOBJ, "Video layer OBJ (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "VideoLayersOBJ";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 12));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 12));
GetMenuOptionInt(keyName, &layerSettings, (1 << 12));
layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false);
}
EVT_HANDLER_MASK(VideoLayersWIN0, "Video layer WIN0 (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "VideoLayersWIN0";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 13));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 13));
GetMenuOptionInt(keyName, &layerSettings, (1 << 13));
layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false);
}
EVT_HANDLER_MASK(VideoLayersWIN1, "Video layer WIN1 (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "VideoLayersWIN1";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 14));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 14));
GetMenuOptionInt(keyName, &layerSettings, (1 << 14));
layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false);
}
EVT_HANDLER_MASK(VideoLayersOBJWIN, "Video layer OBJWIN (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "VideoLayersOBJWIN";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 15));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 15));
GetMenuOptionInt(keyName, &layerSettings, (1 << 15));
layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false);
}
@ -2103,72 +2105,72 @@ EVT_HANDLER_MASK(VideoLayersReset, "Show all video layers", CMDEN_GB | CMDEN_GBA
EVT_HANDLER_MASK(SoundChannel1, "Sound Channel 1 (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "SoundChannel1";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 0));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 0));
GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 0));
soundSetEnable(gopts.sound_en);
update_opts();
}
EVT_HANDLER_MASK(SoundChannel2, "Sound Channel 2 (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "SoundChannel2";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 1));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 1));
GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 1));
soundSetEnable(gopts.sound_en);
update_opts();
}
EVT_HANDLER_MASK(SoundChannel3, "Sound Channel 3 (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "SoundChannel3";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 2));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 2));
GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 2));
soundSetEnable(gopts.sound_en);
update_opts();
}
EVT_HANDLER_MASK(SoundChannel4, "Sound Channel 4 (toggle)", CMDEN_GB | CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "SoundChannel4";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 3));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 3));
GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 3));
soundSetEnable(gopts.sound_en);
update_opts();
}
EVT_HANDLER_MASK(DirectSoundA, "Direct Sound A (toggle)", CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "DirectSoundA";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 8));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 8));
GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 8));
soundSetEnable(gopts.sound_en);
update_opts();
}
EVT_HANDLER_MASK(DirectSoundB, "Direct Sound B (toggle)", CMDEN_GBA)
{
bool menuPress;
bool menuPress = false;
char keyName[] = "DirectSoundB";
GetMenuOptionBool(keyName, menuPress);
GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 9));
SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 9));
GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 9));
soundSetEnable(gopts.sound_en);
update_opts();
}
@ -2315,7 +2317,7 @@ EVT_HANDLER(DebugGDBPort, "Configure port...")
EVT_HANDLER(DebugGDBBreakOnLoad, "Break on load")
{
#ifndef NO_DEBUGGER
GetMenuOptionInt("DebugGDBBreakOnLoad", gdbBreakOnLoad, 1);
GetMenuOptionInt("DebugGDBBreakOnLoad", &gdbBreakOnLoad, 1);
update_opts();
#endif
}
@ -2976,7 +2978,7 @@ EVT_HANDLER(wxID_ABOUT, "About...")
EVT_HANDLER(Bilinear, "Use bilinear filter with 3d renderer")
{
GetMenuOptionBool("Bilinear", gopts.bilinear);
GetMenuOptionBool("Bilinear", &gopts.bilinear);
// Force new panel with new bilinear option
if (panel->panel) {
panel->panel->Destroy();
@ -2987,7 +2989,7 @@ EVT_HANDLER(Bilinear, "Use bilinear filter with 3d renderer")
EVT_HANDLER(RetainAspect, "Retain aspect ratio when resizing")
{
GetMenuOptionBool("RetainAspect", gopts.retain_aspect);
GetMenuOptionBool("RetainAspect", &gopts.retain_aspect);
// Force new panel with new aspect ratio options.
if (panel->panel) {
@ -3000,7 +3002,7 @@ EVT_HANDLER(RetainAspect, "Retain aspect ratio when resizing")
EVT_HANDLER(Printer, "Enable printer emulation")
{
GetMenuOptionInt("Printer", winGbPrinterEnabled, 1);
GetMenuOptionInt("Printer", &winGbPrinterEnabled, 1);
#if (defined __WIN32__ || defined _WIN32)
#ifndef NO_LINK
gbSerialFunction = gbStartLink;
@ -3016,25 +3018,25 @@ EVT_HANDLER(Printer, "Enable printer emulation")
EVT_HANDLER(PrintGather, "Automatically gather a full page before printing")
{
GetMenuOptionBool("PrintGather", gopts.print_auto_page);
GetMenuOptionBool("PrintGather", &gopts.print_auto_page);
update_opts();
}
EVT_HANDLER(PrintSnap, "Automatically save printouts as screen captures with -print suffix")
{
GetMenuOptionBool("PrintSnap", gopts.print_screen_cap);
GetMenuOptionBool("PrintSnap", &gopts.print_screen_cap);
update_opts();
}
EVT_HANDLER(GBASoundInterpolation, "GBA sound interpolation")
{
GetMenuOptionBool("GBASoundInterpolation", soundInterpolation);
GetMenuOptionBool("GBASoundInterpolation", &soundInterpolation);
update_opts();
}
EVT_HANDLER(GBDeclicking, "GB sound declicking")
{
GetMenuOptionBool("GBDeclicking", gopts.gb_declick);
GetMenuOptionBool("GBDeclicking", &gopts.gb_declick);
// note that setting declick may reset gb sound engine
gbSoundSetDeclicking(gopts.gb_declick);
update_opts();
@ -3042,28 +3044,28 @@ EVT_HANDLER(GBDeclicking, "GB sound declicking")
EVT_HANDLER(GBEnhanceSound, "Enable GB sound effects")
{
GetMenuOptionBool("GBEnhanceSound", gopts.gb_effects_config_enabled);
GetMenuOptionBool("GBEnhanceSound", &gopts.gb_effects_config_enabled);
gb_effects_config.enabled = gopts.gb_effects_config_enabled;
update_opts();
}
EVT_HANDLER(GBSurround, "GB surround sound effect (%)")
{
GetMenuOptionBool("GBSurround", gopts.gb_effects_config_surround);
GetMenuOptionBool("GBSurround",&gopts.gb_effects_config_surround);
gb_effects_config.surround = gopts.gb_effects_config_surround;
update_opts();
}
EVT_HANDLER(AGBPrinter, "Enable AGB printer")
{
GetMenuOptionInt("AGBPrinter", agbPrint, 1);
GetMenuOptionInt("AGBPrinter", &agbPrint, 1);
update_opts();
}
EVT_HANDLER_MASK(GBALcdFilter, "Enable LCD filter", CMDEN_GBA)
{
bool menuPress;
GetMenuOptionBool("GBALcdFilter", menuPress);
bool menuPress = false;
GetMenuOptionBool("GBALcdFilter", &menuPress);
toggleBooleanVar(&menuPress, &gbaLcdFilter);
SetMenuOption("GBALcdFilter", gbaLcdFilter ? 1 : 0);
utilUpdateSystemColorMaps(gbaLcdFilter);
@ -3072,8 +3074,8 @@ EVT_HANDLER_MASK(GBALcdFilter, "Enable LCD filter", CMDEN_GBA)
EVT_HANDLER_MASK(GBLcdFilter, "Enable LCD filter", CMDEN_GB)
{
bool menuPress;
GetMenuOptionBool("GBLcdFilter", menuPress);
bool menuPress = false;
GetMenuOptionBool("GBLcdFilter", &menuPress);
toggleBooleanVar(&menuPress, &gbLcdFilter);
SetMenuOption("GBLcdFilter", gbLcdFilter ? 1 : 0);
utilUpdateSystemColorMaps(gbLcdFilter);
@ -3082,9 +3084,9 @@ EVT_HANDLER_MASK(GBLcdFilter, "Enable LCD filter", CMDEN_GB)
EVT_HANDLER(GBColorOption, "Enable GB color option")
{
bool menuPress;
bool menuPress = false;
bool intVar = gbColorOption ? true : false;
GetMenuOptionBool("GBColorOption", menuPress);
GetMenuOptionBool("GBColorOption", &menuPress);
toggleBooleanVar(&menuPress, &intVar);
SetMenuOption("GBColorOption", intVar ? 1 : 0);
gbColorOption = intVar ? 1 : 0;
@ -3093,21 +3095,21 @@ EVT_HANDLER(GBColorOption, "Enable GB color option")
EVT_HANDLER(ApplyPatches, "Apply IPS/UPS/IPF patches if found")
{
GetMenuOptionInt("ApplyPatches", autoPatch, 1);
GetMenuOptionInt("ApplyPatches", &autoPatch, 1);
update_opts();
}
EVT_HANDLER(MMX, "Enable MMX")
{
#ifdef MMX
GetMenuOptionInt("MMX", enableMMX, 1);
GetMenuOptionInt("MMX", &enableMMX, 1);
update_opts();
#endif
}
EVT_HANDLER(KeepOnTop, "Keep window on top")
{
GetMenuOptionBool("KeepOnTop", gopts.keep_on_top);
GetMenuOptionBool("KeepOnTop", &gopts.keep_on_top);
MainFrame* mf = wxGetApp().frame;
if (gopts.keep_on_top)
@ -3120,7 +3122,7 @@ EVT_HANDLER(KeepOnTop, "Keep window on top")
EVT_HANDLER(StatusBar, "Enable status bar")
{
GetMenuOptionInt("StatusBar", gopts.statusbar, 1);
GetMenuOptionInt("StatusBar", &gopts.statusbar, 1);
update_opts();
MainFrame* mf = wxGetApp().frame;
@ -3136,56 +3138,56 @@ EVT_HANDLER(StatusBar, "Enable status bar")
EVT_HANDLER(NoStatusMsg, "Disable on-screen status messages")
{
GetMenuOptionInt("NoStatusMsg", disableStatusMessages, 1);
GetMenuOptionInt("NoStatusMsg", &disableStatusMessages, 1);
update_opts();
}
EVT_HANDLER(FrameSkipAuto, "Auto Skip frames.")
{
GetMenuOptionInt("FrameSkipAuto", autoFrameSkip, 1);
GetMenuOptionInt("FrameSkipAuto", &autoFrameSkip, 1);
update_opts();
}
EVT_HANDLER(Fullscreen, "Enter fullscreen mode at startup")
{
GetMenuOptionInt("Fullscreen", fullScreen, 1);
GetMenuOptionInt("Fullscreen", &fullScreen, 1);
update_opts();
}
EVT_HANDLER(PauseWhenInactive, "Pause game when main window loses focus")
{
GetMenuOptionInt("PauseWhenInactive", pauseWhenInactive, 1);
GetMenuOptionInt("PauseWhenInactive", &pauseWhenInactive, 1);
update_opts();
}
EVT_HANDLER(RTC, "Enable RTC (vba-over.ini override is rtcEnabled")
{
GetMenuOptionInt("RTC", rtcEnabled, 1);
GetMenuOptionInt("RTC", &rtcEnabled, 1);
update_opts();
}
EVT_HANDLER(Transparent, "Draw on-screen messages transparently")
{
GetMenuOptionInt("Transparent", showSpeedTransparent, 1);
GetMenuOptionInt("Transparent", &showSpeedTransparent, 1);
update_opts();
}
EVT_HANDLER(SkipIntro, "Skip BIOS initialization")
{
GetMenuOptionInt("SkipIntro", skipBios, 1);
GetMenuOptionInt("SkipIntro", &skipBios, 1);
update_opts();
}
EVT_HANDLER(BootRomEn, "Use the specified BIOS file for GBA")
{
GetMenuOptionInt("BootRomEn", useBiosFileGBA, 1);
GetMenuOptionInt("BootRomEn", &useBiosFileGBA, 1);
update_opts();
}
EVT_HANDLER(BootRomGB, "Use the specified BIOS file for GB")
{
int val = 0;
GetMenuOptionInt("BootRomGB", val, 1);
GetMenuOptionInt("BootRomGB", &val, 1);
if (val == 1 && colorizerHack == 1) {
wxLogError(_("Cannot use GB BIOS when Colorizer Hack is enabled."));
@ -3200,13 +3202,13 @@ EVT_HANDLER(BootRomGB, "Use the specified BIOS file for GB")
EVT_HANDLER(BootRomGBC, "Use the specified BIOS file for GBC")
{
GetMenuOptionInt("BootRomGBC", useBiosFileGBC, 1);
GetMenuOptionInt("BootRomGBC", &useBiosFileGBC, 1);
update_opts();
}
EVT_HANDLER(VSync, "Wait for vertical sync")
{
GetMenuOptionInt("VSync", vsync, 1);
GetMenuOptionInt("VSync", &vsync, 1);
update_opts();
}
@ -3291,19 +3293,19 @@ EVT_HANDLER(LinkType4Gameboy, "Link Gameboy")
EVT_HANDLER(LinkAuto, "Enable link at boot")
{
GetMenuOptionBool("LinkAuto", gopts.link_auto);
GetMenuOptionBool("LinkAuto", &gopts.link_auto);
update_opts();
}
EVT_HANDLER(SpeedOn, "Enable faster network protocol by default")
{
GetMenuOptionInt("SpeedOn", linkHacks, 1);
GetMenuOptionInt("SpeedOn", &linkHacks, 1);
update_opts();
}
EVT_HANDLER(LinkProto, "Local host IPC")
{
GetMenuOptionInt("LinkProto", gopts.link_proto, 1);
GetMenuOptionInt("LinkProto", &gopts.link_proto, 1);
update_opts();
enable_menus();
EnableNetworkMenu();

View File

@ -2978,10 +2978,14 @@ bool MainFrame::BindControls()
checkable_mi.push_back(cmi);
for (const VbamOption& option : VbamOption::AllOptions()) {
if (cmdtab[i].cmd == option.command()) {
if (option.is_int()) {
MenuOptionIntMask(option.command(), option.GetInt(), (1 << 0));
MenuOptionIntMask(
option.command(), option.GetInt(), (1 << 0));
} else if (option.is_bool()) {
MenuOptionBool(option.command(), option.GetBool());
MenuOptionBool(
option.command(), option.GetBool());
}
}
}
}
@ -3692,8 +3696,11 @@ bool MainFrame::BindControls()
getsc("MaxScale", maxScale);
/// Basic
getrbi("OutputSimple", gopts.render_method, RND_SIMPLE);
#if defined(__WXMAC__)
getrbi("OutputQuartz2D", gopts.render_method, RND_QUARTZ2D);
#if !defined(__WXMAC__)
#else
rb = SafeXRCCTRL<wxRadioButton>(d, "OutputQuartz2D");
rb->Hide();
#endif
getrbi("OutputOpenGL", gopts.render_method, RND_OPENGL);
@ -3706,10 +3713,11 @@ bool MainFrame::BindControls()
rb->Hide();
}
#endif
getrbi("OutputDirect3D", gopts.render_method, RND_DIRECT3D);
#if !defined(__WXMSW__) || defined(NO_D3D) || 1 // not implemented
// Direct3D is not implemented so hide the option on every platform.
rb = SafeXRCCTRL<wxRadioButton>(d, "OutputDirect3D");
rb->Hide();
#endif
ch = GetValidatedChild<wxChoice, wxGenericValidator>(d, "Filter", wxGenericValidator(&gopts.filter));
// Save the Filters choice control to extract the names from the XRC.

View File

@ -18,7 +18,7 @@ struct VbamOptionData {
const VbamOption::Type type;
};
// Static data to initialize global values.;
// Static data to initialize global values.
extern const std::array<VbamOptionData, kNbOptions + 1> kAllOptionsData;
// Conversion utilities.

View File

@ -1,7 +1,8 @@
#include "vbam-options.h"
// Helper implementation file to define and compile all of these huge constants
// separately. These should not be updated very often, so this improves
// separately. These should not be updated very often, so having these in a
// separate file improves incremental build time.
#include <algorithm>
#include <wx/log.h>
@ -9,7 +10,6 @@
#include "../common/ConfigManager.h"
#include "../gb/gbGlobals.h"
#include "opts.h"
#include "wx/stringimpl.h"
#define VBAM_OPTIONS_INTERNAL_INCLUDE
#include "vbam-options-internal.h"
@ -18,6 +18,7 @@
namespace {
// This enum must be kept in sync with the one in wxvbam.h
// TODO: These 2 enums should be unified and a validator created for this enum.
enum class FilterFunction {
kNone,
k2xsai,
@ -78,6 +79,7 @@ static const std::array<wxString, kNbFilterFunctions> kFilterStrings = {
};
// This enum must be kept in sync with the one in wxvbam.h
// TODO: These 2 enums should be unified and a validator created for this enum.
enum class Interframe {
kNone = 0,
kSmart,
@ -98,6 +100,7 @@ static const std::array<wxString, kNbInterframes> kInterframeStrings = {
};
// This enum must be kept in sync with the one in wxvbam.h
// TODO: These 2 enums should be unified and a validator created for this enum.
enum class RenderMethod {
kSimple = 0,
kOpenGL,
@ -126,6 +129,8 @@ static const std::array<wxString, kNbRenderMethods> kRenderMethodStrings = {
};
// This enum must be kept in sync with the one in wxvbam.h
// TODO: These 2 enums should be unified and a validator created for this enum.
// TODO: DirectSound and XAudio2 should only be used on Windows.
enum class AudioApi {
kSdl = 0,
kOpenAL,
@ -469,140 +474,23 @@ const std::array<VbamOptionData, kNbOptions + 1> kAllOptionsData = {
VbamOptionData { "Sound/Quality", "", _("Sound sample rate (kHz)"), VbamOption::Type::kSoundQuality },
VbamOptionData { "Sound/Volume", "", _("Sound volume (%)"), VbamOption::Type::kInt },
// Last
// Last. This should never be used, it actually maps to VbamOptionID::kLast.
// This is to prevent a memory access violation error in case something
// attempts to instantiate a VbamOptionID::kLast. It will trigger a check
// in the VbamOption constructor, but that is after the constructor has
// accessed this entry.
VbamOptionData { "", "", "", VbamOption::Type::kNone },
};
nonstd::optional<VbamOptionID> StringToOptionId(const wxString& input) {
// Note: This map does not include "Joystick" and "Keyboard". This is on
// purpose, as these are handled separately.
static const std::map<wxString, VbamOptionID> kStringToOptionId = {
{ "Display/Bilinear", VbamOptionID::kDisplayBilinear },
{ "Display/Filter", VbamOptionID::kDisplayFilter },
{ "Display/FilterPlugin", VbamOptionID::kDisplayFilterPlugin },
{ "Display/IFB", VbamOptionID::kDisplayIFB },
{ "Display/KeepOnTop", VbamOptionID::kDisplayKeepOnTop },
{ "Display/MaxThreads", VbamOptionID::kDisplayMaxThreads },
{ "Display/RenderMethod", VbamOptionID::kDisplayRenderMethod },
{ "Display/Scale", VbamOptionID::kDisplayScale },
{ "Display/Stretch", VbamOptionID::kDisplayStretch },
/// GB
{ "GB/BiosFile", VbamOptionID::kGBBiosFile },
{ "GB/ColorOption", VbamOptionID::kGBColorOption },
{ "GB/ColorizerHack", VbamOptionID::kGBColorizerHack },
{ "GB/LCDFilter", VbamOptionID::kGBLCDFilter },
{ "GB/GBCBiosFile", VbamOptionID::kGBGBCBiosFile },
{ "GB/Palette0", VbamOptionID::kGBPalette0 },
{ "GB/Palette1", VbamOptionID::kGBPalette1 },
{ "GB/Palette2", VbamOptionID::kGBPalette2 },
{ "GB/PrintAutoPage", VbamOptionID::kGBPrintAutoPage },
{ "GB/PrintScreenCap", VbamOptionID::kGBPrintScreenCap },
{ "GB/ROMDir", VbamOptionID::kGBROMDir },
{ "GB/GBCROMDir", VbamOptionID::kGBGBCROMDir },
/// GBA
{ "GBA/BiosFile", VbamOptionID::kGBABiosFile },
{ "GBA/LCDFilter", VbamOptionID::kGBALCDFilter },
#ifndef NO_LINK
{ "GBA/LinkAuto", VbamOptionID::kGBALinkAuto },
{ "GBA/LinkFast", VbamOptionID::kGBALinkFast },
{ "GBA/LinkHost", VbamOptionID::kGBALinkHost },
{ "GBA/ServerIP", VbamOptionID::kGBAServerIP },
{ "GBA/LinkPort", VbamOptionID::kGBALinkPort },
{ "GBA/LinkProto", VbamOptionID::kGBALinkProto },
{ "GBA/LinkTimeout", VbamOptionID::kGBALinkTimeout },
{ "GBA/LinkType", VbamOptionID::kGBALinkType },
#endif
{ "GBA/ROMDir", VbamOptionID::kGBAROMDir },
/// General
{ "General/AutoLoadLastState", VbamOptionID::kGeneralAutoLoadLastState },
{ "General/BatteryDir", VbamOptionID::kGeneralBatteryDir },
{ "General/FreezeRecent", VbamOptionID::kGeneralFreezeRecent },
{ "General/RecordingDir", VbamOptionID::kGeneralRecordingDir },
{ "General/RewindInterval", VbamOptionID::kGeneralRewindInterval },
{ "General/ScreenshotDir", VbamOptionID::kGeneralScreenshotDir },
{ "General/StateDir", VbamOptionID::kGeneralStateDir },
{ "General/StatusBar", VbamOptionID::kGeneralStatusBar },
/// Joypad
{ "Joypad/AutofireThrottle", VbamOptionID::kJoypadAutofireThrottle },
{ "Joypad/Default", VbamOptionID::kJoypadDefault },
// Core
{ "preferences/agbPrint", VbamOptionID::kpreferencesagbPrint },
{ "preferences/autoFrameSkip", VbamOptionID::kpreferencesautoFrameSkip },
{ "preferences/autoPatch", VbamOptionID::kpreferencesautoPatch },
{ "preferences/autoSaveLoadCheatList", VbamOptionID::kpreferencesautoSaveLoadCheatList },
{ "preferences/borderAutomatic", VbamOptionID::kpreferencesborderAutomatic },
{ "preferences/borderOn", VbamOptionID::kpreferencesborderOn },
{ "preferences/captureFormat", VbamOptionID::kpreferencescaptureFormat },
{ "preferences/cheatsEnabled", VbamOptionID::kpreferencescheatsEnabled },
#ifdef MMX
{ "preferences/enableMMX", VbamOptionID::kpreferencesenableMMX },
#endif
{ "preferences/disableStatus", VbamOptionID::kpreferencesdisableStatus },
{ "preferences/emulatorType", VbamOptionID::kpreferencesemulatorType },
{ "preferences/flashSize", VbamOptionID::kpreferencesflashSize },
{ "preferences/frameSkip", VbamOptionID::kpreferencesframeSkip },
{ "preferences/fsColorDepth", VbamOptionID::kpreferencesfsColorDepth },
{ "preferences/fsFrequency", VbamOptionID::kpreferencesfsFrequency },
{ "preferences/fsHeight", VbamOptionID::kpreferencesfsHeight },
{ "preferences/fsWidth", VbamOptionID::kpreferencesfsWidth },
{ "preferences/gbPaletteOption", VbamOptionID::kpreferencesgbPaletteOption },
{ "preferences/gbPrinter", VbamOptionID::kpreferencesgbPrinter },
{ "preferences/gdbBreakOnLoad", VbamOptionID::kpreferencesgdbBreakOnLoad },
{ "preferences/gdbPort", VbamOptionID::kpreferencesgdbPort },
#ifndef NO_LINK
{ "preferences/LinkNumPlayers", VbamOptionID::kpreferencesLinkNumPlayers },
#endif
{ "preferences/maxScale", VbamOptionID::kpreferencesmaxScale },
{ "preferences/pauseWhenInactive", VbamOptionID::kpreferencespauseWhenInactive },
{ "preferences/rtcEnabled", VbamOptionID::kpreferencesrtcEnabled },
{ "preferences/saveType", VbamOptionID::kpreferencessaveType },
{ "preferences/showSpeed", VbamOptionID::kpreferencesshowSpeed },
{ "preferences/showSpeedTransparent", VbamOptionID::kpreferencesshowSpeedTransparent },
{ "preferences/skipBios", VbamOptionID::kpreferencesskipBios },
{ "preferences/skipSaveGameCheats", VbamOptionID::kpreferencesskipSaveGameCheats },
{ "preferences/skipSaveGameBattery", VbamOptionID::kpreferencesskipSaveGameBattery },
{ "preferences/throttle", VbamOptionID::kpreferencesthrottle },
{ "preferences/speedupThrottle", VbamOptionID::kpreferencesspeedupThrottle },
{ "preferences/speedupFrameSkip", VbamOptionID::kpreferencesspeedupFrameSkip },
{ "preferences/speedupThrottleFrameSkip", VbamOptionID::kpreferencesspeedupThrottleFrameSkip },
{ "preferences/useBiosGB", VbamOptionID::kpreferencesuseBiosGB },
{ "preferences/useBiosGBA", VbamOptionID::kpreferencesuseBiosGBA },
{ "preferences/useBiosGBC", VbamOptionID::kpreferencesuseBiosGBC },
{ "preferences/vsync", VbamOptionID::kpreferencesvsync },
/// Geometry
{ "geometry/fullScreen", VbamOptionID::kgeometryfullScreen },
{ "geometry/isMaximized", VbamOptionID::kgeometryisMaximized },
{ "geometry/windowHeight", VbamOptionID::kgeometrywindowHeight },
{ "geometry/windowWidth", VbamOptionID::kgeometrywindowWidth },
{ "geometry/windowX", VbamOptionID::kgeometrywindowX },
{ "geometry/windowY", VbamOptionID::kgeometrywindowY },
/// UI
{ "ui/allowKeyboardBackgroundInput", VbamOptionID::kuiallowKeyboardBackgroundInput },
{ "ui/allowJoystickBackgroundInput", VbamOptionID::kuiallowJoystickBackgroundInput },
{ "ui/hideMenuBar", VbamOptionID::kuihideMenuBar },
/// Sound
{ "Sound/AudioAPI", VbamOptionID::kSoundAudioAPI },
{ "Sound/AudioDevice", VbamOptionID::kSoundAudioDevice },
{ "Sound/Buffers", VbamOptionID::kSoundBuffers },
{ "Sound/Enable", VbamOptionID::kSoundEnable },
{ "Sound/GBAFiltering", VbamOptionID::kSoundGBAFiltering },
{ "Sound/GBAInterpolation", VbamOptionID::kSoundGBAInterpolation },
{ "Sound/GBDeclicking", VbamOptionID::kSoundGBDeclicking },
{ "Sound/GBEcho", VbamOptionID::kSoundGBEcho },
{ "Sound/GBEnableEffects", VbamOptionID::kSoundGBEnableEffects },
{ "Sound/GBStereo", VbamOptionID::kSoundGBStereo },
{ "Sound/GBSurround", VbamOptionID::kSoundGBSurround },
{ "Sound/Quality", VbamOptionID::kSoundQuality },
{ "Sound/Volume", VbamOptionID::kSoundVolume },
};
static std::map<wxString, VbamOptionID> kStringToOptionId;
if (kStringToOptionId.empty()) {
for (size_t i = 0; i < kNbOptions; i++) {
kStringToOptionId.emplace(
kAllOptionsData[i].config_name, static_cast<VbamOptionID>(i));
}
assert(kStringToOptionId.size() == kNbOptions);
}
const auto iter = kStringToOptionId.find(input);
if (iter == kStringToOptionId.end()) {
@ -637,32 +525,14 @@ wxString SoundQualityToString(int value) {
}
int StringToFilter(const wxString& config_name, const wxString& input) {
static const std::map<wxString, FilterFunction> kStringToFilter = {
{ kFilterStrings[0], FilterFunction::kNone },
{ kFilterStrings[1], FilterFunction::k2xsai },
{ kFilterStrings[2], FilterFunction::kSuper2xsai },
{ kFilterStrings[3], FilterFunction::kSupereagle },
{ kFilterStrings[4], FilterFunction::kPixelate },
{ kFilterStrings[5], FilterFunction::kAdvmame },
{ kFilterStrings[6], FilterFunction::kBilinear },
{ kFilterStrings[7], FilterFunction::kBilinearplus },
{ kFilterStrings[8], FilterFunction::kScanlines },
{ kFilterStrings[9], FilterFunction::kTvmode },
{ kFilterStrings[10], FilterFunction::kHQ2x },
{ kFilterStrings[11], FilterFunction::kLQ2x },
{ kFilterStrings[12], FilterFunction::kSimple2x },
{ kFilterStrings[13], FilterFunction::kSimple3x },
{ kFilterStrings[14], FilterFunction::kHQ3x },
{ kFilterStrings[15], FilterFunction::kSimple4x },
{ kFilterStrings[16], FilterFunction::kHQ4x },
{ kFilterStrings[17], FilterFunction::kXbrz2x },
{ kFilterStrings[18], FilterFunction::kXbrz3x },
{ kFilterStrings[19], FilterFunction::kXbrz4x },
{ kFilterStrings[20], FilterFunction::kXbrz5x },
{ kFilterStrings[21], FilterFunction::kXbrz6x },
{ kFilterStrings[22], FilterFunction::kPlugin },
};
assert(kFilterStrings.size() == kNbFilterFunctions);
static std::map<wxString, FilterFunction> kStringToFilter;
if (kStringToFilter.empty()) {
for (size_t i = 0; i < kNbFilterFunctions; i++) {
kStringToFilter.emplace(
kFilterStrings[i], static_cast<FilterFunction>(i));
}
assert(kStringToFilter.size() == kNbFilterFunctions);
}
const auto iter = kStringToFilter.find(input);
if (iter == kStringToFilter.end()) {
@ -676,12 +546,14 @@ int StringToFilter(const wxString& config_name, const wxString& input) {
}
int StringToInterframe(const wxString& config_name, const wxString& input) {
static const std::map<wxString, Interframe> kStringToInterframe = {
{ kInterframeStrings[0], Interframe::kNone },
{ kInterframeStrings[1], Interframe::kSmart },
{ kInterframeStrings[2], Interframe::kMotionBlur },
};
static std::map<wxString, Interframe> kStringToInterframe;
if (kStringToInterframe.empty()) {
for (size_t i = 0; i < kNbInterframes; i++) {
kStringToInterframe.emplace(
kInterframeStrings[i], static_cast<Interframe>(i));
}
assert(kStringToInterframe.size() == kNbInterframes);
}
const auto iter = kStringToInterframe.find(input);
if (iter == kStringToInterframe.end()) {
@ -695,16 +567,13 @@ int StringToInterframe(const wxString& config_name, const wxString& input) {
}
int StringToRenderMethod(const wxString& config_name, const wxString& input) {
static const std::map<wxString, RenderMethod> kStringToRenderMethod = {
{ kRenderMethodStrings[0], RenderMethod::kSimple },
{ kRenderMethodStrings[1], RenderMethod::kOpenGL },
#ifdef __WXMSW__
{ kRenderMethodStrings[2], RenderMethod::kDirect3d },
#elif defined(__WXMAC__)
{ kRenderMethodStrings[2], RenderMethod::kQuartz2d },
#endif
};
static std::map<wxString, RenderMethod> kStringToRenderMethod;
if (kStringToRenderMethod.empty()) {
for (size_t i = 0; i < kNbRenderMethods; i++) {
kStringToRenderMethod.emplace(kRenderMethodStrings[i], static_cast<RenderMethod>(i));
}
assert(kStringToRenderMethod.size() == kNbRenderMethods);
}
const auto iter = kStringToRenderMethod.find(input);
if (iter == kStringToRenderMethod.end()) {
@ -718,14 +587,13 @@ int StringToRenderMethod(const wxString& config_name, const wxString& input) {
}
int StringToAudioApi(const wxString& config_name, const wxString& input) {
static const std::map<wxString, AudioApi> kStringToAudioApi = {
{ kAudioApiStrings[0], AudioApi::kSdl },
{ kAudioApiStrings[1], AudioApi::kOpenAL },
{ kAudioApiStrings[2], AudioApi::kDirectSound },
{ kAudioApiStrings[3], AudioApi::kXAudio2 },
{ kAudioApiStrings[4], AudioApi::kFaudio },
};
static std::map<wxString, AudioApi> kStringToAudioApi;
if (kStringToAudioApi.empty()) {
for (size_t i = 0; i < kNbAudioApis; i++) {
kStringToAudioApi.emplace(kAudioApiStrings[i], static_cast<AudioApi>(i));
}
assert(kStringToAudioApi.size() == kNbAudioApis);
}
const auto iter = kStringToAudioApi.find(input);
if (iter == kStringToAudioApi.end()) {
@ -739,13 +607,13 @@ int StringToAudioApi(const wxString& config_name, const wxString& input) {
}
int StringToSoundQuality(const wxString& config_name, const wxString& input) {
static const std::map<wxString, SoundQuality> kStringToSoundQuality = {
{ kSoundQualityStrings[0], SoundQuality::k48kHz },
{ kSoundQualityStrings[1], SoundQuality::k44kHz },
{ kSoundQualityStrings[2], SoundQuality::k22kHz },
{ kSoundQualityStrings[3], SoundQuality::k11kHz },
};
static std::map<wxString, SoundQuality> kStringToSoundQuality;
if (kStringToSoundQuality.empty()) {
for (size_t i = 0; i < kNbSoundQualities; i++) {
kStringToSoundQuality.emplace(kSoundQualityStrings[i], static_cast<SoundQuality>(i));
}
assert(kStringToSoundQuality.size() == kNbSoundQualities);
}
const auto iter = kStringToSoundQuality.find(input);
if (iter == kStringToSoundQuality.end()) {

View File

@ -318,7 +318,7 @@ void VbamOption::SetGbPalette(const wxString& value) const {
uint16_t* dest = std::get<uint16_t*>(value_);
for (size_t i = 0; i < 8; i++) {
wxString number = value.substr(i * 4, 4);
wxString number = value.substr(i * 5, 4);
long temp = 0;
if (number.ToLong(&temp, 16)) {
dest[i] = temp;

View File

@ -60,8 +60,6 @@ enum class VbamOptionID {
/// Joypad
kJoypad,
kJoypadAutofireThrottle,
/// Keyboard
kJoypadDefault,
/// Keyboard

View File

@ -221,8 +221,8 @@ public:
void MenuOptionIntMask(const wxString& menuName, int field, int mask);
void MenuOptionIntRadioValue(const wxString& menuName, int field, int mask);
void MenuOptionBool(const wxString& menuName, bool field);
void GetMenuOptionInt(const wxString& menuName, int field, int mask);
void GetMenuOptionBool(const wxString& menuName, bool field);
void GetMenuOptionInt(const wxString& menuName, int* field, int mask);
void GetMenuOptionBool(const wxString& menuName, bool* field);
void SetMenuOption(const wxString& menuName, int value);
void SetJoystick();
@ -435,6 +435,7 @@ enum showspeed {
};
// This enum must be kept in sync with the one in vbam-options-static.cpp.
// TODO: These 2 enums should be unified and a validator created for this enum.
enum filtfunc {
// this order must match order of option enum and selector widget
FF_NONE,
@ -471,6 +472,7 @@ enum filtfunc {
: x == FF_PLUGIN ? 0 : x == FF_NONE ? 1 : 2)
// This enum must be kept in sync with the one in vbam-options-static.cpp.
// TODO: These 2 enums should be unified and a validator created for this enum.
enum ifbfunc {
IFB_NONE,
IFB_SMART,
@ -478,19 +480,26 @@ enum ifbfunc {
};
// This enum must be kept in sync with the one in vbam-options-static.cpp.
// TODO: These 2 enums should be unified and a validator created for this enum.
enum renderer {
RND_SIMPLE,
RND_OPENGL,
#if defined(__WXMSW__)
RND_DIRECT3D,
#elif defined(__WXMAC__)
RND_QUARTZ2D,
#endif
};
// This enum must be kept in sync with the one in vbam-options-static.cpp.
enum audioapi { AUD_SDL,
// TODO: These 2 enums should be unified and a validator created for this enum.
enum audioapi {
AUD_SDL,
AUD_OPENAL,
AUD_DIRECTSOUND,
AUD_XAUDIO2,
AUD_FAUDIO };
AUD_FAUDIO
};
// an unfortunate legacy default; should have a non-digit preceding %d
// the only reason to keep it is that user can set slotdir to old dir