Add less verbose proxy object accessor

This introduces an OPTION macro, as well as assignment operators and
convenience conversion operators to make it easier to treat the
OptionProxy object (renamed from Proxy) as a variable.
This commit is contained in:
Fabrice de Gans 2023-02-05 17:59:07 -08:00 committed by Rafael Kitover
parent 2b950e282f
commit 31e17c1ba4
6 changed files with 139 additions and 113 deletions

View File

@ -2559,32 +2559,32 @@ EVT_HANDLER(GameBoyConfigure, "Game Boy options...")
EVT_HANDLER(SetSize1x, "1x") EVT_HANDLER(SetSize1x, "1x")
{ {
config::Proxy<config::OptionID::kDispScale>().Set(1); OPTION(kDispScale) = 1;
} }
EVT_HANDLER(SetSize2x, "2x") EVT_HANDLER(SetSize2x, "2x")
{ {
config::Proxy<config::OptionID::kDispScale>().Set(2); OPTION(kDispScale) = 2;
} }
EVT_HANDLER(SetSize3x, "3x") EVT_HANDLER(SetSize3x, "3x")
{ {
config::Proxy<config::OptionID::kDispScale>().Set(3); OPTION(kDispScale) = 3;
} }
EVT_HANDLER(SetSize4x, "4x") EVT_HANDLER(SetSize4x, "4x")
{ {
config::Proxy<config::OptionID::kDispScale>().Set(4); OPTION(kDispScale) = 4;
} }
EVT_HANDLER(SetSize5x, "5x") EVT_HANDLER(SetSize5x, "5x")
{ {
config::Proxy<config::OptionID::kDispScale>().Set(5); OPTION(kDispScale) = 5;
} }
EVT_HANDLER(SetSize6x, "6x") EVT_HANDLER(SetSize6x, "6x")
{ {
config::Proxy<config::OptionID::kDispScale>().Set(6); OPTION(kDispScale) = 6;
} }
EVT_HANDLER(GameBoyAdvanceConfigure, "Game Boy Advance options...") EVT_HANDLER(GameBoyAdvanceConfigure, "Game Boy Advance options...")
@ -2764,12 +2764,12 @@ EVT_HANDLER_MASK(DisplayConfigure, "Display options...", CMDEN_NREC_ANY)
EVT_HANDLER_MASK(ChangeFilter, "Change Pixel Filter", CMDEN_NREC_ANY) EVT_HANDLER_MASK(ChangeFilter, "Change Pixel Filter", CMDEN_NREC_ANY)
{ {
config::Proxy<config::OptionID::kDispFilter>().Next(); OPTION(kDispFilter).Next();
} }
EVT_HANDLER_MASK(ChangeIFB, "Change Interframe Blending", CMDEN_NREC_ANY) EVT_HANDLER_MASK(ChangeIFB, "Change Interframe Blending", CMDEN_NREC_ANY)
{ {
config::Proxy<config::OptionID::kDispIFB>().Next(); OPTION(kDispIFB).Next();
} }
EVT_HANDLER_MASK(SoundConfigure, "Sound options...", CMDEN_NREC_ANY) EVT_HANDLER_MASK(SoundConfigure, "Sound options...", CMDEN_NREC_ANY)

View File

@ -248,13 +248,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, Option(OptionID::kPrefPauseWhenInactive, &pauseWhenInactive, 0, 1),
1),
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, &showSpeed, 0, 2),
Option(OptionID::kPrefShowSpeedTransparent, Option(OptionID::kPrefShowSpeedTransparent, &showSpeedTransparent, 0, 1),
&showSpeedTransparent, 0, 1),
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),

View File

