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
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 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.
+ GNU Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License along
+ You should have received a copy of the GNU Lesser 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 "serialization.h"
#include "main.h"
#include <string>
+#include <IGUICheckBox.h>
+#include <IGUIEditBox.h>
+#include <IGUIButton.h>
+#include <IGUIStaticText.h>
+#include <IGUIFont.h>
+#include "settings.h"
+
+enum
+{
+ GUI_ID_BACK_BUTTON = 101, GUI_ID_ABORT_BUTTON, GUI_ID_SCROLL_BAR,
+ //buttons
+ GUI_ID_KEY_FORWARD_BUTTON,
+ GUI_ID_KEY_BACKWARD_BUTTON,
+ GUI_ID_KEY_LEFT_BUTTON,
+ GUI_ID_KEY_RIGHT_BUTTON,
+ GUI_ID_KEY_USE_BUTTON,
+ GUI_ID_KEY_FLY_BUTTON,
+ GUI_ID_KEY_FAST_BUTTON,
+ GUI_ID_KEY_JUMP_BUTTON,
+ GUI_ID_KEY_CHAT_BUTTON,
+ GUI_ID_KEY_CMD_BUTTON,
+ GUI_ID_KEY_CONSOLE_BUTTON,
+ GUI_ID_KEY_SNEAK_BUTTON,
+ GUI_ID_KEY_DROP_BUTTON,
+ GUI_ID_KEY_INVENTORY_BUTTON,
+ GUI_ID_KEY_DUMP_BUTTON,
+ GUI_ID_KEY_RANGE_BUTTON
+};
GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) :
v2s32 topleft(0, 0);
changeCtype("");
{
- core::rect < s32 > rect(0, 0, 125, 20);
+ core::rect < s32 > rect(0, 0, 600, 40);
rect += topleft + v2s32(25, 3);
//gui::IGUIStaticText *t =
- Environment->addStaticText(wgettext("KEYBINDINGS"),
+ Environment->addStaticText(wgettext("Keybindings. (If this menu screws up, remove stuff from minetest.conf)"),
rect, false, true, this, -1);
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
- v2s32 offset(25, 40);
+ v2s32 offset(25, 60);
// buttons
{
wgettext(key_jump.name()));
}
+ offset += v2s32(0, 25);
+ {
+ core::rect < s32 > rect(0, 0, 100, 20);
+ rect += topleft + v2s32(offset.X, offset.Y);
+ Environment->addStaticText(wgettext("Drop"), rect, false, true, this, -1);
+ //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->dropbtn = Environment->addButton(rect, this, GUI_ID_KEY_DROP_BUTTON,
+ wgettext(key_drop.name()));
+ }
+
offset += v2s32(0, 25);
{
core::rect < s32 > rect(0, 0, 100, 20);
this->chat = Environment->addButton(rect, this, GUI_ID_KEY_CHAT_BUTTON,
wgettext(key_chat.name()));
}
+ offset += v2s32(0, 25);
+ {
+ core::rect < s32 > rect(0, 0, 100, 20);
+ rect += topleft + v2s32(offset.X, offset.Y);
+ Environment->addStaticText(wgettext("Command"), rect, false, true, this, -1);
+ //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->cmd = Environment->addButton(rect, this, GUI_ID_KEY_CMD_BUTTON,
+ wgettext(key_cmd.name()));
+ }
+ offset += v2s32(0, 25);
+ {
+ core::rect < s32 > rect(0, 0, 100, 20);
+ rect += topleft + v2s32(offset.X, offset.Y);
+ Environment->addStaticText(wgettext("Console"), rect, false, true, this, -1);
+ //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->console = Environment->addButton(rect, this, GUI_ID_KEY_CONSOLE_BUTTON,
+ wgettext(key_console.name()));
+ }
//next col
- offset = v2s32(250, 40);
+ offset = v2s32(250, 60);
{
core::rect < s32 > rect(0, 0, 100, 20);
rect += topleft + v2s32(offset.X, offset.Y);
bool GUIKeyChangeMenu::acceptInput()
{
- g_settings.set("keymap_forward", key_forward.sym());
- g_settings.set("keymap_backward", key_backward.sym());
- g_settings.set("keymap_left", key_left.sym());
- g_settings.set("keymap_right", key_right.sym());
- g_settings.set("keymap_jump", key_jump.sym());
- g_settings.set("keymap_sneak", key_sneak.sym());
- g_settings.set("keymap_inventory", key_inventory.sym());
- g_settings.set("keymap_chat", key_chat.sym());
- g_settings.set("keymap_rangeselect", key_range.sym());
- g_settings.set("keymap_freemove", key_fly.sym());
- g_settings.set("keymap_fastmove", key_fast.sym());
- g_settings.set("keymap_special1", key_use.sym());
- g_settings.set("keymap_print_debug_stacks", key_dump.sym());
+ g_settings->set("keymap_forward", key_forward.sym());
+ g_settings->set("keymap_backward", key_backward.sym());
+ g_settings->set("keymap_left", key_left.sym());
+ g_settings->set("keymap_right", key_right.sym());
+ g_settings->set("keymap_jump", key_jump.sym());
+ g_settings->set("keymap_sneak", key_sneak.sym());
+ g_settings->set("keymap_drop", key_drop.sym());
+ g_settings->set("keymap_inventory", key_inventory.sym());
+ g_settings->set("keymap_chat", key_chat.sym());
+ g_settings->set("keymap_cmd", key_cmd.sym());
+ g_settings->set("keymap_console", key_console.sym());
+ g_settings->set("keymap_rangeselect", key_range.sym());
+ g_settings->set("keymap_freemove", key_fly.sym());
+ g_settings->set("keymap_fastmove", key_fast.sym());
+ g_settings->set("keymap_special1", key_use.sym());
+ g_settings->set("keymap_print_debug_stacks", key_dump.sym());
clearKeyCache();
return true;
}
key_right = getKeySetting("keymap_right");
key_jump = getKeySetting("keymap_jump");
key_sneak = getKeySetting("keymap_sneak");
+ key_drop = getKeySetting("keymap_drop");
key_inventory = getKeySetting("keymap_inventory");
key_chat = getKeySetting("keymap_chat");
+ key_cmd = getKeySetting("keymap_cmd");
+ key_console = getKeySetting("keymap_console");
key_range = getKeySetting("keymap_rangeselect");
key_fly = getKeySetting("keymap_freemove");
key_fast = getKeySetting("keymap_fastmove");
case GUI_ID_KEY_SNEAK_BUTTON:
this->sneak->setText(wgettext(key_sneak.name()));
break;
+ case GUI_ID_KEY_DROP_BUTTON:
+ this->dropbtn->setText(wgettext(key_drop.name()));
+ break;
case GUI_ID_KEY_INVENTORY_BUTTON:
this->inventory->setText(
wgettext(key_inventory.name()));
case GUI_ID_KEY_CHAT_BUTTON:
this->chat->setText(wgettext(key_chat.name()));
break;
+ case GUI_ID_KEY_CMD_BUTTON:
+ this->cmd->setText(wgettext(key_cmd.name()));
+ break;
+ case GUI_ID_KEY_CONSOLE_BUTTON:
+ this->console->setText(wgettext(key_console.name()));
+ break;
case GUI_ID_KEY_RANGE_BUTTON:
this->range->setText(wgettext(key_range.name()));
break;
this->sneak->setText(wgettext(kp.name()));
this->key_sneak = kp;
}
+ else if (activeKey == GUI_ID_KEY_DROP_BUTTON)
+ {
+ this->dropbtn->setText(wgettext(kp.name()));
+ this->key_drop = kp;
+ }
else if (activeKey == GUI_ID_KEY_INVENTORY_BUTTON)
{
this->inventory->setText(wgettext(kp.name()));
this->chat->setText(wgettext(kp.name()));
this->key_chat = kp;
}
+ else if (activeKey == GUI_ID_KEY_CMD_BUTTON)
+ {
+ this->cmd->setText(wgettext(kp.name()));
+ this->key_cmd = kp;
+ }
+ else if (activeKey == GUI_ID_KEY_CONSOLE_BUTTON)
+ {
+ this->console->setText(wgettext(kp.name()));
+ this->key_console = kp;
+ }
else if (activeKey == GUI_ID_KEY_RANGE_BUTTON)
{
this->range->setText(wgettext(kp.name()));
activeKey = event.GUIEvent.Caller->getID();
this->jump->setText(wgettext("press Key"));
break;
+ case GUI_ID_KEY_DROP_BUTTON:
+ resetMenu();
+ activeKey = event.GUIEvent.Caller->getID();
+ this->dropbtn->setText(wgettext("press Key"));
+ break;
case GUI_ID_KEY_CHAT_BUTTON:
resetMenu();
activeKey = event.GUIEvent.Caller->getID();
this->chat->setText(wgettext("press Key"));
break;
+ case GUI_ID_KEY_CMD_BUTTON:
+ resetMenu();
+ activeKey = event.GUIEvent.Caller->getID();
+ this->cmd->setText(wgettext("press Key"));
+ break;
+ case GUI_ID_KEY_CONSOLE_BUTTON:
+ resetMenu();
+ activeKey = event.GUIEvent.Caller->getID();
+ this->console->setText(wgettext("press Key"));
+ break;
case GUI_ID_KEY_SNEAK_BUTTON:
resetMenu();
activeKey = event.GUIEvent.Caller->getID();