Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
tuntematonjr committed Aug 28, 2021
1 parent 38ea79b commit 19e1151
Show file tree
Hide file tree
Showing 64 changed files with 2,464 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/Briefingtime/$PREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x\tun\addons\Briefingtime
47 changes: 47 additions & 0 deletions addons/Briefingtime/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "script_component.hpp"

[{ !isNil QGVAR(enable)}, {
if (isServer && isMultiplayer && GVAR(enable)) then {


_handle = [{
if (GVAR(value) > 0) then {
DEC(GVAR(value));
publicVariable QGVAR(value);
};
if (cba_missiontime > 0) then {
[_handle] call CBA_fnc_removePerFrameHandler;
};
}, 1, []] call CBA_fnc_addPerFrameHandler;
};

if (hasInterface && isMultiplayer && GVAR(enable)) then {
GVAR(Notifications) = [];
[{ !isNull findDisplay 53 || !isNull findDisplay 52 }, {

private _display = [53, 52] select !isNull findDisplay 52;

private _control = findDisplay _display ctrlCreate [QGVAR(timeText), 320001];
uiNamespace setVariable [QGVAR(timeText), _control ];

_handle = [{
private _time = [GVAR(value), "M:SS"] call CBA_fnc_formatElapsedTime;
private _text = format["Briefing time left: %1", _time];
(uiNamespace getVariable QGVAR(timeText)) ctrlSetText _text;

if (cba_missiontime > 0) then {
[_handle] call CBA_fnc_removePerFrameHandler;
player removeDiarySubject QGVAR(briefingTimeDiary);
};
}, 1, []] call CBA_fnc_addPerFrameHandler;

player createDiarySubject [QGVAR(briefingTimeDiary),"Briefing Time"];
player createDiaryRecord [QGVAR(briefingTimeDiary), ["Briefing Time",
"Do not abuse!
<br/><br/><font size=20><execute expression=' [] call "+QFUNC(openTimeDialog)+"'> Request more time / Modify briefing time</execute>
</font>"
]];

}] call CBA_fnc_waitUntilAndExecute;
};
}] call CBA_fnc_waitUntilAndExecute;
24 changes: 24 additions & 0 deletions addons/Briefingtime/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "script_component.hpp"
#include "XEH_prep.sqf"

[
QGVAR(enable), // Unique setting name. Matches resulting variable name <STRING>
"CHECKBOX", // Type of setting. Can be "CHECKBOX", "EDITBOX", "LIST", "SLIDER" or "COLOR" <STRING>
"Enable Briefingtime", // Display name or display name + tooltip (optional, default: same as setting name) <STRING, ARRAY>
"Tun Utilities - Briefingtime", // Category for the settings menu + optional sub-category <STRING, ARRAY>
true, // Extra properties of the setting depending of _settingType.
1, // 1: all clients share the same setting, 2: setting can't be overwritten (optional, default: 0) <ARRAY>
{}, // Script to execute when setting is changed. (optional) <CODE>
true //Setting will be marked as needing mission restart after being changed. (optional, default false) <BOOL>
] call CBA_Settings_fnc_init;

[
QGVAR(value), // Unique setting name. Matches resulting variable name <STRING>
"SLIDER", // Type of setting. Can be "CHECKBOX", "EDITBOX", "LIST", "SLIDER" or "COLOR" <STRING>
["Briefingtime", "How much there is briefing time at start"], // Display name or display name + tooltip (optional, default: same as setting name) <STRING, ARRAY>
"Tun Utilities - Briefingtime", // Category for the settings menu + optional sub-category <STRING, ARRAY>
[0, 30, 17, 0], // Extra properties of the setting depending of _settingType.
1, // 1: all clients share the same setting, 2: setting can't be overwritten (optional, default: 0) <ARRAY>
{GVAR(value) = _this * 60}, // Script to execute when setting is changed. (optional) <CODE>
true //Setting will be marked as needing mission restart after being changed. (optional, default false) <BOOL>
] call CBA_Settings_fnc_init;
9 changes: 9 additions & 0 deletions addons/Briefingtime/XEH_prep.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "script_component.hpp"

#undef PREP
#define PREP(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction;

PREP(openTimeDialog);
PREP(SliderPosUpdated);
PREP(onCloseDisplay);
PREP(notification);
114 changes: 114 additions & 0 deletions addons/Briefingtime/briafingTime.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//Exported via Arma Dialog Creator (https://github.com/kayler-renslow/arma-dialog-creator)

class RscButton;
class RscText;
class RscXSliderH;

