Open map menu: Select object in menu (ship, factory etc.) / in map menu: Set input focus?

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Open map menu: Select object in menu (ship, factory etc.) / in map menu: Set input focus?

Post by Trajan von Olb » Tue, 6. Sep 22, 13:15

Hi,

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:
Spoiler
Show

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>
...
Spoiler
Show

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()
I would like to reliably set the focus (i.e. where you can move to in the menu using the arrow keys) to a specific place in the left or right menu. So that, for example, I press a key, the left menu opens in object mode, an object (passed to Lua, see 1.) is selected there, but I am specifically in the right menu with the individual crew members for arrow key selection, in order to immediately give commands to individual crew members with arrow keys. It must have something to do with the focus, but I don't yet understand how to do this in LUA...

Does anyone know anything about this? Of course I have more work to do, but one thing at a time...

Greetings

Trajan von Olb
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

User avatar
Dj_FRedy
Posts: 230
Joined: Mon, 27. Jun 11, 05:58
x4

Re: Open map menu: Select object in menu (ship, factory etc.) / in map menu: Set input focus?

Post by Dj_FRedy » Tue, 6. Sep 22, 22:17

Using 'raise_lua_event' , in the 'param' attribute, you can pass more than one value and then retrieve them in the lua menu:

Code: Select all

param="event.param.$event + ':' + player.ship"
To retrieve the values in lua:
If the component, ship, station, etc, is passed as hexadecimal you can convert it to integer with 'tonumber()' or if you need it to be a string 'tostring(tonumber())'.

Code: Select all

local event, component = string.match(param, "(.+):(.+)")
local convertedcomponent = tonumber(component)
To select the component in the 'objectlist/propertyowned' menu modes use the 'addSelectedComponent' menu function and for the left and right 'info' menus set the component in the 'infoSubmenuObject' variable. Refresh both left and right menus with the function 'refreshInfoFrame'.

Code: Select all

mapMenu.addSelectedComponent(convertedcomponent, true, true)

mapMenu.infoSubmenuObject = convertedcomponent
mapMenu.refreshInfoFrame()
Code the rest according to your requirements.
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: Open map menu: Select object in menu (ship, factory etc.) / in map menu: Set input focus?

Post by Trajan von Olb » Wed, 7. Sep 22, 10:13

Hi, thanks for the help. But unfortunately it does not work.
If I (only) change the XML, for testing only the one call (I have different ones), then this one call does not work anymore, but the others do.
If I set the variable in the start block of the Lua script as written by you (2 lines), then the entire Lua script no longer works, nor do other calls. Which shows me that apparently the passing of the variable doesn't work and "event" is corrupted, am I inferring that correctly?
If I insert the variable directly into the function to test it (no idea if this works in Lua), then ONLY this one call no longer works...
I could not check AddSelectedComponent at all, because the whole script no longer works.
Any idea?

Here is my modified, obviously faulty Lua script (besides the variable block, I have so far ONLY changed the second function, "mhk_menu.openPropertyOwnedWithHotkey(_, event)", please have a look there).
Spoiler
Show

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 event, component = string.match(param, "(.+):(.+)")
local convertedcomponent = tonumber(component)

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.addSelectedComponent(convertedcomponent, true, true)
		mapMenu.infoSubmenuObject = convertedcomponent
		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()
Thanks in advance...

Trajan
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

User avatar
Dj_FRedy
Posts: 230
Joined: Mon, 27. Jun 11, 05:58
x4

Re: Open map menu: Select object in menu (ship, factory etc.) / in map menu: Set input focus?

Post by Dj_FRedy » Wed, 7. Sep 22, 11:27

When I talk about passing more than one value I mean in each 'RegisterEvent()' where you see it necessary. I'll give you an example implementation:

Code: Select all

function mhk_menu.openPropertyOwnedWithHotkey(_, param)
    -- param="event.param.$event + ':' + $focusComponent"
    local event, component = string.match(param, "(.+):(.+)")
    local convertedcomponent = tonumber(component)

    if (event == "onPress") then
        mapMenu.infoTableMode = "propertyowned"

        mapMenu.addSelectedComponent(convertedcomponent, true, true)
        mapMenu.infoSubmenuObject = convertedcomponent
        mapMenu.refreshInfoFrame()
    end
