Skip to content

Commit

Permalink
Change "Remove Wheel" Action's Color Based on Damage (#5415)
Browse files Browse the repository at this point in the history
* Change repair action's colors on wheels

* Add dots.
  • Loading branch information
654wak654 authored and jonpas committed Aug 10, 2017
1 parent 2928446 commit ff1247d
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 10 deletions.
1 change: 1 addition & 0 deletions addons/repair/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ PREP(isInRepairFacility);
PREP(isNearRepairVehicle);
PREP(isRepairVehicle);
PREP(modifyInteraction);
PREP(modifySelectionInteraction);
PREP(moduleAddSpareParts);
PREP(moduleAssignEngineer);
PREP(moduleAssignRepairVehicle);
Expand Down
8 changes: 3 additions & 5 deletions addons/repair/functions/fnc_addRepairActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ _hitPointsAddedNames = [];
_hitPointsAddedStrings = [];
_hitPointsAddedAmount = [];
_processedHitpoints = [];
_icon = QPATHTOF(ui\repair_0_ca.paa);

{
_selection = _x;
Expand All @@ -48,8 +49,6 @@ _processedHitpoints = [];
// Wheels should always be unique
if (_hitpoint in _processedHitpoints) exitWith {TRACE_3("Duplicate Wheel",_hitpoint,_forEachIndex,_selection);};

_icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa";

_position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _selection];

TRACE_3("Adding Wheel Actions",_hitpoint,_forEachIndex,_selection);
Expand All @@ -59,7 +58,7 @@ _processedHitpoints = [];
private _text = localize LSTRING(RemoveWheel);
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(canRepair)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(repair)};
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction);
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 2, nil, FUNC(modifySelectionInteraction)] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);

// An action to replace the wheel is required
Expand Down Expand Up @@ -121,7 +120,6 @@ _processedHitpoints = [];

// Prepair the repair action
_name = format ["Repair_%1_%2", _forEachIndex, _selection];
_icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa";

// Find localized string and track those added for numerization
([_hitpoint, "%1", _hitpoint, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_text", "_trackArray"];
Expand Down Expand Up @@ -161,7 +159,7 @@ _processedHitpoints = [];

_condition = {[_this select 1, _this select 0, "", "fullRepair"] call DFUNC(canRepair)};
_statement = {[_this select 1, _this select 0, "", "fullRepair"] call DFUNC(repair)};
_action = [QGVAR(fullRepair), localize LSTRING(fullRepair), "A3\ui_f\data\igui\cfg\actions\repair_ca.paa", _statement, _condition, {}, [], "", 4] call EFUNC(interact_menu,createAction);
_action = [QGVAR(fullRepair), localize LSTRING(fullRepair), _icon, _statement, _condition, {}, [], "", 4] call EFUNC(interact_menu,createAction);
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);

// set class as initialized
Expand Down
2 changes: 1 addition & 1 deletion addons/repair/functions/fnc_doFullRepair.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Author: Glowbal
* Fully repairs vehicle
* Fully repairs vehicle.
*
* Arguments:
* 0: Unit that does the repairing (not used) <OBJECT>
Expand Down
2 changes: 1 addition & 1 deletion addons/repair/functions/fnc_getClaimObjects.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Author: PabstMirror
* Returns array of required nearby repair objects (wheels/tracks)
* Returns array of required nearby repair objects (wheels/tracks).
*
* Arguments:
* 0: Unit that does the repairing <OBJECT>
Expand Down
4 changes: 2 additions & 2 deletions addons/repair/functions/fnc_modifyInteraction.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Author: PabstMirror
* Modifies the base interaction point for repair items to show it's current damage
* Modifies the base interaction point for repair items to show it's current damage.
*
* Arguments:
* 0: Target <OBJECT>
Expand All @@ -12,7 +12,7 @@
* None
*
* Example:
* [cursorObject, player, [], []] call ace_repair_fnc_modifyInteraction;
* [cursorObject, ace_player, [], []] call ace_repair_fnc_modifyInteraction;
*
* Public: No
*/
Expand Down
32 changes: 32 additions & 0 deletions addons/repair/functions/fnc_modifySelectionInteraction.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Author: 654wak654
* Modifies interaction color of vehicle selection to show it's current damage.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Player <OBJECT>
* 2: Args <Any>
* 3: Action Data <ARRAY>
*
* Return Value:
* None
*
* Example:
* [cursorObject, ace_player, [], []] call ace_repair_fnc_modifySelectionInteraction;
*
* Public: No
*/
#include "script_component.hpp"

params ["_target", "_player", "_args", "_actionData"];
TRACE_4("params",_target,_player,_args,_actionData);

// Interaction wrenches numbered 0..8, white to red.
// Convert damage to number (rounding up), so that even slight damage can bee seen

private _fileName = format [
QPATHTOF(ui\repair_%1_ca.paa),
ceil (linearConversion [0, 1, _target getHitPointDamage (_args select 0), 0, 8, true])
];

_actionData set [2, _fileName];
2 changes: 1 addition & 1 deletion addons/repair/functions/fnc_setHitPointDamage.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Author: commy2
* Set the hitpoint damage and change the structural damage acordingly, requires local vehicle.
* Handles the ace_repair_setVehicleHitPointDamage event
* Handles the ace_repair_setVehicleHitPointDamage event.
*
* Arguments:
* 0: Local Vehicle to Damage <OBJECT>
Expand Down
Binary file added addons/repair/ui/repair_0_ca.paa
Binary file not shown.
Binary file added addons/repair/ui/repair_1_ca.paa
Binary file not shown.
Binary file added addons/repair/ui/repair_2_ca.paa
Binary file not shown.
Binary file added addons/repair/ui/repair_3_ca.paa
Binary file not shown.
Binary file added addons/repair/ui/repair_4_ca.paa
Binary file not shown.
Binary file added addons/repair/ui/repair_5_ca.paa
Binary file not shown.
Binary file added addons/repair/ui/repair_6_ca.paa
Binary file not shown.
Binary file added addons/repair/ui/repair_7_ca.paa
Binary file not shown.
Binary file added addons/repair/ui/repair_8_ca.paa
Binary file not shown.

0 comments on commit ff1247d

Please sign in to comment.