diff --git a/addons/explosives/ACE_Arsenal_Stats.hpp b/addons/explosives/ACE_Arsenal_Stats.hpp index 61534b0f9d..cde27f3bde 100644 --- a/addons/explosives/ACE_Arsenal_Stats.hpp +++ b/addons/explosives/ACE_Arsenal_Stats.hpp @@ -4,7 +4,7 @@ class EGVAR(arsenal,stats) { scope = 2; priority = 1; stats[] = {QGVAR(Range)}; - displayName= CSTRING(statExploRange); + displayName = CSTRING(statExploRange); showText = 1; textStatement = QUOTE(params [ARR_2('_stat', '_config')]; private _exploRangeStat = getNumber (_config >> _stat select 0); format [ARR_3('%1m (%2ft)', _exploRangeStat, (_exploRangeStat / 0.3048) toFixed 1)]); condition = QUOTE(params [ARR_2('', '_config')]; (getNumber (_config >> QQGVAR(Detonator))) > 0); diff --git a/addons/explosives/ACE_Triggers.hpp b/addons/explosives/ACE_Triggers.hpp index b62e593261..e9c717504e 100644 --- a/addons/explosives/ACE_Triggers.hpp +++ b/addons/explosives/ACE_Triggers.hpp @@ -1,13 +1,19 @@ class ACE_Triggers { - /* onPlace parameters: -0: OBJECT - unit placing -1: OBJECT - Placed explosive -2: STRING - Magazine classname -3: ARRAY - vars -Last Index: ACE_Triggers config of trigger type. -onSetup parameters: -0: STRING - Magazine Classname - */ + /* onPlace Parameters: + * 0: Unit placing + * 1: Explosive + * 2: Magazine classname + * 3: Additional arguments + * - Same as those passed to FUNC(placeExplosive) for specific trigger type + * - Last element is ACE_Triggers config of the trigger type + * + * onSetup Parameters: + * 0: Explosive + * 1: Magazine classname + * + * For both, expected return type is BOOL. + * True indicates manual handling of explosive setup/placement. + */ class Command { isAttachable = 1; displayName = CSTRING(clacker_displayName); @@ -50,8 +56,8 @@ onSetup parameters: isAttachable = 1; displayName = CSTRING(timerName); picture = QPATHTOF(data\UI\Timer.paa); - onPlace = QUOTE([ARR_2(_this select 1,(_this select 3) select 0)] call FUNC(startTimer);false); - onSetup = QUOTE(_this call FUNC(openTimerSetUI);true); + onPlace = QUOTE([ARR_2(_this select 1, _this select 3 select 0)] call FUNC(startTimer); false); + onSetup = QUOTE(_this call FUNC(openTimerUI)); }; class Tripwire { isAttachable = 0; diff --git a/addons/explosives/CfgEventHandlers.hpp b/addons/explosives/CfgEventHandlers.hpp index 37df24577d..e25f1e14ab 100644 --- a/addons/explosives/CfgEventHandlers.hpp +++ b/addons/explosives/CfgEventHandlers.hpp @@ -1,4 +1,3 @@ - class Extended_PreStart_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_preStart)); diff --git a/addons/explosives/ExplosivesUI.hpp b/addons/explosives/ExplosivesUI.hpp index 7b0b2c6629..cd06abff5b 100644 --- a/addons/explosives/ExplosivesUI.hpp +++ b/addons/explosives/ExplosivesUI.hpp @@ -1,19 +1,4 @@ -#define GUI_GRID_X (0) -#define GUI_GRID_Y (0) -#define GUI_GRID_W (0.025) -#define GUI_GRID_H (0.04) - -#define ST_CENTER 0x02 -#define X_OFFSET 0.25 - -class RscText; -class RscButton; -class RscXSliderH; -class IGUIBack; -class RscPicture; -class RscEdit; - -class Rsc_ACE_CallScreen_Edit:RscEdit { +class Rsc_ACE_CallScreen_Edit: RscEdit { canModify = 1; colorBackground[] = {0,0,0,0}; colorText[] = {0,0,0,1}; @@ -32,7 +17,7 @@ class Rsc_ACE_CallScreen_Edit:RscEdit { w = 0.0825 * safezoneW; h = 0.044 * safezoneH; }; -class Rsc_ACE_HiddenButton:RscButton { +class Rsc_ACE_HiddenButton: RscButton { colorText[] = {0, 0, 0, 0}; colorDisabled[] = {0, 0, 0, 0}; colorBackground[] = {0, 0, 0, 0}; @@ -46,66 +31,7 @@ class Rsc_ACE_HiddenButton:RscButton { shadow = 0; }; -class Rsc_ACE_Timer_Slider:RscXSliderH { - x = 0.4; - y = 0.2; - w = 0.3; - h = "1*((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - colorBackground[] = {0,0,0,0.5}; -}; - -class RscACE_SelectTimeUI { - idd = 8854; - movingEnable = 0; - class controls { - class back:IGUIBack { - x = X_OFFSET; - y = 0; - w = 0.5; - h = 0.2; - colorBackground[] = {0, 0, 0, 0.5}; - }; - class header: RscText{ - idc = 8870; - x = X_OFFSET + 0.005; - y = 0.005; - w = 0.49; - h = 0.05; - style = ST_CENTER; - text = ""; - }; - class slider: Rsc_ACE_Timer_Slider { - idc = 8845; - x = X_OFFSET + 0.005; - y = 0.06; - w = 0.49; - h = 0.025; - onSliderPosChanged = "_mins = floor((_this select 1)/60);_secs=floor((_this select 1) - (_mins*60));ctrlSetText [8870, format[localize 'STR_ACE_Explosives_TimerMenu',_mins, _secs]];"; - }; - class cancelBtn: RscButton { - idc = 8855; - x = X_OFFSET + 0.005; - w = 0.15; - h = 0.1; - y = 0.09; - style = ST_CENTER; - text = CSTRING(Cancel); - action = "closeDialog 0;"; - }; - class approveBtn: RscButton { - idc = 8860; - x = X_OFFSET + 0.345; - y = 0.09; - h = 0.1; - w = 0.15; - style = ST_CENTER; - text = CSTRING(SetTime); - action = "closeDialog 0;"; - }; - }; -}; - -class Rsc_ACE_NumKeyButton: Rsc_ACE_HiddenButton{}; +class Rsc_ACE_NumKeyButton: Rsc_ACE_HiddenButton {}; class Rsc_ACE_PhoneInterface { idd = 8855; movingEnable = 1; diff --git a/addons/explosives/TimerDialog.hpp b/addons/explosives/TimerDialog.hpp new file mode 100644 index 0000000000..a3ab96af06 --- /dev/null +++ b/addons/explosives/TimerDialog.hpp @@ -0,0 +1,97 @@ +class GVAR(timerUI) { + idd = -1; + movingEnable = 1; + enableSimulation = 1; + onLoad = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(timerDisplay), _this select 0)]); + class controlsBackground { + class Header: RscText { + idc = -1; + text = CSTRING(ExplosiveTimer); + x = 13.5 * GUI_GRID_W + GUI_GRID_CENTER_X; + y = 5 * GUI_GRID_H + GUI_GRID_CENTER_Y; + w = 13 * GUI_GRID_W; + h = GUI_GRID_H; + colorBackground[] = GUI_BCG_COLOR; + moving = 1; + }; + class Background: RscText { + idd = -1; + x = 13.5 * GUI_GRID_W + GUI_GRID_CENTER_X; + y = 6.1 * GUI_GRID_H + GUI_GRID_CENTER_Y; + w = 13 * GUI_GRID_W; + h = 6.5 * GUI_GRID_H; + colorBackground[] = {0, 0, 0, 0.8}; + }; + }; + class controls { + class DigitBackground_1: RscPicture { + idc = -1; + text = QPATHTOF(UI\seven_segment_8.paa); + x = 14 * GUI_GRID_W + GUI_GRID_CENTER_X; + y = 6.6 * GUI_GRID_H + GUI_GRID_CENTER_Y; + w = 4 * GUI_GRID_W; + h = 4 * GUI_GRID_H; + colorText[] = {0.3, 0.3, 0.3, 0.5}; + }; + class DigitBackground_2: DigitBackground_1 { + x = 16.4 * GUI_GRID_W + GUI_GRID_CENTER_X; + }; + class DigitBackground_3: DigitBackground_1 { + x = 19.7 * GUI_GRID_W + GUI_GRID_CENTER_X; + }; + class DigitBackground_4: DigitBackground_1 { + x = 22.1 * GUI_GRID_W + GUI_GRID_CENTER_X; + }; + class DigitSeparator: DigitBackground_1 { + text = QPATHTOF(UI\seven_segment_separator.paa); + x = 18.025 * GUI_GRID_W + GUI_GRID_CENTER_X; + colorText[] = {1, 0.05, 0.05, 1}; + }; + class Digit_1: DigitBackground_1 { + idc = IDC_TIMER_DIGIT_1; + text = QPATHTOF(UI\seven_segment_0.paa); + colorText[] = {1, 0.05, 0.05, 1}; + }; + class Digit_2: Digit_1 { + idc = IDC_TIMER_DIGIT_2; + x = 16.4 * GUI_GRID_W + GUI_GRID_CENTER_X; + }; + class Digit_3: Digit_1 { + idc = IDC_TIMER_DIGIT_3; + x = 19.7 * GUI_GRID_W + GUI_GRID_CENTER_X; + }; + class Digit_4: Digit_1 { + idc = IDC_TIMER_DIGIT_4; + x = 22.1 * GUI_GRID_W + GUI_GRID_CENTER_X; + }; + class Slider: ctrlXSliderH { + idc = IDC_TIMER_SLIDER; + x = 14 * GUI_GRID_W + GUI_GRID_CENTER_X; + y = 11.1 * GUI_GRID_H + GUI_GRID_CENTER_Y; + w = 12 * GUI_GRID_W; + h = GUI_GRID_H; + color[] = {0.3, 0.3, 0.3, 0.7}; + colorActive[] = {0.3, 0.3, 0.3, 0.7}; + sliderRange[] = {TIMER_VALUE_MIN, TIMER_VALUE_MAX}; + sliderPosition = TIMER_VALUE_DEFAULT; + }; + class CancelButton: RscButton { + idc = -1; + text = CSTRING(Cancel); + onButtonClick = QUOTE(closeDialog 0); + x = 13.5 * GUI_GRID_W + GUI_GRID_CENTER_X; + y = 12.7 * GUI_GRID_H + GUI_GRID_CENTER_Y; + w = 5 * GUI_GRID_W; + h = GUI_GRID_H; + colorActive[] = {0, 0, 0, 1}; + colorBackground[] = {0, 0, 0, 0.8}; + colorFocused[] = {0, 0, 0, 0.8}; + }; + class ConfirmButton: CancelButton { + idc = IDC_TIMER_CONFIRM; + text = CSTRING(SetTime); + onButtonClick = ""; + x = 21.5 * GUI_GRID_W + GUI_GRID_CENTER_X; + }; + }; +}; diff --git a/addons/explosives/UI/seven_segment_0.paa b/addons/explosives/UI/seven_segment_0.paa new file mode 100644 index 0000000000..39c56516b0 Binary files /dev/null and b/addons/explosives/UI/seven_segment_0.paa differ diff --git a/addons/explosives/UI/seven_segment_1.paa b/addons/explosives/UI/seven_segment_1.paa new file mode 100644 index 0000000000..d88e20c28b Binary files /dev/null and b/addons/explosives/UI/seven_segment_1.paa differ diff --git a/addons/explosives/UI/seven_segment_2.paa b/addons/explosives/UI/seven_segment_2.paa new file mode 100644 index 0000000000..dd1e6bd383 Binary files /dev/null and b/addons/explosives/UI/seven_segment_2.paa differ diff --git a/addons/explosives/UI/seven_segment_3.paa b/addons/explosives/UI/seven_segment_3.paa new file mode 100644 index 0000000000..71da8743c0 Binary files /dev/null and b/addons/explosives/UI/seven_segment_3.paa differ diff --git a/addons/explosives/UI/seven_segment_4.paa b/addons/explosives/UI/seven_segment_4.paa new file mode 100644 index 0000000000..3a054e3c48 Binary files /dev/null and b/addons/explosives/UI/seven_segment_4.paa differ diff --git a/addons/explosives/UI/seven_segment_5.paa b/addons/explosives/UI/seven_segment_5.paa new file mode 100644 index 0000000000..7622645c24 Binary files /dev/null and b/addons/explosives/UI/seven_segment_5.paa differ diff --git a/addons/explosives/UI/seven_segment_6.paa b/addons/explosives/UI/seven_segment_6.paa new file mode 100644 index 0000000000..d805a028d5 Binary files /dev/null and b/addons/explosives/UI/seven_segment_6.paa differ diff --git a/addons/explosives/UI/seven_segment_7.paa b/addons/explosives/UI/seven_segment_7.paa new file mode 100644 index 0000000000..f9070da7a7 Binary files /dev/null and b/addons/explosives/UI/seven_segment_7.paa differ diff --git a/addons/explosives/UI/seven_segment_8.paa b/addons/explosives/UI/seven_segment_8.paa new file mode 100644 index 0000000000..f09be85074 Binary files /dev/null and b/addons/explosives/UI/seven_segment_8.paa differ diff --git a/addons/explosives/UI/seven_segment_9.paa b/addons/explosives/UI/seven_segment_9.paa new file mode 100644 index 0000000000..9139d4ea17 Binary files /dev/null and b/addons/explosives/UI/seven_segment_9.paa differ diff --git a/addons/explosives/UI/seven_segment_separator.paa b/addons/explosives/UI/seven_segment_separator.paa new file mode 100644 index 0000000000..aa5bb0a159 Binary files /dev/null and b/addons/explosives/UI/seven_segment_separator.paa differ diff --git a/addons/explosives/XEH_PREP.hpp b/addons/explosives/XEH_PREP.hpp index 17558ee54c..c04e0d3133 100644 --- a/addons/explosives/XEH_PREP.hpp +++ b/addons/explosives/XEH_PREP.hpp @@ -1,4 +1,3 @@ - PREP(addCellphoneIED); PREP(addClacker); PREP(addDetonateActions); @@ -16,28 +15,19 @@ PREP(detonateExplosive); PREP(detonateExplosiveAll); PREP(dialPhone); PREP(dialingPhone); - PREP(handleScrollWheel); - PREP(hasExplosives); PREP(hasPlacedExplosives); - PREP(interactEH); - PREP(getDetonators); PREP(getPlacedExplosives); PREP(getSpeedDialExplosive); - PREP(module); - PREP(onIncapacitated); PREP(onInventoryChanged); - -PREP(openTimerSetUI); - +PREP(openTimerUI); PREP(placeExplosive); PREP(removeFromSpeedDial); - PREP(scriptedExplosive); PREP(selectTrigger); PREP(setupExplosive); diff --git a/addons/explosives/config.cpp b/addons/explosives/config.cpp index a35137733e..3d2077ff1d 100644 --- a/addons/explosives/config.cpp +++ b/addons/explosives/config.cpp @@ -8,16 +8,14 @@ class CfgPatches { requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_interaction"}; author = ECSTRING(common,ACETeam); - authors[] = {"Garth 'L-H' de Wet"}; + authors[] = {"Garth 'L-H' de Wet", "mharis001"}; url = ECSTRING(main,URL); VERSION_CONFIG; }; }; #include "ACE_Settings.hpp" - #include "CfgEventHandlers.hpp" - #include "CfgAmmo.hpp" #include "CfgMagazines.hpp" #include "CfgWeapons.hpp" @@ -25,10 +23,18 @@ class CfgPatches { #include "CfgCloudlets.hpp" #include "ACE_Triggers.hpp" -#include "ExplosivesUI.hpp" -#include "GUI_VirtualAmmo.hpp" #include "ACE_Arsenal_Stats.hpp" +// UI stuff +class RscText; +class RscEdit; +class RscPicture; +class RscButton; +class ctrlXSliderH; +#include "ExplosivesUI.hpp" +#include "TimerDialog.hpp" +#include "GUI_VirtualAmmo.hpp" + class CfgActions { class None; class ActivateMine: None { diff --git a/addons/explosives/functions/fnc_openTimerSetUI.sqf b/addons/explosives/functions/fnc_openTimerSetUI.sqf deleted file mode 100644 index 7175f425d4..0000000000 --- a/addons/explosives/functions/fnc_openTimerSetUI.sqf +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Author: Garth 'L-H' de Wet - * Opens the UI for timer setting of an explosive - * - * Arguments: - * 0: Explosive - * 1: Magazine - * - * Return Value: - * None - * - * Example: - * [_explosive, "SatchelCharge_Remote_Mag"] call ACE_Explosives_fnc_openTimerSetUI; - * - * Public: No - */ -#include "script_component.hpp" - -params ["_explosive", "_mag"]; -TRACE_2("params",_explosive,_mag); - -createDialog "RscACE_SelectTimeUI"; -sliderSetRange [8845, 5, 900]; // 5seconds - 15minutes -sliderSetPosition [8845, 30]; - -GVAR(explosive) = _explosive; - -DFUNC(SetTimer) = { - [ - ACE_player, - getPosATL GVAR(explosive), - GVAR(explosive) getVariable QGVAR(Direction), - GVAR(explosive) getVariable QGVAR(class), - "Timer", - [floor sliderPosition 8845], - GVAR(explosive) - ] call FUNC(placeExplosive); - closeDialog 0; -}; - -buttonSetAction [8860, QUOTE(call DFUNC(SetTimer);)]; -buttonSetAction [8855, QUOTE(closeDialog 0;)]; - -ctrlSetText [8870, format[localize LSTRING(TimerMenu),0, 30]]; diff --git a/addons/explosives/functions/fnc_openTimerUI.sqf b/addons/explosives/functions/fnc_openTimerUI.sqf new file mode 100644 index 0000000000..2fddc33e28 --- /dev/null +++ b/addons/explosives/functions/fnc_openTimerUI.sqf @@ -0,0 +1,84 @@ +/* + * Author: mharis001 + * Opens the Explosive Timer UI for given explosive. + * + * Arguments: + * 0: Explosive + * + * Return Value: + * True + * + * Example: + * [_explosive] call ace_explosives_fnc_openTimerUI + * + * Public: No + */ +#include "script_component.hpp" + +params ["_explosive"]; +TRACE_1("Opening timer UI",_explosive); + +createDialog QGVAR(timerUI); +private _display = uiNamespace getVariable [QGVAR(timerDisplay), displayNull]; + +// Update slider speed to 1s +(_display displayCtrl IDC_TIMER_SLIDER) sliderSetSpeed [1, 1]; + +// Add confirm button action +GVAR(explosive) = _explosive; +(_display displayCtrl IDC_TIMER_CONFIRM) ctrlAddEventHandler ["ButtonClick", { + params ["_button"]; + + private _slider = ctrlParent _button displayCtrl IDC_TIMER_SLIDER; + private _time = floor sliderPosition _slider; + private _explosive = GVAR(explosive); + [ + ACE_player, + getPosATL _explosive, + _explosive getVariable QGVAR(Direction), + _explosive getVariable QGVAR(class), + "Timer", + [_time], + _explosive + ] call FUNC(placeExplosive); + closeDialog 0; +}]; + +// Add EH to allow for changing values by scrolling +_display displayAddEventHandler ["MouseZChanged", { + params ["_display", "_scroll"]; + + private _change = round _scroll; + if (cba_events_control) then {_change = _change * 10}; + + private _slider = _display displayCtrl IDC_TIMER_SLIDER; + private _value = (sliderPosition _slider + _change) max TIMER_VALUE_MIN min TIMER_VALUE_MAX; + _slider sliderSetPosition _value; +}]; + +// Add PFH to update the digit display (delay of 0.1s) +// Done like this to avoid flicker that would happen when rapidly changing values through EH method +[{ + params ["_display", "_pfhID"]; + + // Make sure explosive still exists and is near player + if ((!isNull _display) && {!alive ACE_player} || {!alive GVAR(explosive)} || {(ACE_player distance GVAR(explosive)) > 5}) exitWith { + INFO_2("explosive became invalid",ACE_player,GVAR(explosive)); + closeDialog 0; + _pfhID call CBA_fnc_removePerFrameHandler; + }; + + if (isNull _display) exitWith { + _pfhID call CBA_fnc_removePerFrameHandler; + }; + + private _value = sliderPosition (_display displayCtrl IDC_TIMER_SLIDER); + private _minutes = floor (_value / 60); + private _seconds = floor (_value % 60); + private _digitArray = [floor (_minutes / 10), _minutes mod 10, floor (_seconds / 10), _seconds mod 10]; + { + (_display displayCtrl _x) ctrlSetText format [QPATHTOF(UI\seven_segment_%1.paa), _digitArray select _forEachIndex]; + } forEach TIMER_DIGIT_IDCs; +}, 0.1, _display] call CBA_fnc_addPerFrameHandler; + +true diff --git a/addons/explosives/functions/fnc_startTimer.sqf b/addons/explosives/functions/fnc_startTimer.sqf index 737e6a6586..10faae3707 100644 --- a/addons/explosives/functions/fnc_startTimer.sqf +++ b/addons/explosives/functions/fnc_startTimer.sqf @@ -5,7 +5,7 @@ * Arguments: * 0: Explosive * 1: Time till detonate - * 2: Trigger Item Classname (default: "#timer") + * 2: Trigger classname (default: "#timer") * * Return Value: * None @@ -17,13 +17,13 @@ */ #include "script_component.hpp" -params ["_explosive", "_delay", ["_triggerClassname", "#timer", [""]]]; -TRACE_3("startTimer",_explosive,_delay,_triggerClassname); +params ["_explosive", "_delay", ["_trigger", "#timer", [""]]]; +TRACE_3("Starting timer",_explosive,_delay,_trigger); [{ - params ["_explosive", "_triggerClassname"]; - TRACE_1("Explosive Going Boom",_explosive); + params ["_explosive", "_trigger"]; + TRACE_1("Explosive detonating from timer",_explosive); if (!isNull _explosive) then { - [_explosive, -1, [_explosive, 0], _triggerClassname] call FUNC(detonateExplosive); + [_explosive, -1, [_explosive, 0], _trigger] call FUNC(detonateExplosive); }; -}, [_explosive, _triggerClassname], _delay] call CBA_fnc_waitAndExecute; +}, [_explosive, _trigger], _delay] call CBA_fnc_waitAndExecute; diff --git a/addons/explosives/script_component.hpp b/addons/explosives/script_component.hpp index b276fc8356..77ca89d32e 100644 --- a/addons/explosives/script_component.hpp +++ b/addons/explosives/script_component.hpp @@ -16,6 +16,21 @@ #include "\z\ace\addons\main\script_macros.hpp" +#include "\a3\ui_f\hpp\defineCommonGrids.inc" +#include "\a3\ui_f\hpp\defineCommonColors.inc" + +#define IDC_TIMER_DIGIT_1 8501 +#define IDC_TIMER_DIGIT_2 8502 +#define IDC_TIMER_DIGIT_3 8503 +#define IDC_TIMER_DIGIT_4 8504 +#define IDC_TIMER_SLIDER 8505 +#define IDC_TIMER_CONFIRM 8506 +#define TIMER_DIGIT_IDCs [IDC_TIMER_DIGIT_1, IDC_TIMER_DIGIT_2, IDC_TIMER_DIGIT_3, IDC_TIMER_DIGIT_4] + +#define TIMER_VALUE_MIN 5 +#define TIMER_VALUE_MAX 900 +#define TIMER_VALUE_DEFAULT 30 + #define PLACE_WAITING -1 #define PLACE_CANCEL 0 #define PLACE_APPROVE 1 diff --git a/addons/explosives/stringtable.xml b/addons/explosives/stringtable.xml index eed77e702a..c06378c583 100644 --- a/addons/explosives/stringtable.xml +++ b/addons/explosives/stringtable.xml @@ -1027,5 +1027,8 @@ 爆炸範圍 Raggio di detonazione + + Explosive Timer +