UI modding - support thread

The place to discuss scripting and game modifications for X Rebirth.

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

Phipsz
Posts: 335
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz » Mon, 23. Feb 15, 23:46

wysiwyg wrote:
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.
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.

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:

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 :P 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

User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg » Tue, 24. Feb 15, 08:14

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:

Code: Select all

<addon name="my_menu" viewtype="fullscreen" ......>
     <file name="mymenu.lua"/>
     <dependency name="fullscreenHelper"/>
</addon>
works fine and the menu shows up no problem. However,

Code: Select all

<addon name="my_menu" viewtype="fullscreen" ......>
     <file name="mymenu.lua"/>
     <file name="mymonitor.lua"/>
     <dependency name="fullscreenHelper"/>
     <dependency name="detailmonitorHelper"/>
</addon>
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 :)

stefanEgo
Posts: 545
Joined: Thu, 11. Apr 13, 14:12
x4

Post by stefanEgo » Tue, 24. Feb 15, 10:26

@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
Stefan Hett

User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg » Tue, 24. Feb 15, 12:37

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

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 :)

stefanEgo
Posts: 545
Joined: Thu, 11. Apr 13, 14:12
x4

Post by stefanEgo » Tue, 24. Feb 15, 13:23

@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.
Stefan Hett

blackmilan
Posts: 124
Joined: Sat, 22. Jan 11, 21:13
xr

Post by blackmilan » Tue, 24. Feb 15, 18:30

Thanks for your support. I think that should pretty much solve it (at least for what I have currently in mind).
I will try out hooking into the trade menu with the current version (or the next build if it is already available) in the next days and let you know how it went.

User avatar
YorrickVander
Posts: 2702
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Tue, 24. Feb 15, 19:25

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.

User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg » Tue, 24. Feb 15, 21:02

YorrickVander wrote:I'm yet to get this to work along side the custom dialogs for YAT though :(
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.

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!

User avatar
YorrickVander
Posts: 2702
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Tue, 24. Feb 15, 21:45

Yeah, am waiting now for the next iterations to get YAT back up nicely. At least we can do basic menu > xml calls without overwriting other mods changes more easily soon.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg » Tue, 24. Feb 15, 22:12

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:

Code: Select all

local emt_menu = {}
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)

Code: Select all

local Funcs = {}
Now, here's the important bit (with comments):

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
Job Done - well almost - we still need to define our own functions below, so (without all the boring details)

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
Finally, call the init() function and the mod is patched into the original menu framework

Code: Select all

init()
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.

Code: Select all

Funcs.LocalFunction = function()
	local foo = 5
	return foo
end

bar = Funcs:LocalFunction()
-- bar is assigned the value 5
Hope this helps
Wysi :)

Phipsz
Posts: 335
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz » Wed, 25. Feb 15, 00:00

maybe I'm just stupid, but how do I pack the files for workshop? I just don't get it...

User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg » Wed, 25. Feb 15, 00:02

Phipsz wrote:maybe I'm just stupid, but how do I pack the files for workshop? I just don't get it...
Having the same trouble here - I've just filed a bug report on the tracker.

Mod works fine unpacked, but when packed up the game can't see either the ui.xml file or any lua files.

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Wed, 25. Feb 15, 00:13

Phipsz wrote:maybe I'm just stupid, but how do I pack the files for workshop? I just don't get it...
If it helps, your ui stuff for Multiassignment is packed in a subst_01.cat/dat again. When the files were packed in ext_01.cat/dat, the mod worked fine.

Phipsz
Posts: 335
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz » Wed, 25. Feb 15, 00:17

@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
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Wed, 25. Feb 15, 00:20

Ah, ok. Sorry, don't speak lua so didn't look in there.

User avatar
BigBANGtheory
Posts: 3168
Joined: Sun, 23. Oct 05, 12:13
x4

Post by BigBANGtheory » Wed, 25. Feb 15, 12:50

stefanEgo wrote: 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.
I have a number of new UI related use cases so I appreciate any pointers from modders or Egosoft even if you believe it is not currently possible. To avoid swamping anyone I'll try to limit these to no more than 1 per month.

Tactical UI Use Case 1.0 (feb2015)
The goal here is for certain player interactions with the holomap (or a modified version of it) to be visible as a means to identify objects of interest and assist with the 3D nature of space being presented on a 2D plane/viewport/monitor.

The trigger would be the players use of the cursor in combination with the players physical controller keeping a key or button pressed in a 'drag action' commonly used in MS Windows applications. So when the player 'drags' the cursor within the holomap from a selected object the UI will draw common shapes around that object e.g. a line extending from the object to the current cursor position and a circle whose radius extends from the object to the current cursor position. You can see an example of this in my signature below...

Will basic Lua graphics commands/functions work in response to the players actions e.g. drawLine, drawArc, fillPolygon
Last edited by BigBANGtheory on Thu, 26. Feb 15, 11:59, edited 1 time in total.

stefanEgo
Posts: 545
Joined: Thu, 11. Apr 13, 14:12
x4

Post by stefanEgo » Wed, 25. Feb 15, 14:35

@all: To let you know, we've just added documentation regarding the FFI/Lua interface and handling of universeIDs to the UI modding documentation thread here: http://forum.egosoft.com/viewtopic.php?t=377561
@wysiwyg: Nice work on documenting how you migrated the addon to 3.50b1. Note that the UI documentation thread is unlocked for any posts. Maybe you wanna post your description there too, since I think that several other modders will benefit from that.
@wysiwyg/Phipsz: Thanks for adding to the bugtracker --- it's already beeing checked out atm - http://www.egosoft.com:8282/jira/browse/XRUIMOD-10
@BigBANGtheory: You co
Last edited by stefanEgo on Wed, 25. Feb 15, 17:32, edited 1 time in total.
Stefan Hett

stefanEgo
Posts: 545
Joined: Thu, 11. Apr 13, 14:12
x4

Post by stefanEgo » Wed, 25. Feb 15, 16:30

@wysiwyg/Phipsz: We've identified a bug in the engine which could have caused the problem you described. To be 100% certain, could u provide us with ur extension files to confirm the issue was also fixed? Best to attach it to the issue in the bugtracker. http://www.egosoft.com:8282/jira/browse/XRUIMOD-10
Stefan Hett

stefanEgo
Posts: 545
Joined: Thu, 11. Apr 13, 14:12
x4

Post by stefanEgo » Thu, 26. Feb 15, 12:26

@wysiwyg/Phipsz: Just wanted to let you know that we just confirmed that the bugfix also solved the issue you have atm with the mt_enhanced_money_transfer mod. The fix should be in the next version.
Stefan Hett

stefanEgo
Posts: 545
Joined: Thu, 11. Apr 13, 14:12
x4

Post by stefanEgo » Fri, 27. Feb 15, 15:14

Just to give you a heads-up of the latest change: Issues in the bugtracker will now also reflect if they are being worked on (showing: In progress).
We hope that this will also improve the information flow slightly for modders.
Stefan Hett

Post Reply

Return to “X Rebirth - Scripts and Modding”