Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Field rations - Add inventory context menu action (#229)
Browse files Browse the repository at this point in the history
* fix addIntel

* ContextMenuOption for field_rations; #include above comments; replace old ACE_medical_fnc_setDead

* optimizations

* base class like in intelitems

* localize LSTRING -> LLSTRING

* that is not for the repo

* fix

* use only ACE_ItemCore; show if enabled and field_rations items; enable if is full

* Update addons/field_rations/XEH_postInit.sqf

Co-authored-by: mharis001 <[email protected]>

* moved EatDrink Up

Co-authored-by: mharis001 <[email protected]>
  • Loading branch information
shukari and mharis001 authored Jun 20, 2020
1 parent 3c4d875 commit d0ed5f3
Show file tree
Hide file tree
Showing 38 changed files with 66 additions and 50 deletions.
27 changes: 24 additions & 3 deletions addons/field_rations/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if !(hasInterface) exitWith {};
// Compile water source actions
private _mainAction = [
QGVAR(waterSource),
localize LSTRING(WaterSource),
LLSTRING(WaterSource),
QPATHTOF(ui\icon_water_tap.paa),
{true},
{
Expand All @@ -41,7 +41,7 @@ if !(hasInterface) exitWith {};
private _subActions = [
[
QGVAR(checkWater),
localize LSTRING(CheckWater),
LLSTRING(CheckWater),
QPATHTOF(ui\icon_water_tap.paa),
{
private _waterSource = _target getVariable [QGVAR(waterSource), objNull];
Expand All @@ -54,7 +54,7 @@ if !(hasInterface) exitWith {};
] call ACEFUNC(interact_menu,createAction),
[
QGVAR(drinkFromSource),
localize LSTRING(DrinkFromSource),
LLSTRING(DrinkFromSource),
QPATHTOF(ui\icon_water_tap.paa),
{
private _waterSource = _target getVariable [QGVAR(waterSource), objNull];
Expand All @@ -73,6 +73,27 @@ if !(hasInterface) exitWith {};
[QGVAR(helper), 0, [QGVAR(waterSource)], _x] call ACEFUNC(interact_menu,addActionToClass);
} forEach _subActions;

// Add inventory context menu option to consume items
["ACE_ItemCore", ["CONTAINER"], LSTRING(EatDrink), [], QPATHTOF(ui\icon_survival.paa),
[
{true},
{
params ["", "", "_item"];

GVAR(enabled) && {
private _config = configFile >> "CfgWeapons" >> _item;
getNumber (_config >> QGVAR(thirstQuenched)) > 0
|| {getNumber (_config >> QGVAR(hungerSatiated)) > 0}
}
}
],
{
params ["_unit", "", "_item"];
[objNull, _unit, _item] call FUNC(consumeItem);
false
}
] call CBA_fnc_addItemContextMenuOption;

// Add water source helpers when interaction menu is opened
["ace_interactMenuOpened", {call FUNC(addWaterSourceInteractions)}] call CBA_fnc_addEventHandler;

Expand Down
2 changes: 1 addition & 1 deletion addons/field_rations/functions/fnc_addStatusModifier.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Adds a status modifier. Should be called on all machines.
Expand All @@ -15,7 +16,6 @@
*
* Public: Yes
*/
#include "script_component.hpp"

params [["_type", -1, [0]], ["_code", {}, [{}]]];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: PabstMirror, mharis001
* Dynamically adds actions to nearby water sources when interact_menu is opened.
Expand All @@ -14,7 +15,6 @@
*
* Public: No
*/
#include "script_component.hpp"

params ["_interactionType"];

Expand Down
2 changes: 1 addition & 1 deletion addons/field_rations/functions/fnc_canRefillItem.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001, Glowbal, PabstMirror
* Checks whether the player can refill an item from given water source.
Expand All @@ -15,7 +16,6 @@
*
* Public: No
*/
#include "script_component.hpp"

params ["_source", "_player", "_item"];

Expand Down
4 changes: 2 additions & 2 deletions addons/field_rations/functions/fnc_checkWater.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Displays the remaining water in the given water source.
Expand All @@ -14,7 +15,6 @@
*
* Public: No
*/
#include "script_component.hpp"

params ["_player", "_source"];

Expand All @@ -34,5 +34,5 @@ params ["_player", "_source"];
};
},
{},
localize LSTRING(CheckingWater)
LLSTRING(CheckingWater)
] call ACEFUNC(common,progressBar);
6 changes: 3 additions & 3 deletions addons/field_rations/functions/fnc_consumeItem.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001, Glowbal, PabstMirror
* Consumes an item. Creates a progress bar and handles relevant thirst/hunger values.
Expand All @@ -15,7 +16,6 @@
*
* Public: No
*/
#include "script_component.hpp"

params ["", "_player", "_consumeItem"];
TRACE_2("Consume item started",_player,_consumeItem);
Expand All @@ -36,9 +36,9 @@ private _consumeText = getText (_config >> QGVAR(consumeText));

if (_consumeText == "") then {
_consumeText = if (_hungerSatiated > 0) then {
localize LSTRING(EatingX);
LLSTRING(EatingX);
} else {
localize LSTRING(DrinkingX);
LLSTRING(DrinkingX);
};
};

Expand Down
4 changes: 2 additions & 2 deletions addons/field_rations/functions/fnc_drinkFromSource.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ private _fnc_condition = {

private _sourceType = typeOf _source;
private _progressText = if (_sourceType == "") then {
localize LSTRING(DrinkingFromSource)
LLSTRING(DrinkingFromSource)
} else {
format [localize LSTRING(DrinkingFromX), getText (configFile >> "CfgVehicles" >> _sourceType >> "displayName")]
format [LLSTRING(DrinkingFromX), getText (configFile >> "CfgVehicles" >> _sourceType >> "displayName")]
};

[
Expand Down
2 changes: 1 addition & 1 deletion addons/field_rations/functions/fnc_getActionOffset.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Returns the refill action offset for given object.
Expand All @@ -13,7 +14,6 @@
*
* Public: No
*/
#include "script_component.hpp"

params ["_object"];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001, Glowbal, PabstMirror
* Returns children actions for consumable items in player's inventory.
Expand All @@ -13,7 +14,6 @@
*
* Public: No
*/
#include "script_component.hpp"

params ["_player"];

Expand Down
4 changes: 2 additions & 2 deletions addons/field_rations/functions/fnc_getRefillChildren.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Returns children actions for refillable items in player's inventory for given water source.
Expand All @@ -14,7 +15,6 @@
*
* Public: No
*/
#include "script_component.hpp"

params ["_source", "_player"];

Expand All @@ -28,7 +28,7 @@ private _cfgWeapons = configFile >> "CfgWeapons";
{
private _config = _cfgWeapons >> _x;
if (getText (_config >> QGVAR(refillItem)) != "" && {_water == REFILL_WATER_INFINITE || {getNumber (_config >> QGVAR(refillAmount)) <= _water}}) then {
private _displayName = format ["%1: %2", localize LSTRING(Refill), getText (_config >> "displayName")];
private _displayName = format ["%1: %2", LLSTRING(Refill), getText (_config >> "displayName")];
private _picture = getText (_config >> "picture");
private _action = [_x, _displayName, _picture, FUNC(refillItem), FUNC(canRefillItem), {}, _x] call ACEFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _source];
Expand Down
2 changes: 1 addition & 1 deletion addons/field_rations/functions/fnc_getRemainingWater.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001, PabstMirror
* Returns the remaining water in a source.
Expand All @@ -13,7 +14,6 @@
*
* Public: Yes
*/
#include "script_component.hpp"

params [["_source", objNull, [objNull]]];

Expand Down
2 changes: 1 addition & 1 deletion addons/field_rations/functions/fnc_handleHUD.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Handles creating and updating the visuals of the HUD.
Expand All @@ -14,7 +15,6 @@
*
* Public: No
*/
#include "script_component.hpp"

params [["_thirst", ACE_player getVariable [QGVAR(thirst), 0]], ["_hunger", ACE_player getVariable [QGVAR(hunger), 0]]];

Expand Down
2 changes: 1 addition & 1 deletion addons/field_rations/functions/fnc_handleRespawn.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001, Glowbal, PabstMirror
* Handles the respawning of a unit by resetting necessary variables.
Expand All @@ -14,7 +15,6 @@
*
* Public: No
*/
#include "script_component.hpp"

params ["_unit", "_corpse"];
TRACE_2("Handle Respawn",_unit,_corpse);
Expand Down
4 changes: 2 additions & 2 deletions addons/field_rations/functions/fnc_refillItem.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001, Glowbal, PabstMirror
* Refills an item from given water source.
Expand All @@ -15,7 +16,6 @@
*
* Public: No
*/
#include "script_component.hpp"

params ["_source", "_player", "_item"];
TRACE_3("Item refill started",_source,_player,_item);
Expand Down Expand Up @@ -70,6 +70,6 @@ private _fnc_condition = {
],
_fnc_onSuccess,
_fnc_onFailure,
localize LSTRING(Refilling),
LLSTRING(Refilling),
_fnc_condition
] call ACEFUNC(common,progressBar);
2 changes: 1 addition & 1 deletion addons/field_rations/functions/fnc_setRemainingWater.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001, PabstMirror
* Sets the remaining water supply for given water source.
Expand All @@ -14,7 +15,6 @@
*
* Public: Yes
*/
#include "script_component.hpp"

params [["_source", objNull, [objNull]], ["_water", nil, [0]]];

Expand Down
2 changes: 1 addition & 1 deletion addons/field_rations/functions/fnc_update.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"
/*
* Author: mharis001, Glowbal, PabstMirror
* Main looping function that updates thirst/hunger status.
Expand All @@ -13,7 +14,6 @@
*
* Public: No
*/
#include "script_component.hpp"

// 1 sec (update interval) * 100 (max thirst/hunger) / 3600 (sec in hour) = 0.02777778
#define CHANGE_CONSTANT 0.02777778
Expand Down
4 changes: 4 additions & 0 deletions addons/field_rations/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
<Russian>Выживание</Russian>
<Spanish>Supervivencia</Spanish>
</Key>
<Key ID="STR_ACEX_Field_Rations_EatDrink">
<English>Eat/Drink</English>
<German>Essen/Trinken</German>
</Key>
<Key ID="STR_ACEX_Field_Rations_Enabled_Description">
<English>Enable/Disable Field Rations</English>
<Chinese>啟用/禁用戰地口糧。</Chinese>
Expand Down
2 changes: 1 addition & 1 deletion addons/fortify/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GVAR(objectRotationZ) = 0;
if (_side isEqualTo side group ACE_player && {GVAR(settingHint) isEqualTo 2 || {GVAR(settingHint) isEqualTo 1 && {"ACE_Fortify" in (ACE_player call ACEFUNC(common,uniqueItems))}}}) then {
private _budget = [_side] call FUNC(getBudget);
TRACE_2("sideBudgetHint",_side,_budget);
[format ["%1 $%2", localize LSTRING(Budget), _budget]] call ACEFUNC(common,displayTextStructured);
[format ["%1 $%2", LLSTRING(Budget), _budget]] call ACEFUNC(common,displayTextStructured);
};
}] call CBA_fnc_addEventHandler;

Expand Down
1 change: 0 additions & 1 deletion addons/fortify/functions/fnc_addActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* Public: No
*/


params ["_player"];

private _side = side group _player;
Expand Down
1 change: 0 additions & 1 deletion addons/fortify/functions/fnc_axisLengths.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* Public: Yes
*/


params [["_object", objNull, [objNull]]];

(boundingBoxReal _object) params ["_p1", "_p2"];
Expand Down
1 change: 0 additions & 1 deletion addons/fortify/functions/fnc_canFortify.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* Public: Yes
*/


params ["_player", ["_cost", 0]];

(missionNamespace getVariable [QGVAR(fortifyAllowed), true]) &&
Expand Down
5 changes: 2 additions & 3 deletions addons/fortify/functions/fnc_deployObject.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* Public: No
*/


params ["", "_player", "_params"];
_params params [["_side", sideUnknown, [sideUnknown]], ["_classname", "", [""]], ["_rotations", [0,0,0]]];
TRACE_4("deployObject",_player,_side,_classname,_rotations);
Expand All @@ -35,10 +34,10 @@ GVAR(objectRotationZ) = _rotations select 2;

GVAR(isPlacing) = PLACE_WAITING;

private _lmb = localize LSTRING(confirm);
private _lmb = LLSTRING(confirm);
if (_budget > -1) then {_lmb = _lmb + format [" -$%1", _cost];};
private _rmb = localize ACELSTRING(Common,Cancel);
private _wheel = localize LSTRING(rotate);
private _wheel = LLSTRING(rotate);
private _xAxis = localize "str_disp_conf_xaxis";
private _icons = [["alt", localize "str_3den_display3den_entitymenu_movesurface_text"], ["shift", localize "str_disp_conf_xaxis" + " " + _wheel], ["control", localize "str_disp_conf_yaxis" + " " + _wheel]];
[_lmb, _rmb, _wheel, _icons] call ACEFUNC(interaction,showMouseHint);
Expand Down
1 change: 0 additions & 1 deletion addons/fortify/functions/fnc_getBudget.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* Public: Yes
*/


params ["_side"];

(missionNamespace getVariable [format [QGVAR(Budget_%1), _side], -1])
1 change: 0 additions & 1 deletion addons/fortify/functions/fnc_getCost.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* Public: Yes
*/


params ["_side", "_classname"];

private _objects = missionNamespace getVariable [format [QGVAR(Objects_%1), _side], []];
Expand Down
4 changes: 2 additions & 2 deletions addons/fortify/functions/fnc_modifyAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ params ["", "_player", "", "_actionData"];

private _budget = [side group _player] call FUNC(getBudget);
private _actionText = if (_budget > 0) then {
format ["%1 [$%2]", localize LSTRING(fortify), _budget];
format ["%1 [$%2]", LLSTRING(fortify), _budget];
} else {
localize LSTRING(fortify);
LLSTRING(fortify);
};

_actionData set [1, _actionText];
1 change: 0 additions & 1 deletion addons/fortify/functions/fnc_parseSide.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* Public: Yes
*/


params ["_side"];
TRACE_1("parseSide",_side);

Expand Down
1 change: 0 additions & 1 deletion addons/fortify/functions/fnc_registerObjects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* Public: Yes
*/


if (!isServer) exitWith {};

params [["_side", sideUnknown, [sideUnknown]], ["_budget", -1, [0]], ["_objects", [], [[]]]];
Expand Down
Loading

0 comments on commit d0ed5f3

Please sign in to comment.