Skip to content

Commit

Permalink
implement option to hide context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
blind-coder committed Feb 14, 2016
1 parent 609d775 commit b8d7de6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions media/lua/client/ISUI/hotbar_inventorypage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ HotBar.loadConfig = function()--{{{
HotBar.config.main.numSlots = 10;
HotBar.config.main.size = 75;
HotBar.config.main.smart = "traditional";
HotBar.config.main.showContext = "yes";
HotBar.config.items = {};

local ini = bcUtils.readINI("hotbar.ini");
if not bcUtils.tableIsEmpty(ini) then
if not ini.main then ini.main = {} end
if not ini.items then ini.items = {} end -- safeguard
HotBar.config.main.smart = ini.main.smart or "traditional";
HotBar.config.main.showContext = ini.main.showContext or "yes";
HotBar.config.main.numSlots = tonumber(ini.main.numSlots) or 10;
HotBar.config.main.size = tonumber(ini.main.size) or 75;
for k,v in pairs(ini.items) do
Expand Down Expand Up @@ -368,6 +370,7 @@ end
-- }}}

HotBar.FillContextMenu = function(player, context, items) -- {{{
if HotBar.config.main.showContext == "no" then return end
if #items > 1 then return end; -- we only create an entry for the first object
if HotBar.inventoryPage == nil then -- safeguard
HotBarISInventoryPage.onKeyPressed(getCore():getKey("Toggle Inventory"));
Expand Down
15 changes: 15 additions & 0 deletions media/lua/client/hotbar_keybinds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ function HotBarKeyBinds.SmartChanged(_, box)
end
end

function HotBarKeyBinds.ContextChanged(_, box)
if box.options[box.selected] ~= nil then
local choices = { "yes", "no" }
HotBar.config.main.showContext = choices[box.selected];
HotBar.saveConfig();
end
end

HotBarKeyBinds.MainOptionsCreate = MainOptions.create;
MainOptions.create = function(self)
HotBarKeyBinds.MainOptionsCreate(self);
Expand Down Expand Up @@ -112,5 +120,12 @@ MainOptions.create = function(self)
selected = 1;
end
box = self:addCombo(x, y, w, h, getText("UI_optionscreen_hotbar_smartaction"), { getText("UI_optionscreen_traditional"), getText("UI_optionscreen_smart") }, selected, self, HotBarKeyBinds.SmartChanged);

if HotBar.config.main.showContext == "yes" then
selected = 1;
else
selected = 2;
end
box = self:addCombo(x, y, w, h, getText("UI_optionscreen_show_contextmenu"), { getText("UI_optionscreen_show_contextmenu_yes"), getText("UI_optionscreen_show_contextmenu_no") }, selected, self, HotBarKeyBinds.ContextChanged);
end

3 changes: 3 additions & 0 deletions media/lua/shared/Translate/DE/UI_DE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@ UI_DE = {
UI_optionscreen_binding_Slot28 = "Slot 28",
UI_optionscreen_binding_Slot29 = "Slot 29",
UI_optionscreen_binding_Slot30 = "Slot 30",
UI_optionscreen_show_contextmenu = "Hotbar im Kontextmenue anzeigen:",
UI_optionscreen_show_contextmenu_yes = "Ja",
UI_optionscreen_show_contextmenu_no = "Nein (nur Drag'n'Drop!)",
UI_Clear = "Entfernen"
}
3 changes: 3 additions & 0 deletions media/lua/shared/Translate/EN/UI_EN.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@ UI_EN = {
UI_optionscreen_binding_Slot28 = "Slot 28",
UI_optionscreen_binding_Slot29 = "Slot 29",
UI_optionscreen_binding_Slot30 = "Slot 30",
UI_optionscreen_show_contextmenu = "Show Hotbar in contextmenu:",
UI_optionscreen_show_contextmenu_yes = "Yes",
UI_optionscreen_show_contextmenu_no = "No (Drag'n'Drop only!)",
UI_Clear = "Clear"
}

0 comments on commit b8d7de6

Please sign in to comment.