mirror of https://github.com/stella-emu/stella.git
work on TimeMachine UI started
This commit is contained in:
parent
8fcec0db17
commit
696fc2ab43
|
@ -49,7 +49,8 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent,
|
|||
_visible(false),
|
||||
_processCancel(false),
|
||||
_surface(nullptr),
|
||||
_tabID(0)
|
||||
_tabID(0),
|
||||
_flags(WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -269,12 +270,14 @@ void Dialog::drawDialog()
|
|||
|
||||
if(_dirty)
|
||||
{
|
||||
// cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << " @ " << &s << endl << endl;
|
||||
s.fillRect(_x, _y, _w, _h, kDlgColor);
|
||||
if(_flags & WIDGET_CLEARBG)
|
||||
// cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << " @ " << &s << endl << endl;
|
||||
s.fillRect(_x, _y, _w, _h, kDlgColor);
|
||||
if(_flags & WIDGET_BORDER)
|
||||
#ifndef FLAT_UI
|
||||
s.box(_x, _y, _w, _h, kColor, kShadowColor);
|
||||
s.box(_x, _y, _w, _h, kColor, kShadowColor);
|
||||
#else
|
||||
s.frameRect(_x, _y, _w, _h, kColor);
|
||||
s.frameRect(_x, _y, _w, _h, kColor);
|
||||
#endif // !FLAT_UI
|
||||
|
||||
// Make all child widget dirty
|
||||
|
|
|
@ -79,6 +79,10 @@ class Dialog : public GuiObject
|
|||
*/
|
||||
void addSurface(shared_ptr<FBSurface> surface);
|
||||
|
||||
void setFlags(int flags) { _flags |= flags; setDirty(); }
|
||||
void clearFlags(int flags) { _flags &= ~flags; setDirty(); }
|
||||
int getFlags() const { return _flags; }
|
||||
|
||||
protected:
|
||||
virtual void draw() override { }
|
||||
void releaseFocus() override;
|
||||
|
@ -165,6 +169,7 @@ class Dialog : public GuiObject
|
|||
shared_ptr<FBSurface> _surface;
|
||||
|
||||
int _tabID;
|
||||
int _flags;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "FBSurface.hxx"
|
||||
#include "OSystem.hxx"
|
||||
#include "Widget.hxx"
|
||||
#include "StateManager.hxx"
|
||||
#include "RewindManager.hxx"
|
||||
#include "TimeMachineDialog.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -29,16 +31,212 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
|
|||
int max_w, int max_h)
|
||||
: Dialog(osystem, parent)
|
||||
{
|
||||
const int BUTTON_W = 16, BUTTON_H = 14;
|
||||
|
||||
/*static uInt32 PAUSE[BUTTON_H] =
|
||||
{
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000,
|
||||
0b0001111001111000
|
||||
};*/
|
||||
static uInt32 PLAY[BUTTON_H] =
|
||||
{
|
||||
0b0110000000000000,
|
||||
0b0111100000000000,
|
||||
0b0111111000000000,
|
||||
0b0111111110000000,
|
||||
0b0111111111100000,
|
||||
0b0111111111111000,
|
||||
0b0111111111111110,
|
||||
0b0111111111111110,
|
||||
0b0111111111111000,
|
||||
0b0111111111100000,
|
||||
0b0111111110000000,
|
||||
0b0111111000000000,
|
||||
0b0111100000000000,
|
||||
0b0110000000000000
|
||||
};
|
||||
static uInt32 REWIND_ALL[BUTTON_H] =
|
||||
{
|
||||
0,
|
||||
0b0110000110000110,
|
||||
0b0110001110001110,
|
||||
0b0110011110011110,
|
||||
0b0110111110111110,
|
||||
0b0111111111111110,
|
||||
0b0111111111111110,
|
||||
0b0111111111111110,
|
||||
0b0111111111111110,
|
||||
0b0110111110111110,
|
||||
0b0110011110011110,
|
||||
0b0110001110001110,
|
||||
0b0110000110000110,
|
||||
0
|
||||
};
|
||||
static uInt32 REWIND_10[BUTTON_H] =
|
||||
{
|
||||
0,
|
||||
0b0000010000100110,
|
||||
0b0000110001100110,
|
||||
0b0001110011100110,
|
||||
0b0011110111100110,
|
||||
0b0111111111100110,
|
||||
0b1111111111100110,
|
||||
0b1111111111100110,
|
||||
0b0111111111100110,
|
||||
0b0011110111100110,
|
||||
0b0001110011100110,
|
||||
0b0000110001100110,
|
||||
0b0000010000100110,
|
||||
0
|
||||
};
|
||||
static uInt32 REWIND_1[BUTTON_H] =
|
||||
{
|
||||
0,
|
||||
0b0000001100011100,
|
||||
0b0000011100011100,
|
||||
0b0000111100011100,
|
||||
0b0001111100011100,
|
||||
0b0011111100011100,
|
||||
0b0111111100011100,
|
||||
0b0111111100011100,
|
||||
0b0011111100011100,
|
||||
0b0001111100011100,
|
||||
0b0000111100011100,
|
||||
0b0000011100011100,
|
||||
0b0000001100011100,
|
||||
0
|
||||
};
|
||||
static uInt32 UNWIND_1[BUTTON_H] =
|
||||
{
|
||||
0,
|
||||
0b0011100011000000,
|
||||
0b0011100011100000,
|
||||
0b0011100011110000,
|
||||
0b0011100011111000,
|
||||
0b0011100011111100,
|
||||
0b0011100011111110,
|
||||
0b0011100011111110,
|
||||
0b0011100011111100,
|
||||
0b0011100011111000,
|
||||
0b0011100011110000,
|
||||
0b0011100011100000,
|
||||
0b0011100011000000,
|
||||
0
|
||||
};
|
||||
static uInt32 UNWIND_10[BUTTON_H] =
|
||||
{
|
||||
0,
|
||||
0b0110010000100000,
|
||||
0b0110011000110000,
|
||||
0b0110011100111000,
|
||||
0b0110011110111100,
|
||||
0b0110011111111110,
|
||||
0b0110011111111111,
|
||||
0b0110011111111111,
|
||||
0b0110011111111110,
|
||||
0b0110011110111100,
|
||||
0b0110011100111000,
|
||||
0b0110011000110000,
|
||||
0b0110010000100000,
|
||||
0
|
||||
};
|
||||
static uInt32 UNWIND_ALL[BUTTON_H] =
|
||||
{
|
||||
0,
|
||||
0b0110000110000110,
|
||||
0b0111000111000110,
|
||||
0b0111100111100110,
|
||||
0b0111110111110110,
|
||||
0b0111111111111110,
|
||||
0b0111111111111110,
|
||||
0b0111111111111110,
|
||||
0b0111111111111110,
|
||||
0b0111110111110110,
|
||||
0b0111100111100110,
|
||||
0b0111000111000110,
|
||||
0b0110000110000110,
|
||||
0
|
||||
};
|
||||
|
||||
const GUI::Font& font = instance().frameBuffer().font();
|
||||
const int buttonWidth = font.getStringWidth(" ") + 20,
|
||||
// buttonHeight = font.getLineHeight() + 6,
|
||||
rowHeight = font.getLineHeight() + 10;
|
||||
const int H_BORDER = 8, BUTTON_GAP = 4, V_BORDER = 4, V_GAP = 4;
|
||||
const int buttonWidth = BUTTON_W + 8,
|
||||
buttonHeight = BUTTON_H + 10,
|
||||
rowHeight = font.getLineHeight();
|
||||
|
||||
WidgetArray wid;
|
||||
int xpos, ypos;
|
||||
|
||||
// Set real dimensions
|
||||
_w = 10 * (buttonWidth + 5) + 20;
|
||||
_h = 2 * rowHeight + 15;
|
||||
_w = 20 * (buttonWidth + BUTTON_GAP) + 20;
|
||||
_h = V_BORDER * 2 + rowHeight + buttonHeight + 4;
|
||||
|
||||
//this->clearFlags(WIDGET_CLEARBG); // TODO: does NOT work as expected
|
||||
|
||||
xpos = H_BORDER;
|
||||
ypos = V_BORDER;
|
||||
|
||||
// Add frame info
|
||||
new StaticTextWidget(this, font, xpos, ypos, "04:32 190");
|
||||
|
||||
new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("XX:XX XXX"), ypos, "12:25 144");
|
||||
|
||||
ypos += rowHeight;
|
||||
|
||||
StaticTextWidget* t = new StaticTextWidget(this, font, xpos, ypos + 3, "999");
|
||||
new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("8888"), ypos + 3, "1000");
|
||||
xpos = t->getRight() + 16;
|
||||
|
||||
myRewindAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, REWIND_ALL,
|
||||
BUTTON_W, BUTTON_H, kRewindAll);
|
||||
wid.push_back(myRewindAllWidget);
|
||||
xpos += buttonWidth + BUTTON_GAP;
|
||||
|
||||
myRewind10Widget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, REWIND_10,
|
||||
BUTTON_W, BUTTON_H, kRewind10);
|
||||
wid.push_back(myRewind10Widget);
|
||||
xpos += buttonWidth + BUTTON_GAP;
|
||||
|
||||
myRewind1Widget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, REWIND_1,
|
||||
BUTTON_W, BUTTON_H, kRewind1);
|
||||
wid.push_back(myRewind1Widget);
|
||||
xpos += buttonWidth + BUTTON_GAP*2;
|
||||
|
||||
/*myPauseWidget = new ButtonWidget(this, font, xpos, ypos - 2, buttonWidth + 4, buttonHeight + 4, PAUSE,
|
||||
BUTTON_W, BUTTON_H, kPause);
|
||||
wid.push_back(myPauseWidget);
|
||||
myPauseWidget->clearFlags(WIDGET_ENABLED);*/
|
||||
myPlayWidget = new ButtonWidget(this, font, xpos, ypos - 2, buttonWidth + 4, buttonHeight + 4, PLAY,
|
||||
BUTTON_W, BUTTON_H, kPlay);
|
||||
wid.push_back(myPlayWidget);
|
||||
xpos += buttonWidth + BUTTON_GAP*2 + 4;
|
||||
|
||||
myUnwind1Widget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, UNWIND_1,
|
||||
BUTTON_W, BUTTON_H, kUnwind1);
|
||||
wid.push_back(myUnwind1Widget);
|
||||
xpos += buttonWidth + BUTTON_GAP;
|
||||
|
||||
myUnwind10Widget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, UNWIND_10,
|
||||
BUTTON_W, BUTTON_H, kUnwind10);
|
||||
wid.push_back(myUnwind10Widget);
|
||||
xpos += buttonWidth + BUTTON_GAP;
|
||||
|
||||
myUnwindAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, UNWIND_ALL,
|
||||
BUTTON_W, BUTTON_H, kUnwindAll);
|
||||
wid.push_back(myUnwindAllWidget);
|
||||
xpos += buttonWidth + BUTTON_GAP;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -53,6 +251,7 @@ void TimeMachineDialog::center()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TimeMachineDialog::loadConfig()
|
||||
{
|
||||
handleWinds();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -62,7 +261,54 @@ void TimeMachineDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
cerr << cmd << endl;
|
||||
switch(cmd)
|
||||
{
|
||||
case kPlay:
|
||||
instance().eventHandler().leaveMenuMode();
|
||||
break;
|
||||
|
||||
case kRewind1:
|
||||
handleWinds(-1);
|
||||
break;
|
||||
|
||||
case kRewind10:
|
||||
handleWinds(-10);
|
||||
break;
|
||||
|
||||
case kRewindAll:
|
||||
handleWinds(-1000);
|
||||
break;
|
||||
|
||||
case kUnwind1:
|
||||
handleWinds(1);
|
||||
break;
|
||||
|
||||
case kUnwind10:
|
||||
handleWinds(10);
|
||||
break;
|
||||
|
||||
case kUnwindAll:
|
||||
handleWinds(1000);
|
||||
break;
|
||||
|
||||
default:
|
||||
Dialog::handleCommand(sender, cmd, data, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TimeMachineDialog::handleWinds(Int32 numWinds)
|
||||
{
|
||||
RewindManager& r = instance().state().rewindManager();
|
||||
|
||||
if(numWinds < 0)
|
||||
r.rewindState(-numWinds);
|
||||
else if(numWinds > 0)
|
||||
r.unwindState(numWinds);
|
||||
|
||||
myRewindAllWidget->setEnabled(!r.atFirst());
|
||||
myRewind10Widget->setEnabled(!r.atFirst());
|
||||
myRewind1Widget->setEnabled(!r.atFirst());
|
||||
|
||||
myUnwindAllWidget->setEnabled(!r.atLast());
|
||||
myUnwind10Widget->setEnabled(!r.atLast());
|
||||
myUnwind1Widget->setEnabled(!r.atLast());
|
||||
}
|
||||
|
|
|
@ -37,6 +37,30 @@ class TimeMachineDialog : public Dialog
|
|||
/** This dialog uses its own positioning, so we override Dialog::center() */
|
||||
void center() override;
|
||||
|
||||
void handleWinds(Int32 numWinds = 0);
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
kPause = 'TMps',
|
||||
kPlay = 'TMpl',
|
||||
kRewindAll = 'TMra',
|
||||
kRewind10 = 'TMr1',
|
||||
kRewind1 = 'TMre',
|
||||
kUnwindAll = 'TMua',
|
||||
kUnwind10 = 'TMu1',
|
||||
kUnwind1 = 'TMun',
|
||||
};
|
||||
|
||||
ButtonWidget* myPauseWidget;
|
||||
ButtonWidget* myPlayWidget;
|
||||
ButtonWidget* myRewindAllWidget;
|
||||
ButtonWidget* myRewind10Widget;
|
||||
ButtonWidget* myRewind1Widget;
|
||||
ButtonWidget* myUnwind1Widget;
|
||||
ButtonWidget* myUnwind10Widget;
|
||||
ButtonWidget* myUnwindAllWidget;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
TimeMachineDialog() = delete;
|
||||
|
|
Loading…
Reference in New Issue