From dbb5914fa4533e562e810bd064b4a3344cb54498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ed=C3=AAnis=20Freindorfer=20Azevedo?= Date: Wed, 10 Jul 2019 14:57:39 -0300 Subject: [PATCH] Show which BIOS file is currently selected. It is not possible to pre-select a file with `wxFilePickerCtrl`. Hence, we add a label to show the current gopts.{gba_bios,gb_bios,gbc_bios} is being used, if any. - Fix remaining of #196. --- src/wx/guiinit.cpp | 23 +++++++++------ src/wx/widgets/wx/wxmisc.h | 9 ++++-- src/wx/widgets/wxmisc.cpp | 2 ++ src/wx/xrc/GameBoyAdvanceConfig.xrc | 21 ++++++++++++++ src/wx/xrc/GameBoyConfig.xrc | 44 ++++++++++++++++++++++++++++- 5 files changed, 88 insertions(+), 11 deletions(-) diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index 073ed641..c9392db7 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -3405,10 +3405,10 @@ bool MainFrame::BindControls() } while (0) #define getcbie(n, o, v) getbie(n, o, v, cb, wxCheckBox, CB) wxFilePickerCtrl* fp; -#define getfp(n, o) \ - do { \ - fp = SafeXRCCTRL(d, n); \ - fp->SetValidator(wxFileDirPickerValidator(&o)); \ +#define getfp(n, o, l) \ + do { \ + fp = SafeXRCCTRL(d, n); \ + fp->SetValidator(wxFileDirPickerValidator(&o, l)); \ } while (0) d = LoadXRCropertySheetDialog("GameBoyConfig"); { @@ -3418,10 +3418,15 @@ bool MainFrame::BindControls() // in command handler. Plus making changes might require resizing // game area. Validation only here. SafeXRCCTRL(d, "Borders"); - /// Boot ROM - getfp("BootRom", gopts.gb_bios); + /// GB Boot ROM + wxStaticText *label = SafeXRCCTRL(d, "BiosFile"); + if (!gopts.gb_bios.empty()) label->SetLabel(gopts.gb_bios); + getfp("BootRom", gopts.gb_bios, label); getlab("BootRomLab"); - getfp("CBootRom", gopts.gbc_bios); + /// GBC + wxStaticText *clabel = SafeXRCCTRL(d, "CBiosFile"); + if (!gopts.gbc_bios.empty()) clabel->SetLabel(gopts.gbc_bios); + getfp("CBootRom", gopts.gbc_bios, clabel); getlab("CBootRomLab"); /// Custom Colors //getcbi("Color", gbColorOption); @@ -3492,7 +3497,9 @@ bool MainFrame::BindControls() wxCommandEventHandler(BatConfig_t::Detect), NULL, &BatConfigHandler); /// Boot ROM - getfp("BootRom", gopts.gba_bios); + wxStaticText *label = SafeXRCCTRL(d, "BiosFile"); + if (!gopts.gba_bios.empty()) label->SetLabel(gopts.gba_bios); + getfp("BootRom", gopts.gba_bios, label); getlab("BootRomLab"); /// Game Overrides getgbaw("GameSettings"); diff --git a/src/wx/widgets/wx/wxmisc.h b/src/wx/widgets/wx/wxmisc.h index ee0be8b6..d5367e2a 100644 --- a/src/wx/widgets/wx/wxmisc.h +++ b/src/wx/widgets/wx/wxmisc.h @@ -114,22 +114,26 @@ protected: bool* vptr; }; +#include + // wxFilePickerCtrl/wxDirPickerCtrl copy-only vvalidator class wxFileDirPickerValidator : public wxValidator { public: - wxFileDirPickerValidator(wxString* _vptr) + wxFileDirPickerValidator(wxString* _vptr, wxStaticText* _label = NULL) : wxValidator() , vptr(_vptr) + , vlabel(_label) { } wxFileDirPickerValidator(const wxFileDirPickerValidator& v) : wxValidator() , vptr(v.vptr) + , vlabel(v.vlabel) { } wxObject* Clone() const { - return new wxFileDirPickerValidator(vptr); + return new wxFileDirPickerValidator(vptr, vlabel); } bool TransferToWindow(); bool TransferFromWindow(); @@ -141,6 +145,7 @@ public: protected: wxString* vptr; + wxStaticText* vlabel; }; // color copy-only validator that supports either 32-bit or 16-bit color diff --git a/src/wx/widgets/wxmisc.cpp b/src/wx/widgets/wxmisc.cpp index e9cc0a00..136d0655 100644 --- a/src/wx/widgets/wxmisc.cpp +++ b/src/wx/widgets/wxmisc.cpp @@ -230,6 +230,7 @@ bool wxFileDirPickerValidator::TransferFromWindow() if (fp) { *vptr = fp->GetPath(); + if (vlabel) vlabel->SetLabel(*vptr); return true; } @@ -237,6 +238,7 @@ bool wxFileDirPickerValidator::TransferFromWindow() if (dp) { *vptr = dp->GetPath(); + if (vlabel) vlabel->SetLabel(*vptr); return true; } diff --git a/src/wx/xrc/GameBoyAdvanceConfig.xrc b/src/wx/xrc/GameBoyAdvanceConfig.xrc index 6006e907..8f600d9f 100644 --- a/src/wx/xrc/GameBoyAdvanceConfig.xrc +++ b/src/wx/xrc/GameBoyAdvanceConfig.xrc @@ -105,6 +105,27 @@ + + wxALL|wxEXPAND + 5 + + wxHORIZONTAL + + + + + wxALL|wxALIGN_CENTRE_VERTICAL + 5 + + + + + + wxALL|wxALIGN_CENTRE_VERTICAL + 5 + + + wxVERTICAL wxALL|wxEXPAND diff --git a/src/wx/xrc/GameBoyConfig.xrc b/src/wx/xrc/GameBoyConfig.xrc index c14fa24a..5a49ed5c 100644 --- a/src/wx/xrc/GameBoyConfig.xrc +++ b/src/wx/xrc/GameBoyConfig.xrc @@ -81,7 +81,7 @@ wxHORIZONTAL - + wxALL|wxALIGN_CENTRE_VERTICAL 5 @@ -121,6 +121,48 @@ wxEXPAND + + wxALL|wxEXPAND + 5 + + wxHORIZONTAL + + + + + wxALL|wxALIGN_CENTRE_VERTICAL + 5 + + + + + + wxALL|wxALIGN_CENTRE_VERTICAL + 5 + + + + + wxALL|wxEXPAND + 5 + + wxHORIZONTAL + + + + + wxALL|wxALIGN_CENTRE_VERTICAL + 5 + + + + + + wxALL|wxALIGN_CENTRE_VERTICAL + 5 + + +