Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add in-game key change menu
  • Loading branch information
mushiden authored and ShadowNinja committed Oct 7, 2014
1 parent b98e8d6 commit 7b548cd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/game.cpp
Expand Up @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "server.h"
#include "guiPasswordChange.h"
#include "guiVolumeChange.h"
#include "guiKeyChangeMenu.h"
#include "guiFormSpecMenu.h"
#include "tool.h"
#include "guiChatConsole.h"
Expand Down Expand Up @@ -151,6 +152,11 @@ struct LocalFormspecHandler : public TextDest
return;
}

if (fields.find("btn_key_config") != fields.end()) {
g_gamecallback->keyConfig();
return;
}

if (fields.find("btn_exit_menu") != fields.end()) {
g_gamecallback->disconnect();
return;
Expand Down Expand Up @@ -1044,6 +1050,8 @@ static void show_pause_menu(GUIFormSpecMenu** cur_formspec,

os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;"
<< wide_to_narrow(wstrgettext("Sound Volume")) << "]";
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_key_config;"
<< wide_to_narrow(wstrgettext("Change Keys")) << "]";
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_menu;"
<< wide_to_narrow(wstrgettext("Exit to Menu")) << "]";
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_os;"
Expand Down Expand Up @@ -1877,6 +1885,14 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
g_gamecallback->changevolume_requested = false;
}

if(g_gamecallback->keyconfig_requested)
{
(new GUIKeyChangeMenu(guienv, guiroot, -1,
&g_menumgr))->drop();
g_gamecallback->keyconfig_requested = false;
}


/* Process TextureSource's queue */
tsrc->processQueue();

Expand Down
9 changes: 9 additions & 0 deletions src/mainmenumanager.h
Expand Up @@ -31,6 +31,7 @@ class IGameCallback
{
public:
virtual void exitToOS() = 0;
virtual void keyConfig() = 0;
virtual void disconnect() = 0;
virtual void changePassword() = 0;
virtual void changeVolume() = 0;
Expand Down Expand Up @@ -124,6 +125,7 @@ class MainGameCallback : public IGameCallback
disconnect_requested(false),
changepassword_requested(false),
changevolume_requested(false),
keyconfig_requested(false),
shutdown_requested(false),
device(a_device)
{
Expand Down Expand Up @@ -151,10 +153,17 @@ class MainGameCallback : public IGameCallback
{
changevolume_requested = true;
}

virtual void keyConfig()
{
keyconfig_requested = true;
}


bool disconnect_requested;
bool changepassword_requested;
bool changevolume_requested;
bool keyconfig_requested;
bool shutdown_requested;
IrrlichtDevice *device;
};
Expand Down

0 comments on commit 7b548cd

Please sign in to comment.