From 9a81fc5810edda2e2ec7c1f0a5f73bb40316542e Mon Sep 17 00:00:00 2001 From: Benjamin 'blindCoder' Schieder Date: Sat, 29 Aug 2015 13:52:31 +0200 Subject: [PATCH] add activation hotkeys --- .../lua/client/ISUI/hotbar_inventorypage.lua | 20 +++++++++++++++++++ media/lua/client/hotbar_keybinds.lua | 11 ++++++++++ media/lua/shared/Translate/DE/UI_DE.txt | 10 ++++++++++ media/lua/shared/Translate/EN/UI_EN.txt | 10 ++++++++++ 4 files changed, 51 insertions(+) diff --git a/media/lua/client/ISUI/hotbar_inventorypage.lua b/media/lua/client/ISUI/hotbar_inventorypage.lua index 02fc31c..e191861 100755 --- a/media/lua/client/ISUI/hotbar_inventorypage.lua +++ b/media/lua/client/ISUI/hotbar_inventorypage.lua @@ -194,6 +194,20 @@ function HotBarISInventoryPage:onMouseUp(x, y) -- {{{ end end -- }}} +function HotBar.ActivateSlot(i) + if HotBar.inventoryPage.items[i] ~= nil then + local item = getPlayer():getInventory():FindAndReturn(HotBar.inventoryPage.items[i].item); + if not item then return end; + local primary = true; + local twohanded = false; + if instanceof(item, "HandWeapon") then + twohanded = item:isTwoHandWeapon() + else + primary = false; + end + ISTimedActionQueue.add(ISEquipWeaponAction:new(getPlayer(), item, 50, primary, twohanded)); + end +end function HotBarISInventoryPage:prerender() -- {{{ self:drawRect(0, 0, self:getWidth(), self:getHeight(), self.backgroundColor.a, self.backgroundColor.r, self.backgroundColor.g, self.backgroundColor.b); @@ -262,6 +276,12 @@ HotBarISInventoryPage.onKeyPressed = function(key) -- {{{ if key == getCore():getKey("Toggle_Hotbar") and getSpecificPlayer(0) and getGameSpeed() > 0 then HotBar.Toggle(); end + + for i=0,9 do + if key == getCore():getKey("Slot"..i) and getSpecificPlayer(0) and getGameSpeed() > 0 then + HotBar.ActivateSlot(i); + end + end end -- }}} HotBar.Toggle = function() -- {{{ diff --git a/media/lua/client/hotbar_keybinds.lua b/media/lua/client/hotbar_keybinds.lua index eac2a1a..26ff9f5 100644 --- a/media/lua/client/hotbar_keybinds.lua +++ b/media/lua/client/hotbar_keybinds.lua @@ -15,6 +15,17 @@ end table.insert(keyBinding, {value="[Hotbar]"}) -- adds a section header to keys.ini and the options screen addBind("Toggle_Hotbar", 15) -- Tab +addBind("Slot0", 0) +addBind("Slot1", 0) +addBind("Slot2", 0) +addBind("Slot3", 0) +addBind("Slot4", 0) +addBind("Slot5", 0) +addBind("Slot6", 0) +addBind("Slot7", 0) +addBind("Slot8", 0) +addBind("Slot9", 0) + function HotBarKeyBinds.SizeChanged(_, box) if box.options[box.selected] ~= nil then local choices = { 100, 75, 50 }; diff --git a/media/lua/shared/Translate/DE/UI_DE.txt b/media/lua/shared/Translate/DE/UI_DE.txt index 311850d..9bf72fd 100644 --- a/media/lua/shared/Translate/DE/UI_DE.txt +++ b/media/lua/shared/Translate/DE/UI_DE.txt @@ -6,5 +6,15 @@ UI_DE = { UI_optionscreen_binding_Toggle_Hotbar = "Sichtbarkeit umschalten", UI_optionscreen_hotbar_change_size = "Groesse der Leiste", UI_optionscreen_hotbar_num_slots = "Anzahl Slots", + UI_optionscreen_binding_Slot0 = "Slot 1", + UI_optionscreen_binding_Slot1 = "Slot 2", + UI_optionscreen_binding_Slot2 = "Slot 3", + UI_optionscreen_binding_Slot3 = "Slot 4", + UI_optionscreen_binding_Slot4 = "Slot 5", + UI_optionscreen_binding_Slot5 = "Slot 6", + UI_optionscreen_binding_Slot6 = "Slot 7", + UI_optionscreen_binding_Slot7 = "Slot 8", + UI_optionscreen_binding_Slot8 = "Slot 9", + UI_optionscreen_binding_Slot9 = "Slot 10", UI_Clear = "Entfernen" } diff --git a/media/lua/shared/Translate/EN/UI_EN.txt b/media/lua/shared/Translate/EN/UI_EN.txt index 8e0813e..b5bfe78 100644 --- a/media/lua/shared/Translate/EN/UI_EN.txt +++ b/media/lua/shared/Translate/EN/UI_EN.txt @@ -6,5 +6,15 @@ UI_EN = { UI_optionscreen_binding_Toggle_Hotbar = "Toggle hotbar", UI_optionscreen_hotbar_change_size = "Size of Hotbar", UI_optionscreen_hotbar_num_slots = "Num slots", + UI_optionscreen_binding_Slot0 = "Slot 1", + UI_optionscreen_binding_Slot1 = "Slot 2", + UI_optionscreen_binding_Slot2 = "Slot 3", + UI_optionscreen_binding_Slot3 = "Slot 4", + UI_optionscreen_binding_Slot4 = "Slot 5", + UI_optionscreen_binding_Slot5 = "Slot 6", + UI_optionscreen_binding_Slot6 = "Slot 7", + UI_optionscreen_binding_Slot7 = "Slot 8", + UI_optionscreen_binding_Slot8 = "Slot 9", + UI_optionscreen_binding_Slot9 = "Slot 10", UI_Clear = "Clear" }