Spearhead 1944 Map Vote UI
The Spearhead 1944 CDLC introduces a unique way to allow for scenario customization, the voting UI.
Features:
- Autogenerated UI for up to six voting options
- Supports images, title and description
- Customizable voting timer
- Singleplayer and multiplayer compatible
- Easy to set up
Configuration
Placing Map Markers
In order for the vote UI to know the locations of your voting positions, we will use markers. In our example we call them start_n where n is going to be a number from 1 to 2 to create two voting options. The number of markers defines how many voting options will be available. Up to six voting options are supported e.g. start_1, start_2, ..., start_6 Place the markers where the voting options should appear on the map.
Adding the UI Code
The code for the voting logic runs on all machines, client, hosted server and dedicated server. Thus, best place to execute it is from within the init.sqf.
init.sqf
Function Parameters
Syntax
Parameters
- _prefix: String - Prefix of all voting markers e.g. start_1, start_2, ..., start_6, optional, default "player_spawn_"
- _condition: Code - Condition that must be true for given player in order to see the vote, optional, default {[[true]]}
- _completionCondition: Code - Condition that must be true for the voting to be considered done, optional, default {[[time]] > 1}
- _clientCode: Code - Code that is executed on the client when the voting has finished and for JIP player, optional, default {params ["_prefix", "_marker", "_conditionResult"];}
- _completionCode: Code - Code that is executed on the server when the voting has finished, optional, default {params ["_prefix", "_marker"];}
- _updateSelectionCode: Code - Code that is executed on the client when the voting selection changes, optional, default {params ["_prefix", "_winningMarkers", "_allMarkers"];}
- _hoverCandidateCode: Code - Code that is executed on the client when hovering over the voting option, optional, default {params ["_marker", "_hover", "_conditionResult", ["_cleanup", false]];}
- _groupIcons: Array - Vote textures used for the map voting markers, optional, default ["selector_selectedFriendly", "selector_selectedEnemy", "selector_selectedFriendly", "selector_selectedEnemy"] //TODO: What is this exactly?
- _groupIconParams: Array - Vote colors used for the map voting markers, optional, default [[VOTE_UI_COLOUR_DEFAULT_RGBA], [VOTE_UI_COLOUR_VOTED_RGBA], [0.7, 0.7, 0.7, 0], [0.5, 1, 0.5, 0]] //TODO: What is this exactly?
- _cfgOrbat: Array of arrays - CfgORBAT parameters used to fill map voting markers, optional, default []
- _defaultSelection: String - Marker name that is selected by default, optional, default ""
- _uiData: Array of arrays - Data to fill the UI, optional, default []
- _timer: Boolean, Code, Number, String - Voting timer setting, optional, default []
- When Boolean - ???
- When Code - First number in array will be used
- When Number - Value is used as timer
- When String - A missionNamespace variable with given name is begin looked up for a valid value
- _uiFadeOutCondition: Code - Condition to fade out the voting UI, optional, default {missionNamespace getVariable [QGVAR(array), []] isEqualTo []}
- _waitForPlayers: Boolean - Should UI wait for players, default false
Debugging
Extended logging is available if SPE_mapVote_debug is set to true. Variable should be set to true for both server and clients.
After Voting
After the voting has finished and the winner was evaluated, the result of the vote is saved into SPE_missionutilityfunctions_mapvote_start_marker. This variable holds the marker name of the voting option that has won. We can now use that result to adjust our scenario accordingly. For example we can move players around, hide certain compositions, change loadouts or enemy presence.
Example Scenario
Spearhead 1944 - Map Vote UI Tutorial Scenario.zip (OneDrive)