Skip to content

Commit

Permalink
Removed Ferry and Haven from Integral Menu. Increased the number of b…
Browse files Browse the repository at this point in the history
…uttons on the minimap.
  • Loading branch information
GoogleFrog committed Jun 8, 2016
1 parent 7e6bff7 commit 14fef45
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
1 change: 1 addition & 0 deletions LuaRules/Configs/customcmds.h.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
-- if you add a command, please order it by ID!

--CMD_RETREAT = 10000
CMD_SET_FERRY = 11000
CMD_RETREAT_ZONE = 10001
CMD_SETHAVEN = CMD_RETREAT_ZONE
CMD_RESETFIRE = 10003
Expand Down
9 changes: 8 additions & 1 deletion LuaUI/Configs/integral_menu_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ local overrides = {
[CMD_UNIT_FLOAT_STATE] = { texture = {imageDir .. 'states/amph_sink.png', imageDir .. 'states/amph_attack.png', imageDir .. 'states/amph_float.png'}, text='', tooltip=tooltips.floatState},
}

-- Commands that only exist in LuaUI cannot have a hidden param. Therefore those that should be hidden are placed in this table.
local widgetSpaceHidden = {
[60] = true, -- CMD.PAGES
[CMD_SETHAVEN] = true,
[CMD_SET_FERRY] = true,
}

-- This is the list of name ("action name") related to unit command. This name won't work using command line (eg: /fight, won't activate FIGHT command) but it can be binded to a key (eg: /bind f fight, will activate FIGHT when f is pressed)
-- In reverse, one can use Spring.GetActionHotkey(name) to get the key binded to this name.
-- This table is used in Keyboardmenu, Integral menu, and Epicmenu for hotkey management.
Expand Down Expand Up @@ -353,4 +360,4 @@ local custom_cmd_actions = {
}


return common_commands, states_commands, factory_commands, econ_commands, defense_commands, special_commands, globalCommands, overrides, custom_cmd_actions
return common_commands, states_commands, factory_commands, econ_commands, defense_commands, special_commands, globalCommands, overrides, custom_cmd_actions, widgetSpaceHidden
2 changes: 1 addition & 1 deletion LuaUI/Widgets/cmd_ferry_points.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local UNLOAD_RADIUS = 160
local CANT_BE_TRANSPORTED_DECAY_TIME = 200
local COMMAND_MOVE_RADIUS = 80

local CMD_SET_FERRY = 11000
VFS.Include("LuaRules/Configs/customcmds.h.lua")
local CMD_MOVE = CMD.MOVE
local CMD_FIGHT = CMD.FIGHT
local CMD_SET_WANTED_MAX_SPEED = CMD.SET_WANTED_MAX_SPEED
Expand Down
6 changes: 2 additions & 4 deletions LuaUI/Widgets/gui_chili_integral_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ local spGetSpectatingState = Spring.GetSpectatingState

local push = table.insert

local CMD_PAGES = 60

local common_commands, states_commands, factory_commands, econ_commands, defense_commands, special_commands, globalCommands, overrides, custom_cmd_actions = include("Configs/integral_menu_commands.lua")
local common_commands, states_commands, factory_commands, econ_commands, defense_commands, special_commands, globalCommands, overrides, custom_cmd_actions, widgetSpaceHidden = include("Configs/integral_menu_commands.lua")

local function CapCase(str)
local str = str:lower()
Expand Down Expand Up @@ -646,7 +644,7 @@ end

--sorts commands into categories
local function ProcessCommand(cmd)
if not cmd.hidden and cmd.id ~= CMD_PAGES then
if not cmd.hidden and not widgetSpaceHidden[cmd.id] then
-- state icons
if (cmd.type == CMDTYPE.ICON_MODE and cmd.params ~= nil and #cmd.params > 1) then
n_states[#n_states+1] = cmd
Expand Down
28 changes: 23 additions & 5 deletions LuaUI/Widgets/gui_chili_minimap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function widget:GetInfo()
}
end

VFS.Include("LuaRules/Configs/customcmds.h.lua")

--// gl const

Expand Down Expand Up @@ -215,7 +216,7 @@ options = {
WG.ToggleShoweco()
end
end,
},
},

lable_initialView = { type = 'label', name = 'Initial Map Overlay', },

Expand Down Expand Up @@ -566,7 +567,7 @@ end

local function MakeMinimapButton(file, params)
local option = params.option
local name, desc, action, hotkey
local name, desc, action, hotkey, command
if option then
name = options[option].name
desc = options[option].desc and (' (' .. options[option].desc .. ')') or ''
Expand All @@ -576,6 +577,7 @@ local function MakeMinimapButton(file, params)
desc = desc or params.desc or ""
action = action or params.action
hotkey = WG.crude.GetHotkey(action)
command = params.command

if hotkey ~= '' then
hotkey = ' (\255\0\255\0' .. hotkey:upper() .. '\008)'
Expand All @@ -594,7 +596,15 @@ local function MakeMinimapButton(file, params)
WG.crude.ShowMenu() --make epic Chili menu appear.
return true
end
Spring.SendCommands( action )
Spring.Echo(command)
if command then
local left, right = true, false
local alt, ctrl, meta, shift = Spring.GetModKeyState()
local index = Spring.GetCmdDescIndex(command)
Spring.SetActiveCommand(index, 1, left, right, alt, ctrl, meta, shift)
else
Spring.SendCommands(action)
end
end },
children={
file and
Expand Down Expand Up @@ -636,11 +646,11 @@ MakeMinimapWindow = function()
local map_panel_right = 0

local buttons_height = iconsize+3
local buttons_width = iconsize*10
local buttons_width = iconsize*13
if options.buttonsOnRight.value then
map_panel_bottom = 0
map_panel_right = iconsize*1.3
buttons_height = iconsize*10
buttons_height = iconsize*13
buttons_width = iconsize+3
end

Expand Down Expand Up @@ -703,8 +713,16 @@ MakeMinimapWindow = function()

Chili.Label:New{ width=iconsize/2, height=iconsize/2, caption='', autosize = false,},

MakeMinimapButton( 'LuaUI/images/commands/Bold/retreat.png', {name = "Place Retreat Zone", action = 'sethaven', command = CMD_RETREAT_ZONE, desc = " (Shift to place multiple zones, overlap to remove)"}),
MakeMinimapButton( 'LuaUI/images/commands/Bold/ferry.png', {name = "Place Ferry Route", action = 'setferry', command = CMD_SET_FERRY, desc = " (Shift to queue and edit waypoints, overlap the start to remove)"}),

Chili.Label:New{ width=iconsize/2, height=iconsize/2, caption='', autosize = false,},

MakeMinimapButton( 'LuaUI/images/drawingcursors/eraser.png', {option = 'clearmapmarks'} ),
MakeMinimapButton( 'LuaUI/images/Crystal_Clear_action_flag.png', {option = 'lastmsgpos'} ),

Chili.Label:New{ width=iconsize/2, height=iconsize/2, caption='', autosize = false,},

},
}

Expand Down

0 comments on commit 14fef45

Please sign in to comment.