-
Notifications
You must be signed in to change notification settings - Fork 17
Stylized Journal Progress Bars
With this part of the Community Mod Framework, journal entry progress bars can be given styling to show 'drift' and target values.
These styles are entirely optional and do not replace base game or previous CMF progress bar styles. They can also be used with both the International Situations and International Organizations Frameworks.
Most of the complexity is masked behind tailored and documented scripted effects. A full list of them can be found below in the script docs.
To use the styled progress bars, first add this widget to your journal entry:
widget = {
gui = "gui/com_journal_injects/injects.gui"
name = "com_journal_entry_progress_bars"
container = "com_custom_widget_container_scripted_progress_bars"
}
Each progress bar in a journal entry can be styled separately, and most stylings are independently settable
- Each bar is identified by its id, which can be any localization key
- If multiple countries have the same journal entry active, each bar is considered a separate entity
To set up a progress bar with custom styling, there is a basic initialization and four more complete versions:
- initialize_com_progress_bar initializes the progress bar as available for styling.
- create_com_progress_bar initializes the progress bar and sets its color.
- create_com_progress_bar_with_drift initializes the progress bar, sets its color, and sets the color and value of the 'drift' effect.
- create_com_progress_bar_with_target initializes the progress bar, sets its color, and sets the style and value of the target effect.
- create_com_progress_bar_with_both initializes the progress bar, sets its color, and sets up both the drift and target effect.
NOTE If a progress bar has already been initialized, any of the other creation effects work as expected, and do not reset anything other than specified.
All effects and triggers and lists from the script docs can be used from any context.
For other effects and triggers, use the wrappers run_in_com_progress_bar_scope and test_in_com_progress_bar_scope.
For example, to set a custom icon, you can use the following format:
run_in_com_progress_bar_scope = {
progress_bar = <progress_bar_id>
effect = "set_ideology = ideology:<custom_ideology_name>"
}
The progress bar drift and target each require an associated script value. The drift script value should generally match the value of the scripted progress, plus the current value of the progress bar. Note that the final value must be in the range 0-1, so it should be divided by bar max value - bar min value.
The target script value can be set to match the current value, replicating base game behavior, or it be set to a static or dynamic value to create a visual target for the bar to approach. This value is also in the range 0-1.
The progress bar and the drift style can be given one of five colors, default/blue, bad/red, green, gold, and white, or made blank with transparent.
The progress bar can be given visual level indicators, similar to the levels of legitimacy, liberty desire, or power bloc cohesion. The number of levels is dynamically changeable, and additionally the highlighting effect for the current level can be set or removed.
There is an example journal entry which was used for testing in the Community Mod Framework.
This journal entry can be found here.
Use the effect add_journal_entry = { type = je_com_progress_in_style } to activate the entry
These are following effects and triggers available to use for styling progress bars:
- save_com_progress_bar_scope
- run_in_com_progress_bar_scope
- initialize_com_progress_bar
- create_com_progress_bar
- create_com_progress_bar_with_drift
- create_com_progress_bar_with_target
- create_com_progress_bar_with_both
- remove_com_progress_bar
- set_com_progress_bar_color
- remove_com_progress_bar_color
- set_com_progress_bar_drift
- remove_com_progress_bar_drift
- set_com_progress_bar_target
- remove_com_progress_bar_target
- set_com_progress_bar_levels
- remove_com_progress_bar_levels
- set_com_progress_bar_level_highlight
- remove_com_progress_bar_level_highlight
- hide_com_progress_bar
- unhide_com_progress_bar
- com_debug_progress_bar
Most effects require a parameter progress_bar, which is the localization key used to initialize the progress bar
Set an initialized progress bar as an accessible scope. All effects below automatically do this. This allows using effects and triggers in 'scope:com_$progress_bar$' outside the event chain.
Parameters:
-
progress_barlocalization key identifier of the progress_bar
A wrapper effect to easily run an effect inside 'scope:com_$progress_bar$'
Parameters:
-
progress_barname localization key of progress bar -
effecteffect or series of effects to be run inside 'scope:com_$progress_bar$'
This is the basic initialization effect to set up a progress bar for styling.
This effect has to be run inside a scope where 'scope:journal_entry' is available! Typically, this in the immediate block.
THIS DOES NOT REPLACE THE BASE GAME SETUP!
Parameters:
-
progress_barlocalization key identifier of progress bar -
index0-indexed position of the progress bar in the journal, first scripted progress bar in the journal entry is 0, second is 1, and so on.
Extension of initialize_com_progress_bar that also sets the color of the progress bar.
This effect has to be run inside a scope where 'scope:journal_entry' is available! Typically, this in the immediate block.
THIS DOES NOT REPLACE THE BASE GAME SETUP!
Parameters:
-
progress_barlocalization key identifier of progress bar -
index0-indexed position of the progress bar in the journal -
colorcolor of base bar, valid colors aredefault/blue,bad/red,green,gold, andwhite, ortransparent
Extension of initialize_com_progress_bar that also sets the color and drift style of the progress bar.
This effect has to be run inside a scope where 'scope:journal_entry' is available! Typically, this in the immediate block.
THIS DOES NOT REPLACE THE BASE GAME SETUP!
Parameters:
-
progress_barlocalization key identifier of progress bar -
index0-indexed position of the progress bar in the journal -
colorcolor of base bar, valid colors aredefault/blue,bad/red,green,gold, andwhite, ortransparent -
bar_increase_colorcolor of drift bar when increasing, same valid colors as the base -
bar_decrease_colorcolor of drift bar when decreasing, same valid colors as the base -
drift_valuea 0-1 script value key which sets the size and direction of the drift
Extension of initialize_com_progress_bar that also sets the color and target style of the progress bar.
This effect has to be run inside a scope where 'scope:journal_entry' is available! Typically, this in the immediate block.
THIS DOES NOT REPLACE THE BASE GAME SETUP!
Parameters:
-
progress_barlocalization key identifier of progress bar -
index0-indexed position of the progress bar in the journal -
colorcolor of base bar, valid colors aredefault/blue,bad/red,green,gold, andwhite, ortransparent -
target_type= icon type for target value, valid values arejournal_icon,gold_marker,gold_bar, and"color"_line, where "color" is any of the valid colors -
target_value= a 0-1 script value key which sets the position of the target
Extension of initialize_com_progress_bar that also sets the color, drift effect, and target style of the progress bar
This effect has to be run inside a scope where 'scope:journal_entry' is available! Typically, this in the immediate block.
THIS DOES NOT REPLACE THE BASE GAME SETUP!
Parameters:
-
progress_barlocalization key identifier of progress bar -
index0-indexed position of the progress bar in the journal -
colorcolor of base bar, valid colors aredefault/blue,bad/red,green,gold, andwhite, ortransparent -
bar_increase_colorcolor of drift bar when increasing, same valid colors as the base -
bar_decrease_colorcolor of drift bar when decreasing, same valid colors as the base -
drift_valuea 0-1 script value key which sets the size and direction of the drift -
target_type= icon type for target value, valid values arecustom_icon,journal_icon,gold_marker,gold_bar, and"color"_line, where "color" is any of the valid colors -
target_value= a 0-1 script value key which sets the position of the target
Clean up effect that also removes any styling. This effect should be run when the journal entry concludes. Parameters:
-
progress_barlocalization key identifier of progress bar
Sets the color of the progress bar.
Parameters:
-
progress_barlocalization key identifier of progress bar -
colorcolor of bar, valid colors aredefault/blue,bad/red,green,gold, andwhite, ortransparent -
sidewhich side to color, 'left' or 'right'
Unsets the color of the progress bar, i.e. returns it to base game color
Parameters:
-
progress_barlocalization key identifier of progress bar
Sets the drift style of the progress bar.
Parameters:
-
progress_barlocalization key identifier of progress bar -
bar_increase_colorcolor of drift bar when increasing, valid colors aredefault/blue,bad/red,green,gold, andwhite, ortransparent -
bar_decrease_colorcolor of drift bar when decreasing, same valid colors as the increase colors -
drift_valuea 0-1 script value key which sets the size and direction of the drift
Removes the drift style of the progress bar
Parameters:
-
progress_barlocalization key identifier of progress bar
Sets the target style of the progress bar. The custom icon uses the an ideology, so custom ideologies can be defined to use any desired image or icon. To set a custom icon, set the custom ideology in 'scope:com_$progress_bar$'
Parameters:
-
progress_barlocalization key identifier of progress bar -
target_type= icon type for target value, valid values arecustom_icon,journal_icon,gold_marker,gold_bar, and"color"_line, where "color" is any of the valid colors -
target_value= a 0-1 script value key which sets the position of the target
Removes the target style of the progress bar
Parameters:
-
progress_barlocalization key identifier of progress bar
Sets the number of levels of the progress bar. This also sets that many dividers minus one. All levels are evenly spaced.
Parameters:
-
progress_barlocalization key identifier of progress bar -
levels= A positive integer for the number of levels on the bar
Removes the levels of the progress bar
Parameters:
-
progress_barlocalization key identifier of progress bar
Sets a highlight effect on the current level of the progress bar, no effect if the bar does not have levels set with set_com_progress_bar_levels
Parameters:
-
progress_barlocalization key identifier of progress bar
Removes highlight effect from the progress bar
Parameters:
-
progress_barlocalization key identifier of progress bar
Hides the specified progress bar from the journal
Parameters:
-
progress_barlocalization key identifier of progress bar
Unhides the specified progress bar from the journal
Parameters:
-
progress_barlocalization key identifier of progress bar
Debug effect to check variable values, should be used in script explorer only.
Parameters:
-
progress_barlocalization key identifier of progress bar -
index0-indexed position of the progress bar in the journal -
jejournal entry key
Check whether the given progress bar has been initialized for styling.
Parameters:
-
progress_bar= localization key identifier of the progress_bar
Check whether the given progress bar is visible or not.
Parameters:
-
progress_bar= localization key identifier of the progress_bar
A wrapper effect to easily check a trigger inside 'scope:com_$progress_bar$'
Parameters:
-
progress_barname localization key of progress bar -
triggertrigger or series of triggers to be run inside 'scope:com_$progress_bar$'
If you do not want to make the Community Mod Framework a required dependency for your mod, but you want the styles to be used when the CMF is enabled, you can define a set of dummy scripted effects and triggers with the same names as everything in the script docs, these should in a file that comes before com_progressbar_effects.txt so that it is overwritten by CMF and the effects can be active.
To avoid errors because of the parameters, you can have the dummy effects set a local variable for each parameter, such as set_local_variable = $progress_bar$