Skip to content

Commit

Permalink
Player menu function files
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyqer committed Aug 5, 2018
1 parent 56c71e3 commit 5a702fc
Show file tree
Hide file tree
Showing 7 changed files with 309 additions and 2 deletions.
40 changes: 40 additions & 0 deletions Missionframework/modules/99_playerMenu/fnc/fn_plm_apply.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
KPLIB_fnc_plm_apply
File: fn_plm_apply.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-08-04
Last Update: 2018-08-05
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Applies and saves the selected settings from the player menu dialog.
Parameter(s):
NONE
Returns:
BOOL
*/

// Apply current view distance and sound volume
[] call KPLIB_fnc_plm_getInOut;

// Apply terrain detail setting
switch (KPLIB_plm_terrain) do {
case 0: {setTerrainGrid 50;};
case 1: {setTerrainGrid 25;};
case 2: {setTerrainGrid 12.5;};
case 3: {setTerrainGrid 6.25;};
case 4: {setTerrainGrid 3.125;};
default {setTerrainGrid 10;};
};

// Apply radio chatter setting
switch (KPLIB_plm_radio) do {
case 1: {enableRadio true; 1 fadeRadio 0;};
case 2: {enableRadio false; 1 fadeRadio 0;};
default {enableRadio true; 1 fadeRadio 1;};
};

true
27 changes: 27 additions & 0 deletions Missionframework/modules/99_playerMenu/fnc/fn_plm_create.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
KPLIB_fnc_plm_create
File: fn_plm_create.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-08-05
Last Update: 2018-08-05
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Creates a new group for the player.
Parameter(s):
NONE
Returns:
BOOL
*/

private _grp = createGroup [(side player), true];
[player] join _grp;

// Refresh Dialog
closeDialog 0;
[{!dialog}, {call KPLIB_fnc_plm_openDialog;}] call CBA_fnc_waitUntilAndExecute;

true
48 changes: 48 additions & 0 deletions Missionframework/modules/99_playerMenu/fnc/fn_plm_getInOut.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
KPLIB_fnc_plm_getInOut
File: fn_plm_getInOut.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-08-05
Last Update: 2018-08-05
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Sets the view distance and the sound volume of the player depending on the current vehicle.
Also changes the camera view, if functionality is enabled by the player.
Parameter(s):
NONE
Returns:
BOOL
*/

// Player on foot
if (isNull objectParent player) then {
setViewDistance KPLIB_plm_viewFoot;
setObjectViewDistance KPLIB_plm_viewFoot;
1 fadeSound 1;
};

// Player in boat or land vehicle
if (vehicle player isKindOf "LandVehicle" || vehicle player isKindOf "Ship") then {
setViewDistance KPLIB_plm_viewVeh;
setObjectViewDistance KPLIB_plm_viewVeh;
1 fadeSound KPLIB_plm_soundVeh;
if (difficultyOption "thirdPersonView" == 1) then {
if (KPLIB_plm_tpv > 1) then {player switchCamera "EXTERNAL";};
};
};

// Player in air vehicle
if (vehicle player isKindOf "Air") then {
setViewDistance KPLIB_plm_viewAir;
setObjectViewDistance KPLIB_plm_viewAir;
1 fadeSound KPLIB_plm_soundVeh;
if (difficultyOption "thirdPersonView" == 1) then {
if (KPLIB_plm_tpv == 1 || KPLIB_plm_tpv == 3) then {player switchCamera "EXTERNAL";};
};
};

true
31 changes: 31 additions & 0 deletions Missionframework/modules/99_playerMenu/fnc/fn_plm_join.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
KPLIB_fnc_plm_join
File: fn_plm_join.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-08-05
Last Update: 2018-08-05
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Joins the group which is currently selected in the group list.
Parameter(s):
NONE
Returns:
BOOL
*/

// Dialog controls
private _dialog = findDisplay 75803;
private _ctrlGroupList = _dialog displayCtrl 758038;

private _grp = KPLIB_plm_groups select (lbCurSel _ctrlGroupList);
[player] join _grp;