#include "\a3\3DEN\UI\macros.inc"
//#include "\a3\3DEN\UI\macroexecs.inc"
#include "\a3\ui_f\hpp\definedikcodes.inc"
#include "\a3\ui_f\hpp\definecommoncolors.inc"
#include "\a3\ui_f\hpp\definecommongrids.inc"
#include "\a3\ui_f\hpp\defineresincl.inc"

//#include "script_component.hpp"

class Tun_Briefingtime_timeText : RscText
{
type = 0;
idc = 320001;
x = safeZoneX + safeZoneW * 0.403125;
y = safeZoneY + safeZoneH * 0.00462963;
w = safeZoneW * 0.2625;
h = safeZoneH * 0.025;
style = 0;
};

class Tun_Briefingtime_notificationBox : RscText
{
type = 0;
idc = 320006;
x = safeZoneX + safeZoneW * 0.403125;
y = safeZoneY + safeZoneH * 0.10462963;
w = safeZoneW * 0.2625;
h = safeZoneH * 0.125;
style = 2+16;
sizeEx = GUI_TEXT_SIZE_LARGE;
colorText[] = {0.6, 0, 0, 1};
};

class Tun_Briefingtime_Time
{
idd = 320000;
class ControlsBackground
{
class Tun_Briefingtime_backgreound : RscText
{
type = 0;
idc = 320000;
x = safeZoneX + safeZoneW * 0.4140625;
y = safeZoneY + safeZoneH * 0.43425926;
w = safeZoneW * 0.171875;
h = safeZoneH * 0.12222223;
style = 0;
colorBackground[] = {0.2, 0.2, 0.2, 0.75};
};

};
class Controls
{

class Tun_Briefingtime_time_slider : RscXSliderH
{
type = 43;
idc = 320003;
x = safeZoneX + safeZoneW * 0.41875;
y = safeZoneY + safeZoneH * 0.475;
w = safeZoneW * 0.1625;
h = safeZoneH * 0.02962963;
style = 1024;
onSliderPosChanged = " params ['_control', '_newValue']; [_control,_newValue] call Tun_Briefingtime_fnc_SliderPosUpdated";

};
class Tun_Briefingtime_slider_time_text : RscText
{
type = 0;
idc = 320002;
x = safeZoneX + safeZoneW * 0.41875;
y = safeZoneY + safeZoneH * 0.44351852;
w = safeZoneW * 0.1625;
h = safeZoneH * 0.025;
style = 2;
text = "test";
colorBackground[] = {COLOR_ACTIVE_RGBA};

};
class Tun_Briefingtime_slider_ok : RscButton
{
type = 1;
idc = 320004;
x = safeZoneX + safeZoneW * 0.54375;
y = safeZoneY + safeZoneH * 0.525;
w = safeZoneW * 0.0375;
h = safeZoneH * 0.025;
style = 0;
text = "Ok";
onMouseButtonClick = "(uiNamespace getVariable 'Tun_Briefingtime_Time') closeDisplay 1; [] call Tun_Briefingtime_fnc_onCloseDisplay";

};
class Tun_Briefingtime_slider_cancel : RscButton
{
type = 1;
idc = 320005;
x = safeZoneX + safeZoneW * 0.41875;
y = safeZoneY + safeZoneH * 0.525;
w = safeZoneW * 0.0375;
h = safeZoneH * 0.025;
style = 0;
text = "Cancel";
onMouseButtonClick = "(uiNamespace getVariable 'Tun_Briefingtime_Time') closeDisplay 0;";
};

};

};
28 changes: 28 additions & 0 deletions addons/Briefingtime/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "script_component.hpp"

class CfgPatches
{
class Tun_Briefingtime
{
units[] = {};
weapons[] = {};
requiredVersion = 2.04;
requiredAddons[] = {"cba_main","cba_xeh","cba_settings","ace_common","ace_interaction","ace_interact_menu"};
author = "Tuntematon";
authorUrl = "https://github.com/tuntematonjr/Tun-Utilities";
};
};

