Remove Old Cargo Menu

Update to match Old Cargo Menu
Fix some Merge issues that happend
This commit is contained in:
jokoho482 2024-04-21 01:01:55 +02:00
parent 0959735400
commit 7c3713a03f
12 changed files with 46 additions and 286 deletions

View File

@ -15,7 +15,6 @@ PREP(initObject);
PREP(initVehicle);
PREP(loadItem);
PREP(moduleSettings);
PREP(onMenuOpen);
PREP(onOpenInventory);
PREP(paradropItem);
PREP(removeCargoItem);

View File

@ -30,9 +30,7 @@
[[_hint, _itemName, _vehicleName], 3] call EFUNC(common,displayTextStructured);
if (_unloaded && {GVAR(openAfterUnload) in [1, 3]}) then {
GVAR(interactionVehicle) = _vehicle;
GVAR(interactionParadrop) = false;
createDialog QGVAR(menu);
_unloader action ["Gear", _vehicle];
};
}] call CBA_fnc_addEventHandler;
@ -63,9 +61,7 @@
private _unloaded = [_item, _vehicle, _showHint] call FUNC(paradropItem);
if (_unloaded && {GVAR(openAfterUnload) in [2, 3]}) then {
GVAR(interactionVehicle) = _vehicle;
GVAR(interactionParadrop) = true;
createDialog QGVAR(menu);
ACE_Player action ["Gear", _vehicle];
};
}] call CBA_fnc_addEventHandler;
@ -73,26 +69,6 @@
[QGVAR(initObject), LINKFUNC(initObject)] call CBA_fnc_addEventHandler;
[QGVAR(initVehicle), LINKFUNC(initVehicle)] call CBA_fnc_addEventHandler;
GVAR(vehicleAction) = [
QGVAR(openMenu), LLSTRING(openMenu), "",
{
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
GVAR(interactionVehicle) = _target;
GVAR(interactionParadrop) = false;
createDialog QGVAR(menu);
},
{
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
GVAR(enable) &&
{alive _target} &&
{locked _target < 2} &&
{(_target getVariable [QGVAR(hasCargo), getNumber (configOf _target >> QGVAR(hasCargo)) == 1])} &&
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
{[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew)} &&
{([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
}
] call EFUNC(interact_menu,createAction);
GVAR(objectActions) = [
[QGVAR(renameObject), LELSTRING(common,rename), "\a3\Modules_F_Curator\Data\iconMissionName_ca.paa",
{
@ -136,15 +112,6 @@ GVAR(objectActions) = [
] call EFUNC(interact_menu,createAction)
];
// Find all remaining configured classes and init them, see XEH_preStart.sqf
private _vehicleClassesAddAction = call (uiNamespace getVariable [QGVAR(initializedVehicleClasses), {[]}]);
{
[_x, 0, ["ACE_MainActions"], GVAR(vehicleAction)] call EFUNC(interact_menu,addActionToClass);
} forEach _vehicleClassesAddAction;
GVAR(initializedVehicleClasses) append _vehicleClassesAddAction;
private _objectClassesAddAction = call (uiNamespace getVariable [QGVAR(initializedItemClasses), {[]}]);
{

View File

@ -18,5 +18,4 @@ class CfgPatches {
#include "CfgEden.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "menu.hpp"
#include "renameMenu.hpp"

View File

@ -15,15 +15,11 @@
* Public: No
*/
disableSerialization;
private _display = uiNamespace getVariable QGVAR(menuDisplay);
if (isNil "_display") exitWith {};
params [["_index", -1, [0]]];
private _loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
if (_loaded isEqualTo []) exitWith {};
// This can be an object or a classname string
_loaded param [lbCurSel (_display displayCtrl 100), nil]
_loaded param [_index, nil]

View File

@ -125,7 +125,7 @@ if (_vehicle isKindOf "Air") then {
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
GVAR(interactionVehicle) = _target;
GVAR(interactionParadrop) = true;
createDialog QGVAR(menu);
ACE_Player action ["Gear", _target];
};
private _text = LLSTRING(openMenu);

View File

@ -1,102 +0,0 @@
#include "..\script_component.hpp"
/*
* Author: Glowbal
* Handles the UI data display.
*
* Arguments:
* 0: Display <DISPLAY>
*
* Return Value:
* None
*
* Example:
* display call ace_cargo_fnc_onMenuOpen
*
* Public: No
*/
disableSerialization;
params ["_display"];
uiNamespace setVariable [QGVAR(menuDisplay), _display];
if (GVAR(interactionParadrop)) then {
(_display displayCtrl 12) ctrlSetText LLSTRING(paradropButton);
};
// Disable deploy option if paradropping or in Zeus
(_display displayCtrl 13) ctrlEnable (GVAR(enableDeploy) && !GVAR(interactionParadrop) && {isNull curatorCamera});
[{
params ["_vehicle", "_pfhID"];
disableSerialization;
private _display = uiNamespace getVariable QGVAR(menuDisplay);
if (isNil "_display") exitWith {
GVAR(interactionParadrop) = nil;
_pfhID call CBA_fnc_removePerFrameHandler;
};
// Close menu if in invalid state
if (
!alive ACE_player ||
{!alive _vehicle} ||
{locked _vehicle >= 2} ||
{!(_vehicle getVariable [QGVAR(hasCargo), true])} || // if the cargo menu could be opened, the vehicle has QGVAR(hasCargo) in its config or the variable is set using FUNC(setSpace)
{
isNull curatorCamera && // if in Zeus, ignore the checks that follow
{([ACE_player, _vehicle] call EFUNC(interaction,getInteractionDistance)) >= MAX_LOAD_DISTANCE} &&
{(vehicle ACE_player) != _vehicle}
}
) exitWith {
closeDialog 0;
GVAR(interactionParadrop) = nil;
_pfhID call CBA_fnc_removePerFrameHandler;
};
private _ctrl = _display displayCtrl 100;
private _label = _display displayCtrl 2;
// Remove previous entries
lbClear _ctrl;
// Display item names
private _displayName = "";
private _itemSize = 0;
private _index = -1;
private _damageStr = "0%";
private _damage = 0;
{
_displayName = [_x, true] call FUNC(getNameItem);
_itemSize = _x call FUNC(getSizeItem);
_damage = if (_x isEqualType "") then {0} else {damage _x};
_damageStr = ((_damage * 100) toFixed 0) + "%";
if (_itemSize >= 0) then {
_index = if (GVAR(interactionParadrop)) then {
_ctrl lbAdd format ["%1. %2 (%3s)", _forEachIndex + 1, _displayName, GVAR(paradropTimeCoefficent) * _itemSize]
} else {
_ctrl lbAdd format ["%1. %2", _forEachIndex + 1, _displayName]
};
private _tooltip = format ["%1\n%2", format [LLSTRING(sizeMenu), _itemSize], format ["%1: %2", localize "str_a3_normaldamage1", _damageStr]];
_ctrl lbSetTooltip [_index, _tooltip];
} else {
// If item has a size < 0, it means it's not loadable
_index = _ctrl lbAdd _displayName;
_ctrl lbSetTooltip [_index, LLSTRING(unloadingImpossible)];
_ctrl lbSetColor [_index, [1, 0, 0, 1]]; // set text to red
_ctrl lbSetSelectColor [_index, [1, 0, 0, 1]];
};
} forEach (_vehicle getVariable [QGVAR(loaded), []]);
_label ctrlSetText format [LLSTRING(labelSpace), (_vehicle call FUNC(getCargoSpaceLeft)) max 0];
}, 0, GVAR(interactionVehicle)] call CBA_fnc_addPerFrameHandler;

View File

@ -93,7 +93,7 @@ GVAR(interactionParadrop) = _container isKindOf "Air" && {
private _index = lbCurSel (uiNamespace getVariable QGVAR(CargoListBox));
if (_index == -1) exitWith {};
closeDialog 602;
[_index] call FUNC(startUnload);
[ACE_Player, _index] call FUNC(startUnload);
}];
_unloadBtn ctrlCommit 0;
@ -118,19 +118,42 @@ GVAR(interactionParadrop) = _container isKindOf "Air" && {
_args params ["_loadBar", "_list"];
private _cargoItems = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
lbClear _list;
{
private _displayName = [_x, true] call FUNC(getNameItem);
if (GVAR(interactionParadrop)) then {
_displayName = format ["%1 (%2s)", _displayName, GVAR(paradropTimeCoefficent) * ([_x] call FUNC(getSizeItem))];
// Display item names
private _displayName = "";
private _itemSize = 0;
private _index = -1;
private _damageStr = "0%";
private _damage = 0;
{
_displayName = [_x, true] call FUNC(getNameItem);
_itemSize = _x call FUNC(getSizeItem);
_damage = if (_x isEqualType "") then {0} else {damage _x};
_damageStr = ((_damage * 100) toFixed 0) + "%";
if (_itemSize >= 0) then {
_index = if (GVAR(interactionParadrop)) then {
_list lbAdd format ["%1. %2 (%3s)", _forEachIndex + 1, _displayName, GVAR(paradropTimeCoefficent) * _itemSize]
} else {
_list lbAdd format ["%1. %2", _forEachIndex + 1, _displayName]
};
private _tooltip = format ["%1\n%2", format [LLSTRING(sizeMenu), _itemSize], format ["%1: %2", localize "str_a3_normaldamage1", _damageStr]];
_list lbSetTooltip [_index, _tooltip];
} else {
// If item has a size < 0, it means it's not loadable
_index = _list lbAdd _displayName;
_list lbSetTooltip [_index, LLSTRING(unloadingImpossible)];
_list lbSetColor [_index, [1, 0, 0, 1]]; // set text to red
_list lbSetSelectColor [_index, [1, 0, 0, 1]];
};
_list lbAdd _displayName;
} forEach _cargoItems;
private _cargoCapacity = GVAR(interactionVehicle) getVariable [QGVAR(spaceMax), getNumber (configOf GVAR(interactionVehicle) >> QGVAR(space))];
private _usedCargoCapacity = _cargoCapacity - ([GVAR(interactionVehicle)] call FUNC(getCargoSpaceLeft));
_loadBar progressSetPosition (_usedCargoCapacity / _cargoCapacity);
}, 1, [_loadBar, _list]] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_waitUntilAndExecute;

View File

@ -15,7 +15,7 @@
* Public: No
*/
private _display = uiNamespace getVariable QGVAR(menuDisplay);
private _display = uiNamespace getVariable QGVAR(renameMenu);
if (isNil "_display") exitWith {};

View File

@ -4,35 +4,23 @@
* Starts unloading item selected in the cargo menu.
*
* Arguments:
* 0: Index of Unloading Item <NUMBER> (default: -1)
* 1: Unit doing the unloading <OBJECT>
* 0: Unit doing the unloading <OBJECT>
* 1: Index of Unloading Item <NUMBER> (default: -1)
*
* Return Value:
* None
*
* Example:
* player call ace_cargo_fnc_startUnload
* [player, 1] call ace_cargo_fnc_startUnload
*
* Public: No
*/
disableSerialization;
params [["_selected", -1, [0]], ["_unit", objNull, [objNull]]];
params [["_unit", objNull, [objNull]], ["_selected", -1, [0]]];
if (_selected == -1) then {
private _display = uiNamespace getVariable QGVAR(menuDisplay);
if (isNil "_display") exitWith {};
private _ctrl = _display displayCtrl 100;
_selected = (lbCurSel _ctrl) max 0;
};
if (_selected == -1) exitWith {};
private _loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
if (_loaded isEqualTo []) exitWith {};
_item = _selected call FUNC(getSelectedItem);
if (isNil "_item") exitWith {};

View File

@ -1,110 +0,0 @@
#include "\z\ace\addons\common\define.hpp"
class GVAR(menu) {
idd = 314614;
movingEnable = 1;
onLoad = QUOTE([_this select 0] call FUNC(onMenuOpen));
onUnload = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(menuDisplay),nil)]);
class controlsBackground {
class HeaderBackground: ACE_gui_backgroundBase {
idc = -1;
SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
x = "13 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)";
y = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
w = "13 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
text = "#(argb,8,8,3)color(0,0,0,0)";
};
class CenterBackground: HeaderBackground {
y = "2.1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
h = "14.2 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
text = "#(argb,8,8,3)color(0,0,0,0.8)";
colorText[] = {0, 0, 0, "(profilenamespace getVariable ['GUI_BCG_RGB_A',0.9])"};
colorBackground[] = {0, 0, 0, "(profilenamespace getVariable ['GUI_BCG_RGB_A',0.9])"};
};
};
class controls {
class HeaderName {
idc = 1;
type = CT_STATIC;
x = "13 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)";
y = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
w = "13 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
style = QUOTE(ST_LEFT + ST_SHADOW);
font = "RobotoCondensed";
SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
colorText[] = {0.95, 0.95, 0.95, 0.75};
colorBackground[] = {"(profilenamespace getVariable ['GUI_BCG_RGB_R',0.69])","(profilenamespace getVariable ['GUI_BCG_RGB_G',0.75])","(profilenamespace getVariable ['GUI_BCG_RGB_B',0.5])", "(profilenamespace getVariable ['GUI_BCG_RGB_A',0.9])"};
text = CSTRING(cargoMenu);
};
class SubHeader: HeaderName {
idc = 2;
x = "13 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)";
y = "2.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
w = "13 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
style = ST_CENTER;
colorText[] = {1, 1, 1, 0.9};
colorBackground[] = {0, 0, 0, 0};
SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1.2)";
text = "";
};
class cargoList: ACE_gui_listBoxBase {
idc = 100;
x = "13.1 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)";
y = "4 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
w = "12.8 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "10 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 0.7)";
rowHeight = 0.03;
colorBackground[] = {0, 0, 0, 0.2};
colorText[] = {1, 1, 1, 1.0};
colorScrollbar[] = {0.95, 0.95, 0.95, 1};
colorSelect[] = {1, 1, 1, 1.0};
colorSelect2[] = {1, 1, 1, 1.0};
colorSelectBackground[] = {0.3, 0.3, 0.3, 1.0};
colorSelectBackground2[] = {0.3, 0.3, 0.3, 1.0};
};
class btnCancel: ACE_gui_buttonBase {
text = "$STR_DISP_CANCEL";
idc = 11;
x = "13.1 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)";
y = "14.1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
w = "6 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
size = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 0.7)";
animTextureNormal = "#(argb,8,8,3)color(0,0,0,0.9)";
animTextureDisabled = "#(argb,8,8,3)color(0,0,0,0.8)";
animTextureOver = "#(argb,8,8,3)color(1,1,1,1)";
animTextureFocused = "#(argb,8,8,3)color(1,1,1,1)";
animTexturePressed = "#(argb,8,8,3)color(1,1,1,1)";
animTextureDefault = "#(argb,8,8,3)color(1,1,1,1)";
color[] = {1, 1, 1, 1};
color2[] = {0, 0, 0, 1};
colorBackgroundFocused[] = {1, 1, 1, 1};
colorBackground[] = {1, 1, 1, 1};
colorbackground2[] = {1, 1, 1, 1};
colorDisabled[] = {1, 1, 1, 1};
colorFocused[] = {0, 0, 0, 1};
periodFocus = 1;
periodOver = 1;
action = QUOTE(closeDialog 0);
};
class btnUnload: btnCancel {
text = CSTRING(unloadObject);
idc = 12;
x = "19.9 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)";
action = QUOTE(ACE_player call FUNC(startUnload));
};
class btnPlace: btnUnload {
text = CSTRING(deployObject);
idc = 13;
y = "15.2 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
action = QUOTE(ACE_player call FUNC(startDeploy));
colorDisabled[] = {0.25, 0.25, 0.25, 1};
};
};
};

View File

@ -3,8 +3,8 @@
class GVAR(renameMenu) {
idd = 314615;
movingEnable = 0;
onLoad = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(menuDisplay),_this select 0)]);
onUnload = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(menuDisplay),nil)]);
onLoad = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(renameMenu),_this select 0)]);
onUnload = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(renameMenu),nil)]);
class controlsBackground {
class HeaderBackground: ACE_gui_backgroundBase {
idc = -1;

View File

@ -2,8 +2,8 @@
#define COMPONENT_BEAUTIFIED Cargo
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
#define DEBUG_MODE_FULL
#define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_CARGO