Skip to content

Commit

Permalink
add activation hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
blind-coder committed Aug 29, 2015
1 parent 900463b commit 9a81fc5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
20 changes: 20 additions & 0 deletions media/lua/client/ISUI/hotbar_inventorypage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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() -- {{{
Expand Down
11 changes: 11 additions & 0 deletions media/lua/client/hotbar_keybinds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
10 changes: 10 additions & 0 deletions media/lua/shared/Translate/DE/UI_DE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
10 changes: 10 additions & 0 deletions media/lua/shared/Translate/EN/UI_EN.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 9a81fc5

Please sign in to comment.