ACE3/addons/medical_gui/functions/fnc_collectActions.sqf
amsteadrayle 1e3d9cc22a
Medical GUI - Show number of available treatment items in medical menu (#9474)
* Initial implementation of item count display

* Put everything inside function, add padding

* Extract and explain null string

* Fix tab in config file

* Add function header

* Use ACE item counting function

* Extract column width to variable

* Move constants declaration closer to usage

* Add special case for sutures

* Add setting to enable/disable

* Expand to allow showing in tooltip

* Split into counting and formatting function

* Fix incorrect check for case with no items

* Remove ineffective padding from tooltip

* Check for surgical kit item instead of display name

* Update return description in header

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Add `private` keyword for inline functions

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* capitalization/vars

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* nil checks, localize macro

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Remove button text mode and setting

* possessive

* Update addons/medical_gui/functions/fnc_formatItemCounts.sqf

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2023-10-12 22:39:23 -04:00

57 lines
1.9 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: Glowbal, mharis001
* Collect treatment actions for medical menu from config.
* Adds dragging actions if it exists.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ace_medical_gui_fnc_collectActions
*
* Public: No
*/
GVAR(actions) = [];
{
private _configName = configName _x;
private _displayName = getText (_x >> "displayName");
private _category = getText (_x >> "category");
private _condition = compile format [QUOTE([ARR_4(ACE_player, GVAR(target), %1 select GVAR(selectedBodyPart), '%2')] call DEFUNC(medical_treatment,canTreatCached)), ALL_BODY_PARTS, _configName];
private _statement = compile format [QUOTE([ARR_4(ACE_player, GVAR(target), %1 select GVAR(selectedBodyPart), '%2')] call DEFUNC(medical_treatment,treatment)), ALL_BODY_PARTS, _configName];
private _items = getArray (_x >> "items");
GVAR(actions) pushBack [_displayName, _category, _condition, _statement, _items];
} forEach configProperties [configFile >> QEGVAR(medical_treatment,actions), "isClass _x"];
if ("ace_dragging" call EFUNC(common,isModLoaded)) then {
GVAR(actions) pushBack [
localize ELSTRING(dragging,Drag), "drag",
{ACE_player != GVAR(target) && {[ACE_player, GVAR(target)] call EFUNC(dragging,canDrag)}},
{
GVAR(pendingReopen) = false;
[ACE_player, GVAR(target)] call EFUNC(dragging,startDrag);
}
];
GVAR(actions) pushBack [
localize ELSTRING(dragging,Carry), "drag",
{ACE_player != GVAR(target) && {[ACE_player, GVAR(target)] call EFUNC(dragging,canCarry)}},
{
GVAR(pendingReopen) = false;
[ACE_player, GVAR(target)] call EFUNC(dragging,startCarry);
}
];
};
// testing code for multi-line
// for "_i" from 0 to 12 do {
// GVAR(actions) pushBack [format ["Example %1", _i], "medication", {true}, compile format ['systemChat "%1"', _i]]
// };