Skip to content

Commit

Permalink
Unshit a bit (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
3Mydlo3 committed Oct 9, 2023
1 parent 1a1149a commit 5e4b971
Show file tree
Hide file tree
Showing 14 changed files with 531 additions and 0 deletions.
8 changes: 8 additions & 0 deletions addons/diagnostics/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREP(dlcOpen);
PREP(dlcRequest);
PREP(dlcRespond);
PREP(dlcUpdate);
PREP(fpsOpen);
PREP(fpsRequest);
PREP(fpsRespond);
PREP(fpsUpdate);
60 changes: 60 additions & 0 deletions addons/diagnostics/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,63 @@
ADDON = false;
#include "XEH_PREP.hpp"
ADDON = true;

#include "initSettings.sqf"

GVAR(dlcList) = [
[288520, "Karts"],
[304380, "Helicopters"],
[332350, "Marksman"],
[395180, "Apex"],
[571710, "Laws of War"],
[601670, "Jets"],
[744950, "Tac Ops"],
[798390, "Tanks"],
[1021790, "Contact"],
[1042220, "GM"],
// TODO: IDs for remaining DLCs
[]
];

if (hasInterface) then {
["DLC List", QGVAR(dlcListDialog)] call CBA_fnc_addPauseMenuOption;
["FPS List", QGVAR(fpsListDialog)] call CBA_fnc_addPauseMenuOption;

[QGVAR(dlcRequest), FUNC(dlcRespond)] call CBA_fnc_addEventHandler;
[QGVAR(dlcResponse), FUNC(dlcUpdate)] call CBA_fnc_addEventHandler;

[QGVAR(fpsRequest), FUNC(fpsRespond)] call CBA_fnc_addEventHandler;
[QGVAR(fpsResponse), FUNC(fpsUpdate)] call CBA_fnc_addEventHandler;
};

if (!isServer) exitWith {};

if (!QGVAR(markersEnabled)) exitWith {};

// By default only server is an FPS diag target
GVAR(fpsTargets) = [2];

// Add headless clients to diag targets when they join
addMissionEventHandler ["PlayerConnected", {
params ["", "_uid", "", "", "_owner"];
if ((_uid select [0,2] != "HC")) exitWith {};

GVAR(fpsTargets) pushBack _owner;
}];

// Cleanup headless client markers on disconnect
addMissionEventHandler ["PlayerDisconnected", {
params ["", "_uid", "", "", "_owner"];
if ((_uid select [0,2] != "HC")) exitWith {};

GVAR(fpsTargets) = GVAR(fpsTargets) - [_owner];

private _fpsMarker = format ["%1_%2", QGVAR(fpsMarker), _owner];
deleteMarker _fpsMarker;
}];

[{
{
[_x, _forEachIndex] remoteExec [QFUNC(updateDiagnosticMarker), _x];
} forEach GVAR(fpsTargets);
}, 15] call CBA_fnc_addPerFrameHandler;
13 changes: 13 additions & 0 deletions addons/diagnostics/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,16 @@ class CfgPatches {
};

#include "CfgEventHandlers.hpp"

// TODO: Move this somewhere appropriate
class GVAR(fpsListDialog) {
idd = -1;
movingEnable = 0;
onLoad = QUOTE(_this call FUNC(fpsOpen));
};

class GVAR(dlcListDialog) {
idd = -1;
movingEnable = 0;
onLoad = QUOTE(_this call FUNC(dlcOpen));
};
92 changes: 92 additions & 0 deletions addons/diagnostics/functions/fn_dlc_open.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
armaforces_diagnostics_fnc_dlc_open
File: fn_dlc_open.sqf
Date: 2019-06-21
Last Update: 2019-07-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Handle DLC List display open.
Parameter(s):
_display - DLC List display [DISPLAY, defaults to displayNull]
Returns:
NOTHING
*/
params [
["_display", displayNull, [displayNull]]
];

if !([] call BIS_fnc_isDebugConsoleAllowed) exitWith {
["No debug console access"] call CBA_fnc_notify;
};

private _width = safezoneW * 0.75;

// Confirm
private _confirm = _display ctrlCreate ["RscButtonMenu", 10];
uiNamespace setVariable [QGVAR(dlcConfirm), _confirm];

private _confirmHeight = safezoneH / 23;
private _confirmY = safezoneY + safezoneH/1.3 - 1.1 * _confirmHeight;

_confirm ctrlSetPosition [
0.5 - _width/2 + _width*0.2,
_confirmY,
_width*0.8, _confirmHeight
];
_confirm ctrlCommit 0;
_confirm ctrlSetText toUpper "REFRESH";

_confirm ctrlAddEventHandler ["MouseButtonDown", {
params ["_confirm", "_button"];
if (_button != 0) exitWith {};
_confirm ctrlEnable false;
[{_this ctrlEnable true}, _confirm, 2] call CBA_fnc_waitAndExecute;

[] call FUNC(dlcRequest);
}];

private _close = _display ctrlCreate ["RscButtonMenu", 1];
_close ctrlSetPosition [
0.5 - _width/2,
_confirmY,
_width*0.2, _confirmHeight
];
_close ctrlCommit 0;
_close ctrlSetText "CLOSE";

// List
private _listHeight = safezoneH/2;

private _listBg = _display ctrlCreate ["RscText", 2]; // centered RscListNBox
_listBg ctrlSetBackgroundColor [0,0,0,0.8];

private _list = _display ctrlCreate ["RscListNBox", 3]; // centered RscListNBox
uiNamespace setVariable [QGVAR(dlcListDialog), _list];

_list lnbAddRow (["Player"] + (GVAR(dlcList) apply {""}));

private _listColOffsets = [];
{
_x params ["", "_name"];

_listColOffsets pushBack 0.12 + ((1 - 0.12) / count GVAR(dlcList)) * _forEachIndex;
} forEach GVAR(dlcList);

_list lnbSetColumnsPos ([0] + _listColOffsets);

{
_x ctrlSetPosition [
0.5 - _width / 2,
_confirmY - _listHeight - _confirmHeight/10 ,
_width, _listHeight
];
_x ctrlCommit 0;
} forEach [_listBg, _list];

[] call FUNC(dlcRequest);

nil
28 changes: 28 additions & 0 deletions addons/diagnostics/functions/fn_dlc_request.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
armaforces_diagnostics_fnc_dlc_request
File: fn_dlc_request.sqf
Date: 2019-06-21
Last Update: 2019-07-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Request DLC ownership from clients.
Parameter(s):
NONE
Returns:
NOTHING
*/
private _list = uiNamespace getVariable [QGVAR(dlcListDialog), controlNull];

lnbClear _list;
_list lnbAddRow (["Player"] + (GVAR(dlcList) apply {"-"}));
_list lnbSetCurSelRow 1;

[{
[QGVAR(dlcRequest), player] call CBA_fnc_globalEvent;
}] call CBA_fnc_execNextFrame;

nil
37 changes: 37 additions & 0 deletions addons/diagnostics/functions/fn_dlc_respond.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
armaforces_diagnostics_fnc_dlc_respond
File: fn_dlc_respond.sqf
Date: 2019-07-28
Last Update: 2019-07-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Respond to DLC ownership request.
Parameter(s):
_requester - Player that requested DLC list [OBJECT, defaults to objNull]
Returns:
NOTHING
*/
params [
["_requester", objNull, [objNull]]
];

private _ownedIds = getDLCs 1;

private _DLCs = GVAR(dlcList);

private _DLCsData = _DLCs apply {
_x params ["_id", "_name"];

[_name, _id in _ownedIds];
};

[QGVAR(dlcResponse),
[name player, _DLCsData],
_requester
] call CBA_fnc_targetEvent;

nil
33 changes: 33 additions & 0 deletions addons/diagnostics/functions/fn_dlc_update.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
armaforces_diagnostics_fnc_dlc_update
File: fn_dlc_update.sqf
Date: 2019-06-21
Last Update: 2019-07-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Update DLC List display contents.
Parameter(s):
NONE
Returns:
NOTHING
*/
params [
["_playerName", "", [""]],
["_DLCsData", [], []]
];

private _list = uiNamespace getVariable [QGVAR(dlcListDialog), controlNull];

private _lastRow = _list lnbAddRow ([_playerName] + (_DLCsData apply {_x select 0}));

private ["_color"];
{
_color = [[1,0,0,1], [0,1,0,1]] select _x;
_list lnbSetColor [[_lastRow, _forEachIndex+1], _color];
} forEach (_DLCsData apply {_x select 1})


84 changes: 84 additions & 0 deletions addons/diagnostics/functions/fn_fps_open.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
armaforces_diagnostics_fnc_fps_open
File: fn_fps_open.sqf
Date: 2019-06-21
Last Update: 2019-07-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Handle FPS List display open.
Parameter(s):
_display - FPS List display [DISPLAY, defaults to displayNull]
Returns:
NOTHING
*/
params [
["_display", displayNull, [displayNull]]
];

if !([] call BIS_fnc_isDebugConsoleAllowed) exitWith {
["No debug console access"] call CBA_fnc_notify;
};

private _width = safezoneW * 0.3;

// Confirm
private _confirm = _display ctrlCreate ["RscButtonMenu", 10];
uiNamespace setVariable [QGVAR(fpsConfirm), _confirm];

private _confirmHeight = safezoneH / 23;
private _confirmY = safezoneY + safezoneH/1.3 - 1.1 * _confirmHeight;

_confirm ctrlSetPosition [
0.5 - _width/2 + _width*0.2,
_confirmY,
_width*0.8, _confirmHeight
];
_confirm ctrlCommit 0;
_confirm ctrlSetText toUpper "REFRESH";

_confirm ctrlAddEventHandler ["MouseButtonDown", {
params ["_confirm", "_button"];
if (_button != 0) exitWith {};
_confirm ctrlEnable false;
[{_this ctrlEnable true}, _confirm, 2] call CBA_fnc_waitAndExecute;

[] call FUNC(fpsRequest);
}];

private _close = _display ctrlCreate ["RscButtonMenu", 1];
_close ctrlSetPosition [
0.5 - _width/2,
_confirmY,
_width*0.2, _confirmHeight
];
_close ctrlCommit 0;
_close ctrlSetText "CLOSE";

// List
private _listHeight = safezoneH/2;

private _listBg = _display ctrlCreate ["RscText", 11]; // centered RscListNBox
_listBg ctrlSetBackgroundColor [0,0,0,0.8];

private _list = _display ctrlCreate ["RscListNBox", 12]; // centered RscListNBox
uiNamespace setVariable [QGVAR(fpsListDialog), _list];
_list lnbSetColumnsPos [0.1,0.5,0.7];
_list lnbAddRow ["Player", "FPS Avg ", "FPS Min"];
_list lnbSetCurSelRow 1;

{
_x ctrlSetPosition [
0.5 - _width / 2,
_confirmY - _listHeight - _confirmHeight/10 ,
_width, _listHeight
];
_x ctrlCommit 0;
} forEach [_listBg, _list];

[] call FUNC(fpsRequest);

nil
25 changes: 25 additions & 0 deletions addons/diagnostics/functions/fn_fps_request.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
armaforces_diagnostics_fnc_fps_request
File: fn_fps_request.sqf
Date: 2019-06-21
Last Update: 2019-07-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Request FPS values from clients.
Parameter(s):
NONE
Returns:
NOTHING
*/
private _list = uiNamespace getVariable [QGVAR(fpsListDialog), controlNull];

lnbClear _list;
_list lnbAddRow ["Player", "FPS Avg ", "FPS Min"];

[QGVAR(fpsRequest), player] call CBA_fnc_globalEvent;

nil
Loading

0 comments on commit 5e4b971

Please sign in to comment.