I'm trying to get better with the map menu in my "more hotkeys" series. The goal is, as always, to manage as many inputs as possible completely without using the mouse, a bit like in the "old" X3...
This already works quite well, but I have questions about a few small things - especially as I'm not really a programmer and learn everything myself...
1. i can open the menu with a mixture of XML and LUA and directly select left menu items. This works reliably, even if the menu is already open. But is there a way to pass an object (ship or factory etc.) to the menu, which is then also selected in the menu? So that, for example, the ship also appears in the RIGHT menu, e.g. with info or crew (I know how to open the right menu or select a tab).
Here is my XML and Lua code for your perusal:
Code: Select all
<cue name="Mhk_ObjectListOpen" instantiate="true" namespace="this">
<conditions>
<event_cue_signalled/>
</conditions>
<actions>
<set_value name="$isShowZone" exact="true" />
<set_value name="$focusComponent" exact="player.ship" />
<set_value name="$history" exact="null" />
<set_value name="$mode" exact="'infomode'" />
<set_value name="$modeParam" exact="['objectlist']" />
<open_menu menu="MapMenu" param="[0, 0, $isShowZone, $focusComponent, $history, $mode, $modeParam]" />"
<raise_lua_event name="'MoreHotkeys.openObjectListWithHotkey'" param="event.param.$event"/>
</actions>
</cue>
<cue name="Mhk_PropertyOwnedOpen" instantiate="true" namespace="this">
<conditions>
<event_cue_signalled/>
</conditions>
<actions>
<set_value name="$isShowZone" exact="true" />
<set_value name="$focusComponent" exact="player.ship" />
<set_value name="$history" exact="null" />
<set_value name="$mode" exact="'infomode'" />
<set_value name="$modeParam" exact="['propertyowned']" />
<open_menu menu="MapMenu" param="[0, 0, $isShowZone, $focusComponent, $history, $mode, $modeParam]" />"
<raise_lua_event name="'MoreHotkeys.openPropertyOwnedWithHotkey'" param="event.param.$event"/>
</actions>
</cue>
...
Code: Select all
-- ffi setup
local ffi = require("ffi")
local C = ffi.C
-- local Lib = require("extensions.sn_mod_support_apis.lua_library")
local Lib = require("extensions.sn_mod_support_apis.lua_interface").Library
local mapMenu = {}
local mhk_menu = {}
local selectedcomponent = nil
local panelsToggle = {
left = true,
right = true,
infoMod = nil,
searchMode = nil,
}
local function init()
DebugError("More Hotkeys MAM Init")
mapMenu = Lib.Get_Egosoft_Menu("MapMenu")
RegisterEvent("MoreHotkeys.openObjectListWithHotkey", mhk_menu.openObjectListWithHotkey)
RegisterEvent("MoreHotkeys.openPropertyOwnedWithHotkey", mhk_menu.openPropertyOwnedWithHotkey)
RegisterEvent("MoreHotkeys.openMissionOffersWithHotkey", mhk_menu.openMissionOffersWithHotkey)
RegisterEvent("MoreHotkeys.openMissionManagerWithHotkey", mhk_menu.openMissionManagerWithHotkey)
RegisterEvent("MoreHotkeys.openInfoWithHotkey", mhk_menu.openInfoWithHotkey)
RegisterEvent("MoreHotkeys.toggleTradeLayerWithHotkey", mhk_menu.toggleTradeLayerWithHotkey)
RegisterEvent("MoreHotkeys.toggleMiningLayerWithHotkey", mhk_menu.toggleMiningLayerWithHotkey)
RegisterEvent("MoreHotkeys.toggleOtherLayerWithHotkey", mhk_menu.toggleOtherLayerWithHotkey)
RegisterEvent("MoreHotkeys.toggleMenuRightWithHotkey", mhk_menu.toggleMenuRightWithHotkey)
RegisterEvent("MoreHotkeys.rightInfoWithHotkey", mhk_menu.rightInfoWithHotkey)
RegisterEvent("MoreHotkeys.rightCrewWithHotkey", mhk_menu.rightCrewWithHotkey)
RegisterEvent("MoreHotkeys.rightLoadoutWithHotkey", mhk_menu.rightLoadoutWithHotkey)
RegisterEvent("MoreHotkeys.rightLogbookWithHotkey", mhk_menu.rightLogbookWithHotkey)
RegisterEvent("MoreHotkeys.rightOrderWithHotkey", mhk_menu.rightOrderWithHotkey)
RegisterEvent("MoreHotkeys.rightOrderAdvWithHotkey", mhk_menu.rightOrderAdvWithHotkey)
RegisterEvent("MoreHotkeys.rightStandingOrdersWithHotkey", mhk_menu.rightStandingOrdersWithHotkey)
RegisterEvent("MoreHotkeys.closeMapWithHotkey", mhk_menu.closeMapWithHotkey)
end
function mhk_menu.openObjectListWithHotkey(_, event)
if event == "onPress" then
mapMenu.infoTableMode = "objectlist"
-- mapMenu.highlightLeftBar = "objectlist"
mapMenu.refreshMainFrame = true
-- mapMenu.refreshInfoFrame ()
-- mapMenu.updateMapAndInfoFrame ()
mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
-- Helper.closeMenuAndOpenNewMenu("MapMenu", "MapMenu", { 0, 0 }, nil)
-- OpenMenu("MapMenu", { 0, 0 }, nil)
end
end
function mhk_menu.openPropertyOwnedWithHotkey(_, event)
if event == "onPress" then
mapMenu.infoTableMode = "propertyowned"
mapMenu.refreshMainFrame = true
-- mapMenu.updateMapAndInfoFrame ()
mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.openMissionOffersWithHotkey(_, event)
if event == "onPress" then
mapMenu.infoTableMode = "missionoffer"
mapMenu.refreshMainFrame = true
-- mapMenu.updateMapAndInfoFrame ()
mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.openMissionManagerWithHotkey(_, event)
if event == "onPress" then
mapMenu.infoTableMode = "mission"
mapMenu.missionMode = "plot"
mapMenu.refreshMainFrame = true
-- mapMenu.updateMapAndInfoFrame ()
mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.openInfoWithHotkey(_, event)
if event == "onPress" then
mapMenu.infoTableMode = "info"
mapMenu.refreshMainFrame = true
-- mapMenu.updateMapAndInfoFrame ()
mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.toggleTradeLayerWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
mapMenu.buttonSetFilterLayer("layer_trade", 0, 0)
end
end
function mhk_menu.toggleMiningLayerWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
mapMenu.buttonSetFilterLayer("layer_mining", 0, 0)
end
end
function mhk_menu.toggleOtherLayerWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
mapMenu.buttonSetFilterLayer("layer_other", 0, 0)
end
end
function mhk_menu.toggleMenuRightWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
mapMenu.buttonToggleRightBar("info", false)
end
end
function mhk_menu.rightInfoWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
if (not mapMenu.searchTableMode) then
mapMenu.buttonToggleRightBar("info", false)
end
mapMenu.infoMode.right = "objectinfo"
mapMenu.refreshMainFrame = true
-- mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.rightCrewWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
if (not mapMenu.searchTableMode) then
mapMenu.buttonToggleRightBar("info", false)
end
mapMenu.infoMode.right = "objectcrew"
mapMenu.refreshMainFrame = true
-- mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.rightLoadoutWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
if (not mapMenu.searchTableMode) then
mapMenu.buttonToggleRightBar("info", false)
end
mapMenu.infoMode.right = "objectloadout"
mapMenu.refreshMainFrame = true
-- mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.rightLogbookWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
if (not mapMenu.searchTableMode) then
mapMenu.buttonToggleRightBar("info", false)
end
mapMenu.infoMode.right = "objectlogbook"
mapMenu.refreshMainFrame = true
-- mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.rightOrderWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
if (not mapMenu.searchTableMode) then
mapMenu.buttonToggleRightBar("info", false)
end
mapMenu.infoMode.right = "orderqueue"
mapMenu.refreshMainFrame = true
-- mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.rightOrderAdvWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
if (not mapMenu.searchTableMode) then
mapMenu.buttonToggleRightBar("info", false)
end
mapMenu.infoMode.right = "orderqueue_advanced"
mapMenu.refreshMainFrame = true
-- mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.rightStandingOrdersWithHotkey(_, event)
if event == "onPress" and mapMenu.map then
if (not mapMenu.searchTableMode) then
mapMenu.buttonToggleRightBar("info", false)
end
mapMenu.infoMode.right = "standingorders"
mapMenu.refreshMainFrame = true
-- mapMenu.refreshInfoFrame()
mapMenu.refreshInfoFrame2()
end
end
function mhk_menu.closeMapWithHotkey(_, event)
if event == "onPress" then
mapMenu.onCloseElement ("close")
Helper.closeMenu ("MapMenu", "close")
mapMenu.cleanup ()
end
end
-- ------------------------------------------------------------------------------------------------
init()
Does anyone know anything about this? Of course I have more work to do, but one thing at a time...
Greetings
Trajan von Olb