mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-26 05:24:21 +01:00
Add highlighted key
This commit is contained in:
parent
2e768d0c67
commit
b94df096f0
10
gui.cpp
10
gui.cpp
@ -67,6 +67,7 @@ Gui::Gui()
|
||||
/* Create the views */
|
||||
this->mv = new MainView();
|
||||
this->dv = new DiscView();
|
||||
this->kv = VirtualKeyboard::kbd;
|
||||
this->pushView(mv);
|
||||
}
|
||||
|
||||
@ -87,6 +88,9 @@ bool Gui::setTheme(const char *path)
|
||||
this->dialogue_bg = this->loadThemeImage(path, "dialogue_box.png");
|
||||
this->disc_info = this->loadThemeImage(path, "disc_info.png");
|
||||
|
||||
this->highlighted_key = this->loadThemeImage(path, "highlighted_key.png");
|
||||
this->selected_key = this->loadThemeImage(path, "selected_key.png");
|
||||
|
||||
this->default_font = this->loadThemeFont(path, "font.ttf", 18);
|
||||
this->small_font = this->loadThemeFont(path, "font.ttf", 16);
|
||||
|
||||
@ -95,6 +99,8 @@ bool Gui::setTheme(const char *path)
|
||||
!this->bg_submenu_middle ||
|
||||
!this->dialogue_bg ||
|
||||
!this->disc_info ||
|
||||
!this->selected_key ||
|
||||
!this->highlighted_key ||
|
||||
!this->default_font ||
|
||||
!this->small_font)
|
||||
{
|
||||
@ -110,6 +116,8 @@ bool Gui::setTheme(const char *path)
|
||||
SDL_FreeSurface(this->dialogue_bg);
|
||||
SDL_FreeSurface(this->disc_info);
|
||||
SDL_FreeSurface(this->textbox);
|
||||
SDL_FreeSurface(this->selected_key);
|
||||
SDL_FreeSurface(this->highlighted_key);
|
||||
|
||||
if (this->default_font)
|
||||
delete this->default_font;
|
||||
@ -119,9 +127,9 @@ bool Gui::setTheme(const char *path)
|
||||
return false;
|
||||
}
|
||||
|
||||
VirtualKeyboard::kbd->setFont(this->default_font);
|
||||
this->mv->updateTheme();
|
||||
this->dv->updateTheme();
|
||||
this->kv->updateTheme();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
6
gui.hh
6
gui.hh
@ -10,7 +10,7 @@
|
||||
|
||||
class MainView;
|
||||
class DiscView;
|
||||
class KeyboardView;
|
||||
class VirtualKeyboard;
|
||||
|
||||
class Gui
|
||||
{
|
||||
@ -63,6 +63,8 @@ public:
|
||||
SDL_Surface *disc_info;
|
||||
SDL_Surface *bg_left, *bg_right, *bg_middle,
|
||||
*bg_submenu_left, *bg_submenu_right, *bg_submenu_middle;
|
||||
SDL_Surface *highlighted_key;
|
||||
SDL_Surface *selected_key;
|
||||
|
||||
Font *default_font;
|
||||
Font *small_font;
|
||||
@ -70,7 +72,7 @@ public:
|
||||
|
||||
MainView *mv;
|
||||
DiscView *dv;
|
||||
KeyboardView *kv;
|
||||
VirtualKeyboard *kv;
|
||||
GuiView **views;
|
||||
int n_views;
|
||||
|
||||
|
@ -72,6 +72,8 @@ public:
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
Gui::gui->pushView(Gui::gui->kv);
|
||||
Gui::gui->kv->activate();
|
||||
break;
|
||||
|
||||
case 11:
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "virtual_keyboard.hh"
|
||||
#include "utils.hh"
|
||||
#include "gui.hh"
|
||||
|
||||
typedef struct virtkey
|
||||
{
|
||||
@ -113,6 +114,13 @@ void VirtualKeyboard::draw(SDL_Surface *where, int x, int y, int w, int h)
|
||||
if (this->shift_on && shifted_names[which])
|
||||
what = shifted_names[which];
|
||||
|
||||
if (this->sel_x == x && this->sel_y == y)
|
||||
{
|
||||
SDL_Rect dst = (SDL_Rect){x * key_w + border_x - 8,
|
||||
y * key_h + border_y - 4, 0,0};
|
||||
|
||||
SDL_BlitSurface(Gui::gui->selected_key, NULL, where, &dst);
|
||||
}
|
||||
this->font->draw(where, what,
|
||||
x * key_w + border_x, y * key_h + border_y, w, h);
|
||||
}
|
||||
@ -351,10 +359,12 @@ void VirtualKeyboard::runLogic()
|
||||
|
||||
void VirtualKeyboard::draw(SDL_Surface *where)
|
||||
{
|
||||
this->draw(where, 20, 240, 600, 240);
|
||||
}
|
||||
|
||||
void VirtualKeyboard::updateTheme()
|
||||
{
|
||||
this->setFont(Gui::gui->small_font);
|
||||
}
|
||||
|
||||
/* The singleton */
|
||||
|
Loading…
Reference in New Issue
Block a user