CampaignUI
The CampaignUI
script object is created automatically when the campaign UI loads, and offers a suite a functions that allow scripts to query and customise bits of the UI. It does not need to be created by script, and the functions it provides may be called directly on the object in the following form.
Example:
CampaignUI.<function_name>(<args>)
Loaded in Campaign | |
Loaded in Battle | |
Loaded in Frontend |
-
CampaignUI.ZoomToSmooth(
x
number
,
y
number
,
horizontal distance
[number
],
bearing
[number
],
vertical distance
[number
]
) -
Zooms the game camera to the specified display co-ordinates using smooth movement. x and y must be provided. If no bearing and distance values are provided then the current camera bearing and distance values are used.
Parameters:
1
x display position.
2
y display position.
3
optional, default value=nil
Horizontal distance from camera to camera target.
4
optional, default value=nil
Bearing in radians from camera to camera target.
5
optional, default value=nil
Vertical distance from camera to camera target.
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 342
-
CampaignUI.ClosePanel(
panel namestring
)
-
Closes an open UI panel by name.
Parameters:
1
panel name
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 385
-
CampaignUI.ToggleScreenCover(
enable coverboolean
)
-
Creates or destroys a black screen cover (when not eyefinity).
Parameters:
1
enable cover
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 400
-
CampaignUI.ToggleCinematicBorders(
enable bordersboolean
)
-
Creates or destroys top and bottom cinematic borders.
Parameters:
1
enable borders
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 439
-
CampaignUI.ShowVictoryScreen([
is victoryboolean
], [
can continueboolean
], [
mission keystring
])
-
Shows the campaign victory screen, optionally corresponding to a specified mission. All three arguments must be specified, or none can be specified.
Parameters:
1
optional, default value=
nil
is victory
2
optional, default value=
nil
can continue
3
optional, default value=
nil
mission key
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 454
-
CampaignUI.ClearSelection()
-
Clears the current ui selection, ensuring that no settlements or characters are selected by the player.
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 486
-
CampaignUI.UpdateSettlementEffectIcons()
-
Updates any settlement effect icons on the campaign interface. This should be called after the script does anything that might modify settlement effects.
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 495
-
CampaignUI.QuitToWindows()
-
Exits the game. This is used for autotesting.
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 510
-
CampaignUI.SetOverlayVisible(
activate overlayboolean
)
-
Sets the campaign overlay to be visible or not. The campaign overlay colourises regions on the campaign map display for various purposes (it is used by the tactical map, for example). The overlay mode to display, and what regions to display it on, should be set with
CampaignUI.SetOverlayMode
before activating the overlay with this function.Parameters:
1
activate overlay
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 530
-
CampaignUI.SetOverlayMode(
overlay modenumber
,
overlay mode masknumber
, ...
region(s))
-
Sets the overlay mode to display by numeric id with a mode mask, and one or more regions to display it across by region key. Multiple region keys may be specified with separate arguments. Calling this function has no effect until the overlay is subsequently enabled with
CampaignUI.SetOverlayVisible
.
Valid overlay mode ids:
overlay mode id description
0
DIPLOMACY_STATUS
1
DIPLOMACY_ATTITUDE_FACTION
2
DIPLOMACY_ATTITUDE_OWNER
3
RADAR
4
HISTORICAL_OWNERSHIP
5
REGION_GROWTH
6
REGION_HAPPINESS
7
REGION_SLAVES
8
REGION_FOOD
9
REGION_CORRUPTION
10
WINDS_OF_MAGIC
11
CLIMATE_SUITABILITY
12
GEOMATIC_WEB
13
TUTORIAL_REGION_HIGHLIGHT
14
ATTRITION_FOR_SELECTED_CHARACTER
Parameters:
1
Overlay mode (see lookup table above).
2
The mode mask, which can specify additional information about the overlay mode in certain circumstances. Where no special mode mask is required (i.e. most circumstances) the value
0
should be supplied here.When showing the corruption overlay, this value specifies a corruption type (in order within the
corruption_types
table). When showing the happiness overlay, supplying a value other than 0 shows happiness trending rather than current happiness.3
...
One or more
string
region keysReturns:
nil
Example:
CampaignUI.SetOverlayMode(5, 0, lothern_region_str, glittering_tower_region_str, tower_of_lysean_region_str)
CampaignUI.SetOverlayVisible(true)
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 549
-
CampaignUI.SuppressAllEventTypesInUI(
enable suppressionboolean
)
-
Enables or disables a suppression lock that prevents any event messages being shown on the UI. Once the lock is enabled, individual event types may be whitelisted for display with
CampaignUI.WhiteListEventTypeInUI
, at which point they will bypass the suppression.Parameters:
1
enable suppression
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 626
-
CampaignUI.WhiteListEventTypeInUI(
event typestring
)
-
Whitelists an event type to bypass suppression activated by
CampaignUI.SuppressAllEventTypesInUI
. Event types to be whitelisted are specified by a compound key from theevent_feed_targeted_events
table - the key must be specified by concatenating theevent
andtarget>
field values for a given record from that table. Currently valid examples might include"faction_event_mission_issuedevent_feed_target_mission_faction"
or"scripted_persistent_located_eventevent_feed_target_faction"
. Whitelisting an event type has no effect if suppression has not been enabled.Parameters:
1
event type
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 645
-
CampaignUI.DoesEventTypeExist(
event typestring
)
-
Returns whether or not an event of the specified type exists in the display queue (i.e. is being displayed or is pending to be displayed). Event types are specified by a compound key from the
event_feed_targeted_events
table - the key must be specified by concatenating theevent
andtarget>
field values for a given record from that table.Parameters:
1
event type
Returns:
event type existsboolean
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 666
-
CampaignUI.DoesEventTypeRequireResponse(
event typestring
)
-
Returns whether or not an event of the specified type exists in the display queue (i.e. is being displayed or is pending to be displayed) and requires a response. Event types are specified by a compound key from the
event_feed_targeted_events
table - the key must be specified by concatenating theevent
andtarget>
field values for a given record from that table.
This is of most use for testing if a dilemma is currently active.Parameters:
1
event type
Returns:
event type requires responseboolean
Example:
if CampaignUI.DoesEventTypeRequireResponse("faction_event_dilemmaevent_feed_target_dilemma_faction") then
out("dilemma is open")
end
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 688
-
CampaignUI.TriggerIncident(
incident keystring
)
-
Triggers an incident for the local player, specified by incident key. If called on one machine in a multiplayer game this will trigger the incident on all machines - as such, it can be called in script that is triggered from a UI event in a multiplayer game.
Parameters:
1
incident key
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 717
-
CampaignUI.TriggerCampaignScriptEvent([
faction cqinumber
], [
event idstring
])
-
Allows the script running on one machine in a multiplayer game to cause a scripted event,
UITrigger
, to be triggered on all machines in that game. By listening for this event, scripts on all machines in a multiplayer game can therefore respond to a UI event occuring on just one of those machines.
An optional string event id and number faction cqi may be specified. If specified, these values are passed from the triggering script through to all listening scripts, using the context objects supplied with the events. The event id may be accessed by listening scripts by calling<context>:trigger()
on the supplied context object, and can be used to identify the script event being triggered. The faction cqi may be accessed by calling<context>:faction_cqi()
on the context object, and can be used to identify a faction associated with the event. Both must be specified, or neither.Parameters:
1
optional, default value=nil
faction cqi
2
optional, default value=nil
event id
Returns:
nil
Example:
core:add_listener(
"test",
"UITrigger",
true,
function(context)
out("* UITrigger received, id: " .. tostring(context:trigger()) .. ", faction cqi: " .. tostring(context:faction_cqi()))
end,
true
)
// later, perhaps on a different machine:
CampaignUI.TriggerCampaignScriptEvent(123, "test_event")
* UITrigger received, id: test_event, faction cqi: 123
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 741
-
CampaignUI.AddBuildingChainToWhitelist(
building chain keystring
)
-
Adds building chains to whitelist.
Parameters:
1
building chain key
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 783
-
CampaignUI.ClearBuildingChainWhitelist()
-
Clears the building chain whitelist.
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 802
-
CampaignUI.AddUnitToBlacklist(
main unit record keystring
)
-
Adds a unit to the blacklist
Parameters:
1
main unit record key
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 816
-
CampaignUI.ClearUnitBlacklist()
-
Clears the unit blacklist.
Returns:
nil
defined in ../../common/UIDll/Source/Campaign/CampaignUIScriptInterface.cpp, line 835
-
CampaignUI.IsMinimalViewModeEnabled()
-
Returns true if campaign_minimal_view_mode enabled (set in userscript to speed up campaign loading)
Returns:
is_campaign_minimal_view_mode_enabledboolean
defined in ../../common/UIDll/Source/Campaign/EmpireCampaignUI.cpp, line 802