Merge pull request #2743 from acemod/medicalStuff

Medical Menu Fixes
This commit is contained in:
Glowbal 2015-10-19 22:47:13 +02:00
commit 57abe3b885
19 changed files with 99 additions and 58 deletions

View File

@ -45,12 +45,9 @@ _createLitter = {
if(surfaceIsWater (getPos _unit)) exitWith { false };
_position = getPosATL _unit;
_position params ["_posX", "_posY"];
_position = if (random(1) >= 0.5) then {
[_posX + random 1, _posY + random 1, 0]
} else {
[_posX - random 1, _posY - random 1, 0];
};
_position params ["_posX", "_posY", "_posZ"];
_position = [_posX + (random 2) - 1, _posY + (random 2) - 1, _posZ];
_direction = (random 360);
// Create the litter, and timeout the event based on the cleanup delay

View File

@ -24,4 +24,10 @@ class ACE_Settings {
isClientSettable = 1;
category = ECSTRING(medical,Category_Medical);
};
class GVAR(maxRange) {
//for ref: 3d interaction (MEDICAL_ACTION_DISTANCE) is 1.75
value = 3;
typeName = "SCALAR";
category = ECSTRING(medical,Category_Medical);
};
};

View File

@ -2,6 +2,10 @@
if (!hasInterface) exitwith {};
GVAR(MenuPFHID) = -1;
GVAR(lastOpenedOn) = -1;
GVAR(pendingReopen) = false;
["medical_treatmentSuccess", {
if (GVAR(openAfterTreatment) && {GVAR(pendingReopen)}) then {
@ -15,8 +19,9 @@ if (!hasInterface) exitwith {};
["ACE3 Common", QGVAR(displayMenuKeyPressed), localize LSTRING(DisplayMenuKey),
{
_target = cursorTarget;
if (!(_target isKindOf "CAManBase") || ACE_player distance _target > 10) then {_target = ACE_player};
local _target = cursorTarget;
if (!((_target isKindOf "CAManBase") && {[ACE_player, _target] call FUNC(canOpenMenu)})) then {_target = ACE_player};
// Conditions: canInteract
if !([ACE_player, _target, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
if !([ACE_player, _target] call FUNC(canOpenMenu)) exitwith {false};
@ -27,7 +32,7 @@ if (!hasInterface) exitwith {};
},
{
if (ACE_time - GVAR(lastOpenedOn) > 0.5) exitWith {
[ObjNull] call FUNC(openMenu);
[objNull] call FUNC(openMenu);
};
false
},

View File

@ -10,7 +10,7 @@
* Can open <BOOL>
*
* Example:
* [] call ace_medical_menu_canOpenMenu
* [player, cursorTarget] call ace_medical_menu_fnc_canOpenMenu
*
* Public: No
*/
@ -18,7 +18,8 @@
params ["_caller", "_target"];
if !(GVAR(allow) == 1 || (GVAR(allow) == 2 && {vehicle _caller != _caller || vehicle _target != _target} && {alive ACE_player})) exitwith {false};
if !(GVAR(useMenu) == 1 || (GVAR(useMenu) == 2 && {vehicle _caller != _caller || vehicle _target != _target} && {alive ACE_player})) exitwith {false};
true
(alive _caller)
&& {!isNull _target}
&& {((_caller distance _target) < GVAR(maxRange)) || {(vehicle _caller) == (vehicle _target)}} //for now, ignore range when in same vehicle
&& {(GVAR(allow) == 1) || {(GVAR(allow) == 2) && {(vehicle _caller != _caller) || {vehicle _target != _target}}}}
&& {(GVAR(useMenu) == 1) || {(GVAR(useMenu) == 2) && {(vehicle _caller != _caller) || {vehicle _target != _target}}}}

View File

@ -20,7 +20,7 @@ _configBasic = (configFile >> "ACE_Medical_Actions" >> "Basic");
_configAdvanced = (configFile >> "ACE_Medical_Actions" >> "Advanced");
_fnc_compileActionsLevel = {
private ["_entryCount", "_actions", "_displayName", "_condition", "_category", "_statement"];
private ["_actions", "_displayName", "_condition", "_category", "_statement"];
params ["_config"];
_actions = [];
@ -40,3 +40,26 @@ _fnc_compileActionsLevel = {
GVAR(actionsBasic) = [_configBasic] call _fnc_compileActionsLevel;
GVAR(actionsAdvanced) = [_configAdvanced] call _fnc_compileActionsLevel;
//Manually add the drag actions, if dragging exists.
if (["ace_dragging"] call EFUNC(common,isModLoaded)) then {
_condition = {
(ACE_player != GVAR(INTERACTION_TARGET)) && {[ACE_player, GVAR(INTERACTION_TARGET)] call EFUNC(dragging,canDrag)}
};
_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 = {
(ACE_player != GVAR(INTERACTION_TARGET)) && {[ACE_player, GVAR(INTERACTION_TARGET)] call EFUNC(dragging,canCarry)}
};
_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);
};
GVAR(actionsBasic) pushBack [localize ELSTRING(dragging,Carry), "drag", _condition, _statement];
GVAR(actionsAdvanced) pushBack [localize ELSTRING(dragging,Carry), "drag", _condition, _statement];
};

View File

@ -17,9 +17,10 @@
*/
#include "script_component.hpp"
private "_actions";
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 {

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* ["some category"] call ace_medical_menu_handleUI_DisplayOptions
* ["some category"] call ace_medical_menu_fnc_handleUI_DisplayOptions
*
* Public: No
*/
@ -21,7 +21,7 @@
if (!hasInterface) exitwith{};
private ["_entries", "_display", "_newTarget", "_card", "_ctrl", "_code"];
private ["_entries", "_display", "_newTarget", "_ctrl", "_code"];
params ["_name"];
@ -31,9 +31,11 @@ _display = uiNamespace getVariable QGVAR(medicalMenu);
if (isNil "_display") exitwith {}; // no valid dialog present
if (_name isEqualTo "toggle") exitwith {
if (GVAR(INTERACTION_TARGET) != ACE_player) then {
_newTarget = ACE_player;
} else {
_newTarget = ACE_player;
//If we are on the player, and only if our old target is still valid, switch to it:
if ((GVAR(INTERACTION_TARGET) == ACE_player) &&
{[ACE_player, GVAR(INTERACTION_TARGET_PREVIOUS), ["isNotInside"]] call EFUNC(common,canInteractWith)} &&
{[ACE_player, GVAR(INTERACTION_TARGET_PREVIOUS)] call FUNC(canOpenMenu)}) then {
_newTarget = GVAR(INTERACTION_TARGET_PREVIOUS);
};

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* [] call ace_medical_menu_handleUI_dropDownTriageCard
* [] call ace_medical_menu_fnc_handleUI_dropDownTriageCard
*
* Public: No
*/

View File

@ -15,7 +15,7 @@
#include "script_component.hpp"
params ["_logic", "_units", "_activated"];
params ["_logic", "", "_activated"];
if !(_activated) exitWith {};

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* call ace_medical_menu_onMenuClosed
* call ace_medical_menu_fnc_onMenuClosed
*
* Public: No
*/
@ -19,3 +19,4 @@ if (EGVAR(interact_menu,menuBackground)==1) then {[QGVAR(id), false] call EFUNC(
if (EGVAR(interact_menu,menuBackground)==2) then {(uiNamespace getVariable [QEGVAR(interact_menu,menuBackground), displayNull]) closeDisplay 0;};
[GVAR(MenuPFHID)] call CBA_fnc_removePerFrameHandler;
GVAR(MenuPFHID) = -1;

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* [medical_menu] call ace_medical_menu_onMenuOpen
* [medical_menu] call ace_medical_menu_fnc_onMenuOpen
*
* Public: No
*/
@ -64,6 +64,8 @@ disableSerialization;
(_display displayCtrl 1) ctrlSetText format ["%1", [_target] call EFUNC(common,getName)];
setMousePosition [0.4, 0.4];
if (GVAR(MenuPFHID) != -1) exitWith {ERROR("PFID already running");};
GVAR(MenuPFHID) = [{
(_this select 0) params ["_display"];
@ -74,15 +76,15 @@ GVAR(MenuPFHID) = [{
[GVAR(INTERACTION_TARGET)] call FUNC(updateIcons);
[GVAR(LatestDisplayOptionMenu)] call FUNC(handleUI_DisplayOptions);
_status = [GVAR(INTERACTION_TARGET)] call EFUNC(medical,getTriageStatus);
(_display displayCtrl 2000) ctrlSetText (_status select 0);
(_display displayCtrl 2000) ctrlSetBackgroundColor (_status select 2);
if (ACE_player distance _target > MAX_DISTANCE) exitwith {
//Check that it's valid to stay open:
if !(([ACE_player, _target, ["isNotInside"]] call EFUNC(common,canInteractWith)) && {[ACE_player, _target] call FUNC(canOpenMenu)}) then {
closeDialog 314412;
["displayTextStructured", [ACE_player], [[ELSTRING(medical,DistanceToFar), [_target] call EFUNC(common,getName)], 1.75, ACE_player]] call EFUNC(common,targetEvent);
//If we failed because of distance check, show UI message:
if ((ACE_player distance GVAR(INTERACTION_TARGET)) > GVAR(maxRange)) then {
["displayTextStructured", [ACE_player], [[ELSTRING(medical,DistanceToFar), [GVAR(INTERACTION_TARGET)] call EFUNC(common,getName)], 1.75, ACE_player]] call EFUNC(common,targetEvent);
};
};
}, 0, [_display]] call CBA_fnc_addPerFrameHandler;
["Medical_onMenuOpen", [ACE_player, _interactionTarget]] call EFUNC(common,localEvent);
["Medical_onMenuOpen", [ACE_player, _target]] call EFUNC(common,localEvent);

View File

@ -9,7 +9,7 @@
* If action was taken <BOOL>
*
* Example:
* [some_player] call ace_medical_menu_openMenu
* [some_player] call ace_medical_menu_fnc_openMenu
*
* Public: No
*/
@ -17,7 +17,7 @@
params ["_interactionTarget"];
if (dialog || isNull _interactionTarget) exitwith {
if (dialog || {isNull _interactionTarget}) exitwith {
disableSerialization;
private ["_display", "_handled"];

View File

@ -10,7 +10,7 @@
* None
*
* Example:
* [some_display, log] call ace_medical_menu_updateActivityLog
* [some_display, log] call ace_medical_menu_fnc_updateActivityLog
*
* Public: No
*/
@ -24,7 +24,7 @@ _logCtrl = _display displayCtrl 214;
lbClear _logCtrl;
{
_x params ["_message", "_moment", "_dummy", "_arguments"];
_x params ["_message", "_moment", "", "_arguments"];
if (isLocalized _message) then {
_message = localize _message;

View File

@ -4,22 +4,23 @@
*
* Arguments:
* 0: selection bloodloss <ARRAY>
* 1: display <DISPLAY>
* 1: damaged (array of bools) <ARRAY>
* 2: display <DISPLAY>
*
* Return Value:
* None
*
* Example:
* [0.3, some_display] call ace_medical_menu_updateBodyImage
* [0.3, some_display] call ace_medical_menu_fnc_updateBodyImage
*
* Public: No
*/
#include "script_component.hpp"
params ["_selectionBloodLoss", "_display"];
params ["_selectionBloodLoss", "_damaged", "_display"];
// Handle the body image coloring
_availableSelections = [50, 51, 52, 53, 54, 55];
local _availableSelections = [50, 51, 52, 53, 54, 55];
{
private ["_red", "_green", "_blue"];

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* [] call ace_medical_menu_updateIcons
* [] call ace_medical_menu_fnc_updateIcons
*
* Public: No
*/
@ -18,7 +18,7 @@
#define START_IDC 111
#define END_IDC 118
private ["_display", "_idc", "_options", "_name", "_amount"];
private ["_display", "_idc", "_options", "_amount"];
disableSerialization;

View File

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

View File

@ -10,7 +10,7 @@
* None
*
* Example:
* [some_display, log] call ace_medical_menu_updateQuickViewLog
* [some_display, log] call ace_medical_menu_fnc_updateQuickViewLog
*
* Public: No
*/
@ -24,7 +24,7 @@ _logCtrl = _display displayCtrl 215;
lbClear _logCtrl;
{
_x params ["_message", "_moment", "_dummy", "_arguments"];
_x params ["_message", "_moment", "", "_arguments"];
if (isLocalized _message) then {
_message = localize _message;

View File

@ -10,18 +10,20 @@
* None
*
* Example:
* [some_player, some_display] call ace_medical_menu_updateUIInfo
* [some_player, some_display] call ace_medical_menu_fnc_updateUIInfo
*
* Public: No
*/
#include "script_component.hpp"
private ["_genericMessages", "_totalIvVolume", "_damaged", "_selectionBloodLoss", "_allInjuryTexts"];
params ["_target", "_display"];
private["_allInjuryTexts", "_bandagedwounds", "_damaged", "_genericMessages", "_logs", "_openWounds", "_part", "_partText", "_pointDamage", "_selectionBloodLoss", "_selectionN", "_severity", "_totalIvVolume", "_triageStatus"];
if (isNil "_display" || {isNull _display}) exitWith {ERROR("No display");};
_selectionN = GVAR(selectedBodyPart);
if (_selectionN < 0 || _selectionN > 5) exitwith {};
if (_selectionN < 0 || {_selectionN > 5}) exitwith {};
_genericMessages = [];
_partText = [ELSTRING(medical,Head), ELSTRING(medical,Torso), ELSTRING(medical,LeftArm) ,ELSTRING(medical,RightArm) ,ELSTRING(medical,LeftLeg), ELSTRING(medical,RightLeg)] select _selectionN;
@ -109,7 +111,7 @@ if (EGVAR(medical,level) >= 2) then {
{
_selectionBloodLoss set [_forEachIndex, _x];
if (_x > 0 && _forEachIndex == _selectionN) then {
if ((_x > 0) && {_forEachIndex == _selectionN}) then {
_pointDamage = _x;
_severity = switch (true) do {
case (_pointDamage > 0.5): {localize ELSTRING(medical,HeavilyWounded)};
@ -129,7 +131,7 @@ if (EGVAR(medical,level) >= 2) then {
} forEach (_target getvariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0]]);
};
[_selectionBloodLoss, _display] call FUNC(updateBodyImage);
[_selectionBloodLoss, _damaged, _display] call FUNC(updateBodyImage);
[_display, _genericMessages, _allInjuryTexts] call FUNC(updateInformationLists);
_logs = _target getVariable [QEGVAR(medical,logFile_activity_view), []];

View File

@ -325,7 +325,7 @@ class GVAR(medicalMenu) {
animTextureFocused = "#(argb,8,8,3)color(0,0,0,0.0)";
animTexturePressed = "#(argb,8,8,3)color(0,0,0,0.0)";
animTextureDefault = "#(argb,8,8,3)color(0,0,0,0.0)";
action = QUOTE(GVAR(selectedBodyPart) = 0; [GVAR(INTERACTION_TARGET)] call FUNC(updateUIInfo););
action = QUOTE(GVAR(selectedBodyPart) = 0;);
};
class selectTorso : selectHead {
idc = 302;
@ -333,7 +333,7 @@ class GVAR(medicalMenu) {
y = "5.4 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
w = "2.2 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "4.1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
action = QUOTE(GVAR(selectedBodyPart) = 1; [GVAR(INTERACTION_TARGET)] call FUNC(updateUIInfo););
action = QUOTE(GVAR(selectedBodyPart) = 1;);
};
class selectLeftArm: selectHead{
idc = 303;
@ -341,12 +341,12 @@ class GVAR(medicalMenu) {
y = "5.9 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
w = "1.1 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "4.3 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
action = QUOTE(GVAR(selectedBodyPart) = 3; [GVAR(INTERACTION_TARGET)] call FUNC(updateUIInfo););
action = QUOTE(GVAR(selectedBodyPart) = 3;);
};
class selectRightArm: selectLeftArm{
idc = 304;
x = "20.6 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)";
action = QUOTE(GVAR(selectedBodyPart) = 2; [GVAR(INTERACTION_TARGET)] call FUNC(updateUIInfo););
action = QUOTE(GVAR(selectedBodyPart) = 2;);
};
class selectLeftLeg :selectHead {
idc = 305;
@ -354,12 +354,12 @@ class GVAR(medicalMenu) {
y = "9.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
w = "1.1 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "6 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
action = QUOTE(GVAR(selectedBodyPart) = 5; [GVAR(INTERACTION_TARGET)] call FUNC(updateUIInfo););
action = QUOTE(GVAR(selectedBodyPart) = 5;);
};
class selectRightLeg :selectLeftLeg {
idc = 306;
x = "19.6 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)";
action = QUOTE(GVAR(selectedBodyPart) = 4; [GVAR(INTERACTION_TARGET)] call FUNC(updateUIInfo););
action = QUOTE(GVAR(selectedBodyPart) = 4;);
};