Overview
For all those of you struggling with GUI modding in HOI IV, struggle no longer. In this guide I will explain the basic components of gui modding, such as the interface, scripted guis, scripted localilsation and localisation.
Getting Started
If you have the debug mode active, you will receive messages that show you how and where you made mistakes when you start the game or reload files.
1 – Right click on Hoi IV in the Steam Library
2 – Select “Properties”
3 – Under “GENERALl”, press “SET LAUNCH OPTIONS”
4 – Write “-debug” and then press OK
Next, you will want to create your own mod to test what you do.
1 – Start the game client
2 – Go to “Mods”
3 – Press “Mod Tools”
4 – Press “Create Mod”
5 – Add title, directory (what your mod folder will be called) and mod tags
6 – Open “DocumentsParadox InteractiveHearts of Iron IVmoddirectory
As I am using the CAT as an example, it might be useful to take it as a template for your mod.
To find it after downloading, go to “C:Program Files (x86)SteamSteamAppsworkshopcontent and search for “cat”.
Copy and paste it into your mod folder.
These are the folders that you need for basic gui modding. Depending on what you want to do you might need more at some point.
- commonscripted_guis
- commonscripted_localisation
- interface
- localisation
If you already have a little experience with modding, I suggest you first do the following before you start working on your mod:
– Make a clear summary of the functions your mod should have
– Decide on the components of your mod, assign buttons to functions…
– Decide on a layout and make a quick sketch of it
Interface
GUI Modding always starts with the interface, it will be the bread and butter of your mod. However, keep in mind that you will not see any window unless the conditions that you write in scripted_guis are met.
In here go all different Windows
All items within the parentheses of the container window can be seen as one unit.
- name: Must be different for each container, duplicates are ignored.
- orientation: Where the object is located initially. Use: LOWER_RIGHT, LOWER_LEFT, UPPER_RIGHT, UPPER_LEFT, CENTER, CENTER_RIGHT, CENTER_LEFT
- origo: Which part of the window will be seen as the “origin”. Use: lower_right, lower_left, upper_right, upper_left, center, center_right, center_left
Example: A combination of orientation = CENTER and origo = lower_left will result in the bottom left corner of the window being at the center of the screen. - position: Location of an item relative from the orientation. Higher x means further right, higher y means lower. You can also use negative numbers.
- size: How big the container is. Try to adjust it to your background.
- fade_time: How quickly the container appears.
- fade_type: Must be defined so that the fade_time actually has an effect. Maybe there are types other than linear, I haven’t found any so far.
- show_sound: The sound that is heard when the window opens.
- moveable: Define whether the player should be able to move the window or not.
A background could be defined as a background.
- name: Must be different for each item in the container, duplicates are ingored. Items in different containers can share names without errors.
- spriteType: What the background looks like. You can also use quadTextureSprite, they are interchangeable most of the time.
Buttons are things you can press.
- name: Same as before.
- quadTextureSprite: What the button looks like.
- position: Where the button is positioned relative to the window, use orientation to change anchor point.
- shortcut: The keyboard keys that can be used for this button.
- pdx_tooltip: The tooltip that is shown when hovering over the button.
- clicksound: Sound that is made when button is pressed.
- oversound: The sound that is made when hovering over the button…?
- scale: Makes the button bigger or smaller.
You can write text into text boxes.
- name: Same as before.
- position: Same as before.
- text: Write whatever you want. Colouring (e.g. §G) and the like do not work here. Instead, define the text via loclization. You can also put the text in [brackets] to combine it with scripted localization.
- maxWidth: How long the text can be until it jumps to a new line.
- maxHeight: I don’t really know what this does, it never changed anything for me.
- format: Choose the anchor point of the text. If you use scripted localization, I recommend using format = center as the text length and thus the positioning of the text can change with other formats.
- alwaystransparent: Keep this activated so that the (invisible) text background doesn’t cover the buttons. Covered button areas show no tooltip.
- font: The text corresponds to the font type, the number to the font size.
Here is a list of all the fonts that I have found:- loadscreen_header (huge)
- loadscreen_tip (very large)
- cg_16b
- cg_18b
- garamond_12
- garamond_14
- garamond_14_bold
- hoi_16mbs
- hoi_18mbs (default)
- hoi_18 = hoi_18b
- hoi_20b = hoi_20bs
- hoi_33
- hoi_22tech
- hoi_24header
- hoi_30header
- hoi_36header
- hoi_arrow_font
- hoi4_typewriter16
- hoi4_typewriter22
- standard_18
- standard_22
Don’t forget to close off with parentheses at the end.
Scripted GUIs
Now that we have built the base, it is time to move to scripted guis, the heart of your mod. This is where all the effects and triggers are located.
All different gui codes go in here.
- cat_main_container: Name of the script, duplicates are ignored.
- context_type: What the initial target of the script will be. Use select_country_context or select_state_context. (Maybe there are more, I don’t know.) More to this later.
- window_name: The window that this script should apply to.
- visible: Define here under what conditions the window mentioned above should be visible.
- effects: All effects must go in here.
- cat_army_button_on_click: The name of the button of which you want to specify the effects. Do not forget to add _click at the end. Depending on whether your selected context is that of countries or that of states, the scope of this effect change.
Example: You have a text box that displays the name of the unit that you have clicked on in-game. You have selected the state “Brandenburg”, which is owned by Germany, in-game.
If you use the selected_country_context, the name displayed will be “Germany”.
If you use the selected_state_context, the name displayed will be “Brandenburg”. - triggers: Define here when which buttons or text boxes should be visible, invisible, available or unavailable.
- cat_army_button_on_visible: By adding _visible, define here under what circumstances your item should be visible (invisible also means unavailable).
- cat_annex_click_enabled: By adding _click_enabled, define here under what circumstances the player should be able to use this button.
If you have a box that can be checked like this one, you need to do the following:
Add an effect to the unchecked box (left) so that it sets a country or global flag on click.
Make the unchecked box only visible when the specified flag from earlier is not set.
Add an effect to the checked (right) box so that it clears the specified flag on click.
Make the checked box only visible when the specified flag is set.
Scripted Localisation
Now that we have built the base, it is time to move to scripted guis, the heart of your mod. This is where all the effects and triggers are located.
- defined_text: Everything within these parentheses is one unit of defined text.
- name: The localization key that has been added in the interface file.
- text: A text that appears under certain conditions.
- trigger: Defines under which circumstances the text should appear.
- localization_key: What the text should say. Has to be defined in a localization file.
- Leaving out the trigger of one text makes it so that it appears only when the other texts are invisible.
Localisation
english: Makes the file belong to the specified language. Also needs to be specified in the title of the file.
CAT_OPEN:0 One of the texts defined in scripted_localisation.
CAT_ARMY:0 One of the texts defined in the interface file.
(What I have found so far)
- §H[Text]§! Highlighted Text (Yellow)
- §G[Text]§! Green Text
- §Y[Text]§! Yellow Text
- §B[Text]§! Blue Text
- §R[Text]§! Red Text
- £trigger_yes Green Check Mark
- £trigger_no Red Cross
Last Advice
Snuff around in the game files to find the items that you need. Have a look at the gfx and gui files in interface.
Now all that is left is trial and error. Good luck!