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.
This commit is contained in:
Edênis Freindorfer Azevedo 2019-07-10 14:57:39 -03:00 committed by Rafael Kitover
parent 76756ef916
commit dbb5914fa4
5 changed files with 88 additions and 11 deletions

View File

@ -3405,10 +3405,10 @@ bool MainFrame::BindControls()
} while (0) } while (0)
#define getcbie(n, o, v) getbie(n, o, v, cb, wxCheckBox, CB) #define getcbie(n, o, v) getbie(n, o, v, cb, wxCheckBox, CB)
wxFilePickerCtrl* fp; wxFilePickerCtrl* fp;
#define getfp(n, o) \ #define getfp(n, o, l) \
do { \ do { \
fp = SafeXRCCTRL<wxFilePickerCtrl>(d, n); \ fp = SafeXRCCTRL<wxFilePickerCtrl>(d, n); \
fp->SetValidator(wxFileDirPickerValidator(&o)); \ fp->SetValidator(wxFileDirPickerValidator(&o, l)); \
} while (0) } while (0)
d = LoadXRCropertySheetDialog("GameBoyConfig"); d = LoadXRCropertySheetDialog("GameBoyConfig");
{ {
@ -3418,10 +3418,15 @@ bool MainFrame::BindControls()
// in command handler. Plus making changes might require resizing // in command handler. Plus making changes might require resizing
// game area. Validation only here. // game area. Validation only here.
SafeXRCCTRL<wxChoice>(d, "Borders"); SafeXRCCTRL<wxChoice>(d, "Borders");
/// Boot ROM /// GB Boot ROM
getfp("BootRom", gopts.gb_bios); wxStaticText *label = SafeXRCCTRL<wxStaticText>(d, "BiosFile");
if (!gopts.gb_bios.empty()) label->SetLabel(gopts.gb_bios);
getfp("BootRom", gopts.gb_bios, label);
getlab("BootRomLab"); 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"); getlab("CBootRomLab");
/// Custom Colors /// Custom Colors
//getcbi("Color", gbColorOption); //getcbi("Color", gbColorOption);
@ -3492,7 +3497,9 @@ bool MainFrame::BindControls()
wxCommandEventHandler(BatConfig_t::Detect), wxCommandEventHandler(BatConfig_t::Detect),
NULL, &BatConfigHandler); NULL, &BatConfigHandler);
/// Boot ROM /// 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"); getlab("BootRomLab");
/// Game Overrides /// Game Overrides
getgbaw("GameSettings"); getgbaw("GameSettings");

View File

@ -114,22 +114,26 @@ protected:
bool* vptr; bool* vptr;
}; };
#include <wx/stattext.h>
// wxFilePickerCtrl/wxDirPickerCtrl copy-only vvalidator // wxFilePickerCtrl/wxDirPickerCtrl copy-only vvalidator
class wxFileDirPickerValidator : public wxValidator { class wxFileDirPickerValidator : public wxValidator {
public: public:
wxFileDirPickerValidator(wxString* _vptr) wxFileDirPickerValidator(wxString* _vptr, wxStaticText* _label = NULL)
: wxValidator() : wxValidator()
, vptr(_vptr) , vptr(_vptr)
, vlabel(_label)
{ {
} }
wxFileDirPickerValidator(const wxFileDirPickerValidator& v) wxFileDirPickerValidator(const wxFileDirPickerValidator& v)
: wxValidator() : wxValidator()
, vptr(v.vptr) , vptr(v.vptr)
, vlabel(v.vlabel)
{ {
} }
wxObject* Clone() const wxObject* Clone() const
{ {
return new wxFileDirPickerValidator(vptr); return new wxFileDirPickerValidator(vptr, vlabel);
} }
bool TransferToWindow(); bool TransferToWindow();
bool TransferFromWindow(); bool TransferFromWindow();
@ -141,6 +145,7 @@ public:
protected: protected:
wxString* vptr; wxString* vptr;
wxStaticText* vlabel;
}; };
// color copy-only validator that supports either 32-bit or 16-bit color // color copy-only validator that supports either 32-bit or 16-bit color

View File

@ -230,6 +230,7 @@ bool wxFileDirPickerValidator::TransferFromWindow()
if (fp) { if (fp) {
*vptr = fp->GetPath(); *vptr = fp->GetPath();
if (vlabel) vlabel->SetLabel(*vptr);
return true; return true;
} }
@ -237,6 +238,7 @@ bool wxFileDirPickerValidator::TransferFromWindow()
if (dp) { if (dp) {
*vptr = dp->GetPath(); *vptr = dp->GetPath();
if (vlabel) vlabel->SetLabel(*vptr);
return true; return true;
} }

View File

@ -105,6 +105,27 @@
</object> </object>
</object> </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> <orient>wxVERTICAL</orient>
</object> </object>
<flag>wxALL|wxEXPAND</flag> <flag>wxALL|wxEXPAND</flag>

View File

@ -81,7 +81,7 @@
<orient>wxHORIZONTAL</orient> <orient>wxHORIZONTAL</orient>
<object class="sizeritem"> <object class="sizeritem">
<object class="wxStaticText" name="BootRomLab"> <object class="wxStaticText" name="BootRomLab">
<label>Boot _ROM file :</label> <label>GB Boot _ROM file :</label>
</object> </object>
<flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag> <flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag>
<border>5</border> <border>5</border>
@ -121,6 +121,48 @@
</object> </object>
<flag>wxEXPAND</flag> <flag>wxEXPAND</flag>
</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 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>
</object> </object>
<label>Boot ROM</label> <label>Boot ROM</label>