Modding GUI


Element positioning

Position. Element's position is calculated for its upper left corner relative to its parent.

Orientation changes the basepoint when calculating the position of the element relative to its parent. By default, it's upper_left. Other options are:

How to center elements

Use old CSS hacks of half-size back:

instantTextBoxType = {
        name = "alice_readme_text"
        position = { -235 -180 }
        maxsize = { 460 160 }
        fixedsize = yes
        font = "Arial14"
        Orientation = "CENTER_DOWN"
    }

Scripting GUI

Scriptable buttons

Adding new buttons wouldn't mean much if you couldn't make them do things. To allow you to add custom button effects to the game, we have introduced two new ui element types: provinceScriptButtonType and nationScriptButtonType. These buttons are defined in the same way as a guiButtonType, except that they can be given additional allow and effect parameters. For example:

    provinceScriptButtonType = {
        name = "wololo_button"
        extends = "province_view_header"
        position = { x= 146 y = 3 }
        quadTextureSprite = "GFX_wololo"
        visible = {
            tag = USA
        }
        allow = {
            owner = { tag = FROM }
        }
        effect = {
            assimilate = "yes please"
        }
    }

    nationScriptButtonType = {
        name = "wololo_button"
        extends = "province_view_header"
        position = { x= 146 y = 3 }
        quadTextureSprite = "GFX_wololo"
        visible = {
            tag = USA
        }
        allow = {
            owner = { tag = FROM }
        }
        effect = {
            assimilate = "yes please"
        }
        ai_will_do = {
            always = yes
        }
    }

How does it work:

As a Modder, I want to mod scripted buttons, So that I add extra interactions to the game.

Acceptance Criteria:

Criteria Description
AC1 Allow trigger is parsed
AC2 Visible trigger is parsed
AC3 Effect is parsed
AC4 Ai_will_do block is parsed
AC5 AI takes national interactions

Toggleable windows

As a Modder, I want to mod buttons that toggle windows visibility, So that I add extra windows to the game.

Acceptance Criteria:

Criteria Description
AC1 uiscriptbuttontype elements can have toggle_ui_key with a name of UI variable
AC2 when clicking uiscriptbuttontype the associated UI variable is toggled True/False
AC3 windowType elements can have visible_ui_key with a name of UI variable
AC4 Window is shown only when UI variable in visible_ui_key is set to True
AC5 uiscriptbuttontype can have visible triggers
AC6 uiscriptbuttontype can have allow triggers
uiscriptbuttontype = {
        name = "starting_bonuses_button"
        position = { x=425 y = 700 }
        buttonText = "Starting Bonuses"
        buttonFont = "vic_18_black"
        spriteType = "GFX_button_standard_177"
        extends="topbar"
        toggle_ui_key = "starting_bonuses_window"
        visible = {
            OR = {
                NOT = { has_country_flag = starting_bonus_0_selected }
                NOT = { has_country_flag = starting_bonus_1_selected }
                NOT = { has_country_flag = starting_bonus_2_selected }
            }
        }
    }

  windowType = {
        name = "starting_bonuses_window"
        position = { x = 400 y = 150 }
        size = { x=310 y=600 }
        moveable = 1
        dontRender = ""
        horizontalBorder = "0"
        verticalBorder = ""
        fullScreen = no
        visible_ui_key = "starting_bonuses_window"

        extends="topbar"
...
}

Scriptable images with dynamic frames through datamodels

As a Modder, I want to mod in icons that have dynamic frames, So that I add extra consistency to the UI.

Acceptance Criteria:

Criteria Description
AC1 GUI elements can have datamodel with one of the datamodel options
AC2 Datamodel can be state_religion
AC3 When a supper element has datamodel="state_religion", it always displays the state religion of the player
AC4 uiscriptbuttontype can have a datamodel
AC5 iconType can have a datamodel
uiscriptbuttontype = {
        name = "religion_button"
        position = { x=485 y = 5 }
        spriteType = "GFX_icon_religion"
        extends="topbar"
        datamodel = "state_religion"
        toggle_ui_key = "religion_window"
    }