@ -138,138 +138,174 @@ static constexpr std::array<Option::Type, kNbOptions> kOptionsTypes = {
// Less verbose accessor for a specific OptionID with compile-time type checks. // Less verbose accessor for a specific OptionID with compile-time type checks.
// //
// Sample usage: // Sample usage:
// if (Proxy<OptionID::kDispBilinear>::Get()) { //
// if (OPTION(kDispBilinear)) {
// // Do something if bilinear filter is on. // // Do something if bilinear filter is on.
// } // }
// //
// Proxy<OptionID::kDispBilinear>::Set(false); // // Set this Option to false.
// OPTION(kDispBilinear) = false;
#define OPTION(option_id) ::config::OptionProxy<::config::OptionID::option_id>()
template <OptionID ID, typename = void> template <OptionID ID, typename = void>
class Proxy {}; class OptionProxy {};
template <OptionID ID> template <OptionID ID>
class Proxy< class OptionProxy<
ID, ID,
typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] == Option::Type::kBool>::type> { typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] ==
Option::Type::kBool>::type> {
public: public:
Proxy() : option_(Option::ByID(ID)) {} OptionProxy() : option_(Option::ByID(ID)) {}
~Proxy() = default; ~OptionProxy() = default;
bool Get() { return option_->GetBool(); } bool Get() const { return option_->GetBool(); }
bool Set(bool value) { return option_->SetBool(value); } bool Set(bool value) { return option_->SetBool(value); }
bool operator=(bool value) { return Set(value); }
operator bool() const { return Get(); }
private: private:
Option* option_; Option* option_;
}; };
template <OptionID ID> template <OptionID ID>
class Proxy<ID, class OptionProxy<
typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] == ID,
Option::Type::kDouble>::type> { typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] ==
Option::Type::kDouble>::type> {
public: public:
Proxy() : option_(Option::ByID(ID)) {} OptionProxy() : option_(Option::ByID(ID)) {}
~Proxy() = default; ~OptionProxy() = default;
double Get() { return option_->GetDouble(); } double Get() const { return option_->GetDouble(); }
bool Set(double value) { return option_->SetDouble(value); } bool Set(double value) { return option_->SetDouble(value); }
double Min() const { return option_->GetDoubleMin(); } double Min() const { return option_->GetDoubleMin(); }
double Max() const { return option_->GetDoubleMax(); } double Max() const { return option_->GetDoubleMax(); }
bool operator=(double value) { return Set(value); }
operator double() const { return Get(); }
private: private:
Option* option_; Option* option_;
}; };
template <OptionID ID> template <OptionID ID>
class Proxy< class OptionProxy<
ID, ID,
typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] == Option::Type::kInt>::type> { typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] ==
Option::Type::kInt>::type> {
public: public:
Proxy() : option_(Option::ByID(ID)) {} OptionProxy() : option_(Option::ByID(ID)) {}
~Proxy() = default; ~OptionProxy() = default;
int32_t Get() { return option_->GetInt(); } int32_t Get() const { return option_->GetInt(); }
bool Set(int32_t value) { return option_->SetInt(value); } bool Set(int32_t value) { return option_->SetInt(value); }
int32_t Min() const { return option_->GetIntMin(); } int32_t Min() const { return option_->GetIntMin(); }
int32_t Max() const { return option_->GetIntMax(); } int32_t Max() const { return option_->GetIntMax(); }
bool operator=(int32_t value) { return Set(value); }
operator int32_t() const { return Get(); }
private: private:
Option* option_; Option* option_;
}; };
template <OptionID ID> template <OptionID ID>
class Proxy<ID, class OptionProxy<
typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] == ID,
Option::Type::kUnsigned>::type> { typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] ==
Option::Type::kUnsigned>::type> {
public: public:
Proxy() : option_(Option::ByID(ID)) {} OptionProxy() : option_(Option::ByID(ID)) {}
~Proxy() = default; ~OptionProxy() = default;
uint32_t Get() { return option_->GetUnsigned(); } uint32_t Get() const { return option_->GetUnsigned(); }
bool Set(uint32_t value) { return option_->SetUnsigned(value); } bool Set(uint32_t value) { return option_->SetUnsigned(value); }
uint32_t Min() const { return option_->GetUnsignedMin(); } uint32_t Min() const { return option_->GetUnsignedMin(); }
uint32_t Max() const { return option_->GetUnsignedMax(); } uint32_t Max() const { return option_->GetUnsignedMax(); }
bool operator=(int32_t value) { return Set(value); }
operator int32_t() const { return Get(); }
private: private:
Option* option_; Option* option_;
}; };
template <OptionID ID> template <OptionID ID>
class Proxy<ID, class OptionProxy<
typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] == ID,
Option::Type::kString>::type> { typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] ==
Option::Type::kString>::type> {
public: public:
Proxy() : option_(Option::ByID(ID)) {} OptionProxy() : option_(Option::ByID(ID)) {}
~Proxy() = default; ~OptionProxy() = default;
const wxString& Get() { return option_->GetString(); } const wxString& Get() const { return option_->GetString(); }
bool Set(const wxString& value) { return option_->SetString(value); } bool Set(const wxString& value) { return option_->SetString(value); }
bool operator=(wxString value) { return Set(value); }
operator wxString() const { return Get(); }
private: private:
Option* option_; Option* option_;
}; };
template <OptionID ID> template <OptionID ID>
class Proxy<ID, class OptionProxy<
typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] == ID,
Option::Type::kFilter>::type> { typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] ==
Option::Type::kFilter>::type> {
public: public:
Proxy() : option_(Option::ByID(ID)) {} OptionProxy() : option_(Option::ByID(ID)) {}
~Proxy() = default; ~OptionProxy() = default;
Filter Get() { return option_->GetFilter(); } Filter Get() const { return option_->GetFilter(); }
bool Set(Filter value) { return option_->SetFilter(value); } bool Set(Filter value) { return option_->SetFilter(value); }
void Next() { option_->NextFilter(); } void Next() { option_->NextFilter(); }
bool operator=(Filter value) { return Set(value); }
operator Filter() const { return Get(); }
private: private:
Option* option_; Option* option_;
}; };
template <OptionID ID> template <OptionID ID>
class Proxy<ID, class OptionProxy<
typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] == ID,
Option::Type::kInterframe>::type> { typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] ==
Option::Type::kInterframe>::type> {
public: public:
Proxy() : option_(Option::ByID(ID)) {} OptionProxy() : option_(Option::ByID(ID)) {}
~Proxy() = default; ~OptionProxy() = default;
Interframe Get() { return option_->GetInterframe(); } Interframe Get() const { return option_->GetInterframe(); }
bool Set(Interframe value) { return option_->SetInterframe(value); } bool Set(Interframe value) { return option_->SetInterframe(value); }
void Next() { option_->NextInterframe(); } void Next() { option_->NextInterframe(); }
bool operator=(Interframe value) { return Set(value); }
operator Interframe() const { return Get(); }
private: private:
Option* option_; Option* option_;
}; };
template <OptionID ID> template <OptionID ID>
class Proxy<ID, class OptionProxy<
typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] == ID,
Option::Type::kRenderMethod>::type> { typename std::enable_if<kOptionsTypes[static_cast<size_t>(ID)] ==
Option::Type::kRenderMethod>::type> {
public: public:
Proxy() : option_(Option::ByID(ID)) {} OptionProxy() : option_(Option::ByID(ID)) {}
~Proxy() = default; ~OptionProxy() = default;
RenderMethod Get() { return option_->GetRenderMethod(); } RenderMethod Get() const { return option_->GetRenderMethod(); }
bool Set(RenderMethod value) { return option_->SetRenderMethod(value); } bool Set(RenderMethod value) { return option_->SetRenderMethod(value); }
bool operator=(RenderMethod value) { return Set(value); }
operator RenderMethod() const { return Get(); }
private: private:
Option* option_; Option* option_;
}; };

