Add new explosive timer UI

This commit is contained in:
Unknown 2018-06-22 15:41:43 -04:00
parent fdf6100fb6
commit bbbfabec03
23 changed files with 232 additions and 157 deletions

View File

@ -4,7 +4,7 @@ class EGVAR(arsenal,stats) {
scope = 2; scope = 2;
priority = 1; priority = 1;
stats[] = {QGVAR(Range)}; stats[] = {QGVAR(Range)};
displayName= CSTRING(statExploRange); displayName = CSTRING(statExploRange);
showText = 1; 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)]); 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); condition = QUOTE(params [ARR_2('', '_config')]; (getNumber (_config >> QQGVAR(Detonator))) > 0);

View File

@ -1,13 +1,19 @@
class ACE_Triggers { class ACE_Triggers {
/* onPlace parameters: /* onPlace Parameters:
0: OBJECT - unit placing * 0: Unit placing <OBJECT>
1: OBJECT - Placed explosive * 1: Explosive <OBJECT>
2: STRING - Magazine classname * 2: Magazine classname <STRING>
3: ARRAY - vars * 3: Additional arguments <ARRAY>
Last Index: ACE_Triggers config of trigger type. * - Same as those passed to FUNC(placeExplosive) for specific trigger type
onSetup parameters: * - Last element is ACE_Triggers config of the trigger type <CONFIG>
0: STRING - Magazine Classname *
*/ * onSetup Parameters:
* 0: Explosive <OBJECT>
* 1: Magazine classname <STRING>
*
* For both, expected return type is BOOL.
* True indicates manual handling of explosive setup/placement.
*/
class Command { class Command {
isAttachable = 1; isAttachable = 1;
displayName = CSTRING(clacker_displayName); displayName = CSTRING(clacker_displayName);
@ -50,8 +56,8 @@ onSetup parameters:
isAttachable = 1; isAttachable = 1;
displayName = CSTRING(timerName); displayName = CSTRING(timerName);
picture = QPATHTOF(data\UI\Timer.paa); picture = QPATHTOF(data\UI\Timer.paa);
onPlace = QUOTE([ARR_2(_this select 1,(_this select 3) select 0)] call FUNC(startTimer);false); onPlace = QUOTE([ARR_2(_this select 1, _this select 3 select 0)] call FUNC(startTimer); false);
onSetup = QUOTE(_this call FUNC(openTimerSetUI);true); onSetup = QUOTE(_this call FUNC(openTimerUI));
}; };
class Tripwire { class Tripwire {
isAttachable = 0; isAttachable = 0;

View File

@ -1,4 +1,3 @@
class Extended_PreStart_EventHandlers { class Extended_PreStart_EventHandlers {
class ADDON { class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart)); init = QUOTE(call COMPILE_FILE(XEH_preStart));

View File

@ -1,19 +1,4 @@
#define GUI_GRID_X (0) class Rsc_ACE_CallScreen_Edit: RscEdit {
#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 {
canModify = 1; canModify = 1;
colorBackground[] = {0,0,0,0}; colorBackground[] = {0,0,0,0};
colorText[] = {0,0,0,1}; colorText[] = {0,0,0,1};
@ -32,7 +17,7 @@ class Rsc_ACE_CallScreen_Edit:RscEdit {
w = 0.0825 * safezoneW; w = 0.0825 * safezoneW;
h = 0.044 * safezoneH; h = 0.044 * safezoneH;
}; };
class Rsc_ACE_HiddenButton:RscButton { class Rsc_ACE_HiddenButton: RscButton {
colorText[] = {0, 0, 0, 0}; colorText[] = {0, 0, 0, 0};
colorDisabled[] = {0, 0, 0, 0}; colorDisabled[] = {0, 0, 0, 0};
colorBackground[] = {0, 0, 0, 0}; colorBackground[] = {0, 0, 0, 0};
@ -46,66 +31,7 @@ class Rsc_ACE_HiddenButton:RscButton {
shadow = 0; shadow = 0;
}; };
class Rsc_ACE_Timer_Slider:RscXSliderH { class Rsc_ACE_NumKeyButton: Rsc_ACE_HiddenButton {};
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_PhoneInterface { class Rsc_ACE_PhoneInterface {
idd = 8855; idd = 8855;
movingEnable = 1; movingEnable = 1;

View File

@ -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;
};
};
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,3 @@
PREP(addCellphoneIED); PREP(addCellphoneIED);
PREP(addClacker); PREP(addClacker);
PREP(addDetonateActions); PREP(addDetonateActions);
@ -16,28 +15,19 @@ PREP(detonateExplosive);
PREP(detonateExplosiveAll); PREP(detonateExplosiveAll);
PREP(dialPhone); PREP(dialPhone);
PREP(dialingPhone); PREP(dialingPhone);
PREP(handleScrollWheel); PREP(handleScrollWheel);
PREP(hasExplosives); PREP(hasExplosives);
PREP(hasPlacedExplosives); PREP(hasPlacedExplosives);
PREP(interactEH); PREP(interactEH);
PREP(getDetonators); PREP(getDetonators);
PREP(getPlacedExplosives); PREP(getPlacedExplosives);
PREP(getSpeedDialExplosive); PREP(getSpeedDialExplosive);
PREP(module); PREP(module);
PREP(onIncapacitated); PREP(onIncapacitated);
PREP(onInventoryChanged); PREP(onInventoryChanged);
PREP(openTimerUI);
PREP(openTimerSetUI);
PREP(placeExplosive); PREP(placeExplosive);
PREP(removeFromSpeedDial); PREP(removeFromSpeedDial);
PREP(scriptedExplosive); PREP(scriptedExplosive);
PREP(selectTrigger); PREP(selectTrigger);
PREP(setupExplosive); PREP(setupExplosive);

View File

@ -8,16 +8,14 @@ class CfgPatches {
requiredVersion = REQUIRED_VERSION; requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"}; requiredAddons[] = {"ace_interaction"};
author = ECSTRING(common,ACETeam); author = ECSTRING(common,ACETeam);
authors[] = {"Garth 'L-H' de Wet"}; authors[] = {"Garth 'L-H' de Wet", "mharis001"};
url = ECSTRING(main,URL); url = ECSTRING(main,URL);
VERSION_CONFIG; VERSION_CONFIG;
}; };
}; };
#include "ACE_Settings.hpp" #include "ACE_Settings.hpp"
#include "CfgEventHandlers.hpp" #include "CfgEventHandlers.hpp"
#include "CfgAmmo.hpp" #include "CfgAmmo.hpp"
#include "CfgMagazines.hpp" #include "CfgMagazines.hpp"
#include "CfgWeapons.hpp" #include "CfgWeapons.hpp"
@ -25,10 +23,18 @@ class CfgPatches {
#include "CfgCloudlets.hpp" #include "CfgCloudlets.hpp"
#include "ACE_Triggers.hpp" #include "ACE_Triggers.hpp"
#include "ExplosivesUI.hpp"
#include "GUI_VirtualAmmo.hpp"
#include "ACE_Arsenal_Stats.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 CfgActions {
class None; class None;
class ActivateMine: None { class ActivateMine: None {

View File

@ -1,44 +0,0 @@
/*
* Author: Garth 'L-H' de Wet
* Opens the UI for timer setting of an explosive
*
* Arguments:
* 0: Explosive <OBJECT>
* 1: Magazine <STRING>
*
* 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]];

View File

@ -0,0 +1,77 @@
/*
* Author: mharis001
* Opens the Explosive Timer UI for given explosive.
*
* Arguments:
* 0: Explosive <OBJECT>
*
* Return Value:
* True <BOOL>
*
* 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"];
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

View File

@ -5,7 +5,7 @@
* Arguments: * Arguments:
* 0: Explosive <OBJECT> * 0: Explosive <OBJECT>
* 1: Time till detonate <NUMBER> * 1: Time till detonate <NUMBER>
* 2: Trigger Item Classname <STRING> (default: "#timer") * 2: Trigger classname <STRING> (default: "#timer")
* *
* Return Value: * Return Value:
* None * None
@ -17,13 +17,13 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_explosive", "_delay", ["_triggerClassname", "#timer", [""]]]; params ["_explosive", "_delay", ["_trigger", "#timer", [""]]];
TRACE_3("startTimer",_explosive,_delay,_triggerClassname); TRACE_3("Starting timer",_explosive,_delay,_trigger);
[{ [{
params ["_explosive", "_triggerClassname"]; params ["_explosive", "_trigger"];
TRACE_1("Explosive Going Boom",_explosive); TRACE_1("Explosive detonating from timer",_explosive);
if (!isNull _explosive) then { 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;

View File

@ -16,6 +16,21 @@
#include "\z\ace\addons\main\script_macros.hpp" #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_WAITING -1
#define PLACE_CANCEL 0 #define PLACE_CANCEL 0
#define PLACE_APPROVE 1 #define PLACE_APPROVE 1

View File

@ -1024,5 +1024,8 @@
<French>Portée du détonateur</French> <French>Portée du détonateur</French>
<Japanese>爆発範囲</Japanese> <Japanese>爆発範囲</Japanese>
</Key> </Key>
<Key ID="STR_ACE_Explosives_ExplosiveTimer">
<English>Explosive Timer</English>
</Key>
</Package> </Package>
</Project> </Project>