Add options shared with sdl to wx g_owned_opts
This removed the dependency on ConfigManager from the wx frontend. Next: Move ConfigManager to be only used by the SDL frontend.
This commit is contained in:
parent
efffe7c333
commit
bd7eac6c4b
|
@ -19,7 +19,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <SDL_events.h>
|
#include <SDL_events.h>
|
||||||
#include "SoundSDL.h"
|
#include "SoundSDL.h"
|
||||||
#include "ConfigManager.h"
|
|
||||||
#include "../gba/Globals.h"
|
#include "../gba/Globals.h"
|
||||||
#include "../gba/Sound.h"
|
#include "../gba/Sound.h"
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ void MainFrame::GetMenuOptionInt(const wxString& menuName, int* field, int mask)
|
||||||
*field = ((*field) & ~(mask)) | (is_checked ? (value) : 0);
|
*field = ((*field) & ~(mask)) | (is_checked ? (value) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::SetMenuOption(const wxString& menuName, int value)
|
void MainFrame::SetMenuOption(const wxString& menuName, bool value)
|
||||||
{
|
{
|
||||||
int id = wxXmlResource::GetXRCID(menuName);
|
int id = wxXmlResource::GetXRCID(menuName);
|
||||||
|
|
||||||
|
@ -1177,14 +1177,15 @@ EVT_HANDLER_MASK(ScreenCapture, "Screen capture...", CMDEN_GB | CMDEN_GBA)
|
||||||
wxString scap_path = GetGamePath(gopts.scrshot_dir);
|
wxString scap_path = GetGamePath(gopts.scrshot_dir);
|
||||||
wxString def_name = panel->game_name();
|
wxString def_name = panel->game_name();
|
||||||
|
|
||||||
if (captureFormat == 0)
|
const int capture_format = OPTION(kPrefCaptureFormat);
|
||||||
def_name.append(wxT(".png"));
|
if (capture_format == 0)
|
||||||
|
def_name.append(".png");
|
||||||
else
|
else
|
||||||
def_name.append(wxT(".bmp"));
|
def_name.append(".bmp");
|
||||||
|
|
||||||
wxFileDialog dlg(this, _("Select output file"), scap_path, def_name,
|
wxFileDialog dlg(this, _("Select output file"), scap_path, def_name,
|
||||||
_("PNG images|*.png|BMP images|*.bmp"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
_("PNG images|*.png|BMP images|*.bmp"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
dlg.SetFilterIndex(captureFormat);
|
dlg.SetFilterIndex(capture_format);
|
||||||
int ret = ShowModal(&dlg);
|
int ret = ShowModal(&dlg);
|
||||||
scap_path = dlg.GetDirectory();
|
scap_path = dlg.GetDirectory();
|
||||||
|
|
||||||
|
@ -1512,10 +1513,10 @@ EVT_HANDLER(Pause, "Pause (toggle)")
|
||||||
panel->Resume();
|
panel->Resume();
|
||||||
|
|
||||||
// undo next-frame's zeroing of frameskip
|
// undo next-frame's zeroing of frameskip
|
||||||
int fs = frameSkip;
|
const int frame_skip = OPTION(kPrefFrameSkip);
|
||||||
|
if (frame_skip != -1) {
|
||||||
if (fs >= 0)
|
systemFrameSkip = frame_skip;
|
||||||
systemFrameSkip = fs;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// new
|
// new
|
||||||
|
@ -2614,7 +2615,7 @@ EVT_HANDLER(GameBoyAdvanceConfigure, "Game Boy Advance options...")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (panel->game_type() == IMAGE_GBA) {
|
if (panel->game_type() == IMAGE_GBA) {
|
||||||
agbPrintEnable(agbPrint);
|
agbPrintEnable(OPTION(kPrefAgbPrint));
|
||||||
wxString s = wxString((const char*)&rom[0xac], wxConvLibc, 4);
|
wxString s = wxString((const char*)&rom[0xac], wxConvLibc, 4);
|
||||||
wxFileConfig* cfg = wxGetApp().overrides;
|
wxFileConfig* cfg = wxGetApp().overrides;
|
||||||
bool chg;
|
bool chg;
|
||||||
|
@ -2726,8 +2727,9 @@ EVT_HANDLER_MASK(DisplayConfigure, "Display options...", CMDEN_NREC_ANY)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frameSkip >= 0) {
|
const int frame_skip = OPTION(kPrefFrameSkip);
|
||||||
systemFrameSkip = frameSkip;
|
if (frame_skip != -1) {
|
||||||
|
systemFrameSkip = frame_skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_opts();
|
update_opts();
|
||||||
|
@ -3000,8 +3002,7 @@ EVT_HANDLER(GBSurround, "GB surround sound effect (%)")
|
||||||
|
|
||||||
EVT_HANDLER(AGBPrinter, "Enable AGB printer")
|
EVT_HANDLER(AGBPrinter, "Enable AGB printer")
|
||||||
{
|
{
|
||||||
GetMenuOptionInt("AGBPrinter", &agbPrint, 1);
|
GetMenuOptionConfig("AGBPrinter", config::OptionID::kPrefAgbPrint);
|
||||||
update_opts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EVT_HANDLER_MASK(GBALcdFilter, "Enable LCD filter", CMDEN_GBA)
|
EVT_HANDLER_MASK(GBALcdFilter, "Enable LCD filter", CMDEN_GBA)
|
||||||
|
@ -3037,8 +3038,7 @@ EVT_HANDLER(GBColorOption, "Enable GB color option")
|
||||||
|
|
||||||
EVT_HANDLER(ApplyPatches, "Apply IPS/UPS/IPF patches if found")
|
EVT_HANDLER(ApplyPatches, "Apply IPS/UPS/IPF patches if found")
|
||||||
{
|
{
|
||||||
GetMenuOptionInt("ApplyPatches", &autoPatch, 1);
|
GetMenuOptionConfig("ApplyPatches", config::OptionID::kPrefAutoPatch);
|
||||||
update_opts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EVT_HANDLER(KeepOnTop, "Keep window on top")
|
EVT_HANDLER(KeepOnTop, "Keep window on top")
|
||||||
|
@ -3064,14 +3064,12 @@ EVT_HANDLER(StatusBar, "Enable status bar")
|
||||||
|
|
||||||
EVT_HANDLER(NoStatusMsg, "Disable on-screen status messages")
|
EVT_HANDLER(NoStatusMsg, "Disable on-screen status messages")
|
||||||
{
|
{
|
||||||
GetMenuOptionInt("NoStatusMsg", &disableStatusMessages, 1);
|
GetMenuOptionConfig("NoStatusMsg", config::OptionID::kPrefDisableStatus);
|
||||||
update_opts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EVT_HANDLER(FrameSkipAuto, "Auto Skip frames.")
|
EVT_HANDLER(FrameSkipAuto, "Auto Skip frames.")
|
||||||
{
|
{
|
||||||
GetMenuOptionInt("FrameSkipAuto", &autoFrameSkip, 1);
|
GetMenuOptionConfig("FrameSkipAuto", config::OptionID::kPrefAutoFrameSkip);
|
||||||
update_opts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EVT_HANDLER(Fullscreen, "Enter fullscreen mode at startup")
|
EVT_HANDLER(Fullscreen, "Enter fullscreen mode at startup")
|
||||||
|
@ -3081,8 +3079,7 @@ EVT_HANDLER(Fullscreen, "Enter fullscreen mode at startup")
|
||||||
|
|
||||||
EVT_HANDLER(PauseWhenInactive, "Pause game when main window loses focus")
|
EVT_HANDLER(PauseWhenInactive, "Pause game when main window loses focus")
|
||||||
{
|
{
|
||||||
GetMenuOptionInt("PauseWhenInactive", &pauseWhenInactive, 1);
|
GetMenuOptionConfig("PauseWhenInactive", config::OptionID::kPrefPauseWhenInactive);
|
||||||
update_opts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EVT_HANDLER(RTC, "Enable RTC (vba-over.ini override is rtcEnabled")
|
EVT_HANDLER(RTC, "Enable RTC (vba-over.ini override is rtcEnabled")
|
||||||
|
@ -3093,8 +3090,7 @@ EVT_HANDLER(RTC, "Enable RTC (vba-over.ini override is rtcEnabled")
|
||||||
|
|
||||||
EVT_HANDLER(Transparent, "Draw on-screen messages transparently")
|
EVT_HANDLER(Transparent, "Draw on-screen messages transparently")
|
||||||
{
|
{
|
||||||
GetMenuOptionInt("Transparent", &showSpeedTransparent, 1);
|
GetMenuOptionConfig("Transparent", config::OptionID::kPrefShowSpeedTransparent);
|
||||||
update_opts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EVT_HANDLER(SkipIntro, "Skip BIOS initialization")
|
EVT_HANDLER(SkipIntro, "Skip BIOS initialization")
|
||||||
|
|
|
@ -164,6 +164,18 @@ std::array<Option, kNbOptions>& Option::All() {
|
||||||
/// GB
|
/// GB
|
||||||
bool colorizer_hack = false;
|
bool colorizer_hack = false;
|
||||||
|
|
||||||
|
/// Core
|
||||||
|
bool agb_print = false;
|
||||||
|
bool auto_frame_skip = false;
|
||||||
|
bool auto_patch = true;
|
||||||
|
uint32_t capture_format = 0;
|
||||||
|
bool disable_status_messages = false;
|
||||||
|
uint32_t flash_size = 0;
|
||||||
|
int32_t frame_skip = 0;
|
||||||
|
bool pause_when_inactive = false;
|
||||||
|
uint32_t show_speed = 0;
|
||||||
|
bool show_speed_transparent = false;
|
||||||
|
|
||||||
/// General
|
/// General
|
||||||
uint32_t ini_version = kIniLatestVersion;
|
uint32_t ini_version = kIniLatestVersion;
|
||||||
|
|
||||||
|
@ -248,18 +260,18 @@ std::array<Option, kNbOptions>& Option::All() {
|
||||||
Option(OptionID::kKeyboard),
|
Option(OptionID::kKeyboard),
|
||||||
|
|
||||||
/// Core
|
/// Core
|
||||||
Option(OptionID::kPrefAgbPrint, &agbPrint, 0, 1),
|
Option(OptionID::kPrefAgbPrint, &g_owned_opts.agb_print),
|
||||||
Option(OptionID::kPrefAutoFrameSkip, &autoFrameSkip, 0, 1),
|
Option(OptionID::kPrefAutoFrameSkip, &g_owned_opts.auto_frame_skip),
|
||||||
Option(OptionID::kPrefAutoPatch, &autoPatch, 0, 1),
|
Option(OptionID::kPrefAutoPatch, &g_owned_opts.auto_patch),
|
||||||
Option(OptionID::kPrefAutoSaveLoadCheatList, &gopts.autoload_cheats),
|
Option(OptionID::kPrefAutoSaveLoadCheatList, &gopts.autoload_cheats),
|
||||||
Option(OptionID::kPrefBorderAutomatic, &gbBorderAutomatic, 0, 1),
|
Option(OptionID::kPrefBorderAutomatic, &gbBorderAutomatic, 0, 1),
|
||||||
Option(OptionID::kPrefBorderOn, &gbBorderOn, 0, 1),
|
Option(OptionID::kPrefBorderOn, &gbBorderOn, 0, 1),
|
||||||
Option(OptionID::kPrefCaptureFormat, &captureFormat, 0, 1),
|
Option(OptionID::kPrefCaptureFormat, &g_owned_opts.capture_format, 0, 1),
|
||||||
Option(OptionID::kPrefCheatsEnabled, &coreOptions.cheatsEnabled, 0, 1),
|
Option(OptionID::kPrefCheatsEnabled, &coreOptions.cheatsEnabled, 0, 1),
|
||||||
Option(OptionID::kPrefDisableStatus, &disableStatusMessages, 0, 1),
|
Option(OptionID::kPrefDisableStatus, &g_owned_opts.disable_status_messages),
|
||||||
Option(OptionID::kPrefEmulatorType, &gbEmulatorType, 0, 5),
|
Option(OptionID::kPrefEmulatorType, &gbEmulatorType, 0, 5),
|
||||||
Option(OptionID::kPrefFlashSize, &optFlashSize, 0, 1),
|
Option(OptionID::kPrefFlashSize, &g_owned_opts.flash_size, 0, 1),
|
||||||
Option(OptionID::kPrefFrameSkip, &frameSkip, -1, 9),
|
Option(OptionID::kPrefFrameSkip, &g_owned_opts.frame_skip, -1, 9),
|
||||||
Option(OptionID::kPrefGBPaletteOption, &gbPaletteOption, 0, 2),
|
Option(OptionID::kPrefGBPaletteOption, &gbPaletteOption, 0, 2),
|
||||||
Option(OptionID::kPrefGBPrinter, &coreOptions.winGbPrinterEnabled, 0, 1),
|
Option(OptionID::kPrefGBPrinter, &coreOptions.winGbPrinterEnabled, 0, 1),
|
||||||
Option(OptionID::kPrefGDBBreakOnLoad, &gopts.gdb_break_on_load),
|
Option(OptionID::kPrefGDBBreakOnLoad, &gopts.gdb_break_on_load),
|
||||||
|
@ -268,11 +280,11 @@ std::array<Option, kNbOptions>& Option::All() {
|
||||||
Option(OptionID::kPrefLinkNumPlayers, &gopts.link_num_players, 2, 4),
|
Option(OptionID::kPrefLinkNumPlayers, &gopts.link_num_players, 2, 4),
|
||||||
#endif
|
#endif
|
||||||
Option(OptionID::kPrefMaxScale, &gopts.max_scale, 0, 100),
|
Option(OptionID::kPrefMaxScale, &gopts.max_scale, 0, 100),
|
||||||
Option(OptionID::kPrefPauseWhenInactive, &pauseWhenInactive, 0, 1),
|
Option(OptionID::kPrefPauseWhenInactive, &g_owned_opts.pause_when_inactive),
|
||||||
Option(OptionID::kPrefRTCEnabled, &coreOptions.rtcEnabled, 0, 1),
|
Option(OptionID::kPrefRTCEnabled, &coreOptions.rtcEnabled, 0, 1),
|
||||||
Option(OptionID::kPrefSaveType, &coreOptions.cpuSaveType, 0, 5),
|
Option(OptionID::kPrefSaveType, &coreOptions.cpuSaveType, 0, 5),
|
||||||
Option(OptionID::kPrefShowSpeed, &showSpeed, 0, 2),
|
Option(OptionID::kPrefShowSpeed, &g_owned_opts.show_speed, 0, 2),
|
||||||
Option(OptionID::kPrefShowSpeedTransparent, &showSpeedTransparent, 0, 1),
|
Option(OptionID::kPrefShowSpeedTransparent, &g_owned_opts.show_speed_transparent),
|
||||||
Option(OptionID::kPrefSkipBios, &coreOptions.skipBios, 0, 1),
|
Option(OptionID::kPrefSkipBios, &coreOptions.skipBios, 0, 1),
|
||||||
Option(OptionID::kPrefSkipSaveGameCheats, &coreOptions.skipSaveGameCheats, 0, 1),
|
Option(OptionID::kPrefSkipSaveGameCheats, &coreOptions.skipSaveGameCheats, 0, 1),
|
||||||
Option(OptionID::kPrefSkipSaveGameBattery, &coreOptions.skipSaveGameBattery, 0, 1),
|
Option(OptionID::kPrefSkipSaveGameBattery, &coreOptions.skipSaveGameBattery, 0, 1),
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef VBAM_WX_CONFIG_OPTION_ID_H_
|
#ifndef VBAM_WX_CONFIG_OPTION_ID_H_
|
||||||
#define VBAM_WX_CONFIG_OPTION_ID_H_
|
#define VBAM_WX_CONFIG_OPTION_ID_H_
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace config {
|
namespace config {
|
||||||
|
|
||||||
enum class OptionID {
|
enum class OptionID {
|
||||||
|
|
|
@ -70,17 +70,17 @@ static constexpr std::array<Option::Type, kNbOptions> kOptionsTypes = {
|
||||||
/*kKeyboard*/ Option::Type::kNone,
|
/*kKeyboard*/ Option::Type::kNone,
|
||||||
|
|
||||||
/// Core
|
/// Core
|
||||||
/*kPrefAgbPrint*/ Option::Type::kInt,
|
/*kPrefAgbPrint*/ Option::Type::kBool,
|
||||||
/*kPrefAutoFrameSkip*/ Option::Type::kInt,
|
/*kPrefAutoFrameSkip*/ Option::Type::kBool,
|
||||||
/*kPrefAutoPatch*/ Option::Type::kInt,
|
/*kPrefAutoPatch*/ Option::Type::kBool,
|
||||||
/*kPrefAutoSaveLoadCheatList*/ Option::Type::kBool,
|
/*kPrefAutoSaveLoadCheatList*/ Option::Type::kBool,
|
||||||
/*kPrefBorderAutomatic*/ Option::Type::kInt,
|
/*kPrefBorderAutomatic*/ Option::Type::kInt,
|
||||||
/*kPrefBorderOn*/ Option::Type::kInt,
|
/*kPrefBorderOn*/ Option::Type::kInt,
|
||||||
/*kPrefCaptureFormat*/ Option::Type::kInt,
|
/*kPrefCaptureFormat*/ Option::Type::kUnsigned,
|
||||||
/*kPrefCheatsEnabled*/ Option::Type::kInt,
|
/*kPrefCheatsEnabled*/ Option::Type::kInt,
|
||||||
/*kPrefDisableStatus*/ Option::Type::kInt,
|
/*kPrefDisableStatus*/ Option::Type::kBool,
|
||||||
/*kPrefEmulatorType*/ Option::Type::kInt,
|
/*kPrefEmulatorType*/ Option::Type::kInt,
|
||||||
/*kPrefFlashSize*/ Option::Type::kInt,
|
/*kPrefFlashSize*/ Option::Type::kUnsigned,
|
||||||
/*kPrefFrameSkip*/ Option::Type::kInt,
|
/*kPrefFrameSkip*/ Option::Type::kInt,
|
||||||
/*kPrefGBPaletteOption*/ Option::Type::kInt,
|
/*kPrefGBPaletteOption*/ Option::Type::kInt,
|
||||||
/*kPrefGBPrinter*/ Option::Type::kInt,
|
/*kPrefGBPrinter*/ Option::Type::kInt,
|
||||||
|
@ -90,11 +90,11 @@ static constexpr std::array<Option::Type, kNbOptions> kOptionsTypes = {
|
||||||
/*kPrefLinkNumPlayers*/ Option::Type::kInt,
|
/*kPrefLinkNumPlayers*/ Option::Type::kInt,
|
||||||
#endif
|
#endif
|
||||||
/*kPrefMaxScale*/ Option::Type::kInt,
|
/*kPrefMaxScale*/ Option::Type::kInt,
|
||||||
/*kPrefPauseWhenInactive*/ Option::Type::kInt,
|
/*kPrefPauseWhenInactive*/ Option::Type::kBool,
|
||||||
/*kPrefRTCEnabled*/ Option::Type::kInt,
|
/*kPrefRTCEnabled*/ Option::Type::kInt,
|
||||||
/*kPrefSaveType*/ Option::Type::kInt,
|
/*kPrefSaveType*/ Option::Type::kInt,
|
||||||
/*kPrefShowSpeed*/ Option::Type::kInt,
|
/*kPrefShowSpeed*/ Option::Type::kUnsigned,
|
||||||
/*kPrefShowSpeedTransparent*/ Option::Type::kInt,
|
/*kPrefShowSpeedTransparent*/ Option::Type::kBool,
|
||||||
/*kPrefSkipBios*/ Option::Type::kInt,
|
/*kPrefSkipBios*/ Option::Type::kInt,
|
||||||
/*kPrefSkipSaveGameCheats*/ Option::Type::kInt,
|
/*kPrefSkipSaveGameCheats*/ Option::Type::kInt,
|
||||||
/*kPrefSkipSaveGameBattery*/ Option::Type::kInt,
|
/*kPrefSkipSaveGameBattery*/ Option::Type::kInt,
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
#include <wx/object.h>
|
#include <wx/object.h>
|
||||||
#include <wx/radiobut.h>
|
#include <wx/radiobut.h>
|
||||||
#include <wx/spinctrl.h>
|
|
||||||
#include <wx/stdpaths.h>
|
|
||||||
#include <wx/textctrl.h>
|
#include <wx/textctrl.h>
|
||||||
#include <wx/valnum.h>
|
#include <wx/valnum.h>
|
||||||
|
|
||||||
|
@ -261,17 +259,14 @@ DisplayConfig::DisplayConfig(wxWindow* parent)
|
||||||
wxXmlResource::Get()->LoadDialog(this, parent, "DisplayConfig");
|
wxXmlResource::Get()->LoadDialog(this, parent, "DisplayConfig");
|
||||||
|
|
||||||
// Speed
|
// Speed
|
||||||
// AutoSkip/FrameSkip are 2 controls for 1 value. Needs post-process
|
|
||||||
// to ensure checkbox not ignored
|
|
||||||
GetValidatedChild(this, "FrameSkip")
|
GetValidatedChild(this, "FrameSkip")
|
||||||
->SetValidator(wxGenericValidator(&frameSkip));
|
->SetValidator(
|
||||||
if (frameSkip >= 0) {
|
widgets::OptionSpinCtrlValidator(config::OptionID::kPrefFrameSkip));
|
||||||
systemFrameSkip = frameSkip;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On-Screen Display
|
// On-Screen Display
|
||||||
GetValidatedChild(this, "SpeedIndicator")
|
GetValidatedChild(this, "SpeedIndicator")
|
||||||
->SetValidator(wxGenericValidator(&showSpeed));
|
->SetValidator(
|
||||||
|
widgets::OptionChoiceValidator(config::OptionID::kPrefShowSpeed));
|
||||||
|
|
||||||
// Zoom
|
// Zoom
|
||||||
GetValidatedChild(this, "DefaultScale")->SetValidator(ScaleValidator());
|
GetValidatedChild(this, "DefaultScale")->SetValidator(ScaleValidator());
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
// these are all the viewer dialogs with graphical panel areas
|
// these are all the viewer dialogs with graphical panel areas
|
||||||
// they can be instantiated multiple times
|
// they can be instantiated multiple times
|
||||||
|
|
||||||
#include "viewsupt.h"
|
|
||||||
#include "wxvbam.h"
|
|
||||||
#include <wx/colordlg.h>
|
#include <wx/colordlg.h>
|
||||||
#include <wx/ffile.h>
|
#include <wx/ffile.h>
|
||||||
|
|
||||||
|
#include "config/option-proxy.h"
|
||||||
|
#include "viewsupt.h"
|
||||||
|
#include "wxvbam.h"
|
||||||
|
|
||||||
// FIXME: many of these read e.g. palette data directly without regard to
|
// FIXME: many of these read e.g. palette data directly without regard to
|
||||||
// byte order. Need to determine where things are stored in emulated machine
|
// byte order. Need to determine where things are stored in emulated machine
|
||||||
// order and where in native order, and swap the latter on big-endian
|
// order and where in native order, and swap the latter on big-endian
|
||||||
|
@ -1592,14 +1594,15 @@ public:
|
||||||
wxString def_name = panel->game_name() + wxT('-') + dname;
|
wxString def_name = panel->game_name() + wxT('-') + dname;
|
||||||
def_name.resize(def_name.size() - 6); // strlen("Viewer")
|
def_name.resize(def_name.size() - 6); // strlen("Viewer")
|
||||||
|
|
||||||
if (captureFormat)
|
const int capture_format = OPTION(kPrefCaptureFormat);
|
||||||
def_name += wxT(".bmp");
|
if (capture_format == 0)
|
||||||
|
def_name.append(".png");
|
||||||
else
|
else
|
||||||
def_name += wxT(".png");
|
def_name.append(".bmp");
|
||||||
|
|
||||||
wxFileDialog dlg(GetGrandParent(), _("Select output file"), bmp_save_dir, def_name,
|
wxFileDialog dlg(GetGrandParent(), _("Select output file"), bmp_save_dir, def_name,
|
||||||
_("PNG images|*.png|BMP images|*.bmp"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
_("PNG images|*.png|BMP images|*.bmp"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
dlg.SetFilterIndex(captureFormat);
|
dlg.SetFilterIndex(capture_format);
|
||||||
int ret = dlg.ShowModal();
|
int ret = dlg.ShowModal();
|
||||||
bmp_save_dir = dlg.GetDirectory();
|
bmp_save_dir = dlg.GetDirectory();
|
||||||
|
|
||||||
|
@ -1734,14 +1737,15 @@ public:
|
||||||
wxString def_name = panel->game_name() + wxT('-') + dname;
|
wxString def_name = panel->game_name() + wxT('-') + dname;
|
||||||
def_name.resize(def_name.size() - 6); // strlen("Viewer")
|
def_name.resize(def_name.size() - 6); // strlen("Viewer")
|
||||||
|
|
||||||
if (captureFormat)
|
const int capture_format = OPTION(kPrefCaptureFormat);
|
||||||
def_name += wxT(".bmp");
|
if (capture_format == 0)
|
||||||
|
def_name.append(".png");
|
||||||
else
|
else
|
||||||
def_name += wxT(".png");
|
def_name.append(".bmp");
|
||||||
|
|
||||||
wxFileDialog dlg(GetGrandParent(), _("Select output file"), bmp_save_dir, def_name,
|
wxFileDialog dlg(GetGrandParent(), _("Select output file"), bmp_save_dir, def_name,
|
||||||
_("PNG images|*.png|BMP images|*.bmp"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
_("PNG images|*.png|BMP images|*.bmp"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
dlg.SetFilterIndex(captureFormat);
|
dlg.SetFilterIndex(capture_format);
|
||||||
int ret = dlg.ShowModal();
|
int ret = dlg.ShowModal();
|
||||||
bmp_save_dir = dlg.GetDirectory();
|
bmp_save_dir = dlg.GetDirectory();
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "config/user-input.h"
|
#include "config/user-input.h"
|
||||||
#include "dialogs/display-config.h"
|
#include "dialogs/display-config.h"
|
||||||
#include "opts.h"
|
#include "opts.h"
|
||||||
|
#include "widgets/option-validator.h"
|
||||||
|
|
||||||
#if defined(__WXGTK__)
|
#if defined(__WXGTK__)
|
||||||
#include "wayland.h"
|
#include "wayland.h"
|
||||||
|
@ -2981,6 +2982,12 @@ bool MainFrame::BindControls()
|
||||||
d = LoadXRCDialog("NetLink");
|
d = LoadXRCDialog("NetLink");
|
||||||
#endif
|
#endif
|
||||||
wxRadioButton* rb;
|
wxRadioButton* rb;
|
||||||
|
#define getrbo(name, option_id, value) \
|
||||||
|
do { \
|
||||||
|
rb = SafeXRCCTRL<wxRadioButton>(d, name); \
|
||||||
|
rb->SetValidator( \
|
||||||
|
::widgets::OptionSelectedValidator(option_id, value)); \
|
||||||
|
} while (0)
|
||||||
#define getrbi(n, o, v) \
|
#define getrbi(n, o, v) \
|
||||||
do { \
|
do { \
|
||||||
rb = SafeXRCCTRL<wxRadioButton>(d, n); \
|
rb = SafeXRCCTRL<wxRadioButton>(d, n); \
|
||||||
|
@ -3300,8 +3307,8 @@ bool MainFrame::BindControls()
|
||||||
sc->SetValidator(wxUIntValidator(&o)); \
|
sc->SetValidator(wxUIntValidator(&o)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
{
|
{
|
||||||
getrbi("PNG", captureFormat, 0);
|
getrbo("PNG", config::OptionID::kPrefCaptureFormat, 0);
|
||||||
getrbi("BMP", captureFormat, 1);
|
getrbo("BMP", config::OptionID::kPrefCaptureFormat, 1);
|
||||||
getsc("RewindInterval", gopts.rewind_interval);
|
getsc("RewindInterval", gopts.rewind_interval);
|
||||||
getsc_uint("Throttle", coreOptions.throttle);
|
getsc_uint("Throttle", coreOptions.throttle);
|
||||||
throttle_ctrl.thr = sc;
|
throttle_ctrl.thr = sc;
|
||||||
|
@ -3455,7 +3462,10 @@ bool MainFrame::BindControls()
|
||||||
/// System and peripherals
|
/// System and peripherals
|
||||||
ch = GetValidatedChild<wxChoice, wxGenericValidator>(d, "SaveType", wxGenericValidator(&coreOptions.cpuSaveType));
|
ch = GetValidatedChild<wxChoice, wxGenericValidator>(d, "SaveType", wxGenericValidator(&coreOptions.cpuSaveType));
|
||||||
BatConfigHandler.type = ch;
|
BatConfigHandler.type = ch;
|
||||||
ch = GetValidatedChild<wxChoice, wxGenericValidator>(d, "FlashSize", wxGenericValidator(&optFlashSize));
|
ch = GetValidatedChild<wxChoice, widgets::OptionChoiceValidator>(
|
||||||
|
d, "FlashSize",
|
||||||
|
widgets::OptionChoiceValidator(
|
||||||
|
config::OptionID::kPrefFlashSize));
|
||||||
BatConfigHandler.size = ch;
|
BatConfigHandler.size = ch;
|
||||||
d->Connect(XRCID("SaveType"), wxEVT_COMMAND_CHOICE_SELECTED,
|
d->Connect(XRCID("SaveType"), wxEVT_COMMAND_CHOICE_SELECTED,
|
||||||
wxCommandEventHandler(BatConfig_t::ChangeType),
|
wxCommandEventHandler(BatConfig_t::ChangeType),
|
||||||
|
|
|
@ -338,10 +338,6 @@ wxAcceleratorEntry_v sys_accels;
|
||||||
opts_t::opts_t()
|
opts_t::opts_t()
|
||||||
{
|
{
|
||||||
recent = new wxFileHistory(10);
|
recent = new wxFileHistory(10);
|
||||||
|
|
||||||
// These are globals being set here.
|
|
||||||
frameSkip = -1;
|
|
||||||
autoPatch = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: simulate MakeInstanceFilename(vbam.ini) using subkeys (Slave%d/*)
|
// FIXME: simulate MakeInstanceFilename(vbam.ini) using subkeys (Slave%d/*)
|
||||||
|
|
|
@ -198,7 +198,7 @@ void GameArea::LoadGame(const wxString& name)
|
||||||
// out to a temporary file and load it (and can't just use
|
// out to a temporary file and load it (and can't just use
|
||||||
// AssignTempFileName because it needs correct extension)
|
// AssignTempFileName because it needs correct extension)
|
||||||
// too much trouble for now, though
|
// too much trouble for now, though
|
||||||
bool loadpatch = autoPatch;
|
bool loadpatch = OPTION(kPrefAutoPatch);
|
||||||
wxFileName pfn = loaded_game;
|
wxFileName pfn = loaded_game;
|
||||||
int ovSaveType = 0;
|
int ovSaveType = 0;
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ void GameArea::LoadGame(const wxString& name)
|
||||||
int fsz = cfg->Read(wxT("flashSize"), (long)0);
|
int fsz = cfg->Read(wxT("flashSize"), (long)0);
|
||||||
|
|
||||||
if (fsz != 0x10000 && fsz != 0x20000)
|
if (fsz != 0x10000 && fsz != 0x20000)
|
||||||
fsz = 0x10000 << optFlashSize;
|
fsz = 0x10000 << OPTION(kPrefFlashSize);
|
||||||
|
|
||||||
flashSetSize(fsz);
|
flashSetSize(fsz);
|
||||||
ovSaveType = cfg->Read(wxT("coreOptions.saveType"), coreOptions.cpuSaveType);
|
ovSaveType = cfg->Read(wxT("coreOptions.saveType"), coreOptions.cpuSaveType);
|
||||||
|
@ -348,7 +348,7 @@ void GameArea::LoadGame(const wxString& name)
|
||||||
cfg->SetPath(wxT("/"));
|
cfg->SetPath(wxT("/"));
|
||||||
} else {
|
} else {
|
||||||
rtcEnable(coreOptions.rtcEnabled);
|
rtcEnable(coreOptions.rtcEnabled);
|
||||||
flashSetSize(0x10000 << optFlashSize);
|
flashSetSize(0x10000 << OPTION(kPrefFlashSize));
|
||||||
|
|
||||||
if (coreOptions.cpuSaveType < 0 || coreOptions.cpuSaveType > 5)
|
if (coreOptions.cpuSaveType < 0 || coreOptions.cpuSaveType > 5)
|
||||||
coreOptions.cpuSaveType = 0;
|
coreOptions.cpuSaveType = 0;
|
||||||
|
@ -420,12 +420,13 @@ void GameArea::LoadGame(const wxString& name)
|
||||||
gbSerialFunction = gbPrinterSend;
|
gbSerialFunction = gbPrinterSend;
|
||||||
|
|
||||||
// probably only need to do this for GBA carts
|
// probably only need to do this for GBA carts
|
||||||
agbPrintEnable(agbPrint);
|
agbPrintEnable(OPTION(kPrefAgbPrint));
|
||||||
// set frame skip based on ROM type
|
|
||||||
systemFrameSkip = frameSkip;
|
|
||||||
|
|
||||||
if (systemFrameSkip < 0)
|
// set frame skip based on ROM type
|
||||||
systemFrameSkip = 0;
|
const int frame_skip = OPTION(kPrefFrameSkip);
|
||||||
|
if (frame_skip != -1) {
|
||||||
|
systemFrameSkip = frame_skip;
|
||||||
|
}
|
||||||
|
|
||||||
// load battery and/or saved state
|
// load battery and/or saved state
|
||||||
recompute_dirs();
|
recompute_dirs();
|
||||||
|
@ -1892,9 +1893,9 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
|
||||||
|
|
||||||
if (panel->osdstat.size())
|
if (panel->osdstat.size())
|
||||||
drawText(todraw + outstride * (systemColorDepth != 24), outstride,
|
drawText(todraw + outstride * (systemColorDepth != 24), outstride,
|
||||||
10, 20, UTF8(panel->osdstat), showSpeedTransparent);
|
10, 20, UTF8(panel->osdstat), OPTION(kPrefShowSpeedTransparent));
|
||||||
|
|
||||||
if (!disableStatusMessages && !panel->osdtext.empty()) {
|
if (!OPTION(kPrefDisableStatus) && !panel->osdtext.empty()) {
|
||||||
if (systemGetClock() - panel->osdtime < OSD_TIME) {
|
if (systemGetClock() - panel->osdtime < OSD_TIME) {
|
||||||
wxString message = panel->osdtext;
|
wxString message = panel->osdtext;
|
||||||
int linelen = std::ceil(width * scale - 20) / 8;
|
int linelen = std::ceil(width * scale - 20) / 8;
|
||||||
|
@ -1908,7 +1909,7 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
|
||||||
ptr[linelen] = 0;
|
ptr[linelen] = 0;
|
||||||
drawText(todraw + outstride * (systemColorDepth != 24),
|
drawText(todraw + outstride * (systemColorDepth != 24),
|
||||||
outstride, 10, cury, ptr,
|
outstride, 10, cury, ptr,
|
||||||
showSpeedTransparent);
|
OPTION(kPrefShowSpeedTransparent));
|
||||||
cury += 10;
|
cury += 10;
|
||||||
nlines--;
|
nlines--;
|
||||||
ptr += linelen;
|
ptr += linelen;
|
||||||
|
@ -1917,7 +1918,7 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
|
||||||
|
|
||||||
drawText(todraw + outstride * (systemColorDepth != 24),
|
drawText(todraw + outstride * (systemColorDepth != 24),
|
||||||
outstride, 10, cury, ptr,
|
outstride, 10, cury, ptr,
|
||||||
showSpeedTransparent);
|
OPTION(kPrefShowSpeedTransparent));
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
|
@ -1957,7 +1958,7 @@ void DrawingPanelBase::DrawOSD(wxWindowDC& dc)
|
||||||
// directly into the output like DrawText, this is only enabled for
|
// directly into the output like DrawText, this is only enabled for
|
||||||
// non-3d renderers.
|
// non-3d renderers.
|
||||||
GameArea* panel = wxGetApp().frame->GetPanel();
|
GameArea* panel = wxGetApp().frame->GetPanel();
|
||||||
dc.SetTextForeground(wxColour(255, 0, 0, showSpeedTransparent ? 128 : 255));
|
dc.SetTextForeground(wxColour(255, 0, 0, OPTION(kPrefShowSpeedTransparent) ? 128 : 255));
|
||||||
dc.SetTextBackground(wxColour(0, 0, 0, 0));
|
dc.SetTextBackground(wxColour(0, 0, 0, 0));
|
||||||
dc.SetUserScale(1.0, 1.0);
|
dc.SetUserScale(1.0, 1.0);
|
||||||
|
|
||||||
|
@ -1971,7 +1972,7 @@ void DrawingPanelBase::DrawOSD(wxWindowDC& dc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!disableStatusMessages && !panel->osdtext.empty()) {
|
if (!OPTION(kPrefDisableStatus) && !panel->osdtext.empty()) {
|
||||||
wxSize asz = dc.GetSize();
|
wxSize asz = dc.GetSize();
|
||||||
wxString msg = panel->osdtext;
|
wxString msg = panel->osdtext;
|
||||||
int lw, lh;
|
int lw, lh;
|
||||||
|
|
|
@ -452,7 +452,7 @@ void systemShowSpeed(int speed)
|
||||||
wxString s;
|
wxString s;
|
||||||
s.Printf(_("%d %% (%d, %d fps)"), speed, systemFrameSkip, frames * speed / 100);
|
s.Printf(_("%d %% (%d, %d fps)"), speed, systemFrameSkip, frames * speed / 100);
|
||||||
|
|
||||||
switch (showSpeed) {
|
switch (OPTION(kPrefShowSpeed)) {
|
||||||
case SS_NONE:
|
case SS_NONE:
|
||||||
f->GetPanel()->osdstat.clear();
|
f->GetPanel()->osdstat.clear();
|
||||||
break;
|
break;
|
||||||
|
@ -474,9 +474,8 @@ int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
|
||||||
|
|
||||||
void system10Frames() {
|
void system10Frames() {
|
||||||
GameArea* panel = wxGetApp().frame->GetPanel();
|
GameArea* panel = wxGetApp().frame->GetPanel();
|
||||||
int fs = frameSkip;
|
|
||||||
|
|
||||||
if (fs < 0) {
|
if (OPTION(kPrefFrameSkip) == -1) {
|
||||||
// We keep a rolling mean of the last second and use this value to
|
// We keep a rolling mean of the last second and use this value to
|
||||||
// adjust the systemFrameSkip value dynamically.
|
// adjust the systemFrameSkip value dynamically.
|
||||||
|
|
||||||
|
@ -550,24 +549,25 @@ void systemScreenCapture(int num)
|
||||||
GameArea* panel = wxGetApp().frame->GetPanel();
|
GameArea* panel = wxGetApp().frame->GetPanel();
|
||||||
wxFileName fn = wxFileName(wxGetApp().frame->GetGamePath(gopts.scrshot_dir), wxEmptyString);
|
wxFileName fn = wxFileName(wxGetApp().frame->GetGamePath(gopts.scrshot_dir), wxEmptyString);
|
||||||
|
|
||||||
|
const int capture_format = OPTION(kPrefCaptureFormat);
|
||||||
do {
|
do {
|
||||||
wxString bfn;
|
wxString bfn;
|
||||||
bfn.Printf(wxT("%s%02d"), panel->game_name().c_str(),
|
bfn.Printf(wxT("%s%02d"), panel->game_name().c_str(),
|
||||||
num++);
|
num++);
|
||||||
|
|
||||||
if (captureFormat == 0)
|
if (capture_format == 0)
|
||||||
bfn.append(wxT(".png"));
|
bfn.append(".png");
|
||||||
else // if(gopts.cap_format == 1)
|
else
|
||||||
bfn.append(wxT(".bmp"));
|
bfn.append(".bmp");
|
||||||
|
|
||||||
fn.SetFullName(bfn);
|
fn.SetFullName(bfn);
|
||||||
} while (fn.FileExists());
|
} while (fn.FileExists());
|
||||||
|
|
||||||
fn.Mkdir(0777, wxPATH_MKDIR_FULL);
|
fn.Mkdir(0777, wxPATH_MKDIR_FULL);
|
||||||
|
|
||||||
if (captureFormat == 0)
|
if (capture_format == 0)
|
||||||
panel->emusys->emuWritePNG(UTF8(fn.GetFullPath()));
|
panel->emusys->emuWritePNG(UTF8(fn.GetFullPath()));
|
||||||
else // if(gopts.cap_format == 1)
|
else
|
||||||
panel->emusys->emuWriteBMP(UTF8(fn.GetFullPath()));
|
panel->emusys->emuWriteBMP(UTF8(fn.GetFullPath()));
|
||||||
|
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
@ -930,10 +930,10 @@ void PrintDialog::DoSave(wxCommandEvent&)
|
||||||
pats.append(wxALL_FILES);
|
pats.append(wxALL_FILES);
|
||||||
wxString dn = wxGetApp().frame->GetPanel()->game_name();
|
wxString dn = wxGetApp().frame->GetPanel()->game_name();
|
||||||
|
|
||||||
if (captureFormat == 0)
|
if (OPTION(kPrefCaptureFormat) == 0)
|
||||||
dn.append(wxT(".png"));
|
dn.append(".png");
|
||||||
else // if(gopts.cap_format == 1)
|
else
|
||||||
dn.append(wxT(".bmp"));
|
dn.append(".bmp");
|
||||||
|
|
||||||
wxFileDialog fdlg(dlg, _("Save printer image to"), prsav_path, dn,
|
wxFileDialog fdlg(dlg, _("Save printer image to"), prsav_path, dn,
|
||||||
pats, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
pats, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
|
@ -1106,16 +1106,17 @@ void systemGbPrint(uint8_t* data, int len, int pages, int feed, int pal, int con
|
||||||
if (gopts.print_screen_cap) {
|
if (gopts.print_screen_cap) {
|
||||||
wxFileName fn = wxFileName(wxGetApp().frame->GetGamePath(gopts.scrshot_dir), wxEmptyString);
|
wxFileName fn = wxFileName(wxGetApp().frame->GetGamePath(gopts.scrshot_dir), wxEmptyString);
|
||||||
int num = 1;
|
int num = 1;
|
||||||
|
const int capture_format = OPTION(kPrefCaptureFormat);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
wxString bfn;
|
wxString bfn;
|
||||||
bfn.Printf(wxT("%s-print%02d"), panel->game_name().c_str(),
|
bfn.Printf(wxT("%s-print%02d"), panel->game_name().c_str(),
|
||||||
num++);
|
num++);
|
||||||
|
|
||||||
if (captureFormat == 0)
|
if (capture_format == 0)
|
||||||
bfn.append(wxT(".png"));
|
bfn.append(".png");
|
||||||
else // if(gopts.cap_format == 1)
|
else
|
||||||
bfn.append(wxT(".bmp"));
|
bfn.append(".bmp");
|
||||||
|
|
||||||
fn.SetFullName(bfn);
|
fn.SetFullName(bfn);
|
||||||
} while (fn.FileExists());
|
} while (fn.FileExists());
|
||||||
|
@ -1128,7 +1129,7 @@ void systemGbPrint(uint8_t* data, int len, int pages, int feed, int pal, int con
|
||||||
systemGreenShift = 5;
|
systemGreenShift = 5;
|
||||||
systemBlueShift = 0;
|
systemBlueShift = 0;
|
||||||
wxString of = fn.GetFullPath();
|
wxString of = fn.GetFullPath();
|
||||||
bool ret = captureFormat == 0 ? utilWritePNGFile(UTF8(of), 160, lines, (uint8_t*)to_print) : utilWriteBMPFile(UTF8(of), 160, lines, (uint8_t*)to_print);
|
bool ret = capture_format == 0 ? utilWritePNGFile(UTF8(of), 160, lines, (uint8_t*)to_print) : utilWriteBMPFile(UTF8(of), 160, lines, (uint8_t*)to_print);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "viewsupt.h"
|
#include "viewsupt.h"
|
||||||
|
|
||||||
|
#include "config/option-proxy.h"
|
||||||
#include "wxvbam.h"
|
#include "wxvbam.h"
|
||||||
#include "wxutil.h"
|
#include "wxutil.h"
|
||||||
|
|
||||||
|
@ -1172,14 +1174,15 @@ void GfxViewer::SaveBMP(wxCommandEvent& ev)
|
||||||
wxString def_name = panel->game_name() + wxT('-') + dname;
|
wxString def_name = panel->game_name() + wxT('-') + dname;
|
||||||
def_name.resize(def_name.size() - 6); // strlen("Viewer")
|
def_name.resize(def_name.size() - 6); // strlen("Viewer")
|
||||||
|
|
||||||
if (captureFormat)
|
const int capture_format = OPTION(kPrefCaptureFormat);
|
||||||
def_name += wxT(".bmp");
|
if (capture_format == 0)
|
||||||
|
def_name.append(".png");
|
||||||
else
|
else
|
||||||
def_name += wxT(".png");
|
def_name.append(".bmp");
|
||||||
|
|
||||||
wxFileDialog dlg(GetGrandParent(), _("Select output file"), bmp_save_dir, def_name,
|
wxFileDialog dlg(GetGrandParent(), _("Select output file"), bmp_save_dir, def_name,
|
||||||
_("PNG images|*.png|BMP images|*.bmp"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
_("PNG images|*.png|BMP images|*.bmp"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
dlg.SetFilterIndex(captureFormat);
|
dlg.SetFilterIndex(capture_format);
|
||||||
int ret = dlg.ShowModal();
|
int ret = dlg.ShowModal();
|
||||||
bmp_save_dir = dlg.GetDirectory();
|
bmp_save_dir = dlg.GetDirectory();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
#include "widgets/option-validator.h"
|
#include "widgets/option-validator.h"
|
||||||
|
|
||||||
|
#include <wx/checkbox.h>
|
||||||
|
#include <wx/choice.h>
|
||||||
|
#include <wx/radiobut.h>
|
||||||
|
#include <wx/spinctrl.h>
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
OptionValidator::OptionValidator(config::OptionID option_id)
|
OptionValidator::OptionValidator(config::OptionID option_id)
|
||||||
|
@ -30,4 +35,111 @@ void OptionValidator::OnValueChanged() {
|
||||||
assert(write_success);
|
assert(write_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OptionSelectedValidator::OptionSelectedValidator(config::OptionID option_id,
|
||||||
|
uint32_t value)
|
||||||
|
: OptionValidator(option_id), value_(value) {
|
||||||
|
assert(option()->is_unsigned());
|
||||||
|
assert(value_ >= option()->GetUnsignedMin());
|
||||||
|
assert(value_ <= option()->GetUnsignedMax());
|
||||||
|
}
|
||||||
|
|
||||||
|
wxObject* OptionSelectedValidator::Clone() const {
|
||||||
|
return new OptionSelectedValidator(option()->id(), value_);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OptionSelectedValidator::IsWindowValueValid() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OptionSelectedValidator::WriteToWindow() {
|
||||||
|
wxCheckBox* checkbox = wxDynamicCast(GetWindow(), wxCheckBox);
|
||||||
|
if (checkbox) {
|
||||||
|
checkbox->SetValue(option()->GetUnsigned() == value_);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRadioButton* radio_button = wxDynamicCast(GetWindow(), wxRadioButton);
|
||||||
|
if (radio_button) {
|
||||||
|
radio_button->SetValue(option()->GetUnsigned() == value_);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OptionSelectedValidator::WriteToOption() {
|
||||||
|
const wxCheckBox* checkbox = wxDynamicCast(GetWindow(), wxCheckBox);
|
||||||
|
if (checkbox) {
|
||||||
|
if (checkbox->GetValue()) {
|
||||||
|
option()->SetUnsigned(value_);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxRadioButton* radio_button =
|
||||||
|
wxDynamicCast(GetWindow(), wxRadioButton);
|
||||||
|
if (radio_button) {
|
||||||
|
if (radio_button->GetValue()) {
|
||||||
|
option()->SetUnsigned(value_);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
OptionSpinCtrlValidator::OptionSpinCtrlValidator(config::OptionID option_id)
|
||||||
|
: OptionValidator(option_id) {
|
||||||
|
assert(option()->is_int());
|
||||||
|
}
|
||||||
|
|
||||||
|
wxObject* OptionSpinCtrlValidator::Clone() const {
|
||||||
|
return new OptionSpinCtrlValidator(option()->id());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OptionSpinCtrlValidator::IsWindowValueValid() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OptionSpinCtrlValidator::WriteToWindow() {
|
||||||
|
wxSpinCtrl* spin_ctrl = wxDynamicCast(GetWindow(), wxSpinCtrl);
|
||||||
|
assert(spin_ctrl);
|
||||||
|
spin_ctrl->SetValue(option()->GetInt());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OptionSpinCtrlValidator::WriteToOption() {
|
||||||
|
const wxSpinCtrl* spin_ctrl = wxDynamicCast(GetWindow(), wxSpinCtrl);
|
||||||
|
assert(spin_ctrl);
|
||||||
|
return option()->SetInt(spin_ctrl->GetValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
OptionChoiceValidator::OptionChoiceValidator(config::OptionID option_id)
|
||||||
|
: OptionValidator(option_id) {
|
||||||
|
assert(option()->is_unsigned());
|
||||||
|
}
|
||||||
|
|
||||||
|
wxObject* OptionChoiceValidator::Clone() const {
|
||||||
|
return new OptionChoiceValidator(option()->id());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OptionChoiceValidator::IsWindowValueValid() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OptionChoiceValidator::WriteToWindow() {
|
||||||
|
wxChoice* choice = wxDynamicCast(GetWindow(), wxChoice);
|
||||||
|
assert(choice);
|
||||||
|
choice->SetSelection(option()->GetUnsigned());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OptionChoiceValidator::WriteToOption() {
|
||||||
|
const wxChoice* choice = wxDynamicCast(GetWindow(), wxChoice);
|
||||||
|
assert(choice);
|
||||||
|
return option()->SetUnsigned(choice->GetSelection());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace widgets
|
} // namespace widgets
|
||||||
|
|
|
@ -85,6 +85,61 @@ private:
|
||||||
void OnValueChanged() final;
|
void OnValueChanged() final;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// "Generic" validator for a wxChecBox or wxRadioButton widget with a kUnsigned
|
||||||
|
// Option. This will make sure the kUnsigned Option and the wxRadioButton or
|
||||||
|
// wxCheckBox are kept in sync. The widget will be checked if the kUnsigned
|
||||||
|
// Option matches the provided `value` parameter in the constructor.
|
||||||
|
class OptionSelectedValidator : public OptionValidator {
|
||||||
|
public:
|
||||||
|
OptionSelectedValidator(config::OptionID option_id, uint32_t value);
|
||||||
|
~OptionSelectedValidator() override = default;
|
||||||
|
|
||||||
|
// Returns a copy of the object.
|
||||||
|
wxObject* Clone() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// OptionValidator implementation.
|
||||||
|
bool IsWindowValueValid() override;
|
||||||
|
bool WriteToWindow() override;
|
||||||
|
bool WriteToOption() override;
|
||||||
|
|
||||||
|
const uint32_t value_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Validator for a wxSpinCtrl widget with a kInt Option. This will keep the
|
||||||
|
// kInt Option and the wxSpinCtrl selection in sync.
|
||||||
|
class OptionSpinCtrlValidator : public OptionValidator {
|
||||||
|
public:
|
||||||
|
explicit OptionSpinCtrlValidator(config::OptionID option_id);
|
||||||
|
~OptionSpinCtrlValidator() override = default;
|
||||||
|
|
||||||
|
// Returns a copy of the object.
|
||||||
|
wxObject* Clone() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// OptionValidator implementation.
|
||||||
|
bool IsWindowValueValid() override;
|
||||||
|
bool WriteToWindow() override;
|
||||||
|
bool WriteToOption() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Validator for a wxChoice widget with a kUnsigned Option. This will keep the
|
||||||
|
// kUnsigned Option and the wxChoice selection in sync.
|
||||||
|
class OptionChoiceValidator : public OptionValidator {
|
||||||
|
public:
|
||||||
|
explicit OptionChoiceValidator(config::OptionID option_id);
|
||||||
|
~OptionChoiceValidator() override = default;
|
||||||
|
|
||||||
|
// Returns a copy of the object.
|
||||||
|
wxObject* Clone() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// OptionValidator implementation.
|
||||||
|
bool IsWindowValueValid() override;
|
||||||
|
bool WriteToWindow() override;
|
||||||
|
bool WriteToOption() override;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace widgets
|
} // namespace widgets
|
||||||
|
|
||||||
#endif // VBAM_WX_WIDGETS_OPTION_VALIDATOR_H_
|
#endif // VBAM_WX_WIDGETS_OPTION_VALIDATOR_H_
|
||||||
|
|
|
@ -817,7 +817,7 @@ void MainFrame::OnActivate(wxActivateEvent& event)
|
||||||
if (panel && focused)
|
if (panel && focused)
|
||||||
panel->SetFocus();
|
panel->SetFocus();
|
||||||
|
|
||||||
if (pauseWhenInactive) {
|
if (OPTION(kPrefPauseWhenInactive)) {
|
||||||
if (panel && focused && !paused) {
|
if (panel && focused && !paused) {
|
||||||
panel->Resume();
|
panel->Resume();
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,7 +224,7 @@ public:
|
||||||
const config::OptionID& option_id);
|
const config::OptionID& option_id);
|
||||||
void GetMenuOptionInt(const wxString& menuName, int* field, int mask);
|
void GetMenuOptionInt(const wxString& menuName, int* field, int mask);
|
||||||
void GetMenuOptionBool(const wxString& menuName, bool* field);
|
void GetMenuOptionBool(const wxString& menuName, bool* field);
|
||||||
void SetMenuOption(const wxString& menuName, int value);
|
void SetMenuOption(const wxString& menuName, bool value);
|
||||||
|
|
||||||
void SetJoystick();
|
void SetJoystick();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue