Thinned Station Columns Mod

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

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

RondoX4
Posts: 39
Joined: Thu, 30. Jun 22, 02:31
x4

Thinned Station Columns Mod

Post by RondoX4 »

This all started because I have a burning desire to change staion and fleet text lines to ONE line and not TWO lines.
I think other players would like this option if they have developed and extensive trade empire like I have.
1. Located a Nexus Mod named "Just Another Modified UI" by Wiwip created in Apr 2020. Yes that is over 5 years and has never been updated.
2. It also needed SirNukes Mod downloadable in the current workshop.
3. Wiwip got his idea from an X4 WIKI "[MOD] UI Thinned Station Columns" suggested by pesoda and and commented on by a modding moderator
4. pesoda (or the moderator) suggested a slight modification of a local isdoublerow isstation script line in menu_map.lua
5. I manualy installed the files for the "Just Another" mod and subscribed to the 8.0 compatable SirNukes mod from the X4 workshop.
6. Both the "Just Another Modified UI" and SirNukes mode are recognized and activated but there is no effect on the text lines.

If there is someone who can help me troubleshoot this issue I would greatly appreciate it.
I already have 18 stations and to be able to had more stations would be more conducive to my play style.
User avatar
ChemODun
Posts: 595
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Thinned Station Columns Mod

Post by ChemODun »

Technically it is possible, but it will block you from using any mod which depend on UI Extensions and HUD by kuertee

So, are you sure?
Multiply entropy by absolute zero

Freedom in space
RondoX4
Posts: 39
Joined: Thu, 30. Jun 22, 02:31
x4

Re: Thinned Station Columns Mod

Post by RondoX4 »

Thanks for responding so quickly. I occasionally use the (1) Cheat Menu and other passive mods are (2) increased long lang scan (3) orange mouse cursor [otherwise the mouse is blue grey. It was nice green but changed by itself] and (4) assorted mods that add ships.
Would I be adding a mod to the extensions folder? Or would I be changing the xml code in the menu_map.lua?
I am not an experienced xml coder, but know how to use Notepad++, create back up files before changing anything, and have modified save files to locate abandoned ships and temporarily modified a save file to help locate anomalies.

If you have suggestions let me know.
Thanks again
User avatar
ChemODun
Posts: 595
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Thinned Station Columns Mod

Post by ChemODun »

It is not so simple...

But initially I want to check one more time - do you have in extensions folder with name kuertee_ui_extensions ?
Multiply entropy by absolute zero

Freedom in space
User avatar
ChemODun
Posts: 595
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Thinned Station Columns Mod

Post by ChemODun »

For changes in game I will recommend a Gate Manager
Multiply entropy by absolute zero

Freedom in space
RondoX4
Posts: 39
Joined: Thu, 30. Jun 22, 02:31
x4

Re: Thinned Station Columns Mod

Post by RondoX4 »

