UI modding - support thread

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

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

Post Reply
hhr
Posts: 61
Joined: Fri, 6. Oct 06, 15:18
x4

Post by hhr » Tue, 10. Mar 15, 15:29

tell me, what is my mistake?

1) make directory \extensions\test_ui
2) copy original \ui\addons\ego_gameoptions\gameoptions.lua to \extensions\test_ui\ui\gameoptions.lua without changes
3) content.xml:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<content id="test_ui" name="Test UI" description="Test UI description" author="hhrhhr" version="100" date="2015-03-09" save="false">
  <dependency version="350" />
</content>
4) ui.xml:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<addon name="test_ui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../core/coreaddon.xsd">
  <environment type="fullscreen">
    <file name="ui/gameoptions.lua" />
    <dependency name="ego_gameoptions" />
  </environment>
</addon>
result:

when the game starts immediately see a message in the log

Code: Select all

Error: Invalid call to SetScript(). Given script function must be a function but is 'string'
Error: Invalid call to RemoveScript(). Given script function must be a function but is 'string'
Error: c:\\dev\\x4_hotfix\\X4\\ui\\xanark\\anarkviewbridge.cpp(111): Warning. The current frame for 'fullscreen' was already updated without processing the update event. Check for errors in addon scripts issuing too many update calls.\
(version: 3.50 - Code revision: 192786)
if i load or start a new game, then after pressing the Esc log appended the first two lines and the game freezes.

User avatar
wysiwyg
Posts: 584
Joined: Thu, 26. Feb 04, 01:08
x4

Post by wysiwyg » Tue, 10. Mar 15, 16:08

@hhr - I suspect you are calling two completely separate instances of gameoptions.lua there that are conflicting with each other. Your version of the .lua file will need changing if you want the options menu to behave differently. You'll basically need to 'hook' your modified functions into the existing Menu table as described in the previous pages of this thread. See here for an example of hooking into "Menu"
Hope this helps
Wysi :)

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

Post by stefanEgo » Tue, 10. Mar 15, 16:18

@hhr: wysiwyg was a bit faster than I was. So basically this is just repeating what he already said:
The problem you are running in is that now you end-up with two menus being registered to open alongside the optionsmenu-show-event. The standard one and ur copy of the standard version.
Take a look at the init() function. Since in principle it's now being called twice, it also registers two menus via the call to Helper.registerMenu(menu). In ego_fullscreenHelper/helper.lua you find the registerMenu()-function which basically does two register calls.

Code: Select all

[...]
	RegisterEvent("show"..menu.name, showMenuCallback)
	RegisterEvent("showNonInteractive"..menu.name, showNonInteractiveMenuCallback)
end
This now results in two functions being called when the showOptionsMenu event occurs.

If you really want to replace the entire menu, you'd have to hook into the onShowMenu() function of the existing menu.
Aka:
- update the init() function in your copy
- search the list of existing menus for the OptionsMenu one
- replace that menus callback functions (like the onShowMenu()-function) with your own functions

To provide an easier way for this use-case, I've added a feature request for you ( http://www.egosoft.com:8282/jira/browse/XRUIMOD-23 ) to provide means to completely unregister menus which were registered with the helper. Hopefully this will be ready in-time for 3.50 but can't make any promises here, unfortunately.
There are other means to tackle this case, but I'd say that while the one mentioned above is certainly not the easiest one to work with, it's IMO the safest variation atm.
Stefan Hett

hhr
Posts: 61
Joined: Fri, 6. Oct 06, 15:18
x4

Post by hhr » Tue, 10. Mar 15, 16:49

stefanEgo wrote:If you really want to replace the entire menu...
not exactly.
I had a desire to make a menu for the entire height of the screen and change the width of columns in some settings. it needs to dynamically change the members of table "config" depending on the current (selected) resolutions.

now it looks like this:

Code: Select all

-- old code
-- local config = {...
--	frameHeight = 550,
--	tableHeight = 430,
--...}

-- new code
local config = {}

local function setConfig()
    local res = GetResolutionOption()
    local width = res.width
    local height = rse.height
    ...
    config.frameHeight = height
    config.tableHeight = height - config.tableOffsety * 2
    ....
end
and after every call of SetResolutionOption() I inserted a call to this function (setConfig) to update the values.

affected functions - onUpdate and onSelectElement, to write the "interceptor", then I'll have to copy the entire contents for pasting a single line. is there no other way?