// Refresh Dialog
closeDialog 0;
[{!dialog}, {call KPLIB_fnc_plm_openDialog;}] call CBA_fnc_waitUntilAndExecute;

true
75 changes: 73 additions & 2 deletions Missionframework/modules/99_playerMenu/fnc/fn_plm_openDialog.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_plm_openDialog.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-08-03
Last Update: 2018-08-03
Last Update: 2018-08-05
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Expand All @@ -18,6 +18,77 @@
*/

// Create player options dialog
createDialog "KPLIB_playerMenu";
createDialog "KP_playerMenu";
disableSerialization;

// Dialog controls
private _dialog = findDisplay 75803;
private _ctrlLabelRank = _dialog displayCtrl 758031;
private _ctrlRank = _dialog displayCtrl 758032;
private _ctrlLabelScore = _dialog displayCtrl 758033;
private _ctrlScore = _dialog displayCtrl 758034;
private _ctrlLabelPlaytime = _dialog displayCtrl 758035;
private _ctrlPlaytime = _dialog displayCtrl 758036;
private _ctrlNoRanks = _dialog displayCtrl 758037;
private _ctrlGroupList = _dialog displayCtrl 758038;
private _ctrlViewFoot = _dialog displayCtrl 7580310;
private _ctrlViewVeh = _dialog displayCtrl 7580311;
private _ctrlViewAir = _dialog displayCtrl 7580312;
private _ctrlTerrain = _dialog displayCtrl 7580313;
private _ctrlTpv = _dialog displayCtrl 7580314;
private _ctrlRadio = _dialog displayCtrl 7580315;
private _ctrlValueSound = _dialog displayCtrl 7580316;
private _ctrlSliderSound = _dialog displayCtrl 7580317;

// Display KP Ranks data or hide the player menu entries for the data
if (KPLIB_kpr_enabled) then {
[] call KPLIB_fnc_plm_showRankData;
} else {
{
_x ctrlShow false;
} forEach [_ctrlLabelRank, _ctrlRank, _ctrlLabelScore, _ctrlScore, _ctrlLabelPlaytime, _ctrlPlaytime];
};

// Fill group list with all groups leaded by players
{
if (player in units _x) then {
_ctrlGroupList lbSetCurSel (_ctrlGroupList lbAdd format [">> %1 - %2 (%3)", groupId _x, name leader _x, count units _x]);
} else {
_ctrlGroupList lbAdd format ["%1 - %2 (%3)", groupId _x, name leader _x, count units _x];
};

} forEach KPLIB_plm_groups;

// Set initial values for view distances
_ctrlViewFoot ctrlSetText str KPLIB_plm_viewFoot;
_ctrlViewVeh ctrlSetText str KPLIB_plm_viewVeh;
_ctrlViewAir ctrlSetText str KPLIB_plm_viewAir;

// Fill density, auto tpv and radio dropdowns. Also preselect the saved values
_ctrlTerrain lbAdd localize "STR_PLAYERDIALOG_TERRAINLOW"; // 50
_ctrlTerrain lbAdd localize "STR_PLAYERDIALOG_TERRAINSTANDARD"; // 25
_ctrlTerrain lbAdd localize "STR_PLAYERDIALOG_TERRAINHIGH"; // 12.5
_ctrlTerrain lbAdd localize "STR_PLAYERDIALOG_TERRAINVHIGH"; // 6.25
_ctrlTerrain lbAdd localize "STR_PLAYERDIALOG_TERRAINULTRA"; // 3.125
_ctrlTerrain lbSetCurSel KPLIB_plm_terrain;

_ctrlTpv lbAdd localize "STR_PARAMS_DISABLED";
_ctrlTpv lbAdd localize "STR_PLAYERDIALOG_TPVAIR";
_ctrlTpv lbAdd localize "STR_PLAYERDIALOG_TPVLAND";
_ctrlTpv lbAdd localize "STR_PLAYERDIALOG_TPVALL";
_ctrlTpv lbSetCurSel KPLIB_plm_tpv;

