#2528 - Medical Menu Work

(1) Verify target is valid and in reasonable range
This commit is contained in:
PabstMirror 2015-10-13 02:01:59 -05:00
parent 4ba0d72bfd
commit ad1191cdd5
16 changed files with 64 additions and 44 deletions

View File

@ -24,4 +24,8 @@ class ACE_Settings {
isClientSettable = 1;
category = ECSTRING(medical,Category_Medical);
};
class GVAR(maxRange) {
value = 4;
typeName = "SCALAR";
};
};

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,9 @@
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};
(alive _caller)
&& {!isNull _target}
&& {(_caller distance _target) < GVAR(maxRange)}
&& {(GVAR(allow) == 1) || {(GVAR(allow) == 2) && {vehicle _caller != _caller || vehicle _target != _target}}}
&& {(GVAR(useMenu) == 1) || {(GVAR(useMenu) == 2) && {vehicle _caller != _caller || vehicle _target != _target}}}
true

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 (isNull _display) exitWith {ERROR("bad 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), []];