mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-26 05:24:21 +01:00
Refactor handling of the virtual keyboard to have it on top of the
current view. Makes things a bit nicer but unfortunately makes the keyboard a special case.
This commit is contained in:
parent
e903594921
commit
c9c6b0f365
15
gui.cpp
15
gui.cpp
@ -81,13 +81,13 @@ Gui::Gui()
|
||||
this->game_base_path = GAME_ROOT_PATH;
|
||||
|
||||
this->dlg = NULL;
|
||||
this->kbd = NULL;
|
||||
|
||||
/* Create the views */
|
||||
this->mv = new MainView();
|
||||
this->dv = new DiscView();
|
||||
this->ov = new OptionsView();
|
||||
this->nv = new NetworkView();
|
||||
this->kv = VirtualKeyboard::kbd;
|
||||
this->pushView(mv);
|
||||
}
|
||||
|
||||
@ -149,10 +149,11 @@ bool Gui::setTheme(const char *path)
|
||||
|
||||
this->mv->updateTheme();
|
||||
this->dv->updateTheme();
|
||||
this->kv->updateTheme();
|
||||
this->ov->updateTheme();
|
||||
this->nv->updateTheme();
|
||||
|
||||
VirtualKeyboard::kbd->updateTheme();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -164,6 +165,8 @@ void Gui::runLogic(void)
|
||||
return;
|
||||
if (this->dlg)
|
||||
this->dlg->runLogic();
|
||||
else if (this->kbd)
|
||||
this->kbd->runLogic();
|
||||
else
|
||||
cur_view->runLogic();
|
||||
this->timerController->tick();
|
||||
@ -234,10 +237,10 @@ void Gui::pushEvent(SDL_Event *ev)
|
||||
if (!this->is_active || !cur_view)
|
||||
return;
|
||||
if (this->dlg)
|
||||
{
|
||||
this->dlg->pushEvent(ev);
|
||||
return;
|
||||
}
|
||||
else if (this->kbd)
|
||||
this->kbd->pushEvent(ev);
|
||||
else
|
||||
cur_view->pushEvent(ev);
|
||||
}
|
||||
|
||||
@ -250,6 +253,8 @@ void Gui::draw(SDL_Surface *where)
|
||||
|
||||
SDL_BlitSurface(this->background, NULL, screen, NULL);
|
||||
cur_view->draw(where);
|
||||
if (this->kbd)
|
||||
this->kbd->draw(where);
|
||||
if (this->dlg)
|
||||
this->dlg->draw(where);
|
||||
}
|
||||
|
5
gui.hh
5
gui.hh
@ -39,6 +39,8 @@ public:
|
||||
|
||||
void pushView(GuiView *view);
|
||||
|
||||
void pushVirtualKeyboard(VirtualKeyboard *kbd);
|
||||
|
||||
void pushDialogueBox(DialogueBox *dlg);
|
||||
|
||||
DialogueBox *popDialogueBox();
|
||||
@ -80,13 +82,14 @@ public:
|
||||
Font *small_font;
|
||||
TimerController *timerController;
|
||||
|
||||
/* Handled specially */
|
||||
VirtualKeyboard *kbd;
|
||||
DialogueBox *dlg;
|
||||
|
||||
MainView *mv;
|
||||
DiscView *dv;
|
||||
OptionsView *ov;
|
||||
NetworkView *nv;
|
||||
VirtualKeyboard *kv;
|
||||
GuiView **views;
|
||||
int n_views;
|
||||
|
||||
|
@ -55,8 +55,8 @@ public:
|
||||
case 2: /* Load/save states */
|
||||
break;
|
||||
case 4: /* Keyboard */
|
||||
Gui::gui->kv->activate();
|
||||
Gui::gui->kv->registerListener(new KeyboardTypingListener());
|
||||
VirtualKeyboard::kbd->activate();
|
||||
VirtualKeyboard::kbd->registerListener(new KeyboardTypingListener());
|
||||
break;
|
||||
case 7: /* Reset the C64 */
|
||||
printf("Resetting the C64\n");
|
||||
|
@ -60,8 +60,8 @@ public:
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
Gui::gui->kv->activate();
|
||||
Gui::gui->kv->registerListener(this);
|
||||
VirtualKeyboard::kbd->activate();
|
||||
VirtualKeyboard::kbd->registerListener(this);
|
||||
break;
|
||||
case 4:
|
||||
if ( strncmp(Gui::gui->np->NetworkName, "Unset", strlen("Unset")) == 0)
|
||||
|
@ -259,7 +259,7 @@ const char VirtualKeyboard::keycodeToChar(int kc)
|
||||
|
||||
void VirtualKeyboard::activate()
|
||||
{
|
||||
Gui::gui->pushView(Gui::gui->kv);
|
||||
Gui::gui->kbd = this;
|
||||
this->is_active = true;
|
||||
memset(this->buf, 0, sizeof(struct virtkey) * this->buf_len);
|
||||
this->buf_head = 0;
|
||||
@ -340,7 +340,7 @@ void VirtualKeyboard::deactivate()
|
||||
{
|
||||
this->is_active = false;
|
||||
this->flushListeners();
|
||||
Gui::gui->popView();
|
||||
Gui::gui->kbd = NULL;
|
||||
}
|
||||
|
||||
void VirtualKeyboard::done()
|
||||
|
Loading…
Reference in New Issue
Block a user