]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/guiKeyChangeMenu.cpp
Fix key change menu a bit
[dragonfireclient.git] / src / guiKeyChangeMenu.cpp
index 5968d5c12b156b4ea0efa69ef7ff6bc66ca4fc74..01f583a0175dc8d79976079d5c62679b41aa8fd2 100644 (file)
 #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"
 
 GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
                gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) :
@@ -196,6 +202,21 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
                                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);
@@ -226,6 +247,21 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
                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()));
+       }
+
 
        //next col
        offset = v2s32(250, 40);
@@ -325,19 +361,21 @@ void GUIKeyChangeMenu::drawMenu()
 
 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_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;
 }
@@ -349,8 +387,10 @@ void GUIKeyChangeMenu::init_keys()
        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_range = getKeySetting("keymap_rangeselect");
        key_fly = getKeySetting("keymap_freemove");
        key_fast = getKeySetting("keymap_fastmove");
@@ -384,6 +424,9 @@ bool GUIKeyChangeMenu::resetMenu()
                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()));
@@ -391,6 +434,9 @@ bool GUIKeyChangeMenu::resetMenu()
                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_RANGE_BUTTON:
                        this->range->setText(wgettext(key_range.name()));
                        break;
@@ -450,6 +496,11 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
                        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()));
@@ -460,6 +511,11 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
                        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_RANGE_BUTTON)
                {
                        this->range->setText(wgettext(kp.name()));
@@ -559,11 +615,21 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
                                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_SNEAK_BUTTON:
                                resetMenu();
                                activeKey = event.GUIEvent.Caller->getID();