I appreciate your caution and checking in this matter. I checked my extensions folder with Windows File Explorer. I DO NOT see a folder with the name "kuertee_ui_extensions" in the folder extentions.
I also checked all the subfolders and any object for the specified file. I DO NOT see this file.
My experience has proven to me that dealing with any mod in X4 is not simple and being careful is a requirement to maintain file integrity.
What does a Gate Manager do?
I suggest since we will end up with one line of text for stations/fleets it should look like [Station Name Sector Name] with the station name left justified and sector name right justified.
For the the Fleet line [Fleet Name #OfShips].
We will have to make sure right click functionality and expandabilty works properly.
Please let me know if you need any additional information and I will participate in any testing or coding needed if requested.
RondoX4
Posts: 39
Joined: Thu, 30. Jun 22, 02:31
x4

Re: Thinned Station Columns Mod

Post by RondoX4 »

PS we will also need to make sure the sort functionality works correctly.
User avatar
ChemODun
Posts: 595
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Thinned Station Columns Mod

Post by ChemODun »

Ok.

I will try to describe somehow scope of work for you.
  1. Simple test what we already have, i.e. try to make JAMUI working.
    • Download it - I assume is done
    • Unpack zip locally
    • Create folder ui inside JAMUI
    • Move jamui_map.lua to ui
    • Create the ui.xml in JAMUI with content:

      Code: Select all

      <?xml version="1.0" encoding="UTF-8"?>
      <addon name="JAMUI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../core/coreaddon.xsd">
        <environment type="menus">
          <dependency name="ego_detailmonitor" />
          <dependency name="sn_mod_support_apis" />
          <file name="ui/jamui_map.lua" />
        </environment>
      </addon>
      
    • In addition, we have to fix call of Library from SN Mods API
      Replace the

      Code: Select all

      local Lib = require("extensions.sn_mod_support_apis.lua_library")
      
      with

      Code: Select all

      local Lib = require("extensions.sn_mod_support_apis.ui.Library")
      
  2. Then copy JAMUI folder in extensions of the game without subfolder md.
    I.e. in JAMUI under extensions has to be only

    Code: Select all

    t          
    ui         
    content.xml
    ui.xml     
    
  3. Then load game and when you will try to open your inventory - it has to show nothing
I.e. code now is working, but working wrong way.
Why - because it made for replace some Egosoft function by modified ones. And from the time of development this mod a lot of things in Egosoft UI (Lua) functions are changed.

So, next step - to make own your new mod, on first stage fully equal to original Egosoft functionality, but prepared for modification.

So, please be prepared and unpack ui folder from game catalog files.
Multiply entropy by absolute zero

Freedom in space
RondoX4
Posts: 39
Joined: Thu, 30. Jun 22, 02:31
x4

Re: Thinned Station Columns Mod

Post by RondoX4 »

Attempted to install modifications
(1) Resubscribed to SirNukes Mod Support APIs
(2) Redownloaded JAMUI
(3) Created folder in JAMUI named "ui" and move jamui_map.lua into it
(4) Created text file ui.xml and copied your content into it
(5) In the extensions file sn_mod_support_apis I noted the file ext_01.dat
It did not contain "local lib = required("extensions.sn_mod_support_apis.lua_library")"
however it did already have many "apis.ui.library"
(6) JAMUI ended up with (a) "t" folder [original to JAMUI] (b) "ui" folder [with the original jamui_map_lua]
(c) "content" labeled as type Microsoft Edge HTML Document (d) ui.xml
(7) copied JAMUI into extensions and turned it on

No change was noted
User avatar
ChemODun
Posts: 595
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Thinned Station Columns Mod

Post by ChemODun »

Excuse me for not clear message:

Code: Select all

In addition, we have to fix call of Library from SN Mods API
Replace the
I mean replacement of SN library call in ui/jamui_map.lua has to be fixed.
  • In addition, we have to in ui/jamui_map.lua fix the call of Library from SN Mods API
    Replace the

    Code: Select all

    local Lib = require("extensions.sn_mod_support_apis.lua_library")
    
    with

    Code: Select all

    local Lib = require("extensions.sn_mod_support_apis.ui.Library")
    
And please, if you want to do something with script and/or ui - always start a game with debug log.
It will significantly help you during development
Multiply entropy by absolute zero

Freedom in space
User avatar
ChemODun
Posts: 595
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Thinned Station Columns Mod

Post by ChemODun »

Next step preparing base for the new extension, compatible with latest game.

Unfortunately, in diAAerence with script languages and game resources, there is no possibility to use diAA files for the UI modding.
We have to replace at least some parts of source UI files written in Lus.
Fortunately, Lua give a possibility to make it more or less simple way.

For the preparing rows of a table with user owned objects used the menu.createPropertyRow function in file menu_map.lua.
And now we will try to make an extension which will have an equal copy of this function, but this function will work from an extension not from the Egosoft game resources.

As I wrote before - the unpacked ui folder from Egosoft catalogs with game resources is needed.
  • Let's assume the new extension will be named thin_columns.
  • So, let's make such folder somewhere.
    For editing game files I prefer a VS Code. Or you can use Notepad+, or any other editor, but not a word or wordpad.
  • So, let's make a content.xml file, which will inform a game that folder where it located - is extension folder.

    Code: Select all

    <?xml version="1.0" encoding="utf-8"?>
    <content id="thin_columns" name="Thin columns" description="Thin columns" author="Somebody" version="001" date="2025-12-10" save="0" enabled="1">
        <dependency id="ws_2042901274" name="SirNukes Mod Support APIs" version="195" optional="false"/>
    </content>
    
  • Our extension will strictly depend on SirNukes Mod Support APIs, which provide a simple way to access to MenuMap object.
  • As we have plans to modify ui - we have to create an ui.xml file in the same folder.

    Code: Select all

    <?xml version="1.0" encoding="UTF-8"?>
    <addon name="thin_columns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../core/coreaddon.xsd">
      <environment type="menus">
        <dependency name="ego_detailmonitor" />
        <dependency name="sn_mod_support_apis" />
        <file name="ui/thin_columns.lua" />
      </environment>
    </addon>
    
  • Then we need to make an ui subfolder.
  • And create in this subfolder a file thin_columns.lua
  • There is a base code for this file

    Code: Select all

    -- ffi setup
    local ffi = require("ffi")
    local C = ffi.C
    
    local L = {
        egoCreatePropertyRow = nil,
    }
    local Lib = require("extensions.sn_mod_support_apis.ui.Library")
    
    local menu = nil
    
    local function init()
    
        menu = Lib.Get_Egosoft_Menu("MapMenu")
    
        if not menu then
            DebugError("Thin columns - Could not find MapMenu, aborting UI modifications.")
            return
        end
    
        -- Functions that creates the Property Owned table row
        L.egoCreatePropertydRow = menu.createPropertyRow
        menu.createPropertyRow = L.createPropertyRow
    
        DebugError("Thin columns - MapMenu modifications applied.")
    end
    
    --
    -- place for code from map_menu.lua - begin
    --
    
    
    --
    -- place for code from map_menu.lua - end
    --
    
    init()
    
  • It makes next things
    • Establishes access to C function in our Lua code.
    • Prepare local object(table) for internal functions
    • Preparing local variable menu to access to MenuMap menu.
    • Make a local init function, which replaces original createPropertyRow with local L.createPropertyRow
    • Calling the init to make this replace.
  • Next - you need to take from original ui\addons\ego_detailmonitor\menu_map.lua:
    • The whole copy of local config and put it into the prepared place in file

      Code: Select all

      local config = {
      ...
      }
      
    • The whole copy of menu.createPropertyRow, placed after config and in extension file it has to be named L.createPropertyRow

      Code: Select all

      function L.createPropertyRow(frame, instance)
      ...
      end
      
  • Now everything looks prepared ...
  • So, copy the thin_columns with all created files into the extensions folder of a game, and start game with debug log.
  • Load the saved game and open "Property Owned" items. Everything should work like without the extension.
  • But in a log file has to be presented lines:

    Code: Select all

    [=ERROR=] ... Thin columns - MapMenu modifications applied.
    
Last edited by ChemODun on Fri, 12. Dec 25, 13:55, edited 4 times in total.
Multiply entropy by absolute zero

Freedom in space
User avatar
ChemODun
Posts: 595
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Thinned Station Columns Mod

Post by ChemODun »

And for sure - please went thru the [Index] X4: Foundations Tools, Tutorials and Resources !
Multiply entropy by absolute zero

Freedom in space
RondoX4
Posts: 39
Joined: Thu, 30. Jun 22, 02:31
x4

Re: Thinned Station Columns Mod

Post by RondoX4 »

Thanks for your efforts so far. Please keep in mind I am a novice at this and need detailed instructions about the creation of files and coding.
It looks like we are scrapping JAMUI. So far (1) created folder thin_columns (2) context.xml (3) ui.xml (4) subfolder ui and in the subfolder thin_columns.lua. For the xml files I have been initially creating text files and editing them with notepad++.
After that point it becomes unlear what to do next. I have looked around to find and unpack the ui folder from Egosoft Catalogs but unsuccessful. I am unsure where to place
ui\addons\ego_detailmonitor\menu_map.lua. Looks like it needs to go in the place you have in thin_columns.lua. Looks like a copy of some config file
goes in to a new file beginning with local config. And a whole copy of menu.createPropertyOwned placed in L.createPropertyOwned. Never loaded a game with a debug log or added the lines [=ERROR ...etc
Where is the actual code that changes the text to one line? Looks like we are getting there but I am fuzzy on file and coding details.
Please don't give on me. I can be quite persistent
User avatar
ChemODun
Posts: 595
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Thinned Station Columns Mod

Post by ChemODun »

  • No, the previous step with modification of original mod is important, to more or less understand how it works
  • Regarding unpacking - read the Getting Started: Tools, Scripting and Modding
  • Regarding config - it is not a config file, it is a variable definition in the ui\addons\ego_detailmonitor\menu_map.lua
  • The similar thing about menu.createPropertyRow - it is definition of function, which has to be fully copied into the new extension file, and slightly renamed
  • And we are a far away from one line working mod. It is basement.
  • How to get debug log - one of possible explanations.
  • If you have not a lot of knowledge about programming languages, and Lua itself - try to use the any AI, post him my instructions and ask to explain...
And one important point - I will not write a mod instead of you, otherwise it will be my mod. I can only guide you how it can be done. But it will require a lot of your own work with adopting the existing code to your needs.
Last edited by ChemODun on Thu, 11. Dec 25, 06:14, edited 1 time in total.
Multiply entropy by absolute zero

Freedom in space
RondoX4
Posts: 39
Joined: Thu, 30. Jun 22, 02:31
x4

Re: Thinned Station Columns Mod

Post by RondoX4 »

Thanks for being upfront with me.
I obviously underestimated the complexities of this project.
I have a feeling that you think this is a worthwhile mod and would not have helped me unless you thought so.
Even if I was able to get this mod running with your help it would still be YOUR mod.
I would insist that you take ownership and credit!
I REALY like this game and just want to make it better for myself and others.
If you want to write this mod that would be absolutely GREAT.
If you really don't want to invest the time are there other coders who would?
For now I will be reviewing Getting Started
User avatar
ChemODun
Posts: 595
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Thinned Station Columns Mod

Post by ChemODun »

Ok, motivation speech is not my strong side ...

I would prefer if you will try make this mod.

From my point of view - plus one mod maker is better than plus one mod ...

I'm understand - there is not an optimal way to study with such delay between question and answer...
But again - let's try to do it.

Despite this bug amount of data, which has to be added to the new mod, changes should be made only in this small part of code:

Code: Select all

function L.createPropertyRow(instance, ftable, component, iteration, commanderlocation, showmodules, hidesubordinates, numdisplayed, sorter)
...
			if isstation then
				-- station case
				local secondline = ""
				if displaylocation then
					secondline = locationtext
				end
				row[2]:setColSpan(4 + maxicons - #fleettypes - 1)
				local stationname = alertString .. Helper.convertColorToText(color) .. name .. "\27X"
				if isconstruction then
					stationname = stationname .. ColorText["text_inactive"] .. " (" .. ReadText(1001, 3217) .. ")\27X"
				end
				if alertMouseOver ~= "" then
					if mouseover ~= "" then
						mouseover = mouseover .. "\n\n"
					end
					mouseover = mouseover .. alertMouseOver
				end
				row[2]:createText(stationname .. "\n" .. secondline, { font = font, mouseOverText = mouseover })
...
end
P.S. And I made mistake, when stated the createPropertyOwned instead of createPropertyRow
Multiply entropy by absolute zero

Freedom in space
RondoX4
Posts: 39
Joined: Thu, 30. Jun 22, 02:31
x4

Re: Thinned Station Columns Mod

Post by RondoX4 »

Some progress made
(1) unpacted cat 1 - 9
(2) located local config = {
...
} in ui\addons\ego_detailmonitor\menu_map.lua which is "config variable - put all static setup here" which is line 40-62
(3)have not located menu.createPropertyOwned in the unpacked cat 1-9
noted comment internet search menu.createproperty owned was not a standard command and appeared to be user-created
(4) looked at debug info
RondoX4
Posts: 39
Joined: Thu, 30. Jun 22, 02:31
x4

Re: Thinned Station Columns Mod

Post by RondoX4 »

so your uup late also.
If you create this mod that would be awsome. Let me know if you actually attempt it. If you think of a way I could help let me know.
Maybe if there were a lesser more "novice" challenge I could do better with that.
RondoX4
Posts: 39
Joined: Thu, 30. Jun 22, 02:31
x4

Re: Thinned Station Columns Mod

Post by RondoX4 »

Tried to locate createpropertyrow without success.
I'll keep trying to work on the mod if your willing to help, still if I can manage you need to take credit.
User avatar
ChemODun
Posts: 595
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Thinned Station Columns Mod

Post by ChemODun »

Ok, good progress.

For me function menu.createPropertyRow is located at line 8358 in menu_map.lua
Multiply entropy by absolute zero

Freedom in space

Return to “X4: Foundations - Scripts and Modding”