refactored RadioButtonWidget into own class

This commit is contained in:
thrust26 2017-11-24 12:33:22 +01:00
parent 44d6cf15a0
commit 5d0bc45a09
6 changed files with 52 additions and 144 deletions

View File

@ -144,6 +144,23 @@ Settings::Settings(OSystem& osystem)
setInternal("dis.relocate", "false");
#endif
// player settings
setInternal("plr.settings", "false");
setInternal("plr.stats", "false");
setInternal("plr.bankrandom", "true");
setInternal("plr.ramrandom", "true");
setInternal("plr.cpurandom", "SAXYP");
setInternal("plr.colorloss", "true");
setInternal("plr.tv.jitter", "true");
setInternal("plr.tv.jitter_recovery", "2");
setInternal("plr.debugcolors", "false");
setInternal("plr.tiadriven", "true");
setInternal("plr.console", "2600"); // 7800
setInternal("plr.rewind", false);
setInternal("plr.rewind.size", 100);
setInternal("plr.rewind.interval", 2); // = 1 frame
setInternal("plr.rewind.horizon", 3); // = ~10 seconds
// developer settings
setInternal("dev.settings", "false");
setInternal("dev.stats", "false");
@ -311,6 +328,18 @@ void Settings::validate()
i = getInt("dev.rewind.horizon");
if(i < 0 || i > 6) setInternal("dev.rewind.horizon", 3);
i = getInt("plr.tv.jitter_recovery");
if(i < 1 || i > 20) setInternal("plr.tv.jitter_recovery", "10");
i = getInt("plr.rewind.size");
if(i < 100 || i > 1000) setInternal("plr.rewind.size", 100);
i = getInt("plr.rewind.interval");
if(i < 0 || i > 5) setInternal("plr.rewind.interval", 2);
i = getInt("plr.rewind.horizon");
if(i < 0 || i > 6) setInternal("plr.rewind.horizon", 3);
#ifdef SOUND_SUPPORT
i = getInt("volume");
if(i < 0 || i > 100) setInternal("volume", "100");
@ -509,8 +538,22 @@ void Settings::usage() const
<< " -height <arg> Sets the 'Display.Height' property\n"
<< " -pp <arg> Sets the 'Display.Phosphor' property\n"
<< " -ppblend <arg> Sets the 'Display.PPBlend' property\n"
<< endl
#endif
<< " Various development related parameters for player settings mode\n"
<< endl
<< " -plr.console <2600|7800> Select console for B/W and Pause key handling\n"
<< " -plr.stats <1|0> Overlay console info during emulation\n"
<< " -plr.tiadriven <1|0> Drive unused TIA pins randomly on a read/peek\n"
<< " -plr.cpurandom <1|0> Randomize the contents of CPU registers on reset\n"
<< " -plr.ramrandom <1|0> Randomize the contents of RAM on reset\n"
<< " -plr.colorloss <1|0> Enable PAL color-loss effect\n"
<< " -plr.tv.jitter <1|0> Enable TV jitter effect\n"
<< " -plr.tv.jitter_recovery <1-20> Set recovery time for TV jitter effect\n"
<< " -plr.debugcolors <1|0> Enable debug colors\n"
<< endl
<< " The same parameters but for developer settings mode\n"
<< " -dev.console <2600|7800> Select console for B/W and Pause key handling\n"
<< " -dev.stats <1|0> Overlay console info during emulation\n"
<< " -dev.tiadriven <1|0> Drive unused TIA pins randomly on a read/peek\n"

View File

