UI modding - support thread

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

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

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

UI modding - support thread

Post by stefanEgo » Fri, 20. Feb 15, 01:21

This thread serves as the support thread for questions/issues you might have when modifying the UI.

Before you post anything here, it might be useful to:
- check out the UI modding documentation (https://wiki.egosoft.com:1337/X%20Rebir ... 20support/)
- check out the X Rebirth Wiki (https://wiki.egosoft.com:1337/X%20Rebirth%20Wiki/)
- check whether your issue/question was already answered in this thread or forum

If you still can't find any help with your bug/question, feel free to create a new issue on the bugtracker and/or post in this thread.

Some shortcuts to certain pages in the Wiki system:
UI modding changelog: https://wiki.egosoft.com:1337/X%20Rebir ... Changelog/
Last edited by stefanEgo on Wed, 9. Sep 15, 10:25, edited 8 times in total.
Stefan Hett

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

Post by YorrickVander » Fri, 20. Feb 15, 05:44

-hugs Egosoft team- Thanks very much!
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

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

Post by BigBANGtheory » Fri, 20. Feb 15, 08:55

Ah now we get to the gem feature behind v3.5, this could be the start of something special... nice one.

Stefan you said in your documentation post about certain UI modifications not being possible atm. Could you please give us an example or two of what is not possible?

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

Post by stefanEgo » Fri, 20. Feb 15, 09:54

@BigBANGtheory: I assume you are referring to this section of the documentation "Certain things are, unfortunately, out of the scope of what we can make available to everybody, but whatever we can provide to the community with, we will make every effort to do so. ".
If so then it's merely meant as a general statement. There are different cases which we have to live with.
One reason being license issues. Like every other company out there we license other tools/frameworks/libraries/etc. While we always try to find products which won't limit us with regards to making things later available for the community, there are a few which unfortunately have a restriction put on us. In these cases we cannot, even if we would like to, directly open up these things to everybody. Still we are always trying to find ways around these limitations (one example where we did that on the UI side is the widget system which circumvents one of these legal restrictions).
Other things are safety and security considerations. In certain cases we therefore have to limit the functionality (disabled byte-code support in Lua is one example for this case).
A last example is to limit certain functionality, so to provide a minimal level of safety against bugs in one mod having a backfiring-effect on other mods. While this cannot be totally ensured, we at least designed the UI engine with that goal in mind and in some cases this causes restrictions (each mod having its distinct ui.xml-file and no direct file access from the UI level on files/content in other mods is an example here).

There are of cause further cases, but I guess these examples already draw a picture on what the statement above means.
Stefan Hett

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

Post by BigBANGtheory » Fri, 20. Feb 15, 12:12

ok I see what you mean ty for the explanation. You've disabled bytecode to stop people writing potentially harmful code then yes that makes sense.

This might seem like a silly question and apologies in advance if I'm being premature here :oops: Where does one get started with modding the UI e.g. how does XR's UI Engine work, do you need to learn LUA programming (if so which version), location of the LUA source scripts?

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

Post by stefanEgo » Fri, 20. Feb 15, 12:14

@BigBANGtheory: The documentation is currently being worked on and part of it should be available later today. So stay tuned. :-)
Stefan Hett

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

Post by YorrickVander » Fri, 20. Feb 15, 16:50

Stefan - you say in the documentation :
debug/os/io libraries are not available
In 3.20 I successfully dumped ware names to a text file with a modified version of (the 2.51 since that was the last version to decompile with ljd) trade window. I haven't tested it again yet, but if that ability has been removed, is there a reason for it? It would open up some interesting options for 3rd party apps running out of game or in the steam browser.
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 » Fri, 20. Feb 15, 20:10

I guess the downside of allowing uncontrolled file io access is that someone with bad intentions could write please-format-hdd.bat to the windows start folder! More likely some bad html or such. Either way it would need a mechanism to restrict it to safe use if allowed.

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

Post by stefanEgo » Fri, 20. Feb 15, 20:42

@YorrickVander: More or less exactly what wysiwyg stated. Most of the functions available in these libraries are of security or stability concerns. Therefore these libraries are disabled. If you have a certain use case which you can't realize with the existing functionality, we will certainly consider supporting that by other (more secure) means.
For instance we provide a GetDate() function which is a 1-to-1-replacement for os.date() or TraceBack() which is a replacement for the disabled debug.traceback() function.

In case of dumping data: Via the savegame- and or userdata-storage you do actually have means to store anything into external files. The userdata is stored in the uidata.xml-file located in the user's personal directory (for instance: C:\Users\[username]\Egosoft\X Rebirth\[SteamUserID]). Does that work for ur requirement?
Stefan Hett

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

Post by YorrickVander » Fri, 20. Feb 15, 20:49

Concern understood, and yeah that could work :) Certainly better than the debug log parsing I was forced to use to get market data into sql previously (http://www.nexusmods.com/xrebirth/mods/339/? for anyone that remembers it, back when the economy really needed watching)
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

bm01
Posts: 421
Joined: Wed, 22. Jul 09, 22:31
x4

Post by bm01 » Sat, 21. Feb 15, 04:19

Is there a way to use both detailmonitor and fullscreen (viewtypes)?
Unless I'm missing something, that's what I need if I want to add a button on the sidebar which opens a window.
I naively tried this:

Code: Select all

<addons>
  <addon name="x" viewtype="detailmonitor">
    ...
  </addon>
  <addon name="x" viewtype="fullscreen">
    ...
  </addon>
</addons>
Obviously it didn't work.

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

Post by stefanEgo » Sat, 21. Feb 15, 09:12

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

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

Post by BigBANGtheory » Sun, 22. Feb 15, 12:27

Stefan if we were to provide a list of UI modding objectives/projects would you be prepared to glance through them and advise in your opinion which of those are realistic (as of v3.5beta) and those that are better served by a feature request in the bug tracker?

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

Post by blackmilan » Sun, 22. Feb 15, 12:36

The top UI modders and the UI Engine Architect in one place. I think I like this thread, it seems to be the perfect place for a few questions. :D

One thing that is currently not clear to me is how modifications of existing UI LUA scripts provided by Egosoft are handled now. Let's say I want to make some changes to the trade menu (ui/addons/menu_trading_offers.lua). Do I still use the method of putting my modified file into a subst.cat or is this now somehow done via the ui.xml file?
I am thinking about importing an existing UI file, overriding the functions I want to change and telling the UI that it should load the modified file instead of the original one.

@stefanEgo
Thanks for adding the UI modding support!

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

Post by wysiwyg » Sun, 22. Feb 15, 13:34

blackmilan wrote:One thing that is currently not clear to me is how modifications of existing UI LUA scripts provided by Egosoft are handled now. Let's say I want to make some changes to the trade menu (ui/addons/menu_trading_offers.lua). Do I still use the method of putting my modified file into a subst.cat or is this now somehow done via the ui.xml file?
I am thinking about importing an existing UI file, overriding the functions I want to change and telling the UI that it should load the modified file instead of the original one.
That's a really good question. I had managed to avoid the subst_xx.dat/cat files by making sure the mod's version of the ui.xml file had the correct path so that the game could find it e.g.

Code: Select all

 ../../../extensions/my_mod/ui/addons/ego_xxxx/my_lua_file.lua
However the ui.xml was still a diff file so that add/replace could be used to replace vanilla files as I do with my money transfer dialog replacement. Keen to know if we can still use the diff method.

And +1 for the support as well ;)

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

