Skip to content

Commit

Permalink
Hold actions overwrites (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerZade committed Oct 29, 2021
1 parent 03aa26b commit 8b15fed
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 2 deletions.
14 changes: 14 additions & 0 deletions addons/defaultactionicon/CfgFunctions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CfgFunctions {
class A3 {
class HoldActions {
file = "x\grad_minui\addons\defaultactionicon\functions";
};
};
class grad_minui {
tag="grad_minui";
class HoldActions {
file = "x\grad_minui\addons\defaultactionicon\functions";
class showHoldActionProgress {};
};
};
};
25 changes: 25 additions & 0 deletions addons/defaultactionicon/RscTitles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class ctrlStructuredText;

class RscTitles {
class PROGRESS_DISPLAY_CLASS {
onLoad = "uiNamespace setVariable ['grad_minui_holdAction_progress',_this select 0];";
fadeIn = 0;
duration = 200;
fadeOut = 0;
idd = -1;
class controlsBackground {};
class controls {
class txt: ctrlStructuredText {
idc = 1;
x = "safezoneX + safezoneW / 2 - 0.1";
y = "safezoneY + safezoneH / 2 - 0.1";
w = "0.2";
h = "safezoneH * 0.5";
class Attributes: Attributes {
size = 0.8;
align = "center";
};
}
};
};
};
4 changes: 3 additions & 1 deletion addons/defaultactionicon/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CfgPatches {
units[] = {};
weapons[] = {};
requiredVersion = 0.1;
requiredAddons[] = {"grad_minui_main", "grad_minui_settings"};
requiredAddons[] = {"grad_minui_main", "grad_minui_settings", "A3_Functions_F"};
authors[] = {"DerZade", "Fusselwurm"};
VERSION_CONFIG;
};
Expand All @@ -16,3 +16,5 @@ class MOD_CONFIG_CLASS_NAME {
};

#include "ui.hpp"
#include "RscTitles.hpp"
#include "CfgFunctions.hpp"
37 changes: 37 additions & 0 deletions addons/defaultactionicon/functions/fn_holdActionAdd.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "\A3\functions_f\HoldActions\fn_holdActionAdd.sqf"
; // This is needed because the original function does not include a ; at the end


private _iconSize = ["defaultactionicon_size"] call grad_minui_fnc_setting;

if (_iconSize isNotEqualTo 0) exitWith {};

grad_minui_hold_color = [profilenamespace getvariable ['IGUI_WARNING_RGB_R',0.77], profilenamespace getvariable ['IGUI_WARNING_RGB_G',0.51], profilenamespace getvariable ['IGUI_WARNING_RGB_B',0.08]] call BIS_fnc_colorRGBtoHTML;

bis_fnc_holdAction_showIcon = {
params [
["_target", objNull, [objNull]],
["_actionID", 0, [123]],
["_title", "", [""]],
["_icon", "", ["", {}]],
["_texSet", TEXTURES_PROGRESS, [[]]],
["_frame", 0, [123]],
["_hint", "", [""]]
];

if (_icon isEqualType {}) then {
_icon = _target call _icon;
};

if (_texSet isEqualTo TEXTURES_PROGRESS) then {
[_frame] call grad_minui_fnc_showHoldActionProgress;
};

_target setUserActionText [_actionID, format ["<t color='%2' size='0.8' valign='middle'>[HOLD]</t> %1", _title, grad_minui_hold_color], "", ""];
};

// make sure the new function is applied immediately
[_target, _actionID, _title, _iconIdle, TEXTURES_IDLE, 0] call bis_fnc_holdAction_showIcon;

// return _actionID, like the original function does
_actionID
3 changes: 3 additions & 0 deletions addons/defaultactionicon/functions/fn_holdActionRemove.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file just exists, so that the CfgFunction file overwrite wörks

#include "\A3\functions_f\HoldActions\fn_holdActionRemove.sqf"
23 changes: 23 additions & 0 deletions addons/defaultactionicon/functions/fn_showHoldActionProgress.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "\A3\functions_f\HoldActions\defines.inc"
#include "script_component.hpp"

params [
["_frame", 0, [123]]
];

private _display = uiNamespace getVariable [QUOTE(PROGRESS_DISPLAY_CLASS), displayNull];

if ((_frame isEqualTo 0) && !(isNull _display)) exitWith {
// the user aborted the hold action, if there already
// is a display and we get frame 0 -> close display
PROGRESS_DISPLAY_LAYER cutText ["", "PLAIN"];
};

// create display if it does not exist
if (isNull _display) then {
PROGRESS_DISPLAY_LAYER cutRsc [QUOTE(PROGRESS_DISPLAY_CLASS), "PLAIN"];
_display = uiNamespace getVariable QUOTE(PROGRESS_DISPLAY_CLASS);
};

private _image = TEXTURES_PROGRESS select _frame;
(_display displayCtrl 1) ctrlSetStructuredText parseText format ["<t size='0.8'>%1</t>", _image];
1 change: 1 addition & 0 deletions addons/defaultactionicon/functions/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "..\script_component.hpp"
5 changes: 4 additions & 1 deletion addons/defaultactionicon/script_component.hpp
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#include "\x\grad_minui\addons\main\script_mod.hpp"
#include "\x\grad_minui\addons\main\script_mod.hpp"

#define PROGRESS_DISPLAY_CLASS grad_minui_holdAction_progress
#define PROGRESS_DISPLAY_LAYER QUOTE(PROGRESS_DISPLAY_CLASS)

0 comments on commit 8b15fed

Please sign in to comment.