Results 1 to 11 of 11

Thread: Is it possible to add UI elements?

  1. #1

    Default Is it possible to add UI elements?

    I have never modded in my life. I want to add a couple of utility UI elements to the Province floating list:
    • number of empty slots, upgradable buildings or tearable slums
    • predicted food and public order for the next turns depending on undergoing constructions

    I've checked out the TW wiki entry for modding but there doesn't seem to be many resources to learn it. The most extense collection seems to be a YouTube series by Magnar, but there isn't a single episode on UI modding.

    I thought what I want would actually be impossible because as far as I can tell when I open a .pack file with the PFM all I can do is tweak values from the database. But I noticed a lua folder so I assume you can do some scripting, which of course opens up a lot of possibilities.

    Although I can see many twcenter subforums dedicated to different aspects of modding I can't really find a modding guide to help beginners start from scratch. I'd appreciate some help because I am a bit in the dark here, don't know where to start for this particular mod.


    Can anyone help me out with this?

    • is the mod I want doable?
    • any good UI modding guide?

  2. #2
    Commissar Caligula_'s Avatar The Ecstasy of Potatoes
    Join Date
    Dec 2013
    Location
    The alcoves in the Koningin Astridpark
    Posts
    5,876

    Default Re: Is it possible to add UI elements?

    Probably, but it'd require heaps of scripting.
    I'd suggest asking the Divide et Impera team, People Of Rome 2 team, or Hardballer since they're the only ones I know of who have done stuff like this.



  3. #3

    Default Re: Is it possible to add UI elements?

    Thank you! Hopefully they can help me out.

  4. #4

    Default Re: Is it possible to add UI elements?

    Quote Originally Posted by kpagcha View Post
    Thank you! Hopefully they can help me out.
    Did they help you out?

    I am also looking to add/edit the game's UI.

  5. #5
    Jake Armitage's Avatar Artifex
    Patrician

    Join Date
    Apr 2011
    Location
    apartment 6
    Posts
    4,694

    Default Re: Is it possible to add UI elements?

    What you want to do?
    There is a way to overwrite some UI's text depending on what kind of button they are (not every button is moddable, most of them is hardcoded afaik)
    PS. images and script are not related, images are old ones just to give you an example
    Spoiler Alert, click show to read: 


    This is part of the script I'm doing with ivanpera for your people trust overhaul.
    Does it mean something to you or you're completely "ignorant" about these kind of things?
    Code:
    -- ###------------------------- START *******
    -- TOOLTIPS ---------------------------------------------------------------------
    -- ###-------------------------
    
    local function AeF_03_econ_DisplayTooltip(context)
    
        -- *** BASE COLOR
        local color1 = "";
        local color2 = "";
        local color3 = "";
        local color4 = "";
    
        -- *** CHANGE VANILLA UI TOOLTIP
        if context.string == "tab_regions"
        then
            local tt_text = UIComponent(context.component):GetTooltipText();
            local string1 = "Provinces";
            local string2 = "Fides Oeconomicae";
    
            -- *** CHANGE COLORS
            if string.find(tt_text, string1) or string.find(tt_text, string2) or tt_text == ""
            then
                local length = #TRUST_LEVEL_THRESHOLDS;
                done1 = false; done2 = false;
                for i = 1, length do
                    if (AeF_03_econ_trust <= TRUST_LEVEL_THRESHOLDS[i] or i == length) and done1 == false
                    then
                        color1 = COLOR1_TABLE[i];
                        color2 = COLOR2_TABLE[i];
                        done1 = true;
                    end
                if (old_trust <= TRUST_LEVEL_THRESHOLDS[i] or i == length) and done2 == false
                then
                    color3 = COLOR1_TABLE[i];
                    color4 = COLOR2_TABLE[i];
                    done2 = true;
                end
                if done1 and done2
                then
                    break;
                end
            end
    
            -- *** SET TOOLTIP
            local index = #TRUST_LEVEL_THRESHOLDS
            local trust_max = TRUST_LEVEL_THRESHOLDS[index]
            local ratio = math.ceil(old_trust/trust_max*100);
            local component = UIComponent(context.component):Id();
            UIComponent(context.component):SetTooltipText(WHITE..
                                                        "CURRENT\nFides Oeconomicae :\n"..
                                                        color1..AeF_03_econ_trust..WHITE.."/"..trust_max..
                                                        "\n\nPREVIOUS\nFides Oeconomicae :\n "..
                                                        color3..old_trust..WHITE.."/"..trust_max..
                                                        " "..LINE1..trust_tooltip.."");
            end
        end
    end
    
    -- ###---------------------------------- END*
    Last edited by Jake Armitage; February 16, 2019 at 09:42 AM.

  6. #6

    Default Re: Is it possible to add UI elements?

    Thanks for the replies, Jake.

    The first thing I want to try is increasing the size of the Rome 2 building icon slots so that they're larger than Attila's on the regions panel.

    The second thing is to change the city bar to display population size from the People of Rome 2 Mod.

  7. #7
    Daruwind's Avatar Citizen
    Join Date
    Oct 2013
    Location
    Prague
    Posts
    2,898

    Default Re: Is it possible to add UI elements?

    Quote Originally Posted by RJC View Post
    Thanks for the replies, Jake.

    The first thing I want to try is increasing the size of the Rome 2 building icon slots so that they're larger than Attila's on the regions panel.

    The second thing is to change the city bar to display population size from the People of Rome 2 Mod.
    Both things doable even in hardcoded UI but it would be pain in the ass and you would need a lot of time to bugfix and bughunt everything. I would recommend doing second part via script as Jake suggested, DeI and others have a lot experience with that, it is pretty easy and working well.

    Things like city espionage, sabotaging buildings...all these are using the same building icons. If you start changing size, all these will fall apart as well. Another problem is, increasing UI in width is okayish, increasing in height is way more complicated. If you look at settlement , it consists of multiple objects drawn a top each other, each line, shading, bar, bar borders, bar progress, background pictures, background shading..all possible transition between provincies with different number of settlements, ... We are speaking about dozens and dozens of parameters for building slots, settlements, panel..All parameters are hardcoded, if you increase size of building icons, everything falls appart. I was unable to locate all parameters for change position of all parts... Now I was playing only with building slots but if you plan to later icons, you will have to find much more elements...

    Warhammers are using improved UI, but while Whs are very dynamic, most parts auto adjust with adding new slots for settlements, there is nothing like this for Rome 2. Everything is set in stone and would require manual change.

    The best result with height experimenting was
    Spoiler Alert, click show to read: 

    that is pretty bad when you compare my result with width...where i was able to align things nicely..
    Spoiler Alert, click show to read: 


    This is result of a few years of hex editing. With a few hundrers hex bits edits...
    Last edited by Daruwind; March 02, 2019 at 03:18 AM.
    DMR: (R2) (Attila) (ToB) (Wh1/2) (3K) (Troy)

  8. #8

    Icon14 Re: Is it possible to add UI elements?

    Both things doable
    Excellent!

    it would be pain in the ass and you would need a lot of time to bugfix and bughunt everything.
    Don't care.

    I would recommend doing second part via script as Jake suggested, DeI and others have a lot experience with that, it is pretty easy and working well.
    Ok, just my own .lua script or one of those compressed luas with no file extension?

    The best result with height experimenting
    Could you show me the code you used for that, please?

    Thanks for the help!

  9. #9
    Daruwind's Avatar Citizen
    Join Date
    Oct 2013
    Location
    Prague
    Posts
    2,898

    Default Re: Is it possible to add UI elements?

    Quote Originally Posted by RJC View Post
    Excellent!

    Don't care.

    Ok, just my own .lua script or one of those compressed luas with no file extension?

    Could you show me the code you used for that, please?

    Thanks for the help!
    Jack wrote the example for lua script. Iīm not using script for my stuff.

    Work in progress. No. (mainly because there is nothing like code for me, just lots and lots of manula changes I found through years. Iīm making direct hex editing of game files. And because my goal is different, I donīt experiment much with every parameter, only with those related to my stuff. Donīt take it personally but i had a few people willing to help me during years. Nobody does. So Iīm basically no more wasting times on random people..)

    Start with data_rome2.pack and inspect UI section. Use tools like total commander, PFM, hex editor for example https://hexed.it/ for small work.
    Last edited by Daruwind; March 03, 2019 at 09:01 AM.
    DMR: (R2) (Attila) (ToB) (Wh1/2) (3K) (Troy)

  10. #10

    Default Re: Is it possible to add UI elements?

    Hi Daruwind,

    I figured out how to change the icon/slot sizes, i.e. replace the '38 00 00 00 38' hex values in ui/campaign ui/buildingframe. I made them '6C 00 00 00 4C' like Attila's for now, but gonna make them even bigger.

    It would save me so much time if you could tell me how you expanded the settlement panel. Please, pretty please?

  11. #11
    Benjin's Avatar Artifex
    Join Date
    May 2015
    Location
    London, UK
    Posts
    377

    Default Re: Is it possible to add UI elements?

    Oh damn, really? That would be really interesting for my Attila-Style Building Icons mod - actually making the icon/slot sizes match Attila's (or even bigger) to more properly see what the icons are showing.
    3D ARTIST (MODELS/TEXTURES), ANIMATOR, RIGGER

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •