|
|
(43 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| <!--= Spearhead 1944 Voting UI =-->
| | = Mobile To-Do = |
| {{TOC|side}}
| | ''A list of things that would improve mobile compatibility'' |
| The '''Spearhead 1944''' CDLC introduces a unique way to allow for scenario customization, the voting UI.</br>
| |
| [[File:spe mapVote ui.jpg|500px]]</br>
| |
| 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 {{hl|start_n}} where {{hl|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. {{hl|start_1, start_2, ..., start_6}}
| |
| Place the markers where the voting options should appear on the map.
| |
|
| |
|
| == Adding the UI Code ==
| | ''Lou thinks just because the list is empty there is nothing left to improve. Only if he knew.'' |
| 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]].
| |
|
| |
|
| {{hl|init.sqf}}
| | = Done = |
| <sqf>[
| |
| "start_",
| |
| {true}, // Voter Eligible
| |
| [{(time > 1) || (!isNil "SPE_missionUtilityFunctions_skipVote")}, {((getClientStateNumber >= 10) || (!isNil "SPE_missionUtilityFunctions_skipVote")) && {time > 3}}] select (isMultiplayer), // Vote end condition
| |
| { // completion code (hasInterface inc. JiP)
| |
| },
| |
| { //completion code (server)
| |
| },
| |
| {},
| |
| {//OnHover, map markers
| |
| systemChat str _this;
| |
| },
| |
| ["SPE_b_Icon_Axis_Armored", "SPE_b_Icon_Axis_Armored", "SPE_b_Icon_Axis_Armored", "SPE_b_Icon_Axis_Armored"],
| |
| [[0.34, 0.42, 0.44, 1], [0.34, 0.42, 0.44, 1], [0.34, 0.42, 0.44, 1], [0.34, 0.42, 0.44, 1]],
| |
| [
| |
| ["start_1", ["Title 1", "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage.paa", "Description 1", "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage.paa"]],
| |
| ["start_2", ["Title 2", "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage.paa", "Description 2", "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage.paa"]]
| |
| ],
| |
| "start_1",
| |
| [
| |
| [
| |
| "Option 1",
| |
| "Description 1",
| |
| localize "STR_SPE_Scenario_Der_Zahnarzt_Vote_Detail_Start_Option_1_Advantages",
| |
| "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage_bw.paa",
| |
| "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage.paa"
| |
| ],
| |
| [
| |
| "Option 2",
| |
| "Description 2",
| |
| localize "STR_SPE_Scenario_Der_Zahnarzt_Vote_Detail_Start_Option_1_Advantages",
| |
| "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage_bw.paa",
| |
| "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage.paa"
| |
| ]
| |
| ],
| |
| [false],
| |
| {!(isNull findDisplay 46)},
| |
| true
| |
| ] spawn SPE_missionUtilityFunctions_fnc_mapVote_init;</sqf>
| |
|
| |
|
| === Function Parameters ===
| | * Creator dlc template needs a noresize. |
| ==== Syntax ====
| | ** {{Link|Spearhead_1944}} |
| <sqf>
| | * Long command names should wrap |
| [
| | ** {{Link|removeAllUserActionEventHandlers}} |
| _prefix,
| |
| _condition,
| |
| _completionCondition,
| |
| _clientCode,
| |
| _completionCode,
| |
| _updateSelectionCode,
| |
| _hoverCandidateCode,
| |
| _groupIcons,
| |
| _groupIconParams,
| |
| _cfgOrbat,
| |
| _defaultSelection,
| |
| _uiData,
| |
| _timer,
| |
| _uiFadeOutCondition,
| |
| _waitForPlayers
| |
| ] call SPE_missionUtilityFunctions_fnc_mapVote_init;</sqf>
| |
|
| |
|
| ==== Parameters ====
| | * See also entries on command and function pages are broken |
| # {{hl|_prefix:}} [[String]] - Prefix of all voting markers e.g. start_1, start_2, ..., start_6, optional, default <sqf inline>"player_spawn_"</sqf>
| | ** {{Link|parsingNamespace}} |
| # {{hl|_condition:}} [[Code]] - Condition that must be true for given [[player]] in order to see the vote, optional, default <sqf inline>{[[true]]}</sqf>
| |
| # {{hl|_completionCondition:}} [[Code]] - Condition that must be true for the voting to be considered done, optional, default <sqf inline>{[[time]] > 1}</sqf>
| |
| # {{hl|_clientCode:}} [[Code]] - Code that is executed on the client when the voting has finished and for JIP player, optional, default <sqf inline>{params ["_prefix", "_marker", "_conditionResult"];}</sqf>
| |
| # {{hl|_completionCode:}} [[Code]] - Code that is executed on the server when the voting has finished, optional, default <sqf inline>{params ["_prefix", "_marker"];}</sqf>
| |
| # {{hl|_updateSelectionCode:}} [[Code]] - Code that is executed on the client when the voting selection changes, optional, default <sqf inline>{params ["_prefix", "_winningMarkers", "_allMarkers"];}</sqf>
| |
| # {{hl|_hoverCandidateCode:}} [[Code]] - Code that is executed on the client when hovering over the voting option, optional, default <sqf inline>{params ["_marker", "_hover", "_conditionResult", ["_cleanup", false]];}</sqf>
| |
| # {{hl|_groupIcons:}} [[Array]] - Vote textures used for the map voting markers, optional, default <sqf inline>["selector_selectedFriendly", "selector_selectedEnemy", "selector_selectedFriendly", "selector_selectedEnemy"]</sqf> //TODO: What is this exactly?
| |
| # {{hl|_groupIconParams:}} [[Array]] - Vote colors used for the map voting markers, optional, default <sqf inline>[[VOTE_UI_COLOUR_DEFAULT_RGBA], [VOTE_UI_COLOUR_VOTED_RGBA], [0.7, 0.7, 0.7, 0], [0.5, 1, 0.5, 0]]</sqf> //TODO: What is this exactly?
| |
| # {{hl|_cfgOrbat:}} [[Array]] of [[Array|arrays]] - [[Arma 3: ORBAT Viewer|CfgORBAT]] parameters used to fill map voting markers, optional, default <sqf inline>[]</sqf>
| |
| <sqf>[
| |
| "start_1", //Marker indicating the voting location
| |
| [
| |
| "Title 1", //Title displayed when hovering over the marker
| |
| "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage.paa", //Image shown when hovering over the marker
| |
| "Description 1", //Description displayed when hovering over the marker
| |
| "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage.paa" //Image shown when hovering over the marker
| |
| ]
| |
| ]</sqf>
| |
| # {{hl|_defaultSelection:}} [[String]] - Marker name that is selected by default, optional, default <sqf inline>""</sqf>
| |
| # {{hl|_uiData:}} [[Array]] of [[Array|arrays]] - Data to fill the UI, optional, default <sqf inline>[]</sqf>
| |
| <sqf>[
| |
| [
| |
| "Option 1", //Title of the voting option
| |
| "Description 1", //Description of the voting option
| |
| localize "STR_SPE_Scenario_Der_Zahnarzt_Vote_Detail_Start_Option_1_Advantages", //Additional text displayed of the voting option
| |
| "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage_bw.paa", //Image that is being used if this option is not selected or hovered over
| |
| "\WW2\SPE_Missions_p\Scenarios_p\data\Voting_DerZahnarzt_Sabotage.paa" //Image that is being used if this option is selected or hovered over
| |
| ]
| |
| ]</sqf>
| |
| # {{hl|_timer:}} [[Boolean]], [[Code]], [[Number]], [[String]] - Voting timer setting, optional, default <sqf inline>[]</sqf>
| |
| ## 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
| |
| # {{hl|_uiFadeOutCondition:}} [[Code]] - Condition to fade out the voting UI, optional, default <sqf inline>{missionNamespace getVariable [QGVAR(array), []] isEqualTo []}</sqf>
| |
| # {{hl|_waitForPlayers:}} [[Boolean]] - Should UI wait for players, default <sqf inline>false</sqf>
| |
|
| |
|
| ==== Debugging ===
| | * Command and function template layout wastes a lot of space due to the two column design |
| Extended logging is available if {{hl|SPE_mapVote_debug}} is set to [[true]].
| |
| Variable should be set to [[true]] for both server and clients.
| |
|
| |
|
| = After Voting =
| | * Tables with fixed widths need to be avoided. If they are too wide use noresize class wrapper |
| After the voting has finished and the winner was evaluated, the result of the vote is saved into {{hl|SPE_missionutilityfunctions_mapvote_start_marker}}. This variable holds the marker name of the voting option that has won.
| | ** {{Link|Arma_3:_Visual_Upgrade}} |
| 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.
| |
|
| |
|
| <sqf>
| | * YouTube embeds and images should not have a fixed width |
| switch SPE_missionutilityfunctions_mapvote_start_marker do
| | ** {{Link|Category:DayZ}} |
| { | | ** {{Link|Spearhead_1944_Frontline_Function}} |
| case "start_1": {/* Do things... */};
| | ** It is because the youtube template has a hardcoded minimum width. This should get removed |
| case "start_2": {/* Do things... */};
| |
| case "start_3": {/* Do things... */};
| |
| case "start_4": {/* Do things... */};
| |
| case "start_5": {/* Do things... */};
| |
| case "start_6": {/* Do things... */};
| |
| default {/* Should never be executed... */};
| |
| };
| |
| </sqf>
| |
| | |
| = Example Scenario =
| |
| [https://1drv.ms/u/s!AvgETyKiA6bQscEGoauxZVsxiiiJLw?e=0VKEaX Spearhead 1944 - Map Vote UI Tutorial Scenario.zip (OneDrive)]
| |