Post by YorrickVander » Sun, 22. Feb 15, 21:28

-withdraawn- failed to read a post properly
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

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

Post by stefanEgo » Mon, 23. Feb 15, 09:25

@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:
  1. in ui.xml set ego_detailmonitor as a dependency
  2. in ui.xml specify your own lua-file
  3. in your lua-file add a method-call (for instance init()) and implement that function in that file
  4. in init() iterate over the Menus-table (check entry.name to locate the proper menu)
  5. hook into the corresponding menu-function. For instance to modify how the menu looks, hook into menu.onShowMenu()
There are in principle two ways to hook into the menus. In general we suggest to use the first method, since that is less likely to break new features which could be added in a later version. The second method however is less limited to what you can do:
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
method2: in your own lua file add something like this

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

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

Post by stefanEgo » Mon, 23. Feb 15, 10:14

For easier navigation/usage of the bugtracker, we've updated the initial post with some shortcuts to useful lists/pages on the bugtracker. Hope this makes it a bit easier to find ur way around there.
Stefan Hett

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

Post by stefanEgo » Mon, 23. Feb 15, 10:59

The documentation was updated with a list of all Lua/FFI functions available in 3.50 beta 1. Hope this helps to figure out what's possible with the current UI support and what isn't. Please check out the provided Lua functions to see how these functions are used.
Stefan Hett

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

Post by wysiwyg » Mon, 23. Feb 15, 23:29

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

Post Reply

Return to “X Rebirth - Scripts and Modding”