View File

@ -354,7 +354,7 @@ void DisplayConfig::PopulatePluginOptions() {
plugin_selector_->Clear(); plugin_selector_->Clear();
plugin_selector_->Append(_("None"), new wxStringClientData()); plugin_selector_->Append(_("None"), new wxStringClientData());
const wxString& selected_plugin = config::Proxy<config::OptionID::kDispFilterPlugin>().Get(); const wxString& selected_plugin = OPTION(kDispFilterPlugin);
bool is_plugin_selected = false; bool is_plugin_selected = false;
for (const wxString& plugin : plugins) { for (const wxString& plugin : plugins) {
@ -389,7 +389,7 @@ void DisplayConfig::PopulatePluginOptions() {
} }
if (!is_plugin_selected) { if (!is_plugin_selected) {
config::Proxy<config::OptionID::kDispFilterPlugin>().Set(wxEmptyString); OPTION(kDispFilterPlugin) = wxEmptyString;
} }
plugin_selector_->SetValidator(PluginSelectorValidator()); plugin_selector_->SetValidator(PluginSelectorValidator());
@ -444,14 +444,14 @@ void DisplayConfig::HidePluginOptions() {
if (filter_selector_->GetCount() == config::kNbFilters) { if (filter_selector_->GetCount() == config::kNbFilters) {
// Make sure we have not selected the plugin option. The validator // Make sure we have not selected the plugin option. The validator
// will take care of updating the selector value. // will take care of updating the selector value.
if (config::Proxy<config::OptionID::kDispFilter>().Get() == config::Filter::kPlugin) { if (OPTION(kDispFilter) == config::Filter::kPlugin) {
config::Proxy<config::OptionID::kDispFilter>().Set(config::Filter::kNone); OPTION(kDispFilter) = config::Filter::kNone;
} }
filter_selector_->Delete(config::kNbFilters - 1); filter_selector_->Delete(config::kNbFilters - 1);
} }
// Also erase the Plugin value to avoid issues down the line. // Also erase the Plugin value to avoid issues down the line.
config::Proxy<config::OptionID::kDispFilterPlugin>().Set(wxEmptyString); OPTION(kDispFilterPlugin) = wxEmptyString;
} }
void DisplayConfig::ShowPluginOptions() { void DisplayConfig::ShowPluginOptions() {

View File

@ -47,7 +47,7 @@
namespace { namespace {
double GetFilterScale() { double GetFilterScale() {
switch (config::Proxy<config::OptionID::kDispFilter>().Get()) { switch (OPTION(kDispFilter)) {
case config::Filter::kNone: case config::Filter::kNone:
return 1.0; return 1.0;
case config::Filter::k2xsai: case config::Filter::k2xsai:
@ -388,7 +388,7 @@ void GameArea::LoadGame(const wxString& name)
emusys = &GBASystem; emusys = &GBASystem;
} }
if (config::Proxy<config::OptionID::kGeomFullScreen>().Get()) { if (OPTION(kGeomFullScreen)) {
GameArea::ShowFullScreen(true); GameArea::ShowFullScreen(true);
} }
@ -794,7 +794,7 @@ void GameArea::AdjustMinSize()
{ {
wxWindow* frame = wxGetApp().frame; wxWindow* frame = wxGetApp().frame;
double dpi_scale_factor = widgets::DPIScaleFactorForWindow(this); double dpi_scale_factor = widgets::DPIScaleFactorForWindow(this);
double display_scale = config::Proxy<config::OptionID::kDispScale>().Get(); const double display_scale = OPTION(kDispScale);
// note: could safely set min size to 1x or less regardless of video_scale // note: could safely set min size to 1x or less regardless of video_scale
// but setting it to scaled size makes resizing to default easier // but setting it to scaled size makes resizing to default easier
@ -830,7 +830,7 @@ void GameArea::AdjustSize(bool force)
return; return;
double dpi_scale_factor = widgets::DPIScaleFactorForWindow(this); double dpi_scale_factor = widgets::DPIScaleFactorForWindow(this);
double display_scale = config::Proxy<config::OptionID::kDispScale>().Get(); const double display_scale = OPTION(kDispScale);
const wxSize newsz( const wxSize newsz(
(std::ceil(basic_width * display_scale) * dpi_scale_factor), (std::ceil(basic_width * display_scale) * dpi_scale_factor),
@ -1096,7 +1096,7 @@ void GameArea::OnIdle(wxIdleEvent& event)
return; return;
if (!panel) { if (!panel) {
switch (config::Proxy<config::OptionID::kDispRenderMethod>().Get()) { switch (OPTION(kDispRenderMethod)) {
case config::RenderMethod::kSimple: case config::RenderMethod::kSimple:
panel = new BasicDrawingPanel(this, basic_width, basic_height); panel = new BasicDrawingPanel(this, basic_width, basic_height);
break; break;
@ -1412,9 +1412,9 @@ DrawingPanelBase::DrawingPanelBase(int _width, int _height)
rpi_(nullptr) { rpi_(nullptr) {
memset(delta, 0xff, sizeof(delta)); memset(delta, 0xff, sizeof(delta));
if (config::Proxy<config::OptionID::kDispFilter>().Get() == config::Filter::kPlugin) { if (OPTION(kDispFilter) == config::Filter::kPlugin) {
rpi_ = widgets::MaybeLoadFilterPlugin( rpi_ = widgets::MaybeLoadFilterPlugin(OPTION(kDispFilterPlugin),
config::Proxy<config::OptionID::kDispFilterPlugin>().Get(), &filter_plugin_); &filter_plugin_);
if (rpi_) { if (rpi_) {
rpi_->Flags &= ~RPI_565_SUPP; rpi_->Flags &= ~RPI_565_SUPP;
@ -1434,13 +1434,13 @@ DrawingPanelBase::DrawingPanelBase(int _width, int _height)
scale *= (rpi_->Flags & RPI_OUT_SCLMSK) >> RPI_OUT_SCLSH; scale *= (rpi_->Flags & RPI_OUT_SCLMSK) >> RPI_OUT_SCLSH;
} else { } else {
// This is going to delete the object. Do nothing more here. // This is going to delete the object. Do nothing more here.
config::Proxy<config::OptionID::kDispFilterPlugin>().Set(wxEmptyString); OPTION(kDispFilterPlugin) = wxEmptyString;
config::Proxy<config::OptionID::kDispFilter>().Set(config::Filter::kNone); OPTION(kDispFilter) = config::Filter::kNone;
return; return;
} }
} }
if (config::Proxy<config::OptionID::kDispFilter>().Get() != config::Filter::kPlugin) { if (OPTION(kDispFilter) != config::Filter::kPlugin) {
scale *= GetFilterScale(); scale *= GetFilterScale();
systemColorDepth = 32; systemColorDepth = 32;
} }
@ -1559,8 +1559,7 @@ public:
delta_ += instride * procy; delta_ += instride * procy;
// FIXME: fugly hack // FIXME: fugly hack
if (config::Proxy<config::OptionID::kDispRenderMethod>().Get() == if (OPTION(kDispRenderMethod) == config::RenderMethod::kOpenGL) {
config::RenderMethod::kOpenGL) {
dst_ += (int)std::ceil(outstride * (procy + 1) * scale_); dst_ += (int)std::ceil(outstride * (procy + 1) * scale_);
} else { } else {
dst_ += (int)std::ceil(outstride * (procy + (1 / scale_)) * scale_); dst_ += (int)std::ceil(outstride * (procy + (1 / scale_)) * scale_);
@ -1579,7 +1578,7 @@ public:
// added procy param to provide offset into accum buffers // added procy param to provide offset into accum buffers
ApplyInterframe(instride, procy); ApplyInterframe(instride, procy);
if (config::Proxy<config::OptionID::kDispFilter>().Get() == config::Filter::kNone) { if (OPTION(kDispFilter) == config::Filter::kNone) {
if (nthreads_ == 1) if (nthreads_ == 1)
return 0; return 0;
@ -1608,7 +1607,7 @@ private:
// definitely not thread safe by default // definitely not thread safe by default
// added procy param to provide offset into accum buffers // added procy param to provide offset into accum buffers
void ApplyInterframe(int instride, int procy) { void ApplyInterframe(int instride, int procy) {
switch (config::Proxy<config::OptionID::kDispIFB>().Get()) { switch (OPTION(kDispIFB)) {
case config::Interframe::kNone: case config::Interframe::kNone:
break; break;
@ -1636,7 +1635,7 @@ private:
// naturally, any of these with accumulation buffers like those // naturally, any of these with accumulation buffers like those
// of the IFB filters will screw up royally as well // of the IFB filters will screw up royally as well
void ApplyFilter(int instride, int outstride) { void ApplyFilter(int instride, int outstride) {
switch (config::Proxy<config::OptionID::kDispFilter>().Get()) { switch (OPTION(kDispFilter)) {
case config::Filter::k2xsai: case config::Filter::k2xsai:
_2xSaI32(src_, instride, delta_, dst_, outstride, width_, _2xSaI32(src_, instride, delta_, dst_, outstride, width_,
height_); height_);
@ -1798,7 +1797,7 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
pixbuf2 = (uint8_t*)calloc(allocstride, std::ceil((alloch + 2) * scale)); pixbuf2 = (uint8_t*)calloc(allocstride, std::ceil((alloch + 2) * scale));
} }
if (config::Proxy<config::OptionID::kDispFilter>().Get() == config::Filter::kNone) { if (OPTION(kDispFilter) == config::Filter::kNone) {
todraw = *data; todraw = *data;
// *data is assigned below, after old buf has been processed // *data is assigned below, after old buf has been processed
pixbuf1 = pixbuf2; pixbuf1 = pixbuf2;
@ -1811,8 +1810,8 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
// First, apply filters, if applicable, in parallel, if enabled // First, apply filters, if applicable, in parallel, if enabled
// FIXME: && (gopts.ifb != FF_MOTION_BLUR || !renderer_can_motion_blur) // FIXME: && (gopts.ifb != FF_MOTION_BLUR || !renderer_can_motion_blur)
if (config::Proxy<config::OptionID::kDispFilter>().Get() != config::Filter::kNone || if (OPTION(kDispFilter) != config::Filter::kNone ||
config::Proxy<config::OptionID::kDispIFB>().Get() != config::Interframe::kNone) { OPTION(kDispIFB) != config::Interframe::kNone) {
if (nthreads != gopts.max_threads) { if (nthreads != gopts.max_threads) {
if (nthreads) { if (nthreads) {
if (nthreads > 1) if (nthreads > 1)
@ -1884,7 +1883,7 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
} }
// swap buffers now that src has been processed // swap buffers now that src has been processed
if (config::Proxy<config::OptionID::kDispFilter>().Get() == config::Filter::kNone) { if (OPTION(kDispFilter) == config::Filter::kNone) {
*data = pixbuf1; *data = pixbuf1;
} }
@ -2070,8 +2069,8 @@ BasicDrawingPanel::BasicDrawingPanel(wxWindow* parent, int _width, int _height)
{ {
// wxImage is 24-bit RGB, so 24-bit is preferred. Filters require // wxImage is 24-bit RGB, so 24-bit is preferred. Filters require
// 16 or 32, though // 16 or 32, though
if (config::Proxy<config::OptionID::kDispFilter>().Get() == config::Filter::kNone && if (OPTION(kDispFilter) == config::Filter::kNone &&
config::Proxy<config::OptionID::kDispIFB>().Get() == config::Interframe::kNone) { OPTION(kDispIFB) == config::Interframe::kNone) {
// changing from 32 to 24 does not require regenerating color tables // changing from 32 to 24 does not require regenerating color tables
systemColorDepth = 32; systemColorDepth = 32;
} }
@ -2102,7 +2101,7 @@ void BasicDrawingPanel::DrawArea(wxWindowDC& dc)
src += 2; // skip rhs border src += 2; // skip rhs border
} }
} else if (config::Proxy<config::OptionID::kDispFilter>().Get() != config::Filter::kNone) { } else if (OPTION(kDispFilter) != config::Filter::kNone) {
// scaled by filters, top/right borders, transform to 24-bit // scaled by filters, top/right borders, transform to 24-bit
im = new wxImage(std::ceil(width * scale), std::ceil(height * scale), false); im = new wxImage(std::ceil(width * scale), std::ceil(height * scale), false);
uint32_t* src = (uint32_t*)todraw + (int)std::ceil(width * scale) + 1; // skip top border uint32_t* src = (uint32_t*)todraw + (int)std::ceil(width * scale) + 1; // skip top border

View File

@ -362,8 +362,7 @@ bool wxvbamApp::OnInit() {
// wxGLCanvas segfaults under wayland before wx 3.2 // wxGLCanvas segfaults under wayland before wx 3.2
#if defined(HAVE_WAYLAND_SUPPORT) && !defined(HAVE_WAYLAND_EGL) #if defined(HAVE_WAYLAND_SUPPORT) && !defined(HAVE_WAYLAND_EGL)
if (UsingWayland()) { if (UsingWayland()) {
config::Proxy<config::OptionID::kDispRenderMethod>().Set( OPTION(kDispRenderMethod) = config::RenderMethod::kSimple;
config::RenderMethod::kSimple);
} }
#endif #endif
@ -472,14 +471,12 @@ bool wxvbamApp::OnInit() {
config::GameControlState::Instance().OnGameBindingsChanged(); config::GameControlState::Instance().OnGameBindingsChanged();
// create the main window // create the main window
int x = config::Proxy<config::OptionID::kGeomWindowX>().Get(); int x = OPTION(kGeomWindowX);
int y = config::Proxy<config::OptionID::kGeomWindowY>().Get(); int y = OPTION(kGeomWindowY);
int width = config::Proxy<config::OptionID::kGeomWindowHeight>().Get(); int width = OPTION(kGeomWindowHeight);
int height = config::Proxy<config::OptionID::kGeomWindowHeight>().Get(); int height = OPTION(kGeomWindowHeight);
bool isFullscreen = bool isFullscreen = OPTION(kGeomFullScreen);
config::Proxy<config::OptionID::kGeomFullScreen>().Get(); bool isMaximized = OPTION(kGeomIsMaximized);
bool isMaximized =
config::Proxy<config::OptionID::kGeomIsMaximized>().Get();
frame = wxDynamicCast(xr->LoadFrame(nullptr, "MainFrame"), MainFrame); frame = wxDynamicCast(xr->LoadFrame(nullptr, "MainFrame"), MainFrame);
if (!frame) { if (!frame) {
@ -842,8 +839,8 @@ void MainFrame::OnMove(wxMoveEvent&) {
if (!IsFullScreen() && !IsMaximized()) { if (!IsFullScreen() && !IsMaximized()) {
if (window_pos.x >= 0 && window_pos.y >= 0) { if (window_pos.x >= 0 && window_pos.y >= 0) {
config::Proxy<config::OptionID::kGeomWindowX>().Set(window_pos.x); OPTION(kGeomWindowX) = window_pos.x;
config::Proxy<config::OptionID::kGeomWindowY>().Set(window_pos.y); OPTION(kGeomWindowY) = window_pos.y;
} }
} }
} }
@ -851,26 +848,22 @@ void MainFrame::OnMove(wxMoveEvent&) {
void MainFrame::OnSize(wxSizeEvent& event) void MainFrame::OnSize(wxSizeEvent& event)
{ {
wxFrame::OnSize(event); wxFrame::OnSize(event);
wxRect window_rect = GetRect(); const wxRect window_rect = GetRect();
wxPoint window_pos = GetScreenPosition(); const wxPoint window_pos = GetScreenPosition();
config::Proxy<config::OptionID::kGeomWindowX> window_x;
config::Proxy<config::OptionID::kGeomWindowY> window_y;
if (!IsFullScreen() && !IsMaximized()) { if (!IsFullScreen() && !IsMaximized()) {
if (window_rect.GetHeight() > 0 && window_rect.GetWidth() > 0) { if (window_rect.GetHeight() > 0 && window_rect.GetWidth() > 0) {
config::Proxy<config::OptionID::kGeomWindowHeight>().Set( OPTION(kGeomWindowHeight) = window_rect.GetHeight();
window_rect.GetHeight()); OPTION(kGeomWindowWidth) = window_rect.GetWidth();
config::Proxy<config::OptionID::kGeomWindowWidth>().Set(
window_rect.GetWidth());
} }
if (window_pos.x >= 0 && window_pos.y >= 0) { if (window_pos.x >= 0 && window_pos.y >= 0) {
window_x.Set(window_pos.x); OPTION(kGeomWindowX) = window_pos.x;
window_y.Set(window_pos.y); OPTION(kGeomWindowY) = window_pos.y;
} }
} }
config::Proxy<config::OptionID::kGeomIsMaximized>().Set(IsMaximized()); OPTION(kGeomIsMaximized) = IsMaximized();
config::Proxy<config::OptionID::kGeomFullScreen>().Set(IsFullScreen()); OPTION(kGeomFullScreen) = IsFullScreen();
} }
int MainFrame::FilterEvent(wxEvent& event) int MainFrame::FilterEvent(wxEvent& event)