2011-06-01 19:44:07 +02:00
|
|
|
/*
|
2011-07-30 13:02:11 +02:00
|
|
|
Minetest-c55
|
2011-06-01 19:44:07 +02:00
|
|
|
Copyright (C) 2010-11 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
Copyright (C) 2011 Ciaran Gultnieks <ciaran@ciarang.com>
|
|
|
|
Copyright (C) 2011 teddydestodes <derkomtur@schattengang.net>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "guiKeyChangeMenu.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "serialization.h"
|
|
|
|
#include "keycode.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include <string>
|
|
|
|
|
2011-08-12 23:42:00 +02:00
|
|
|
static const char *KeyNamesLang[] =
|
|
|
|
{ "-", N_("Left Button"), N_("Right Button"), N_("Cancel"), N_("Middle Button"), N_("X Button 1"),
|
|
|
|
N_("X Button 2"), "-", N_("Back"), N_("Tab"), "-", "-", N_("Clear"), N_("Return"), "-",
|
|
|
|
"-", N_("Shift"), N_("Control"), N_("Menu"), N_("Pause"), N_("Capital"), N_("Kana"), "-",
|
|
|
|
N_("Junja"), N_("Final"), N_("Kanji"), "-", N_("Escape"), N_("Convert"), N_("Nonconvert"),
|
|
|
|
N_("Accept"), N_("Mode Change"), N_("Space"), N_("Priot"), N_("Next"), N_("End"), N_("Home"),
|
|
|
|
N_("Left"), N_("Up"), N_("Right"), N_("Down"), N_("Select"), N_("Print"), N_("Execute"),
|
|
|
|
N_("Snapshot"), N_("Insert"), N_("Delete"), N_("Help"), "0", "1", "2", "3", "4", "5",
|
|
|
|
"6", "7", "8", "9", "-", "-", "-", "-", "-", "-", "-", "A", "B", "C",
|
|
|
|
"D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q",
|
|
|
|
"R", "S", "T", "U", "V", "W", "X", "Y", "Z", N_("Left Windows"),
|
|
|
|
N_("Right Windows"), N_("Apps"), "-", N_("Sleep"), N_("Numpad 0"), N_("Numpad 1"),
|
|
|
|
N_("Numpad 2"), N_("Numpad 3"), N_("Numpad 4"), N_("Numpad 5"), N_("Numpad 6"), N_("Numpad 7"),
|
|
|
|
N_("Numpad 8"), N_("Numpad 9"), N_("Numpad *"), N_("Numpad +"), N_("Numpad /"), N_("Numpad -"),
|
|
|
|
"Numpad .", "Numpad /", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8",
|
|
|
|
"F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18",
|
|
|
|
"F19", "F20", "F21", "F22", "F23", "F24", "-", "-", "-", "-", "-", "-",
|
|
|
|
"-", "-", N_("Num Lock"), N_("Scroll Lock"), "-", "-", "-", "-", "-", "-", "-",
|
|
|
|
"-", "-", "-", "-", "-", "-", "-", N_("Left Shift"), N_("Right Shight"),
|
|
|
|
N_("Left Control"), N_("Right Control"), N_("Left Menu"), N_("Right Menu"), "-", "-",
|
|
|
|
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
|
|
|
|
"-", "-", "-", "-", "-", N_("Plus"), N_("Comma"), N_("Minus"), N_("Period"), "-", "-",
|
|
|
|
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
|
|
|
|
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
|
|
|
|
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
|
|
|
|
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", N_("Attn"), N_("CrSel"),
|
|
|
|
N_("ExSel"), N_("Erase OEF"), N_("Play"), N_("Zoom"), N_("PA1"), N_("OEM Clear"), "-" };
|
|
|
|
|
2011-06-01 19:44:07 +02:00
|
|
|
GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
|
|
|
|
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) :
|
|
|
|
GUIModalMenu(env, parent, id, menumgr)
|
|
|
|
{
|
|
|
|
activeKey = -1;
|
|
|
|
init_keys();
|
|
|
|
}
|
|
|
|
|
|
|
|
GUIKeyChangeMenu::~GUIKeyChangeMenu()
|
|
|
|
{
|
|
|
|
removeChildren();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUIKeyChangeMenu::removeChildren()
|
|
|
|
{
|
|
|
|
const core::list<gui::IGUIElement*> &children = getChildren();
|
|
|
|
core::list<gui::IGUIElement*> children_copy;
|
|
|
|
for (core::list<gui::IGUIElement*>::ConstIterator i = children.begin(); i
|
|
|
|
!= children.end(); i++)
|
|
|
|
{
|
|
|
|
children_copy.push_back(*i);
|
|
|
|
}
|
|
|
|
for (core::list<gui::IGUIElement*>::Iterator i = children_copy.begin(); i
|
|
|
|
!= children_copy.end(); i++)
|
|
|
|
{
|
|
|
|
(*i)->remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Remove stuff
|
|
|
|
*/
|
|
|
|
removeChildren();
|
|
|
|
|
|
|
|
/*
|
|
|
|
Calculate new sizes and positions
|
|
|
|
*/
|
|
|
|
|
|
|
|
v2s32 size(620, 430);
|
|
|
|
|
|
|
|
core::rect < s32 > rect(screensize.X / 2 - size.X / 2,
|
|
|
|
screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2,
|
|
|
|
screensize.Y / 2 + size.Y / 2);
|
|
|
|
|
|
|
|
DesiredRect = rect;
|
|
|
|
recalculateAbsolutePosition(false);
|
|
|
|
|
|
|
|
v2s32 topleft(0, 0);
|
2011-08-02 10:44:25 +02:00
|
|
|
changeCtype("");
|
2011-06-01 19:44:07 +02:00
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 125, 20);
|
|
|
|
rect += topleft + v2s32(25, 3);
|
|
|
|
//gui::IGUIStaticText *t =
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("KEYBINDINGS"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
v2s32 offset(25, 40);
|
|
|
|
// buttons
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Forward"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->forward = Environment->addButton(rect, this,
|
|
|
|
GUI_ID_KEY_FORWARD_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_forward]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Backward"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->backward = Environment->addButton(rect, this,
|
|
|
|
GUI_ID_KEY_BACKWARD_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_backward]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Left"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->left = Environment->addButton(rect, this, GUI_ID_KEY_LEFT_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_left]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Right"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->right = Environment->addButton(rect, this,
|
|
|
|
GUI_ID_KEY_RIGHT_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_right]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Use"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->use = Environment->addButton(rect, this, GUI_ID_KEY_USE_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_use]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Sneak"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->sneak = Environment->addButton(rect, this,
|
|
|
|
GUI_ID_KEY_SNEAK_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_sneak]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Jump"), rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->jump = Environment->addButton(rect, this, GUI_ID_KEY_JUMP_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_jump]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Inventory"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->inventory = Environment->addButton(rect, this,
|
|
|
|
GUI_ID_KEY_INVENTORY_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_inventory]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Chat"), rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->chat = Environment->addButton(rect, this, GUI_ID_KEY_CHAT_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_chat]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//next col
|
|
|
|
offset = v2s32(250, 40);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Toggle fly"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->fly = Environment->addButton(rect, this, GUI_ID_KEY_FLY_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_fly]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Toggle fast"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->fast = Environment->addButton(rect, this, GUI_ID_KEY_FAST_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_fast]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Range select"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->range = Environment->addButton(rect, this,
|
|
|
|
GUI_ID_KEY_RANGE_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_range]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
offset += v2s32(0, 25);
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 20);
|
|
|
|
rect += topleft + v2s32(offset.X, offset.Y);
|
2011-07-31 09:05:52 +02:00
|
|
|
Environment->addStaticText(wgettext("Print stacks"),
|
2011-07-30 11:43:20 +02:00
|
|
|
rect, false, true, this, -1);
|
2011-06-01 19:44:07 +02:00
|
|
|
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
|
|
|
|
this->dump = Environment->addButton(rect, this, GUI_ID_KEY_DUMP_BUTTON,
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_dump]));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(size.X - 100 - 20, size.Y - 40);
|
2011-07-30 11:43:20 +02:00
|
|
|
Environment->addButton(rect, this, GUI_ID_BACK_BUTTON,
|
2011-07-31 09:05:52 +02:00
|
|
|
wgettext("Save"));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 100, 30);
|
|
|
|
rect += topleft + v2s32(size.X - 100 - 20 - 100 - 20, size.Y - 40);
|
2011-07-30 11:43:20 +02:00
|
|
|
Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON,
|
2011-07-31 09:05:52 +02:00
|
|
|
wgettext("Cancel"));
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
2011-08-02 10:44:25 +02:00
|
|
|
changeCtype("C");
|
2011-06-01 19:44:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUIKeyChangeMenu::drawMenu()
|
|
|
|
{
|
|
|
|
gui::IGUISkin* skin = Environment->getSkin();
|
|
|
|
if (!skin)
|
|
|
|
return;
|
|
|
|
video::IVideoDriver* driver = Environment->getVideoDriver();
|
|
|
|
|
|
|
|
video::SColor bgcolor(140, 0, 0, 0);
|
|
|
|
|
|
|
|
{
|
|
|
|
core::rect < s32 > rect(0, 0, 620, 620);
|
|
|
|
rect += AbsoluteRect.UpperLeftCorner;
|
|
|
|
driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
gui::IGUIElement::draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GUIKeyChangeMenu::acceptInput()
|
|
|
|
{
|
|
|
|
g_settings.set("keymap_forward", keycode_to_keyname(key_forward));
|
|
|
|
g_settings.set("keymap_backward", keycode_to_keyname(key_backward));
|
|
|
|
g_settings.set("keymap_left", keycode_to_keyname(key_left));
|
|
|
|
g_settings.set("keymap_right", keycode_to_keyname(key_right));
|
|
|
|
g_settings.set("keymap_jump", keycode_to_keyname(key_jump));
|
|
|
|
g_settings.set("keymap_sneak", keycode_to_keyname(key_sneak));
|
|
|
|
g_settings.set("keymap_inventory", keycode_to_keyname(key_inventory));
|
|
|
|
g_settings.set("keymap_chat", keycode_to_keyname(key_chat));
|
|
|
|
g_settings.set("keymap_rangeselect", keycode_to_keyname(key_range));
|
|
|
|
g_settings.set("keymap_freemove", keycode_to_keyname(key_fly));
|
|
|
|
g_settings.set("keymap_fastmove", keycode_to_keyname(key_fast));
|
|
|
|
g_settings.set("keymap_special1", keycode_to_keyname(key_use));
|
|
|
|
g_settings.set("keymap_print_debug_stacks", keycode_to_keyname(key_dump));
|
2011-07-22 21:53:50 +02:00
|
|
|
clearKeyCache();
|
2011-06-01 19:44:07 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
void GUIKeyChangeMenu::init_keys()
|
|
|
|
{
|
|
|
|
key_forward = getKeySetting("keymap_forward");
|
|
|
|
key_backward = getKeySetting("keymap_backward");
|
|
|
|
key_left = getKeySetting("keymap_left");
|
|
|
|
key_right = getKeySetting("keymap_right");
|
|
|
|
key_jump = getKeySetting("keymap_jump");
|
|
|
|
key_sneak = getKeySetting("keymap_sneak");
|
|
|
|
key_inventory = getKeySetting("keymap_inventory");
|
|
|
|
key_chat = getKeySetting("keymap_chat");
|
|
|
|
key_range = getKeySetting("keymap_rangeselect");
|
|
|
|
key_fly = getKeySetting("keymap_freemove");
|
|
|
|
key_fast = getKeySetting("keymap_fastmove");
|
|
|
|
key_use = getKeySetting("keymap_special1");
|
|
|
|
key_dump = getKeySetting("keymap_print_debug_stacks");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GUIKeyChangeMenu::resetMenu()
|
|
|
|
{
|
|
|
|
if (activeKey >= 0)
|
|
|
|
{
|
|
|
|
switch (activeKey)
|
|
|
|
{
|
|
|
|
case GUI_ID_KEY_FORWARD_BUTTON:
|
|
|
|
this->forward->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_forward]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_BACKWARD_BUTTON:
|
|
|
|
this->backward->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_backward]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_LEFT_BUTTON:
|
2011-08-12 23:42:00 +02:00
|
|
|
this->left->setText(wgettext(KeyNamesLang[key_left]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_RIGHT_BUTTON:
|
2011-08-12 23:42:00 +02:00
|
|
|
this->right->setText(wgettext(KeyNamesLang[key_right]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_JUMP_BUTTON:
|
2011-08-12 23:42:00 +02:00
|
|
|
this->jump->setText(wgettext(KeyNamesLang[key_jump]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_SNEAK_BUTTON:
|
2011-08-12 23:42:00 +02:00
|
|
|
this->sneak->setText(wgettext(KeyNamesLang[key_sneak]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_INVENTORY_BUTTON:
|
|
|
|
this->inventory->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[key_inventory]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_CHAT_BUTTON:
|
2011-08-12 23:42:00 +02:00
|
|
|
this->chat->setText(wgettext(KeyNamesLang[key_chat]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_RANGE_BUTTON:
|
2011-08-12 23:42:00 +02:00
|
|
|
this->range->setText(wgettext(KeyNamesLang[key_range]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_FLY_BUTTON:
|
2011-08-12 23:42:00 +02:00
|
|
|
this->fly->setText(wgettext(KeyNamesLang[key_fly]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_FAST_BUTTON:
|
2011-08-12 23:42:00 +02:00
|
|
|
this->fast->setText(wgettext(KeyNamesLang[key_fast]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_USE_BUTTON:
|
2011-08-12 23:42:00 +02:00
|
|
|
this->use->setText(wgettext(KeyNamesLang[key_use]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_DUMP_BUTTON:
|
2011-08-12 23:42:00 +02:00
|
|
|
this->dump->setText(wgettext(KeyNamesLang[key_dump]));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
activeKey = -1;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
|
|
|
|
{
|
|
|
|
if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0
|
|
|
|
&& event.KeyInput.PressedDown)
|
|
|
|
{
|
2011-08-02 10:44:25 +02:00
|
|
|
changeCtype("");
|
2011-06-01 19:44:07 +02:00
|
|
|
if (activeKey == GUI_ID_KEY_FORWARD_BUTTON)
|
|
|
|
{
|
|
|
|
this->forward->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_forward = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_BACKWARD_BUTTON)
|
|
|
|
{
|
|
|
|
this->backward->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_backward = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_LEFT_BUTTON)
|
|
|
|
{
|
|
|
|
this->left->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_left = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_RIGHT_BUTTON)
|
|
|
|
{
|
|
|
|
this->right->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_right = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_JUMP_BUTTON)
|
|
|
|
{
|
|
|
|
this->jump->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_jump = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_SNEAK_BUTTON)
|
|
|
|
{
|
|
|
|
this->sneak->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_sneak = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_INVENTORY_BUTTON)
|
|
|
|
{
|
|
|
|
this->inventory->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_inventory = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_CHAT_BUTTON)
|
|
|
|
{
|
|
|
|
this->chat->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_chat = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_RANGE_BUTTON)
|
|
|
|
{
|
|
|
|
this->range->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_range = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_FLY_BUTTON)
|
|
|
|
{
|
|
|
|
this->fly->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_fly = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_FAST_BUTTON)
|
|
|
|
{
|
|
|
|
this->fast->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_fast = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_USE_BUTTON)
|
|
|
|
{
|
|
|
|
this->use->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_use = event.KeyInput.Key;
|
|
|
|
}
|
|
|
|
else if (activeKey == GUI_ID_KEY_DUMP_BUTTON)
|
|
|
|
{
|
|
|
|
this->dump->setText(
|
2011-08-12 23:42:00 +02:00
|
|
|
wgettext(KeyNamesLang[event.KeyInput.Key]));
|
2011-06-01 19:44:07 +02:00
|
|
|
this->key_dump = event.KeyInput.Key;
|
|
|
|
}
|
2011-08-02 10:44:25 +02:00
|
|
|
changeCtype("C");
|
2011-06-01 19:44:07 +02:00
|
|
|
activeKey = -1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (event.EventType == EET_GUI_EVENT)
|
|
|
|
{
|
|
|
|
if (event.GUIEvent.EventType == gui::EGET_ELEMENT_FOCUS_LOST
|
|
|
|
&& isVisible())
|
|
|
|
{
|
|
|
|
if (!canTakeFocus(event.GUIEvent.Element))
|
|
|
|
{
|
|
|
|
dstream << "GUIMainMenu: Not allowing focus change."
|
|
|
|
<< std::endl;
|
|
|
|
// Returning true disables focus change
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED)
|
|
|
|
{
|
2011-08-02 10:44:25 +02:00
|
|
|
if(event.GUIEvent.Caller->getID() != GUI_ID_BACK_BUTTON &&
|
|
|
|
event.GUIEvent.Caller->getID() != GUI_ID_ABORT_BUTTON)
|
|
|
|
{
|
|
|
|
changeCtype("");
|
|
|
|
}
|
|
|
|
|
2011-06-01 19:44:07 +02:00
|
|
|
switch (event.GUIEvent.Caller->getID())
|
|
|
|
{
|
|
|
|
case GUI_ID_BACK_BUTTON: //back
|
|
|
|
acceptInput();
|
|
|
|
quitMenu();
|
|
|
|
return true;
|
|
|
|
case GUI_ID_ABORT_BUTTON: //abort
|
|
|
|
quitMenu();
|
|
|
|
return true;
|
|
|
|
case GUI_ID_KEY_FORWARD_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->forward->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_BACKWARD_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->backward->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_LEFT_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->left->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_RIGHT_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->right->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_USE_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->use->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_FLY_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->fly->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_FAST_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->fast->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_JUMP_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->jump->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_CHAT_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->chat->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_SNEAK_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->sneak->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_INVENTORY_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->inventory->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_DUMP_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->dump->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
case GUI_ID_KEY_RANGE_BUTTON:
|
|
|
|
resetMenu();
|
|
|
|
activeKey = event.GUIEvent.Caller->getID();
|
2011-07-31 09:05:52 +02:00
|
|
|
this->range->setText(wgettext("press Key"));
|
2011-06-01 19:44:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
//Buttons
|
2011-08-02 10:44:25 +02:00
|
|
|
changeCtype("C");
|
2011-06-01 19:44:07 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Parent ? Parent->OnEvent(event) : false;
|
|
|
|
}
|
|
|
|
|