UI modding - support thread
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
- YorrickVander
- Posts: 2689
- Joined: Tue, 29. Oct 13, 21:59
@BigBANGtheory: unfortunately we do have quite limited resources here. So going over a list of UI mods/projects and investigate what is doable and won't be possible. I suggest you just ask directly how to solve a certain use-case, if in doubt, and we'll see how this can be done. Especially, if there are cases where you managed to do something with version 3.20 and don't know how to do it with 3.50, please let us know directly.
Also don't be afraid of creating issues in the bugtracker which might be inappropriate/invalid. If there will be cases like these, we'll just close them (stating the reason/solution for the issue).
@blackmilan/wysiwyg: Here's a quick run-through about how to modify existing menus now:
method 1: in your own lua file add something like this:
method2: in your own lua file add something like this
I've added a feature request to the bugtracker (http://www.egosoft.com:8282/jira/browse/XRUIMOD-5) to increase the number of use-cases where the first method could be used with. But I can't make any promise whether we will be able to get this in in-time for 3.50.
Also don't be afraid of creating issues in the bugtracker which might be inappropriate/invalid. If there will be cases like these, we'll just close them (stating the reason/solution for the issue).
@blackmilan/wysiwyg: Here's a quick run-through about how to modify existing menus now:
- in ui.xml set ego_detailmonitor as a dependency
- in ui.xml specify your own lua-file
- in your lua-file add a method-call (for instance init()) and implement that function in that file
- in init() iterate over the Menus-table (check entry.name to locate the proper menu)
- hook into the corresponding menu-function. For instance to modify how the menu looks, hook into menu.onShowMenu()
method 1: in your own lua file add something like this:
Code: Select all
local orgOnShowMenu
local function onShowMenuHook()
orgOnShowMenu() -- this ensures that the original menu behavior is retained - you will only extend the existing menu with your own functionality, retrieve the elements of the menu and hook into their functionality
-- add code to retrieve/update constructed elements
end
local function init()
[...]
orgOnShowMenu = menu.onShowMenu
-- menu being already the retrieved menu-entry from the Menus table for the appropriate menu (for instance the trading offers menu)
[...]
end
init() -- calls init upon loading the addon
Code: Select all
local function myOnShowReplacement()
-- copy/paste the content of the original lua-file's onShowMenuHook-function here and adjust it to whatever you feel like
-- most likely when using this method, you'll copy/paste the entire Lua file so you can alter everything
end
local function init()
[...]
menu.onShowMenu = myOnShowReplacement
-- menu being already the retrieved menu-entry from the Menus table for the appropriate menu (for instance the trading offers menu)
-- most likely you will have to replace all the entries in the Menus-table in the end --- depending on what you actually altered/intend to alter in the first place (for instance menu.onUpdate, menu.onRowChanged, etc.)
[...]
end
init() -- calls init() upon loading the addon
Stefan Hett
Request Added to bugtracker - It seems this issue will affect any mod that uses both the detailmonitor and the sidebar menu. Seeing as this worked previously would it not make sense to search in the addons folder of the mod for multiple addons e.g.stefanEgo wrote:@bm01: There are two possibilities atm:
1. Create two separate addons (one in the fullscreen environment, one in the detailmonitor environment)
2. In the fullscreen environment create your own distinct window after you clicking on your button (see DisplayView() and related functions)
Unfortunately the support for cross-environment use-cases is somehow limited atm (especially with respect to working with a single addon set-up).
Feel free to add a feature request to the bugtracker, if you feel like the current support is too limited.
extensions/mymod/ui/addons/mymenu/ui.xml --> my_menu_addon.lua
extensions/mymod/ui/addons/mymonitor/ui.xml --> my_monitor_addon.lua
Just a thought!
Cheers
Wysi
It does seem to work on my side, the folders have to be prefixed with ego_ though atm. don't add ego_ prefix in the ui.xml as name. so basically following structure should work:wysiwyg wrote:Request Added to bugtracker - It seems this issue will affect any mod that uses both the detailmonitor and the sidebar menu. Seeing as this worked previously would it not make sense to search in the addons folder of the mod for multiple addons e.g.stefanEgo wrote:@bm01: There are two possibilities atm:
1. Create two separate addons (one in the fullscreen environment, one in the detailmonitor environment)
2. In the fullscreen environment create your own distinct window after you clicking on your button (see DisplayView() and related functions)
Unfortunately the support for cross-environment use-cases is somehow limited atm (especially with respect to working with a single addon set-up).
Feel free to add a feature request to the bugtracker, if you feel like the current support is too limited.
extensions/mymod/ui/addons/mymenu/ui.xml --> my_menu_addon.lua
extensions/mymod/ui/addons/mymonitor/ui.xml --> my_monitor_addon.lua
Just a thought!
Cheers
Wysi
extensions/mymod/ui/addons/ego_mymenu/ui.xml[name="mymenu"] --> my_menu_addon.lua
extensions/mymod/ui/addons/ego_mymonitor/ui.xml[name="mymonitor"] --> my_monitor_addon.lua
(or use my sidebarextender to circumvent two ui-addons I have already updated sidebarextender on my side and will push the update in a few hours )
I do agree with you though, I would really like to keep the folder structure for ui the same as before. It really would feel more "right", as we already put everything else in folder structure that has been defined by the existing structure and, as a result, would be more consistent
Hi Phipsz - The problem I have is that now the game only sees a single ui.xml file in the mod's root folder. I can get my menus to show up no problem using the existing method of plugging in to the main menu. However, the sidebar menu operates in the "fullscreen" environment so if one then tries to add something in the "detailmonitor" environment, the game throws a dependency error when trying to resolve the dependency for the detailmonitor:
works fine and the menu shows up no problem. However,
does not work as it throws an error looking for the dependency for the detailmonitor.
I think your sidebar extender IS the way forward at the moment and I'm certainly going to look at using it for my Station Logistics mod.
Cheers
Wysi
Code: Select all
<addon name="my_menu" viewtype="fullscreen" ......>
<file name="mymenu.lua"/>
<dependency name="fullscreenHelper"/>
</addon>
Code: Select all
<addon name="my_menu" viewtype="fullscreen" ......>
<file name="mymenu.lua"/>
<file name="mymonitor.lua"/>
<dependency name="fullscreenHelper"/>
<dependency name="detailmonitorHelper"/>
</addon>
I think your sidebar extender IS the way forward at the moment and I'm certainly going to look at using it for my Station Logistics mod.
Cheers
Wysi
@wysiwyg: Makes absolute sense. I'll see what we can do for 3.50 here.
@Phipsz: We'll find a solution to support this properly. Please note that ur "workaround" will only work in this beta. It won't be possible in the released 3.50. I've added a bugtracker item here to make clear that this just works for the time being: http://www.egosoft.com:8282/jira/browse/XRUIMOD-7
@wysiwyg: The error you are seeing with ur second example is because
a) the addon name is incorrect (assuming you didn't create a new mod called: "fullscreenHelper" yourself, the correct name would be: "ego_fullscreenHelper" --- same goes for the detailmonitorHelper)
b) atm you can only set dependencies to addons in the same environment, therefore setting a dependency to ego_detailmonitorHelper will still issue an error here
I see whether we can tackle this alongside http://www.egosoft.com:8282/jira/browse/XRUIMOD-6
@Phipsz: We'll find a solution to support this properly. Please note that ur "workaround" will only work in this beta. It won't be possible in the released 3.50. I've added a bugtracker item here to make clear that this just works for the time being: http://www.egosoft.com:8282/jira/browse/XRUIMOD-7
@wysiwyg: The error you are seeing with ur second example is because
a) the addon name is incorrect (assuming you didn't create a new mod called: "fullscreenHelper" yourself, the correct name would be: "ego_fullscreenHelper" --- same goes for the detailmonitorHelper)
b) atm you can only set dependencies to addons in the same environment, therefore setting a dependency to ego_detailmonitorHelper will still issue an error here
I see whether we can tackle this alongside http://www.egosoft.com:8282/jira/browse/XRUIMOD-6
Stefan Hett
Thanks Stefan - I wrote the post from memory and forgot to add the ego_ prefixes but can confirm what you said in that using the correct dependencies for two different environments in the same <addon/> tags does throw an error.stefanEgo wrote: @wysiwyg: The error you are seeing with ur second example is because
a) the addon name is incorrect (assuming you didn't create a new mod called: "fullscreenHelper" yourself, the correct name would be: "ego_fullscreenHelper" --- same goes for the detailmonitorHelper)
b) atm you can only set dependencies to addons in the same environment, therefore setting a dependency to ego_detailmonitorHelper will still issue an error here
I see whether we can tackle this alongside http://www.egosoft.com:8282/jira/browse/XRUIMOD-6
On another note I was able to successfully plug in to the MoneyTransfer menu as described in your previous post and this seems to work fine. After a bit of testing and tidying up I'll release this and see how it goes. I'll also post a summary of what I did as an example to add a bit more detail to your instructions.
Cheers
Wysi
@blackmilan/wysiwyg: With regards to modifying existing menus, we've improved the support now. The changes are being tested now internally and are expected to make it into the next build. No ETA on that version yet, though. - http://www.egosoft.com:8282/jira/browse/XRUIMOD-5
The improvement is mainly that all functions previously local to the Lua-files are now members of the menu structure. That will allow you to hook into any of the functions without having to copy/paste the entire script any-longer.
That should make the method 2 I described earlier obsolete. Please let us know if there are still any remaining constrains which make you having to revert to the alternative method to alter menus, once the new version is out.
The improvement is mainly that all functions previously local to the Lua-files are now members of the menu structure. That will allow you to hook into any of the functions without having to copy/paste the entire script any-longer.
That should make the method 2 I described earlier obsolete. Please let us know if there are still any remaining constrains which make you having to revert to the alternative method to alter menus, once the new version is out.
Stefan Hett
-
- Posts: 124
- Joined: Sat, 22. Jan 11, 21:13
- YorrickVander
- Posts: 2689
- Joined: Tue, 29. Oct 13, 21:59
Cyberfuzzie's method seems to work ok still if the ui.xml + lua is put into the mods root directory (tip of the hat to w.evans for telling me about this). I'm yet to get this to work along side the custom dialogs for YAT though
X Rebirth - A Sirius Cybernetics Corporation Product
Split irritate visiting pilot with strange vocal patterns.
Split irritate visiting pilot with strange vocal patterns.
That's the crux of the issue at the moment - the sidebar operates in fullscreen mode and the custom dialogs in the detailmonitor mode. As we are only allowed one <addon/> root tag in ui.xml the game has issues finding the helper dependencies. I think Phipsz' sidebar extender is the solution in the short term as the menu runs in one mod and the detailmonitor dialogs in another. There's an issue raised on the bugtracker so hopefully this will change as the betas roll out.YorrickVander wrote:I'm yet to get this to work along side the custom dialogs for YAT though
Edit: Cyberfuzzie's method is essentially using a method similar to that described by Stefan in an earlier post. That's the method I used to plug into the MoneyTransfer menu and so far so good!
- YorrickVander
- Posts: 2689
- Joined: Tue, 29. Oct 13, 21:59
I thought I would share how I ported my Enhanced Money Transfer mod over to the new system in 3.50 b1 I know most people haven't written mods that patch into the existing UI framework but it should help as a reference as how to do it in general. I won't cover the ui.xml as I think that's already fairly clear - just to reiterate that as things stand the game looks for a single ui.xml file in the mod's root folder. You can also now put your .lua files in the root folder and there's no need anymore to put them in a subst_xx.cat file or use a convoluted path in the xml file to locate them.
So, in the versions previous to 3.50 I was able to simply write a new version of the MoneyTransfer lua file and diff patch the ego_detailmonitor.xml file to replace Ego's version with my own. As of 3.50 b1 I can't do that so I now need to locate the existing (vanilla) menu and "hook" my functions into it. Here's how:
First I make a local empty table to hold a copy of the vanilla MoneyTransfer dialog:
I'm also going to make a table to store my collection of functions as this is how I like it (makes debug and cleanup a lot easier)
Now, here's the important bit (with comments):
Job Done - well almost - we still need to define our own functions below, so (without all the boring details)
Finally, call the init() function and the mod is patched into the original menu framework
Remember that if you wish to call any of the functions in the member table (Funcs) locally i.e. inside the mod then use the : operator e.g.
Hope this helps
Wysi
So, in the versions previous to 3.50 I was able to simply write a new version of the MoneyTransfer lua file and diff patch the ego_detailmonitor.xml file to replace Ego's version with my own. As of 3.50 b1 I can't do that so I now need to locate the existing (vanilla) menu and "hook" my functions into it. Here's how:
First I make a local empty table to hold a copy of the vanilla MoneyTransfer dialog:
Code: Select all
local emt_menu = {}
Code: Select all
local Funcs = {}
Code: Select all
local function init() -- This function runs at game startup to load menus
-- iterate over the master "Menus" table to find the menu we want to plug in to
-- Note that "Menus" is THE master table that holds a live copy of all XR's menus/dialogs
for _, menu in ipairs(Menus) do -- note that the underscore is simply a placeholder for an ignored variable
-- We're looking for the menu called "MoneyTransferMenu"
if menu.name == "MoneyTransferMenu" then
-- We found our menu so let's first make a local copy of it that we can use, for example if we need to call any Helper functions
-- or maybe access any passed parameters. In my functions below I can now access passed in parameters as e.g. emt_menu.param1
emt_menu = menu
-- Now we hook in our own functions to replace the originals
menu.onShowMenu = Funcs.EMT_onShowMenu
menu.onUpdate = Funcs.EMT_onUpdate
menu.onSelectElement = Funcs.EMT_onSelectElement
menu.onCloseElement = Funcs.EMT_onCloseElement
menu.cleanup = Funcs.EMT_cleanup
break -- we found our menu so we can break out of the for loop as we don't need to carry on looking anymore
end
end
end
Code: Select all
Funcs.EMT_cleanup = function()
.........
end
Funcs.EMT_onShowMenu = function()
...........
end
-- Note here that I'm using the onUpdate function so I need to set an update interval - I access this via my local copy of the vanilla menu
emt_menu.updateInterval = 0.5
Funcs.EMT_onUpdate = function()
..............
end
Funcs.EMT_onSelectElement = function()
...........
end
Funcs.EMT_onCloseElement= function(dueToClose)
.........
end
Code: Select all
init()
Code: Select all
Funcs.LocalFunction = function()
local foo = 5
return foo
end
bar = Funcs:LocalFunction()
-- bar is assigned the value 5
Wysi
@wysiwyg: phew, kind of glad I'm not the only one here... was almost going crazy. nice example btw
@w.evans: obviously isn't relevant atm, I had a different structure when the ui.xml was in the ext.cat/dat as that was before I ported to the official structure. I won't revert my mod to the old structure, as it will break. I'll wait with this new structure until it is fixed
@w.evans: obviously isn't relevant atm, I had a different structure when the ui.xml was in the ext.cat/dat as that was before I ported to the official structure. I won't revert my mod to the old structure, as it will break. I'll wait with this new structure until it is fixed