class Extended_PostInit_EventHandlers {
class Tun_Briefingtime {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

class Extended_PreInit_EventHandlers {
class Tun_Briefingtime {
init = QUOTE( call COMPILE_FILE(XEH_preInit) );
};
};

#include "briafingTime.hpp"
22 changes: 22 additions & 0 deletions addons/Briefingtime/functions/fnc_SliderPosUpdated.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Author: [Tuntematon]
* [Description]
*
* Arguments:
* 0: UI Control <CONTROL>
* 1: New Time <NUMBER>
*
* Return Value:
* None
*
* Example:
* [slider, 15] call tun_briefingtime_fnc_SliderPosUpdated
*/
#include "script_component.hpp"

params ["_control", "_newValue"];
private _text = ["Requesting additional time:", "Set briefing time to:"] select IS_ADMIN;
private _textControl = (uiNamespace getVariable "Tun_Briefingtime_Time") displayCtrl 320002;
private _roundValue = round _newValue;
_control sliderSetPosition _roundValue;
_textControl ctrlSetText (format ["%1 %2min", _text, _roundValue]);
38 changes: 38 additions & 0 deletions addons/Briefingtime/functions/fnc_notification.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Author: [Tuntematon]
* [Description]
*
* Arguments:
* 0: Text to show <STRING>
*
* Return Value:
* None
*
* Example:
* ["Hello World!"] call tun_briefingtime_fnc_notification
*/
#include "script_component.hpp"

params ["_text"];

//Notification queye
if (!isNull (uiNamespace getVariable "Tun_Briefingtime_notificationBox")) exitWith {
GVAR(Notifications) pushBackUnique _text;
[{isNull (uiNamespace getVariable "Tun_Briefingtime_notificationBox")}, {
private _text = GVAR(Notifications) select 0;
REM(GVAR(Notifications),_text);
[_text] call FUNC(notification);
}] call CBA_fnc_waitUntilAndExecute;
};
private _display = [53, 52] select !isNull findDisplay 52;
private _control = findDisplay _display ctrlCreate ["Tun_Briefingtime_notificationBox", 320006];
uiNamespace setVariable ["Tun_Briefingtime_notificationBox", _control ];

if (!IS_STRING(_text)) then {
_text = str _text;
};
_control ctrlSetText _text;

[{ diag_tickTime > _this select 1 }, {
ctrlDelete (_this select 0);
}, [_control, (diag_tickTime + 10)]] call CBA_fnc_waitUntilAndExecute;
30 changes: 30 additions & 0 deletions addons/Briefingtime/functions/fnc_onCloseDisplay.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Author: [Tuntematon]
* [Description]
*
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call tun_briefingtime_fnc_onCloseDisplay
*/
#include "script_component.hpp"

private _newTime = sliderPosition ((uiNamespace getVariable "Tun_Briefingtime_Time") displayCtrl 320003);

//Create notification and admin will modify
if (IS_ADMIN) then {
//Update time
_newTime = _newTime * 60;
GVAR(value) = _newTime;
publicVariable QGVAR(value);

["Briefing time has been modified"] remoteExecCall [QFUNC(notification), [0,-2] select isDedicated, false];
} else {
private _text = format ["%2 (%1) has requestend additional %3min briefing time", playerSide, profileName, _newTime];
[_text] remoteExecCall [QFUNC(notification), [0,-2] select isDedicated, false];
};
31 changes: 31 additions & 0 deletions addons/Briefingtime/functions/fnc_openTimeDialog.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Author: [Tuntematon]
* [Description]
*
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call tun_briefingtime_fnc_openTimeDialog
*/
#include "script_component.hpp"

private _display = [53, 52] select !isNull findDisplay 52;
private _control = findDisplay _display createDisplay "Tun_Briefingtime_Time";
uiNamespace setVariable ["Tun_Briefingtime_Time", _control ];
[{!isNull findDisplay 320000}, {
_sliderControl = (uiNamespace getVariable "Tun_Briefingtime_Time") displayCtrl 320003;
_sliderControl sliderSetRange [0, 30];
_sliderControl sliderSetSpeed [1, 1];

private _text = ["Requesting additional time:", "Set briefing time to:"] select IS_ADMIN;
private _value = [0, round(GVAR(value) / 60)] select IS_ADMIN;
_sliderControl sliderSetPosition _value;
_textControl = (uiNamespace getVariable "Tun_Briefingtime_Time") displayCtrl 320002;
_textControl ctrlSetText (format ["%1 %2min", _text, _value]);

}] call CBA_fnc_waitUntilAndExecute;
19 changes: 19 additions & 0 deletions addons/Briefingtime/functions/pohja.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Author: [Tuntematon]
* [Description]
*
* Arguments:
* 0: The first argument <STRING>
* 1: The second argument <OBJECT>
* 2: Multiple input types <STRING|ARRAY|CODE>
* 3: Optional input <BOOL> (default: true)
* 4: Optional input with multiple types <CODE|STRING> (default: {true})
* 5: Not mandatory input <STRING> (default: nil)
*
* Return Value:
* The return value <BOOL>
*
* Example:
* ["something", player] call tun_briefingtime_fnc_imanexample
*/
#include "script_component.hpp"
1 change: 1 addition & 0 deletions addons/Briefingtime/functions/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "..\script_component.hpp"
Loading

0 comments on commit 19e1151

Please sign in to comment.