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->game_base_path = GAME_ROOT_PATH;
|
||||||
|
|
||||||
this->dlg = NULL;
|
this->dlg = NULL;
|
||||||
|
this->kbd = NULL;
|
||||||
|
|
||||||
/* Create the views */
|
/* Create the views */
|
||||||
this->mv = new MainView();
|
this->mv = new MainView();
|
||||||
this->dv = new DiscView();
|
this->dv = new DiscView();
|
||||||
this->ov = new OptionsView();
|
this->ov = new OptionsView();
|
||||||
this->nv = new NetworkView();
|
this->nv = new NetworkView();
|
||||||
this->kv = VirtualKeyboard::kbd;
|
|
||||||
this->pushView(mv);
|
this->pushView(mv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,10 +149,11 @@ bool Gui::setTheme(const char *path)
|
|||||||
|
|
||||||
this->mv->updateTheme();
|
this->mv->updateTheme();
|
||||||
this->dv->updateTheme();
|
this->dv->updateTheme();
|
||||||
this->kv->updateTheme();
|
|
||||||
this->ov->updateTheme();
|
this->ov->updateTheme();
|
||||||
this->nv->updateTheme();
|
this->nv->updateTheme();
|
||||||
|
|
||||||
|
VirtualKeyboard::kbd->updateTheme();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +165,8 @@ void Gui::runLogic(void)
|
|||||||
return;
|
return;
|
||||||
if (this->dlg)
|
if (this->dlg)
|
||||||
this->dlg->runLogic();
|
this->dlg->runLogic();
|
||||||
|
else if (this->kbd)
|
||||||
|
this->kbd->runLogic();
|
||||||
else
|
else
|
||||||
cur_view->runLogic();
|
cur_view->runLogic();
|
||||||
this->timerController->tick();
|
this->timerController->tick();
|
||||||
@ -234,10 +237,10 @@ void Gui::pushEvent(SDL_Event *ev)
|
|||||||
if (!this->is_active || !cur_view)
|
if (!this->is_active || !cur_view)
|
||||||
return;
|
return;
|
||||||
if (this->dlg)
|
if (this->dlg)
|
||||||
{
|
|
||||||
this->dlg->pushEvent(ev);
|
this->dlg->pushEvent(ev);
|
||||||
return;
|
else if (this->kbd)
|
||||||
}
|
this->kbd->pushEvent(ev);
|
||||||
|
else
|
||||||
cur_view->pushEvent(ev);
|
cur_view->pushEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,6 +253,8 @@ void Gui::draw(SDL_Surface *where)
|
|||||||
|
|
||||||
SDL_BlitSurface(this->background, NULL, screen, NULL);
|
SDL_BlitSurface(this->background, NULL, screen, NULL);
|
||||||
cur_view->draw(where);
|
cur_view->draw(where);
|
||||||
|
if (this->kbd)
|
||||||
|
this->kbd->draw(where);
|
||||||
if (this->dlg)
|
if (this->dlg)
|
||||||
this->dlg->draw(where);
|
this->dlg->draw(where);
|
||||||
}
|
}
|
||||||
|
5
gui.hh
5
gui.hh
@ -39,6 +39,8 @@ public:
|
|||||||
|
|
||||||
void pushView(GuiView *view);
|
void pushView(GuiView *view);
|
||||||
|
|
||||||
|
void pushVirtualKeyboard(VirtualKeyboard *kbd);
|
||||||
|
|
||||||
void pushDialogueBox(DialogueBox *dlg);
|
void pushDialogueBox(DialogueBox *dlg);
|
||||||
|
|
||||||
DialogueBox *popDialogueBox();
|
DialogueBox *popDialogueBox();
|
||||||
@ -80,13 +82,14 @@ public:
|
|||||||
Font *small_font;
|
Font *small_font;
|
||||||
TimerController *timerController;
|
TimerController *timerController;
|
||||||
|
|
||||||
|
/* Handled specially */
|
||||||
|
VirtualKeyboard *kbd;
|
||||||
DialogueBox *dlg;
|
DialogueBox *dlg;
|
||||||
|
|
||||||
MainView *mv;
|
MainView *mv;
|
||||||
DiscView *dv;
|
DiscView *dv;
|
||||||
OptionsView *ov;
|
OptionsView *ov;
|
||||||
NetworkView *nv;
|
NetworkView *nv;
|
||||||
VirtualKeyboard *kv;
|
|
||||||
GuiView **views;
|
GuiView **views;
|
||||||
int n_views;
|
int n_views;
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ public:
|
|||||||
case 2: /* Load/save states */
|
case 2: /* Load/save states */
|
||||||
break;
|
break;
|
||||||
case 4: /* Keyboard */
|
case 4: /* Keyboard */
|
||||||
Gui::gui->kv->activate();
|
VirtualKeyboard::kbd->activate();
|
||||||
Gui::gui->kv->registerListener(new KeyboardTypingListener());
|
VirtualKeyboard::kbd->registerListener(new KeyboardTypingListener());
|
||||||
break;
|
break;
|
||||||
case 7: /* Reset the C64 */
|
case 7: /* Reset the C64 */
|
||||||
printf("Resetting the C64\n");
|
printf("Resetting the C64\n");
|
||||||
|
@ -60,8 +60,8 @@ public:
|
|||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
Gui::gui->kv->activate();
|
VirtualKeyboard::kbd->activate();
|
||||||
Gui::gui->kv->registerListener(this);
|
VirtualKeyboard::kbd->registerListener(this);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if ( strncmp(Gui::gui->np->NetworkName, "Unset", strlen("Unset")) == 0)
|
if ( strncmp(Gui::gui->np->NetworkName, "Unset", strlen("Unset")) == 0)
|
||||||
|
@ -259,7 +259,7 @@ const char VirtualKeyboard::keycodeToChar(int kc)
|
|||||||
|
|
||||||
void VirtualKeyboard::activate()
|
void VirtualKeyboard::activate()
|
||||||
{
|
{
|
||||||
Gui::gui->pushView(Gui::gui->kv);
|
Gui::gui->kbd = this;
|
||||||
this->is_active = true;
|
this->is_active = true;
|
||||||
memset(this->buf, 0, sizeof(struct virtkey) * this->buf_len);
|
memset(this->buf, 0, sizeof(struct virtkey) * this->buf_len);
|
||||||
this->buf_head = 0;
|
this->buf_head = 0;
|
||||||
@ -340,7 +340,7 @@ void VirtualKeyboard::deactivate()
|
|||||||
{
|
{
|
||||||
this->is_active = false;
|
this->is_active = false;
|
||||||
this->flushListeners();
|
this->flushListeners();
|
||||||
Gui::gui->popView();
|
Gui::gui->kbd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VirtualKeyboard::done()
|
void VirtualKeyboard::done()
|
||||||
|
Loading…
Reference in New Issue
Block a user