end
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: Open map menu: Select object in menu (ship, factory etc.) / in map menu: Set input focus?

Post by Trajan von Olb » Wed, 7. Sep 22, 13:35

Many, many thanks! It works and has helped a lot - also for my understanding of the matter...

Trajan
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: Open map menu: Select object in menu (ship, factory etc.) / in map menu: Set input focus?

Post by Trajan von Olb » Wed, 7. Sep 22, 21:50

Oh, I forgot. Do you happen to know which command (and how) I use to set the input focus on something in the right menu? That is, the place where a menu for a crew member, for example, appears with an emulated right-click (keyboard)? (see in my 1st post, there should be a "2nd" after the code, I just forgot the number :-) )

Thanks again in advance.

Trajan
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

User avatar
Dj_FRedy
Posts: 230
Joined: Mon, 27. Jun 11, 05:58
x4

Re: Open map menu: Select object in menu (ship, factory etc.) / in map menu: Set input focus?

Post by Dj_FRedy » Thu, 8. Sep 22, 14:04

You can move between menus on the map, if they are already active, with the 'Tab' key. To open the context menu with the keyboard the default key combination 'Control Left or Right + Enter' or 'Alt Right + Enter' should work, if that's what you mean.
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: Open map menu: Select object in menu (ship, factory etc.) / in map menu: Set input focus?

Post by Trajan von Olb » Fri, 9. Sep 22, 00:16

Thank you very much, but no, that's not what I meant.
I am looking for a way to set the "cursor" specifically to a position in the right-hand menu via LUA.
A concrete example: A hotkey opens the object list, selects the current player ship, calls the right menu "Crew" and automatically positions the cursor on the first member of the crew (single selection). All with one command... Is that possible?

And yes, THEN I want to (as a player) immediately reassign the first crew member with ctrl-enter - but without having to laboriously navigate through the whole menu with the cursor beforehand. Just one example. With the equipment, for example, I would like to automatically land at the configuration of the weapon turrets, with the ship orders directly at the current order, etc.

For understanding: I try to manage as far as possible all inputs without using the mouse and to be very fast in the input...

Greetings Trajan

Translated with www.DeepL.com/Translator (free version)
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

User avatar
Dj_FRedy
Posts: 230
Joined: Mon, 27. Jun 11, 05:58
x4

Re: Open map menu: Select object in menu (ship, factory etc.) / in map menu: Set input focus?

Post by Dj_FRedy » Sat, 10. Sep 22, 00:40

Ahh, I see what you mean.
If you notice, every time you open the object menu 'objectlist', any previously selected component will keep the selection. You open the menu, close it and open it again and the selection remains. The same is true for the 'propertyowned' menu as there is a set of functions and variables that keep the components of those menus selected, quite effectively I would say. However, to handle what you are looking for would require a code review and modification of the whole system created by EGO in the 'menu_map.lua' file.

Even so, it is possible to search and select a certain row, as long as we have it identified for tracking, in the right menu, but if we don't show 'objectlist or propertyowned' at all, so that the already existing functions and variables that keep the components selected don't interfere.

An example of what I mean:

Code: Select all

function mhk_menu.openPropertyOwnedWithHotkey(_, param)
    -- param="event.param.$event + ':' + $focusComponent"
    local event, component = string.match(param, "(.+):(.+)")
    local convertedcomponent = tonumber(component)

    if (event == "onPress") then
        mapMenu.infoTableMode = nil -- "objectlist"

        mapMenu.addSelectedComponent(convertedcomponent, true, true)
        mapMenu.infoSubmenuObject = convertedcomponent

        mapMenu.searchTableMode = "info"
        mapMenu.infoMode.right = "objectcrew"
        mapMenu.refreshInfoFrame()

        if mapMenu.rowDataMap[mapMenu.infoTableRight] then
            local setrow
            for row, rowdata in pairs(mapMenu.rowDataMap[mapMenu.infoTableRight]) do
                if (type(rowdata) == "table") then
                    if (rowdata[1] == "info_crewperson") then
                        setrow = row
                        DebugError("setrow: " .. tostring(row))

                        break
                    end
                end
            end
            mapMenu.refreshInfoFrame2(setrow)
        end
    end
end
This block should select the first row on which a crew member is printed. Note that 'infoTableMode = nil'.
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.

Post Reply

Return to “X4: Foundations - Scripts and Modding”