UI Modding Questions

How can we make a blank window and add stuff into it? Also, how can we make something like with text when you click somewhere? Like Develop New Game or Game History for example.

Right, I’ll give you an example. In just a second.

You’re going to have to use <divs>. I honestly copied these lines from the Expansion Pack Mod, hoping that no-one got pissed :stuck_out_tongue: But I’ve learnt it now.

How to make a div:

    var div = $("#resources"); 
div.append('<div id="politicsDiv" class="windowBorder tallWindow" style="overflow:auto;display:none;"> <div id="politicsDivTitle" class="windowTitle smallerWindowTitle">Politics</div><h2>Coming soon!</h2></div>');

Inside the div you can use HTML. Thats why its easy to use divs.

How to add a button to open the div: (Thanks @Darkly :P)

oriShowMenu = UI.showContextMenu;
        var myShowMenu = function(items, mouseloc) {
            items.push({ 
                    label: "Poltics...", 
                    action: function () { 
                        Sound.click(); 
                        GameManager.resume(true); 
                        var div = $("#politicsDiv"); 
                        div.scrollTop(); 

                        div.gdDialog({ 
                            popout: !0, 
                            close: !0
                        }); 
                    } 
            });
            oriShowMenu(items, mouseloc);
        }
        UI.showContextMenu = myShowMenu

So, do I have to change anything here? Except Label etc

You’re gonna have to change all the strings, basically. But not really. Just go-over real quick, I think I forgot a few semicolons.

And this makes a button in the menu like Develop New game and when it’s clicked it opens an empty box, right?

Yes. But dont just copy the code, go over the code so that you understand it.

1 Like

Yeah doing this now. Don’t disconnect I will have questions.

I will only answer your questions if you give me credits in your mod :stuck_out_tongue:

Just kidding, but it would be nice!

1 Like

Question 1: Is this a custom name thing? I mean, did you define it with this name? oriShowMenu

OFC I will, but I need to resolve this first.

oriShowMenu is a copy of the class ShowContextMenu, so yes.

I will test it, wait.

Works fine.
And I have 2 more bugs to fix, wanna look at them?

Sure, send me a PM. I’m writing this on a bill, you know.

Any tips on making buttons or sliders?

Add a JavaScript script inside the HTML and add a button that way.

And how do we do dat? :3

There is a reason Google was created. Also, try to learn normal JavaScript before coding all this. Its okay that you want to be part of the modders, but those have tons of experience. (I dont)

I know javascript, but what do you mean when you want to add a button.

Like, how? Will I need to see the game’s code for this?

You use JavaScript to add a button, and you clearly dont know JavaScript properly when you ask that.

1 Like