in its current form, it even works and the main menu and in-game. once the game freezes ;)

(original - modded)
Image - Image

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

Post by stefanEgo » Wed, 11. Mar 15, 10:11

@hhr: We got the unregisterMenu-function in in-time for 3.50 RC2. So with the latest version, you now have an alternative at hand to replace entire menus (if you ever want that) and call

Code: Select all

-- iterate over the Menus array to get the proper menu, then call:
Helper.unregister(menu)
Note that depending on the actual menu, you might have to do additional things to fully clean-up a menu. In case of the game options menu, this means (at the time of writing this) unregistering the "openOptionsMenuParam" event - see gameoptions.lua: init()-function last line.

For your case I guess the easiest approach would be to hook into the SetResolutionOption function directly:

Code: Select all

[...]
local orgSetResolutionOption
local function mySetResolutionOption(arg1, arg2)
	orgSetResolutionOption(arg1, arg2)
	setConfig()
end
[...]
local function init()
	orgSetResolutionOption = SetResolutionOption
	SetResolutionOption = mySetResolutionOption
end
@all: if you previously checked out the Lua/FFI list in Confluence, you might wanna take another look. We extended the documentation quite much over the past few days. While it's not complete yet, most of the functions are now documented here:
https://www.egosoft.com:8444/confluence ... n+overview
https://www.egosoft.com:8444/confluence ... n+overview
Stefan Hett

Vim Razz
Posts: 1837
Joined: Tue, 2. Nov 10, 03:20
x4

Post by Vim Razz » Thu, 12. Mar 15, 08:59

I really appreciate the amount of detail you guys are putting into the documentation. Some things are easy enough to figure out by trial and error, but other details can be hard to catch.


This thread so far has mostly focused on Lua functions so far... Would an MD script function request be appropriate? I'm thinking of a "radial menu section return" expression with the ability to pass back a parameter -- similar to add_player_choice_return, but without the button press.

I've been using a fake detailmoniter menu to get his functionality for several months now, and it allows for some decent UI presentation within the radial menus that you can't otherwise get.


Some examples of user-friendly interface tweaks that I've developed in my own menu mod (Human Resources, linked in my signature) using radial menu section returns:

- Stringing together common actions is much faster than having to re-open a new conversation for each step. Example: Leave/Join my Squad, followed by immediately by a command assignment.

- Sequential button/menu toggling. Example: I've got squad broadcast commands linked to a 3-stage ship-type filter on a sequential toggle button (all ships, combat ships, or non-combat ships) which provides a great deal more control to broadcast commands in a relatively simple way.

- Button Markers. Example: When used with euclid's Manager Call mod, the Human Resources's interface buttons will show markers to indicate that the Station or Accountant Report requests have been sent without getting dumped out of the menu every time.


Anyway, I've gotten used to using a fake Lua menu for this purpose in my own project, but a real MD script expression would still be very nice to have and would provide added flexibility to experimenters who might still be intimidated by the Lua (which is a pretty deep pool to try and wade into >.<).

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

Post by stefanEgo » Thu, 12. Mar 15, 09:09

@Vim Razz: I've forwarded ur request to the appropriate person, but given that this is outside the UI modding scope, I can't give any promises on feedback on that item, unfortunately.
Stefan Hett

Vim Razz
Posts: 1837
Joined: Tue, 2. Nov 10, 03:20
x4

Post by Vim Razz » Thu, 12. Mar 15, 09:30

Thank you. I wasn't sure where the right place for it might be.

KlausM
EGOSOFT
EGOSOFT
Posts: 616
Joined: Wed, 6. Nov 02, 21:31
x4

Post by KlausM » Thu, 12. Mar 15, 11:26

Vim Razz wrote:This thread so far has mostly focused on Lua functions so far... Would an MD script function request be appropriate? I'm thinking of a "radial menu section return" expression with the ability to pass back a parameter -- similar to add_player_choice_return, but without the button press.
I suppose you'd like to trigger a section that does an action (e.g. "add to squad"), and immediately go to another section (e.g. back to the previous section) which adds player choices. Unfortunately this is not possible in the current conversation system - the response and the following player choices must be defined in the same section. That's also a limitation for us, and we'll certainly look into it, but we can't promise an elegant solution to the problem at this point.

As a workaround, you could reuse the same section for different purposes, and define the action to be performed in the passed parameter. So, instead of going to the "add to squad" section, you go to the "player choices" section with an "add to squad" parameter. That would allow you to handle actions and player choices independently in the same section.

Another possible workaround is having the player choices in a library and including that library in all sections that need them, but that could get confusing.

User avatar
YorrickVander
Posts: 2682
Joined: Tue, 29. Oct 13, 22:59
x4

Post by YorrickVander » Thu, 12. Mar 15, 13:37

EDIT *oops* RTFM
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

Vim Razz
Posts: 1837
Joined: Tue, 2. Nov 10, 03:20
x4

Post by Vim Razz » Thu, 12. Mar 15, 19:46

@KlauseM - Thank you for your reply.
KlausM wrote:I suppose you'd like to trigger a section that does an action (e.g. "add to squad"), and immediately go to another section (e.g. back to the previous section) which adds player choices.
Yes, this is what my mod currently does. The examples in my previous post are not ideas that I would like to implement in the future -- they're examples from the current version of my mod that I included to help illustrate my meaning.

As my workaround to the limits of the current system, I've been using a "fake" detailmonitor menu that simply initializes helper functions and issues Helper.closeMenuAndReturn immediately on menu.onShowMenu.

This is the workaround "menu" that I've been using in it's entirety:

Code: Select all

local menu = {
	name = "VR_SectionReturnBumper",
}


local function init()
	Menus = Menus or {}

	if Helper then
		Helper.registerMenu(menu)
	end

	return 
end


menu.cleanup = function ()
	menu.kickback3 = nil

	return 
end


menu.onShowMenu = function ()
	menu.kickback3 = menu.param

	Helper.closeMenuAndReturn(menu, false, menu.kickback3)
	menu.cleanup()

	return 
end


init()

return 
And I was wondering about the possibility of an MD script expression that does something similar, instead of using this.


I have another version that issues Helper.closeMenuForSubSection instead of Helper.closeMenuAndReturn, but the need for that sort of section advance is so rare that I haven't actually used it in any project releases yet and usually forget about it completely.

Thinking about it now, there's one section in my current mod where the section advance might help with a particular issue I've been having, but for most circumstances the current MD script system works great without it.

User avatar
YorrickVander
Posts: 2682
Joined: Tue, 29. Oct 13, 22:59
x4

Post by YorrickVander » Thu, 12. Mar 15, 19:58

would this helper do the job for you?

Code: Select all

function Helper.closeMenuForSubSection(menu, keepvisible, nextsection, choiceparam)
	-- Keep a copy of baseparam as upvalue because menu.param may change
	local baseparam = getSectionBaseParam(menu)
	closeMenu(menu, keepvisible, function() ProceedFromMenu(nextsection, Helper.convertComponentIDs(choiceparam), Helper.convertComponentIDs(baseparam)) end)
end
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

Vim Razz
Posts: 1837
Joined: Tue, 2. Nov 10, 03:20
x4

Post by Vim Razz » Thu, 12. Mar 15, 20:23

@YorrickVander

Thanks, Yorrick! As I said in the last little bit, I already have a fake lua menu that uses that expression to bounce around cue sections, but you almost never need it. I've found that most of the cases where you ~could~ use it (as a fake MD expression) are really better served by improving section organization instead.


Having section return functionality has been extremely useful in making the radial UI more user-friendly, though, and I thought it might be more accessible to others if it were available as a regular MD script expression.

Tromblon
Posts: 6
Joined: Sat, 21. Feb 15, 23:55

Post by Tromblon » Sat, 14. Mar 15, 10:57

Hi guys,

Regarding the visual structure, any idea how i can make a "Rowspan" ?
Image
Or simulated it with a stack (superimpose) of 2 tables, is it possible ?
Image

Thanks for any helps :)

User avatar
wysiwyg
Posts: 584
Joined: Thu, 26. Feb 04, 01:08
x4

Post by wysiwyg » Sat, 14. Mar 15, 12:19

Tromblon wrote:Hi guys,

Regarding the visual structure, any idea how i can make a "Rowspan" ?

Or simulated it with a stack (superimpose) of 2 tables, is it possible ?


Thanks for any helps :)
Not sure if this is possible or not with the current build. I would look at Ego's lua code for screens such as the map screen and the encyclopaedia entry screens - those screens have a more "non -linear" structure than the typical table menu screens like the property menu.

Post Reply

Return to “X Rebirth - Scripts and Modding”