mirror of https://github.com/stella-emu/stella.git
Fixed some compiler warnings from clang.
Refactored Stack::replace() to use Stack::applyAll() lambda instead.
This commit is contained in:
parent
91d5df8f8f
commit
2874a7c504
|
@ -44,20 +44,11 @@ class FixedStack
|
|||
bool full() const { return _size >= CAPACITY; }
|
||||
|
||||
T top() const { return _stack[_size - 1]; }
|
||||
T get(uInt32 pos) { return _stack[pos]; };
|
||||
T get(uInt32 pos) { return _stack[pos]; }
|
||||
void push(const T& x) { _stack[_size++] = x; }
|
||||
T pop() { return std::move(_stack[--_size]); }
|
||||
uInt32 size() const { return _size; }
|
||||
|
||||
void replace(const T& oldItem, const T& newItem) {
|
||||
for(uInt32 i = 0; i < _size; ++i) {
|
||||
if(_stack[i] == oldItem) {
|
||||
_stack[i] = newItem;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the given function to every item in the stack
|
||||
// We do it this way so the stack API can be preserved,
|
||||
// and no access to individual elements is allowed outside
|
||||
|
|
|
@ -26,8 +26,7 @@ PaddleWidget::PaddleWidget(GuiObject* boss, const GUI::Font& font,
|
|||
bool leftport = isLeftPort();
|
||||
const string& label = getHeader();
|
||||
|
||||
const int fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
lineHeight = font.getLineHeight();
|
||||
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Paddles)");
|
||||
|
||||
|
|
|
@ -268,14 +268,12 @@ void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
|
|||
break;
|
||||
|
||||
case FrameStyle::Dashed:
|
||||
uInt32 i, skip, lwidth = 1;
|
||||
|
||||
for(i = x; i < x + w; i += 2)
|
||||
for(uInt32 i = x; i < x + w; i += 2)
|
||||
{
|
||||
hLine(i, y, i, color);
|
||||
hLine(i, y + h - 1, i, color);
|
||||
}
|
||||
for(i = y; i < y + h; i += 2)
|
||||
for(uInt32 i = y; i < y + h; i += 2)
|
||||
{
|
||||
vLine(x, i, i, color);
|
||||
vLine(x + w - 1, i, i, color);
|
||||
|
|
|
@ -42,9 +42,7 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
|
|||
const int INDENT = 20;
|
||||
const int lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
buttonWidth = font.getStringWidth("Defaults") + 20,
|
||||
buttonHeight = font.getLineHeight() + 4;
|
||||
fontHeight = font.getFontHeight();
|
||||
int xpos, ypos;
|
||||
int lwidth = font.getStringWidth("Sample Size (*) "),
|
||||
pwidth = font.getStringWidth("512 bytes");
|
||||
|
|
|
@ -33,10 +33,7 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font,
|
|||
myComboEvent(Event::NoType)
|
||||
{
|
||||
const int lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
buttonWidth = font.getStringWidth("Defaults") + 20,
|
||||
buttonHeight = font.getLineHeight() + 4;
|
||||
fontWidth = font.getMaxCharWidth();
|
||||
int xpos, ypos;
|
||||
WidgetArray wid;
|
||||
|
||||
|
|
|
@ -48,9 +48,6 @@
|
|||
Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font, const string& title,
|
||||
int x, int y, int w, int h)
|
||||
: GuiObject(instance, parent, *this, x, y, w, h),
|
||||
_font(&font),
|
||||
_title(title),
|
||||
_th(0),
|
||||
_mouseWidget(nullptr),
|
||||
_focusedWidget(nullptr),
|
||||
_dragWidget(nullptr),
|
||||
|
@ -58,6 +55,9 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font
|
|||
_cancelWidget(nullptr),
|
||||
_visible(false),
|
||||
_processCancel(false),
|
||||
_title(title),
|
||||
_th(0),
|
||||
_font(&font),
|
||||
_surface(nullptr),
|
||||
_tabID(0),
|
||||
_flags(WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG)
|
||||
|
@ -68,10 +68,6 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font
|
|||
Dialog::Dialog(OSystem& instance, DialogContainer& parent,
|
||||
int x, int y, int w, int h)
|
||||
: GuiObject(instance, parent, *this, x, y, w, h),
|
||||
_font(nullptr),
|
||||
_title(""),
|
||||
_th(0),
|
||||
_fh(0),
|
||||
_mouseWidget(nullptr),
|
||||
_focusedWidget(nullptr),
|
||||
_dragWidget(nullptr),
|
||||
|
@ -79,6 +75,10 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent,
|
|||
_cancelWidget(nullptr),
|
||||
_visible(false),
|
||||
_processCancel(false),
|
||||
_title(""),
|
||||
_th(0),
|
||||
_font(nullptr),
|
||||
_fh(0),
|
||||
_surface(nullptr),
|
||||
_tabID(0),
|
||||
_flags(WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG)
|
||||
|
@ -326,8 +326,8 @@ void Dialog::drawDialog()
|
|||
{
|
||||
// dialog is still on top if e.g a ContextMenu is opened
|
||||
bool onTop = parent().myDialogStack.top() == this
|
||||
|| parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this
|
||||
&& !parent().myDialogStack.top()->hasTitle();
|
||||
|| (parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this
|
||||
&& !parent().myDialogStack.top()->hasTitle());
|
||||
|
||||
if(_flags & WIDGET_CLEARBG)
|
||||
{
|
||||
|
|
|
@ -47,7 +47,6 @@ GameInfoDialog::GameInfoDialog(
|
|||
const int lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
buttonWidth = font.getStringWidth("Defaults") + 20,
|
||||
buttonHeight = font.getLineHeight() + 4;
|
||||
const int vBorder = 8;
|
||||
const int hBorder = 8;
|
||||
|
|
|
@ -36,7 +36,6 @@ GlobalPropsDialog::GlobalPropsDialog(GuiObject* boss, const GUI::Font& font)
|
|||
const int lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
buttonWidth = font.getStringWidth("Defaults") + 20,
|
||||
buttonHeight = font.getLineHeight() + 4;
|
||||
int xpos, ypos;
|
||||
int lwidth = font.getStringWidth("Right Difficulty "),
|
||||
|
|
|
@ -45,7 +45,6 @@ InputDialog::InputDialog(OSystem& osystem, DialogContainer& parent,
|
|||
{
|
||||
const int lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
buttonWidth = font.getStringWidth("Defaults") + 20,
|
||||
buttonHeight = font.getLineHeight() + 4;
|
||||
const int vBorder = 4;
|
||||
int xpos, ypos, tabID;
|
||||
|
|
|
@ -263,11 +263,6 @@ void TabWidget::drawWidget(bool hilite)
|
|||
|
||||
FBSurface& s = dialog().surface();
|
||||
|
||||
const int left1 = _x + 1;
|
||||
const int right1 = _x + kTabLeftOffset + _activeTab * (_tabWidth + kTabSpacing);
|
||||
const int left2 = right1 + _tabWidth;
|
||||
const int right2 = _x + _w - 2;
|
||||
|
||||
// Iterate over all tabs and draw them
|
||||
int i, x = _x + kTabLeftOffset;
|
||||
for (i = 0; i < int(_tabs.size()); ++i)
|
||||
|
|
|
@ -47,7 +47,7 @@ void TimeMachine::requestResize()
|
|||
{
|
||||
myWidth = newWidth;
|
||||
Dialog* oldPtr = myBaseDialog;
|
||||
Int32 enterWinds = ((TimeMachineDialog*)myBaseDialog)->getEnterWinds();
|
||||
Int32 enterWinds = static_cast<TimeMachineDialog*>(myBaseDialog)->getEnterWinds();
|
||||
delete myBaseDialog;
|
||||
myBaseDialog = new TimeMachineDialog(myOSystem, *this, myWidth);
|
||||
setEnterWinds(enterWinds);
|
||||
|
@ -55,12 +55,17 @@ void TimeMachine::requestResize()
|
|||
|
||||
// Update the container stack; it may contain a reference to the old pointer
|
||||
if(oldPtr != newPtr)
|
||||
myDialogStack.replace(oldPtr, newPtr);
|
||||
{
|
||||
myDialogStack.applyAll([&oldPtr,&newPtr](Dialog*& d){
|
||||
if(d == oldPtr)
|
||||
d = newPtr;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TimeMachine::setEnterWinds(Int32 numWinds)
|
||||
{
|
||||
((TimeMachineDialog*)myBaseDialog)->setEnterWinds(numWinds);
|
||||
static_cast<TimeMachineDialog*>(myBaseDialog)->setEnterWinds(numWinds);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ class TimeMachineDialog : public Dialog
|
|||
virtual ~TimeMachineDialog() = default;
|
||||
|
||||
/** set/get number of winds when entering the dialog */
|
||||
void setEnterWinds(Int32 numWinds) { _enterWinds = numWinds; };
|
||||
Int32 getEnterWinds() { return _enterWinds; };
|
||||
void setEnterWinds(Int32 numWinds) { _enterWinds = numWinds; }
|
||||
Int32 getEnterWinds() { return _enterWinds; }
|
||||
|
||||
private:
|
||||
void loadConfig() override;
|
||||
|
|
|
@ -41,7 +41,6 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
const int lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
buttonWidth = font.getStringWidth("Defaults") + 20,
|
||||
buttonHeight = font.getLineHeight() + 4;
|
||||
const int VBORDER = 8;
|
||||
const int HBORDER = 10;
|
||||
|
@ -49,7 +48,6 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
int lwidth, pwidth = font.getStringWidth("Standard");
|
||||
WidgetArray wid;
|
||||
VariantList items;
|
||||
ButtonWidget* b;
|
||||
const GUI::Size& ds = instance().frameBuffer().desktopSize();
|
||||
|
||||
// Set real dimensions
|
||||
|
|
|
@ -44,7 +44,6 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
|
|||
const int lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
buttonWidth = font.getStringWidth("Defaults") + 20,
|
||||
buttonHeight = font.getLineHeight() + 4;
|
||||
int xpos, ypos, tabID;
|
||||
int lwidth = font.getStringWidth("TIA Palette "),
|
||||
|
|
|
@ -644,10 +644,10 @@ SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font,
|
|||
_valueMax(100),
|
||||
_isDragging(false),
|
||||
_labelWidth(labelWidth),
|
||||
_valueLabelGap(valueLabelGap),
|
||||
_valueLabelWidth(valueLabelWidth),
|
||||
_valueLabel(""),
|
||||
_valueUnit(valueUnit),
|
||||
_valueLabelGap(valueLabelGap),
|
||||
_valueLabelWidth(valueLabelWidth),
|
||||
_numIntervals(0)
|
||||
{
|
||||
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE;
|
||||
|
|
|
@ -351,8 +351,8 @@ class SliderWidget : public ButtonWidget
|
|||
int _labelWidth;
|
||||
string _valueLabel;
|
||||
string _valueUnit;
|
||||
int _valueLabelWidth;
|
||||
int _valueLabelGap;
|
||||
int _valueLabelWidth;
|
||||
int _numIntervals;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue