Skip to content
Permalink
Browse files

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.
  • Loading branch information
denisfa authored and rkitover committed Jul 10, 2019
1 parent 76756ef commit dbb5914fa4533e562e810bd064b4a3344cb54498
Showing with 88 additions and 11 deletions.
  1. +15 −8 src/wx/guiinit.cpp
  2. +7 −2 src/wx/widgets/wx/wxmisc.h
  3. +2 −0 src/wx/widgets/wxmisc.cpp
  4. +21 −0 src/wx/xrc/GameBoyAdvanceConfig.xrc
  5. +43 −1 src/wx/xrc/GameBoyConfig.xrc
@@ -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<wxFilePickerCtrl>(d, n); \
fp->SetValidator(wxFileDirPickerValidator(&o)); \
#define getfp(n, o, l) \
do { \
fp = SafeXRCCTRL<wxFilePickerCtrl>(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<wxChoice>(d, "Borders");
/// Boot ROM
getfp("BootRom", gopts.gb_bios);
/// GB Boot ROM
wxStaticText *label = SafeXRCCTRL<wxStaticText>(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<wxStaticText>(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<wxStaticText>(d, "BiosFile");
if (!gopts.gba_bios.empty()) label->SetLabel(gopts.gba_bios);
getfp("BootRom", gopts.gba_bios, label);
getlab("BootRomLab");
/// Game Overrides
getgbaw("GameSettings");
@@ -114,22 +114,26 @@ class wxBoolRevValidator : public wxValidator {
bool* vptr;
};

#include <wx/stattext.h>

// 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 @@ class wxFileDirPickerValidator : public wxValidator {

protected:
wxString* vptr;
wxStaticText* vlabel;
};

// color copy-only validator that supports either 32-bit or 16-bit color
@@ -230,13 +230,15 @@ bool wxFileDirPickerValidator::TransferFromWindow()

if (fp) {
*vptr = fp->GetPath();
if (vlabel) vlabel->SetLabel(*vptr);
return true;
}

wxDirPickerCtrl* dp = wxDynamicCast(GetWindow(), wxDirPickerCtrl);

if (dp) {
*vptr = dp->GetPath();
if (vlabel) vlabel->SetLabel(*vptr);
return true;
}

@@ -105,6 +105,27 @@
</object>
</object>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxStaticText">
<label>Current BIOS file :</label>
</object>
<flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="BiosFile">
<label>(None)</label>
</object>
<flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag>
<border>5</border>
</object>
</object>
</object>
<orient>wxVERTICAL</orient>
</object>
<flag>wxALL|wxEXPAND</flag>
@@ -81,7 +81,7 @@
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxStaticText" name="BootRomLab">
<label>Boot _ROM file :</label>
<label>GB Boot _ROM file :</label>
</object>
<flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag>
<border>5</border>
@@ -121,6 +121,48 @@
</object>
<flag>wxEXPAND</flag>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxStaticText">
<label>Current GB BIOS file :</label>
</object>
<flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="BiosFile">
<label>(None)</label>
</object>
<flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag>
<border>5</border>
</object>
</object>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxStaticText">
<label>Current GBC BIOS file :</label>
</object>
<flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="CBiosFile">
<label>(None)</label>
</object>
<flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag>
<border>5</border>
</object>
</object>
</object>
</object>
</object>
<label>Boot ROM</label>

0 comments on commit dbb5914

Please sign in to comment.
You can’t perform that action at this time.