diff --git a/gui.cpp b/gui.cpp index 198ac0b..8efd839 100644 --- a/gui.cpp +++ b/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,11 +237,11 @@ void Gui::pushEvent(SDL_Event *ev) if (!this->is_active || !cur_view) return; if (this->dlg) - { this->dlg->pushEvent(ev); - return; - } - cur_view->pushEvent(ev); + else if (this->kbd) + this->kbd->pushEvent(ev); + else + cur_view->pushEvent(ev); } void Gui::draw(SDL_Surface *where) @@ -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); } diff --git a/gui.hh b/gui.hh index 178f301..9bd353a 100644 --- a/gui.hh +++ b/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; diff --git a/main_menu.cpp b/main_menu.cpp index c769718..7ff6a3d 100644 --- a/main_menu.cpp +++ b/main_menu.cpp @@ -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"); diff --git a/network_menu.cpp b/network_menu.cpp index 7a9ae90..b4ec7cb 100644 --- a/network_menu.cpp +++ b/network_menu.cpp @@ -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) diff --git a/virtual_keyboard.cpp b/virtual_keyboard.cpp index 8e62388..ee68556 100644 --- a/virtual_keyboard.cpp +++ b/virtual_keyboard.cpp @@ -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()