@ -568,128 +568,6 @@ void CheckboxWidget::drawWidget(bool hilite)
isEnabled() ? kTextColor : kColor);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/* 8x8 radiobutton bitmap */
static uInt32 radio_img_outercircle[14] =
{
0b00001111110000,
0b00111111111100,
0b01110000001110,
0b01100000000110,
0b11000000000011,
0b11000000000011,
0b11000000000011,
0b11000000000011,
0b11000000000011,
0b11000000000011,
0b01100000000110,
0b01110000001110,
0b00111111111100,
0b00001111110000
};
static uInt32 radio_img_innercircle[10] =
{
0b0011111100,
0b0111111110,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b0111111110,
0b0011111100
};
static uInt32 radio_img_active[8] =
{
0b00111100,
0b01111110,
0b11111111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b00111100
};
static uInt32 radio_img_inactive[8] =
{
0b00111100,
0b01111110,
0b11100111,
0b11000011,
0b11000011,
0b11100111,
0b01111110,
0b00111100
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RadioButtonWidget::RadioButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, const string& label,
int cmd)
: CheckboxWidget(boss, font, x, y, label, cmd)
{
_flags = WIDGET_ENABLED;
_bgcolor = _bgcolorhi = kWidColor;
_editable = true;
if(label == "")
_w = 14;
else
_w = font.getStringWidth(label) + 20;
_h = font.getFontHeight() < 14 ? 14 : font.getFontHeight();
// Depending on font size, either the font or box will need to be
// centered vertically
if(_h > 14) // center box
_boxY = (_h - 14) / 2;
else // center text
_textY = (14 - _font.getFontHeight()) / 2;
setFill(CheckboxWidget::Normal);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RadioButtonWidget::setFill(FillType type)
{
switch(type)
{
case CheckboxWidget::Normal:
_img = radio_img_active;
break;
case CheckboxWidget::Inactive:
_img = radio_img_inactive;
break;
default:
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RadioButtonWidget::drawWidget(bool hilite)
{
FBSurface& s = _boss->dialog().surface();
// Draw the outer bounding circle
s.drawBitmap(radio_img_outercircle, _x, _y + _boxY, kShadowColor, 14, 14);
// Draw the inner bounding circle with enabled color
s.drawBitmap(radio_img_innercircle, _x + 2, _y + _boxY + 2, isEnabled() ? _bgcolor : kColor, 10, 10);
// draw state
if(_state)
s.drawBitmap(_img, _x + 3, _y + _boxY + 3, isEnabled() ? kCheckColor : kShadowColor);
// Finally draw the label
s.drawString(_font, _label, _x + 20, _y + _textY, _w,
isEnabled() ? kTextColor : kColor);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h,

View File

@ -279,8 +279,6 @@ class CheckboxWidget : public ButtonWidget
int _boxY;
int _textY;
private:
private:
// Following constructors and assignment operators not supported
CheckboxWidget() = delete;
@ -290,26 +288,6 @@ class CheckboxWidget : public ButtonWidget
CheckboxWidget& operator=(CheckboxWidget&&) = delete;
};
class RadioButtonWidget : public CheckboxWidget
{
public:
RadioButtonWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
const string& label, int cmd = 0);
protected:
void setFill(FillType type);
void drawWidget(bool hilite) override;
private:
// Following constructors and assignment operators not supported
RadioButtonWidget() = delete;
RadioButtonWidget(const RadioButtonWidget&) = delete;
RadioButtonWidget(RadioButtonWidget&&) = delete;
RadioButtonWidget& operator=(const RadioButtonWidget&) = delete;
RadioButtonWidget& operator=(RadioButtonWidget&&) = delete;
};
/* SliderWidget */
class SliderWidget : public ButtonWidget
{

View File

@ -36,6 +36,7 @@ MODULE_OBJS := \
src/gui/OptionsDialog.o \
src/gui/PopUpWidget.o \
src/gui/ProgressDialog.o \
src/gui/RadioButtonWidget.o \
src/gui/RomAuditDialog.o \
src/gui/RomInfoWidget.o \
src/gui/ScrollBarWidget.o \

View File

@ -340,6 +340,7 @@
<ClCompile Include="..\gui\FileListWidget.cxx" />
<ClCompile Include="..\gui\JoystickDialog.cxx" />
<ClCompile Include="..\gui\LoggerDialog.cxx" />
<ClCompile Include="..\gui\RadioButtonWidget.cxx" />
<ClCompile Include="..\gui\SnapshotDialog.cxx" />
<ClCompile Include="FSNodeWINDOWS.cxx" />
<ClCompile Include="OSystemWINDOWS.cxx" />
@ -634,6 +635,7 @@
<ClInclude Include="..\gui\FileListWidget.hxx" />
<ClInclude Include="..\gui\JoystickDialog.hxx" />
<ClInclude Include="..\gui\LoggerDialog.hxx" />
<ClInclude Include="..\gui\RadioButtonWidget.hxx" />
<ClInclude Include="..\gui\SnapshotDialog.hxx" />
<ClInclude Include="..\libpng\pngdebug.h" />
<ClInclude Include="..\libpng\pnginfo.h" />

View File

@ -870,6 +870,9 @@
<ClCompile Include="..\debugger\gui\CartDebugWidget.cxx">
<Filter>Source Files\debugger</Filter>
</ClCompile>
<ClCompile Include="..\gui\RadioButtonWidget.cxx">
<Filter>Source Files\gui</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\bspf.hxx">
@ -1772,6 +1775,9 @@
<ClInclude Include="DeveloperDialog.hxx">
<Filter>Header Files\gui</Filter>
</ClInclude>
<ClInclude Include="..\gui\RadioButtonWidget.hxx">
<Filter>Header Files\gui</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="stella.ico">