mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-13 07:05:12 +01:00
Gui refactoring 2: Separate the timer controller from the Gui
This commit is contained in:
parent
01e2513f62
commit
fd5fe7825f
@ -46,7 +46,7 @@ public:
|
||||
SaveScreenshot() : TimeoutHandler()
|
||||
{
|
||||
/* ~45 seconds from now */
|
||||
Gui::gui->controller->arm(this, 45000);
|
||||
TimerController::controller->arm(this, 45000);
|
||||
}
|
||||
|
||||
virtual void timeoutCallback()
|
||||
@ -56,7 +56,7 @@ public:
|
||||
if (Gui::gui->is_active)
|
||||
{
|
||||
/* Rearm if we are in the GUI */
|
||||
Gui::gui->controller->arm(this, 10000);
|
||||
TimerController::controller->arm(this, 10000);
|
||||
return;
|
||||
}
|
||||
Gui::gui->cur_gameInfo->setScreenshot(TheC64->TheDisplay->SurfaceFromC64Display());
|
||||
@ -74,7 +74,7 @@ public:
|
||||
{
|
||||
Gui::gui->status_bar->queueMessage("Resetting the C64");
|
||||
TheC64->Reset();
|
||||
Gui::gui->controller->arm(this, 4500);
|
||||
TimerController::controller->arm(this, 4500);
|
||||
}
|
||||
|
||||
virtual void timeoutCallback()
|
||||
@ -149,7 +149,7 @@ public:
|
||||
free(tmp_filename);
|
||||
}
|
||||
|
||||
Gui::gui->controller->disarm(this);
|
||||
TimerController::controller->disarm(this);
|
||||
Gui::gui->dv->loadGameInfo(fileName);
|
||||
|
||||
if (Gui::gui->dv->gameInfo->gi)
|
||||
@ -172,7 +172,7 @@ public:
|
||||
|
||||
virtual void hoverCallback(int which)
|
||||
{
|
||||
Gui::gui->controller->arm(this, 350);
|
||||
TimerController::controller->arm(this, 350);
|
||||
}
|
||||
|
||||
virtual void timeoutCallback()
|
||||
@ -182,7 +182,7 @@ public:
|
||||
|
||||
virtual void escapeCallback(int which)
|
||||
{
|
||||
Gui::gui->controller->disarm(this);
|
||||
TimerController::controller->disarm(this);
|
||||
Gui::gui->popView();
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,6 @@ Gui::Gui()
|
||||
|
||||
this->n_views = 0;
|
||||
this->views = NULL;
|
||||
this->controller = new TimerController();
|
||||
|
||||
VirtualKeyboard::kbd = new VirtualKeyboard(NULL);
|
||||
|
||||
@ -143,7 +142,6 @@ Gui::~Gui()
|
||||
delete this->nrv;
|
||||
|
||||
delete this->cur_gameInfo;
|
||||
delete this->controller;
|
||||
|
||||
if (this->status_bar)
|
||||
delete this->status_bar;
|
||||
@ -277,7 +275,7 @@ void Gui::runLogic(void)
|
||||
GuiView *cur_view = this->peekView();
|
||||
|
||||
this->status_bar->runLogic();
|
||||
this->controller->tick();
|
||||
TimerController::controller->tick();
|
||||
if (this->kbd)
|
||||
this->kbd->runLogic();
|
||||
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
TheC64->pushKeyCode(this->kc, false);
|
||||
/* Release it soon */
|
||||
Gui::gui->controller->arm(this, 1);
|
||||
TimerController::controller->arm(this, 1);
|
||||
}
|
||||
|
||||
virtual void timeoutCallback()
|
||||
|
@ -72,7 +72,7 @@ void NetworkServerMessages::timeoutCallback()
|
||||
if (this->messages[this->tail])
|
||||
break;
|
||||
}
|
||||
Gui::gui->controller->arm(this, 5000);
|
||||
TimerController::controller->arm(this, 5000);
|
||||
|
||||
free(cpy);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
|
||||
virtual void hoverCallback(int which)
|
||||
{
|
||||
Gui::gui->controller->arm(this, 350);
|
||||
TimerController::controller->arm(this, 350);
|
||||
}
|
||||
|
||||
virtual void escapeCallback(int which)
|
||||
|
@ -29,7 +29,7 @@ void StatusBar::queueMessage(const char *fmt, ...)
|
||||
|
||||
/* If this is the first message, display it as soon as possible */
|
||||
if (this->head == this->tail)
|
||||
Gui::gui->controller->arm(this, 1);
|
||||
TimerController::controller->arm(this, 1);
|
||||
|
||||
this->head = (this->head + 1) % N_STATUS_MESSAGES;
|
||||
if (this->head == this->tail)
|
||||
@ -60,7 +60,7 @@ void StatusBar::timeoutCallback()
|
||||
this->setText(text);
|
||||
else
|
||||
this->setText(NULL);
|
||||
Gui::gui->controller->arm(this, 2000);
|
||||
TimerController::controller->arm(this, 2000);
|
||||
free((void *)this->cur_message);
|
||||
}
|
||||
|
||||
|
@ -255,6 +255,7 @@ void Frodo::ReadyToRun(void)
|
||||
// Create and start C64
|
||||
TheC64 = new C64;
|
||||
DataStore::ds = new DataStore();
|
||||
TimerController::init();
|
||||
Gui::init();
|
||||
load_rom_files();
|
||||
TheC64->Run();
|
||||
|
@ -10,7 +10,7 @@
|
||||
TimeoutHandler::~TimeoutHandler()
|
||||
{
|
||||
/* If we haven't timed out yet, disarm us */
|
||||
Gui::gui->controller->disarm(this);
|
||||
TimerController::controller->disarm(this);
|
||||
}
|
||||
|
||||
|
||||
@ -80,3 +80,11 @@ void TimerController::tick()
|
||||
cur->tick();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
TimerController *TimerController::controller;
|
||||
void TimerController::init()
|
||||
{
|
||||
TimerController::controller = new TimerController();
|
||||
}
|
||||
|
@ -14,6 +14,10 @@ public:
|
||||
|
||||
void tick();
|
||||
|
||||
/* Singleton */
|
||||
static TimerController *controller;
|
||||
static void init();
|
||||
|
||||
private:
|
||||
int n_handlers;
|
||||
TimeoutHandler **handlers;
|
||||
|
Loading…
Reference in New Issue
Block a user