Clean up medical menu privates

This commit is contained in:
Glowbal 2016-06-13 12:49:35 +02:00
parent 8e59993d7a
commit fd108478fe
10 changed files with 34 additions and 62 deletions

View File

@ -15,27 +15,25 @@
*/
#include "script_component.hpp"
private ["_configBasic", "_configAdvanced", "_fnc_compileActionsLevel"];
_configBasic = (configFile >> "ACE_Medical_Actions" >> "Basic");
_configAdvanced = (configFile >> "ACE_Medical_Actions" >> "Advanced");
private _configBasic = (configFile >> "ACE_Medical_Actions" >> "Basic");
private _configAdvanced = (configFile >> "ACE_Medical_Actions" >> "Advanced");
_fnc_compileActionsLevel = {
private ["_actions", "_displayName", "_condition", "_category", "_statement"];
private _fnc_compileActionsLevel = {
params ["_config"];
_actions = [];
private _actions = [];
{
if (isClass _x) then {
_displayName = getText (_x >> "displayName");
_category = getText (_x >> "category");
_condition = format[QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical,canTreatCached)), configName _x];
_statement = format[QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical,treatment)), configName _x];
private _displayName = getText (_x >> "displayName");
private _category = getText (_x >> "category");
private _condition = format[QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical,canTreatCached)), configName _x];
private _statement = format[QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical,treatment)), configName _x];
_actions pushBack [_displayName, _category, compile _condition, compile _statement];
};
nil
} count ("true" configClasses _config);
_actions // return
_actions;
};
GVAR(actionsBasic) = [_configBasic] call _fnc_compileActionsLevel;
@ -43,20 +41,20 @@ GVAR(actionsAdvanced) = [_configAdvanced] call _fnc_compileActionsLevel;
//Manually add the drag actions, if dragging exists.
if (["ace_dragging"] call EFUNC(common,isModLoaded)) then {
_condition = {
private _condition = {
(ACE_player != GVAR(INTERACTION_TARGET)) && {[ACE_player, GVAR(INTERACTION_TARGET)] call EFUNC(dragging,canDrag)}
};
_statement = {
private _statement = {
GVAR(pendingReopen) = false; //No medical_treatmentSuccess event after drag, so don't want this true
[ACE_player, GVAR(INTERACTION_TARGET)] call EFUNC(dragging,startDrag);
};
GVAR(actionsBasic) pushBack [localize ELSTRING(dragging,Drag), "drag", _condition, _statement];
GVAR(actionsAdvanced) pushBack [localize ELSTRING(dragging,Drag), "drag", _condition, _statement];
_condition = {
private _condition = {
(ACE_player != GVAR(INTERACTION_TARGET)) && {[ACE_player, GVAR(INTERACTION_TARGET)] call EFUNC(dragging,canCarry)}
};
_statement = {
private _statement = {
GVAR(pendingReopen) = false; //No medical_treatmentSuccess event after drag, so don't want this true
[ACE_player, GVAR(INTERACTION_TARGET)] call EFUNC(dragging,startCarry);
};

View File

@ -19,19 +19,16 @@
params ["_player", "_target", "_name"];
private ["_actions", "_collectedActions", "_bodyPart"];
if (!([ACE_player, _target, ["isNotInside"]] call EFUNC(common,canInteractWith))) exitWith {[]};
_actions = if (EGVAR(medical,level) == 2) then {
private _actions = if (EGVAR(medical,level) == 2) then {
GVAR(actionsAdvanced);
} else {
GVAR(actionsBasic);
};
_collectedActions = [];
_bodyPart = EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart);
private _collectedActions = [];
private _bodyPart = EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart);
{
_x params ["", "_currentCategory", "_currentCondition"];
if (_name == _currentCategory && {call _currentCondition}) then {
@ -40,4 +37,4 @@ _bodyPart = EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart);
nil
} count _actions;
_collectedActions // return
_collectedActions;

View File

@ -15,13 +15,11 @@
*/
#include "script_component.hpp"
private ["_display", "_pos", "_ctrl", "_currentPos", "_idc"];
disableSerialization;
_display = uiNamespace getVariable QGVAR(medicalMenu);
_pos = [0, 0, 0, 0];
_currentPos = ctrlPosition (_display displayCtrl 2002);
private _display = uiNamespace getVariable QGVAR(medicalMenu);
private _pos = [0, 0, 0, 0];
private _currentPos = ctrlPosition (_display displayCtrl 2002);
_currentPos params ["_currentPosX", "_currentPosY"];
if (_currentPosX == 0 && _currentPosY == 0) then {
_pos = ctrlPosition (_display displayCtrl 2001);
@ -29,7 +27,7 @@ if (_currentPosX == 0 && _currentPosY == 0) then {
for "_idc" from 2002 to 2006 step 1 do {
_pos set [1, (_pos select 1) + (_pos select 3)];
_ctrl = _display displayCtrl _idc;
private _ctrl = _display displayCtrl _idc;
_ctrl ctrlSetPosition _pos;
_ctrl ctrlCommit 0;
};

View File

@ -16,8 +16,6 @@
#include "script_component.hpp"
#define MAX_DISTANCE 10
private "_target";
params ["_display"];
if (isNil "_display") exitWith {};
@ -34,7 +32,7 @@ if (isNil QGVAR(LatestDisplayOptionMenu)) then {
};
};
_target = GVAR(INTERACTION_TARGET);
private _target = GVAR(INTERACTION_TARGET);
if (isNil QGVAR(INTERACTION_TARGET_PREVIOUS)) then {
GVAR(INTERACTION_TARGET_PREVIOUS) = _target;
};

View File

@ -20,15 +20,10 @@ params ["_interactionTarget"];
if (dialog || {isNull _interactionTarget}) exitWith {
disableSerialization;
private ["_display", "_handled"];
_handled = false;
_display = uiNamespace getVariable QGVAR(medicalMenu);
private _display = uiNamespace getVariable QGVAR(medicalMenu);
if (!isNil "_display") then {
closeDialog 314412;
_handled = true;
};
_handled
};
GVAR(INTERACTION_TARGET) = _interactionTarget;

View File

@ -16,11 +16,9 @@
*/
#include "script_component.hpp"
private "_logCtrl";
params ["_display", "_logs"];
_logCtrl = _display displayCtrl 214;
private _logCtrl = _display displayCtrl 214;
lbClear _logCtrl;
{

View File

@ -22,11 +22,9 @@ params ["_selectionBloodLoss", "_damaged", "_display"];
// Handle the body image coloring
private _availableSelections = [50, 51, 52, 53, 54, 55];
{
private ["_red", "_green", "_blue"];
_red = 1;
_green = 1;
_blue = 1;
private _red = 1;
private _green = 1;
private _blue = 1;
if (_x > 0) then {
if (_damaged select _forEachIndex) then {

View File

@ -18,15 +18,13 @@
#define START_IDC 111
#define END_IDC 118
private ["_display", "_idc", "_options", "_amount"];
disableSerialization;
_display = uiNamespace getVariable QGVAR(medicalMenu);
private _display = uiNamespace getVariable QGVAR(medicalMenu);
private _options = ["triage" , "examine", "bandage", "medication", "airway", "advanced", "drag", "toggle"];
_options = ["triage" , "examine", "bandage", "medication", "airway", "advanced", "drag", "toggle"];
for "_idc" from START_IDC to END_IDC step 1 do {
_amount = [ACE_player, GVAR(INTERACTION_TARGET), _options select (_idc - START_IDC)] call FUNC(getTreatmentOptions);
private _amount = [ACE_player, GVAR(INTERACTION_TARGET), _options select (_idc - START_IDC)] call FUNC(getTreatmentOptions);
if ((count _amount) > 0 || _idc == START_IDC || _idc == END_IDC) then {
(_display displayCtrl _idc) ctrlSettextColor [1, 1, 1, 1];
} else {

View File

@ -14,11 +14,9 @@
*/
#include "script_component.hpp"
private ["_lbCtrl", "_amountOfGeneric"];
params ["_display", "_genericMessages", "_allInjuryTexts"];
_lbCtrl = _display displayCtrl 213;
private _lbCtrl = _display displayCtrl 213;
lbClear _lbCtrl;
{
_x params ["_add", "_color"];
@ -26,7 +24,7 @@ lbClear _lbCtrl;
_lbCtrl lbSetColor [_forEachIndex, _color];
} forEach _genericMessages;
_amountOfGeneric = count _genericMessages;
private _amountOfGeneric = count _genericMessages;
{
_x params ["_add", "_color"];
_lbCtrl lbAdd _add;

View File

@ -16,27 +16,21 @@
*/
#include "script_component.hpp"
private "_logCtrl";
params ["_display", "_logs"];
_logCtrl = _display displayCtrl 215;
private _logCtrl = _display displayCtrl 215;
lbClear _logCtrl;
{
_x params ["_message", "_moment", "", "_arguments"];
if (isLocalized _message) then {
_message = localize _message;
};
{
if (_x isEqualType "" && {isLocalized _x}) then {
_arguments set [_foreachIndex, localize _x];
};
} forEach _arguments;
_message = format ([_message] + _arguments);
_message = format ([([_message, localize _message] select (isLocalized _message))] + _arguments);
_logCtrl lbAdd format ["%1 %2", _moment, _message];
nil
} count _logs;