Skip to content

Commit

Permalink
GUI stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueTheKing committed Oct 14, 2023
1 parent 140bac7 commit 80e165c
Show file tree
Hide file tree
Showing 13 changed files with 416 additions and 172 deletions.
4 changes: 3 additions & 1 deletion addons/breathing/functions/fnc_handlePulmoHit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ if (GVAR(pneumothoraxDamageThreshold_TakenDamage)) then {
};

if (floor (random 100) <= (GVAR(pneumothoraxChance) + _chanceIncrease)) then {
if(_unit getVariable [QGVAR(pneumothorax), 0] isEqualto 0 && !(_unit getVariable [QGVAR(tensionpneumothorax), false])) then { // Initial pneumothorax
if (_unit getVariable [QGVAR(pneumothorax), 0] isEqualto 0 && !(_unit getVariable [QGVAR(tensionpneumothorax), false])) then { // Initial pneumothorax
// add breathing sound
[_unit, 0.2] call ACEFUNC(medical_status,adjustPainLevel);
[_unit] call FUNC(handleBreathing);
_unit setVariable [QGVAR(pneumothorax), 1, true];
_unit setVariable [QGVAR(deepPenetratingInjury), true, true];
_unit setVariable [QGVAR(activeChestSeal), false, true];

// Start deteriorating after delay
[{
Expand Down Expand Up @@ -111,5 +112,6 @@ if (floor (random 100) <= (GVAR(pneumothoraxChance) + _chanceIncrease)) then {
} else { // Damage threshold was passed but no pneumothorax given, try to just give injury instead
if (floor (random 100) <= GVAR(deepPenetratingInjuryChance)) then {
_unit setVariable [QGVAR(deepPenetratingInjury), true, true];
_unit setVariable [QGVAR(activeChestSeal), false, true];
};
};
105 changes: 103 additions & 2 deletions addons/gui/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,109 @@ PREP_RECOMPILE_END;
[
QGVAR(ColoredLogs),
"CHECKBOX",
[LLSTRING(SETTING_ColoredLogs),LLSTRING(SETTING_ColoredLogs_DESC)],
[LLSTRING(SETTING_ColoredLogs), LLSTRING(SETTING_ColoredLogs_DESC)],
[CBA_SETTINGS_CAT, LSTRING(SubCategory_Basic)],
[true],
true
] call CBA_Settings_fnc_init;
] call CBA_Settings_fnc_init;

// Show inactive patient statuses
[
QGVAR(showInactiveStatuses),
"CHECKBOX",
LLSTRING(SETTING_showInactiveStatuses),
[CBA_SETTINGS_CAT, LSTRING(SubCategory_Basic)],
[false],
true
] call CBA_Settings_fnc_init;

// Display bleed rate (slow/moderate/severe/massive)
[
QGVAR(showBleedRate),
"CHECKBOX",
[LLSTRING(SETTING_showBleedRate), LLSTRING(SETTING_showBleedRate_DESC)],
[CBA_SETTINGS_CAT, LSTRING(SubCategory_Basic)],
[false],
true
] call CBA_Settings_fnc_init;

// Overlay selected body part in medical menu
[
QGVAR(overlayBodyPart),
"CHECKBOX",
LLSTRING(SETTING_overlayBodyPart),
[CBA_SETTINGS_CAT, LSTRING(SubCategory_Basic)],
[false],
false
] call CBA_Settings_fnc_init;

// Label left and right in medical menu
[
QGVAR(showPatientSideLabels),
"CHECKBOX",
LLSTRING(SETTING_showPatientSideLabels),
[CBA_SETTINGS_CAT, LSTRING(SubCategory_Basic)],
[false],
false
] call CBA_Settings_fnc_init;

// OVERRIDE ACE

/*
* Default damage colouring follows a "white, yellow, red" colour scale with 10 steps, Bezier interpolation and Correct lightness gradient.
* See: https://gka.github.io/palettes
* // KAM // "#ffef7a, yellow, red" - 9 steps
*/
private _bloodLossColors = [
[1.00, 1.00, 1.00, 1],
[1.00, 0.94, 0.48, 1],
[1.00, 0.87, 0.25, 1],
[1.00, 0.79, 0.17, 1],
[1.00, 0.71, 0.11, 1],
[1.00, 0.62, 0.05, 1],
[1.00, 0.53, 0.01, 1],
[1.00, 0.42, 0.00, 1],
[1.00, 0.29, 0.00, 1],
[1.00, 0.00, 0.00, 1]
];

/*
* Default damage colouring follows a "white, cyan, blue" colour scale with 10 steps, Bezier interpolation and Correct lightness gradient.
* See: https://gka.github.io/palettes
* // KAM // "white, cyan, blue" - 12 steps
*/
private _damageColors = [
[1.00, 1.00, 1.00, 1],
[0.52, 0.73, 1.00, 1],
[0.38, 0.68, 1.00, 1],
[0.37, 0.60, 1.00, 1],
[0.35, 0.53, 1.00, 1],
[0.33, 0.45, 1.00, 1],
[0.30, 0.37, 1.00, 1],
[0.25, 0.29, 1.00, 1],
[0.18, 0.18, 1.00, 1],
[0.00, 0.00, 1.00, 1]
];

private _categoryColors = [ACELSTRING(medical,Category), format ["| %1 |", ACELLSTRING(common,subcategory_colors)]];
{
[
format ["%1_%2", QACEGVAR(medical_gui,bloodLossColor), _forEachIndex],
"COLOR",
[format [localize ACELSTRING(medical_gui,BloodLossColorX_DisplayName), _forEachIndex], ACELSTRING(medical_gui,BloodLossColor_Description)],
_categoryColors,
_x,
false // isGlobal
] call CBA_fnc_addSetting;
} forEach _bloodLossColors;

{
[
format ["%1_%2", QACEGVAR(medical_gui,damageColor), _forEachIndex],
"COLOR",
[format [localize ACELSTRING(medical_gui,DamageColorX_DisplayName), _forEachIndex], ACELSTRING(medical_gui,DamageColor_Description)],
_categoryColors,
_x,
false // isGlobal
] call CBA_fnc_addSetting;
} forEach _damageColors;
2 changes: 1 addition & 1 deletion addons/gui/functions/fnc_displayPatientInformation.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if (isNull _display) then {

// Update body image
private _ctrlBodyImage = _display displayCtrl IDC_BODY_GROUP;
[_ctrlBodyImage, _target] call ACEFUNC(medical_gui,updateBodyImage);
[_ctrlBodyImage, _target, _selectionN] call ACEFUNC(medical_gui,updateBodyImage);

// Update injury list
private _ctrlInjuries = _display displayCtrl IDC_INJURIES;
Expand Down
2 changes: 1 addition & 1 deletion addons/gui/functions/fnc_menuPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private _ctrlInjuries = _display displayCtrl IDC_INJURIES;

// Update body image
private _ctrlBodyImage = _display displayCtrl IDC_BODY_GROUP;
[_ctrlBodyImage, ACEGVAR(medical_gui,target)] call ACEFUNC(medical_gui,updateBodyImage);
[_ctrlBodyImage, ACEGVAR(medical_gui,target), ACEGVAR(medical_gui,selectedBodyPart)] call ACEFUNC(medical_gui,updateBodyImage);

// Update activity and quick view logs
private _ctrlActivityLog = _display displayCtrl IDC_ACTIVITY;
Expand Down
19 changes: 17 additions & 2 deletions addons/gui/functions/fnc_onMenuOpen.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private _countEnabled = {
if (_category isEqualType "") then { _x set [1, (ACEGVAR(medical_gui,actions) findIf {_category == _x select 1}) > -1]; };
_x select 1
} count _list;
private _offsetX = POS_X(1.5) + 0.5 * (POS_X(12) - POS_X(_countEnabled * 1.5));
private _offsetX = POS_X(1.75) + 0.5 * (POS_X(12) - POS_X(_countEnabled * 1.5));
{
_x params ["_idc", "_enabled"];
private _ctrl = _display displayCtrl _idc;
Expand All @@ -71,4 +71,19 @@ private _offsetX = POS_X(1.5) + 0.5 * (POS_X(12) - POS_X(_countEnabled * 1.5));
} else {
_ctrl ctrlShow false;
};
} forEach _list;
} forEach _list;

if (GVAR(showPatientSideLabels)) then {
(_display displayCtrl IDC_SIDE_LABEL_LEFT) ctrlShow true;
(_display displayCtrl IDC_SIDE_LABEL_RIGHT) ctrlShow true;
};

// Set toggle button icon and tooltip
private _ctrl = _display displayCtrl IDC_TOGGLE;
if (ACEGVAR(medical_gui,target) == ACE_player) then {
_ctrl ctrlSetText QACEPATHTOF(medical_gui,data\categories\toggle_to_other.paa);
_ctrl ctrlSetTooltip ACELLSTRING(medical_gui,ToggleToOther);
} else {
_ctrl ctrlSetText QACEPATHTOF(medical_gui,data\categories\toggle_to_self.paa);
_ctrl ctrlSetTooltip ACELLSTRING(medical_gui,ToggleToSelf);
};
12 changes: 11 additions & 1 deletion addons/gui/functions/fnc_updateActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (_showTriage) exitWith {
// Show treatment options on action buttons
private _shownIndex = 0;
{
_x params ["_displayName", "_category", "_condition", "_statement"];
_x params ["_displayName", "_category", "_condition", "_statement", "_items"];

// Check action category and condition
if (_category == _selectedCategory && {call _condition}) then {
Expand All @@ -50,6 +50,16 @@ private _shownIndex = 0;
_ctrl ctrlSetPositionY POS_H(1.1 * _shownIndex);
_ctrl ctrlCommit 0;

private _countText = "";
if (_items isNotEqualTo []) then {
if ("ACE_surgicalKit" in _items && {ACEGVAR(medical_treatment,consumeSurgicalKit) == 2}) then {
_items = ["ACE_suture"];
};
private _counts = [_items] call ACEFUNC(medical_gui,countTreatmentItems);
_countText = _counts call ACEFUNC(medical_gui,formatItemCounts);
};
_ctrl ctrlSetTooltip _countText;

_ctrl ctrlSetText _displayName;
_ctrl ctrlShow true;

Expand Down
31 changes: 20 additions & 11 deletions addons/gui/functions/fnc_updateBodyImage.sqf
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#include "script_component.hpp"
/*
* Author: Glowbal, SilentSpike, mharis001
* Modified: Blue
* Updates the body image for given target.
*
* Arguments:
* 0: Body image controls group <CONTROL>
* 1: Target <OBJECT>
* 2: Body part <NUMBER>
*
* Return Value:
* None
*
* Example:
* [CONTROL, _target] call ace_medical_gui_fnc_updateBodyImage
* [CONTROL, _target, 0] call ace_medical_gui_fnc_updateBodyImage
*
* Public: No
*/

params ["_ctrlGroup", "_target"];
params ["_ctrlGroup", "_target", "_selectionN"];

// Get tourniquets, damage, and blood loss for target
private _tourniquets = GET_TOURNIQUETS(_target);
Expand All @@ -34,7 +36,14 @@ private _bodyPartBloodLoss = [0, 0, 0, 0, 0, 0];
} forEach GET_OPEN_WOUNDS(_target);

{
_x params ["_bodyPartIDC", ["_tourniquetIDC", -1], ["_fractureIDC", -1]];
_x params ["_bodyPartIDC", "_selectedIDC", ["_tourniquetIDC", -1], ["_fractureIDC", -1]];

if (GVAR(overlayBodyPart)) then {
private _selected = _forEachIndex == _selectionN;
private _ctrlSelected = _ctrlGroup controlsGroupCtrl _selectedIDC;
_ctrlSelected ctrlSetTextColor ACEGVAR(medical_gui,bodypartOutlineColor);
_ctrlSelected ctrlShow _selected;
};

// Show or hide the tourniquet icon
if (_tourniquetIDC != -1) then {
Expand Down Expand Up @@ -73,10 +82,10 @@ private _bodyPartBloodLoss = [0, 0, 0, 0, 0, 0];
private _damage = _bodyPartDamage select _forEachIndex;
switch (true) do { // torso damage threshold doesn't need scaling
case (_forEachIndex > 3): { // legs: index 4 & 5
_damageThreshold = LIMPING_DAMAGE_THRESHOLD * 4;
_damageThreshold = LIMPING_DAMAGE_THRESHOLD_DEFAULT * 4;
};
case (_forEachIndex > 1): { // arms: index 2 & 3
_damageThreshold = FRACTURE_DAMAGE_THRESHOLD * 4;
_damageThreshold = FRACTURE_DAMAGE_THRESHOLD_DEFAULT * 4;
};
case (_forEachIndex == 0): { // head: index 0
_damageThreshold = _damageThreshold * 1.25;
Expand All @@ -92,12 +101,12 @@ private _bodyPartBloodLoss = [0, 0, 0, 0, 0, 0];
private _ctrlBodyPart = _ctrlGroup controlsGroupCtrl _bodyPartIDC;
_ctrlBodyPart ctrlSetTextColor _bodyPartColor;
} forEach [
[IDC_BODY_HEAD],
[IDC_BODY_TORSO],
[IDC_BODY_ARMLEFT, IDC_BODY_ARMLEFT_T, IDC_BODY_ARMLEFT_B],
[IDC_BODY_ARMRIGHT, IDC_BODY_ARMRIGHT_T, IDC_BODY_ARMRIGHT_B],
[IDC_BODY_LEGLEFT, IDC_BODY_LEGLEFT_T, IDC_BODY_LEGLEFT_B],
[IDC_BODY_LEGRIGHT, IDC_BODY_LEGRIGHT_T, IDC_BODY_LEGRIGHT_B]
[IDC_BODY_HEAD, IDC_BODY_HEAD_S],
[IDC_BODY_TORSO, IDC_BODY_TORSO_S],
[IDC_BODY_ARMLEFT, IDC_BODY_ARMLEFT_S, IDC_BODY_ARMLEFT_T, IDC_BODY_ARMLEFT_B],
[IDC_BODY_ARMRIGHT, IDC_BODY_ARMRIGHT_S, IDC_BODY_ARMRIGHT_T, IDC_BODY_ARMRIGHT_B],
[IDC_BODY_LEGLEFT, IDC_BODY_LEGLEFT_S, IDC_BODY_LEGLEFT_T, IDC_BODY_LEGLEFT_B],
[IDC_BODY_LEGRIGHT, IDC_BODY_LEGRIGHT_S, IDC_BODY_LEGRIGHT_T, IDC_BODY_LEGRIGHT_B]
];

// Airway
Expand Down
Loading

0 comments on commit 80e165c

Please sign in to comment.