_ctrlRadio lbAdd localize "STR_NO";
_ctrlRadio lbAdd localize "STR_PLAYERDIALOG_RADIOVOICE";
_ctrlRadio lbAdd localize "STR_PLAYERDIALOG_RADIOALL";
_ctrlRadio lbSetCurSel KPLIB_plm_radio;

// Initialize sound slider range, position and speed
_ctrlSliderSound sliderSetRange [0, 100];
_ctrlSliderSound sliderSetPosition (KPLIB_plm_soundVeh * 100);
_ctrlSliderSound sliderSetSpeed [1, 1];

// Set sound value output to initial sound slider value
_ctrlValueSound ctrlSetText format ["%1%2", round sliderPosition _ctrlSliderSound, "%"];

true
38 changes: 38 additions & 0 deletions Missionframework/modules/99_playerMenu/fnc/fn_plm_rename.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
KPLIB_fnc_plm_rename
File: fn_plm_rename.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-08-05
Last Update: 2018-08-05
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Set the new name for the group which is selected in the group list.
Parameter(s):
NONE
Returns:
BOOL
*/

// Dialog controls
private _dialog = findDisplay 75803;
private _ctrlGroupList = _dialog displayCtrl 758038;
private _ctrlEditName = _dialog displayCtrl 758039;
private _grp = KPLIB_plm_groups select (lbCurSel _ctrlGroupList);

// Only allow change, when player is leader
if (leader _grp == player) then {
_grp setGroupIdGlobal [ctrlText _ctrlEditName];

// Refresh Dialog
closeDialog 0;
[{!dialog}, {call KPLIB_fnc_plm_openDialog;}] call CBA_fnc_waitUntilAndExecute;
} else {
hint localize "STR_PLAYERDIALOG_NOTLEADER";
[{hintSilent "";}, [], 3] call CBA_fnc_waitAndExecute;
};

true
52 changes: 52 additions & 0 deletions Missionframework/modules/99_playerMenu/fnc/fn_plm_save.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
KPLIB_fnc_plm_save
File: fn_plm_save.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-08-05
Last Update: 2018-08-05
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Saves the selected settings from the player menu dialog and calls the apply function.
Parameter(s):
NONE
Returns:
BOOL
*/

// Dialog controls
private _dialog = findDisplay 75803;
private _ctrlViewFoot = _dialog displayCtrl 7580310;
private _ctrlViewVeh = _dialog displayCtrl 7580311;
private _ctrlViewAir = _dialog displayCtrl 7580312;
private _ctrlTerrain = _dialog displayCtrl 7580313;
private _ctrlTpv = _dialog displayCtrl 7580314;
private _ctrlRadio = _dialog displayCtrl 7580315;
private _ctrlSliderSound = _dialog displayCtrl 7580317;

// Fetch all selected values
KPLIB_plm_viewFoot = round (parseNumber (ctrlText _ctrlViewFoot));
if (KPLIB_plm_viewFoot == 0) then {KPLIB_plm_viewFoot = 1600;};
KPLIB_plm_viewVeh = round (parseNumber (ctrlText _ctrlViewVeh));
if (KPLIB_plm_viewVeh == 0) then {KPLIB_plm_viewVeh = 1600;};
KPLIB_plm_viewAir = round (parseNumber (ctrlText _ctrlViewAir));
if (KPLIB_plm_viewAir == 0) then {KPLIB_plm_viewAir = 1600;};
KPLIB_plm_terrain = lbCurSel _ctrlTerrain;
KPLIB_plm_tpv = lbCurSel _ctrlTpv;
KPLIB_plm_radio = lbCurSel _ctrlRadio;
KPLIB_plm_soundVeh = (round sliderPosition _ctrlSliderSound) / 100;

// Save settings in user profile
profileNamespace setVariable ["KP_PLM_Settings", [KPLIB_plm_viewFoot, KPLIB_plm_viewVeh, KPLIB_plm_viewAir, KPLIB_plm_terrain, KPLIB_plm_tpv, KPLIB_plm_radio, KPLIB_plm_soundVeh]];
saveProfileNamespace;

// Apply settings
[] call KPLIB_fnc_plm_apply;

// Close the dialog
closeDialog 0;

true

0 comments on commit 5a702fc

Please sign in to comment.