From 1753739f1d3f6ad5cd4f8808e73b8a252eb8a96b Mon Sep 17 00:00:00 2001 From: Jasper Date: Sun, 29 Nov 2020 21:28:20 +0100 Subject: [PATCH 01/16] First Push Added the ability to edit cargo objects (crates/boxes only) names. Either via in-game action on the object it self or via 3den attributes. Added a single function which spawns the UI to edit the name and also edits it. This is an scripted UI, it could be changed to a config version if wanted, but as I'm not good in UI coding I left it on this simple version mainly for testing. Added 4 new stringtable entries, 2 for action and 2 for 3den attributes. --- addons/cargo/CfgEden.hpp | 12 ++++ addons/cargo/XEH_PREP.hpp | 1 + addons/cargo/XEH_postInit.sqf | 67 +++++++++++++-------- addons/cargo/functions/fnc_initObject.sqf | 6 +- addons/cargo/functions/fnc_onMenuOpen.sqf | 2 +- addons/cargo/functions/fnc_paradropItem.sqf | 2 +- addons/cargo/functions/fnc_renameObject.sqf | 66 ++++++++++++++++++++ addons/cargo/functions/fnc_startLoadIn.sqf | 6 +- addons/cargo/functions/fnc_startUnload.sqf | 4 +- addons/cargo/stringtable.xml | 12 ++++ 10 files changed, 144 insertions(+), 34 deletions(-) create mode 100644 addons/cargo/functions/fnc_renameObject.sqf diff --git a/addons/cargo/CfgEden.hpp b/addons/cargo/CfgEden.hpp index 9144ba458b6..03f8f265380 100644 --- a/addons/cargo/CfgEden.hpp +++ b/addons/cargo/CfgEden.hpp @@ -3,6 +3,18 @@ class Cfg3DEN { class AttributeCategories { class ace_attributes { class Attributes { + class GVAR(customName) { + displayName = CSTRING(customName_edenName); + tooltip = CSTRING(customName_edenDesc); + property = QGVAR(customName); + control = "Edit"; + + expression = QUOTE(_this setVariable [ARR_3(QQGVAR(customName), _value, true)];); + defaultValue = QUOTE(getText(configFile >> 'CfgVehicles' >> typeOf _this >> 'displayName')); + + condition = "objectHasInventoryCargo-objectVehicle"; + typeName = "STRING"; + }; class GVAR(space) { displayName = CSTRING(space_edenName); tooltip = CSTRING(space_edenDesc); diff --git a/addons/cargo/XEH_PREP.hpp b/addons/cargo/XEH_PREP.hpp index ad22d5116ff..7bd35d6f067 100644 --- a/addons/cargo/XEH_PREP.hpp +++ b/addons/cargo/XEH_PREP.hpp @@ -19,3 +19,4 @@ PREP(startLoadIn); PREP(startUnload); PREP(unloadItem); PREP(validateCargoSpace); +PREP(renameObject); diff --git a/addons/cargo/XEH_postInit.sqf b/addons/cargo/XEH_postInit.sqf index 7ea978dc73c..6f4b2fc6591 100644 --- a/addons/cargo/XEH_postInit.sqf +++ b/addons/cargo/XEH_postInit.sqf @@ -11,7 +11,7 @@ // Show hint as feedback private _hint = [LSTRING(LoadingFailed), LSTRING(LoadedItem)] select _loaded; - private _itemName = getText (configFile >> "CfgVehicles" >> typeOf _item >> "displayName"); + private _itemName = if (_item isEqualType "") then {getText (configfile >> "CfgVehicles" >> typeOf _item >> "displayName")} else {_item getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> typeOf _item >> "displayName")]}; private _vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName"); [[_hint, _itemName, _vehicleName], 3.0] call EFUNC(common,displayTextStructured); @@ -32,7 +32,7 @@ // Show hint as feedback private _hint = [LSTRING(UnloadingFailed), LSTRING(UnloadedItem)] select _unloaded; - private _itemName = getText (configFile >> "CfgVehicles" >> _itemClass >> "displayName"); + private _itemName = if (_item isEqualType "") then {getText (configfile >> "CfgVehicles" >> _itemClass >> "displayName")} else {_item getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> _itemClass >> "displayName")]}; private _vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName"); [[_hint, _itemName, _vehicleName], 3.0] call EFUNC(common,displayTextStructured); @@ -78,28 +78,44 @@ GVAR(vehicleAction) = [ } ] call EFUNC(interact_menu,createAction); -GVAR(objectAction) = [ - QGVAR(load), localize LSTRING(loadObject), "a3\ui_f\data\IGUI\Cfg\Actions\loadVehicle_ca.paa", - { - params ["_target", "_player"]; - [_player, _target] call FUNC(startLoadIn); - }, - { - //IGNORE_PRIVATE_WARNING ["_target", "_player"]; - GVAR(enable) && - {(_target getVariable [QGVAR(canLoad), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(canLoad))]) in [true, 1]} && - {locked _target < 2} && - {alive _target} && - {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && - {((nearestObjects [_target, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)]) findIf { - private _hasCargoConfig = 1 == getNumber (configFile >> "CfgVehicles" >> typeOf _x >> QGVAR(hasCargo)); - private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false]; - (_hasCargoConfig || {_hasCargoPublic}) && {_x != _target} && {alive _x} && {locked _x < 2} && - {([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} - }) > -1} - }, - LINKFUNC(addCargoVehiclesActions) -] call EFUNC(interact_menu,createAction); +GVAR(objectActions)= [ + [QGVAR(renameObject), localize LSTRING(renameObject), "", //TODO: add icon, maybe a pencil couldn't find it before. + { + params ["_target"]; + [_target] spawn FUNC(renameObject); + }, + { + //IGNORE_PRIVATE_WARNING ["_target", "_player"]; + GVAR(enable) && + {(_target getVariable [QGVAR(canLoad), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(canLoad))]) in [true, 1]} && + {alive _target} && + {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && + {!((typeOf _target) in ["ACE_Wheel", "ACE_Track"])} && // Exclude Wheel and Track + {!(_target iskindOf "Land_CanisterFuel_F")} // Exclude Fuel Canisters + } + ] call EFUNC(interact_menu,createAction), + [QGVAR(load), localize LSTRING(loadObject), "a3\ui_f\data\IGUI\Cfg\Actions\loadVehicle_ca.paa", + { + params ["_target", "_player"]; + [_player, _target] call FUNC(startLoadIn); + }, + { + //IGNORE_PRIVATE_WARNING ["_target", "_player"]; + GVAR(enable) && + {(_target getVariable [QGVAR(canLoad), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(canLoad))]) in [true, 1]} && + {locked _target < 2} && + {alive _target} && + {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && + {((nearestObjects [_target, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)]) findIf { + private _hasCargoConfig = 1 == getNumber (configFile >> "CfgVehicles" >> typeOf _x >> QGVAR(hasCargo)); + private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false]; + (_hasCargoConfig || {_hasCargoPublic}) && {_x != _target} && {alive _x} && {locked _x < 2} && + {([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} + }) > -1} + }, + LINKFUNC(addCargoVehiclesActions) + ] call EFUNC(interact_menu,createAction) +]; // find all remaining configured classes and init them, see XEH_preStart.sqf private _vehicleClassesAddAction = call (uiNamespace getVariable [QGVAR(initializedVehicleClasses), {[]}]); @@ -110,7 +126,8 @@ GVAR(initializedVehicleClasses) append _vehicleClassesAddAction; private _objectClassesAddAction = call (uiNamespace getVariable [QGVAR(initializedItemClasses), {[]}]); { - [_x, 0, ["ACE_MainActions"], GVAR(objectAction)] call EFUNC(interact_menu,addActionToClass); + [_x, 0, ["ACE_MainActions"], GVAR(objectActions) select 0] call EFUNC(interact_menu,addActionToClass); + [_x, 0, ["ACE_MainActions"], GVAR(objectActions) select 1] call EFUNC(interact_menu,addActionToClass); } forEach _objectClassesAddAction; GVAR(initializedItemClasses) append _objectClassesAddAction; diff --git a/addons/cargo/functions/fnc_initObject.sqf b/addons/cargo/functions/fnc_initObject.sqf index 611e3e6391a..db614ffcebe 100644 --- a/addons/cargo/functions/fnc_initObject.sqf +++ b/addons/cargo/functions/fnc_initObject.sqf @@ -41,9 +41,11 @@ if (_object getVariable [QGVAR(initObject),false]) exitWith {}; if (_canLoadConfig) then { GVAR(initializedItemClasses) pushBack _type; TRACE_1("Adding load cargo action to class", _type); - [_type, 0, ["ACE_MainActions"], GVAR(objectAction)] call EFUNC(interact_menu,addActionToClass); + [_type, 0, ["ACE_MainActions"], GVAR(objectActions) select 0] call EFUNC(interact_menu,addActionToClass); + [_type, 0, ["ACE_MainActions"], GVAR(objectActions) select 1] call EFUNC(interact_menu,addActionToClass); } else { _object setVariable [QGVAR(initObject),true]; TRACE_1("Adding load cargo action to object", _object); - [_object, 0, ["ACE_MainActions"], GVAR(objectAction)] call EFUNC(interact_menu,addActionToObject); + [_object, 0, ["ACE_MainActions"], GVAR(objectActions) select 0] call EFUNC(interact_menu,addActionToClass); + [_object, 0, ["ACE_MainActions"], GVAR(objectActions) select 1] call EFUNC(interact_menu,addActionToClass); }; diff --git a/addons/cargo/functions/fnc_onMenuOpen.sqf b/addons/cargo/functions/fnc_onMenuOpen.sqf index d611d18ff2f..ec9185c1ec0 100644 --- a/addons/cargo/functions/fnc_onMenuOpen.sqf +++ b/addons/cargo/functions/fnc_onMenuOpen.sqf @@ -44,7 +44,7 @@ if (GVAR(interactionParadrop)) then { lbClear _ctrl; { private _class = if (_x isEqualType "") then {_x} else {typeOf _x}; - private _displayName = getText (configfile >> "CfgVehicles" >> _class >> "displayName"); + private _displayName = if (_x isEqualType "") then {getText (configfile >> "CfgVehicles" >> _class >> "displayName")} else {_x getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> _class >> "displayName")]}; if (GVAR(interactionParadrop)) then { _ctrl lbAdd format ["%1 (%2s)", _displayName, GVAR(paradropTimeCoefficent) * ([_class] call FUNC(getSizeItem))]; } else { diff --git a/addons/cargo/functions/fnc_paradropItem.sqf b/addons/cargo/functions/fnc_paradropItem.sqf index 4c873d189e6..3ef70edcc25 100644 --- a/addons/cargo/functions/fnc_paradropItem.sqf +++ b/addons/cargo/functions/fnc_paradropItem.sqf @@ -99,7 +99,7 @@ if (_showHint) then { [ [ LSTRING(UnloadedItem), - getText (configFile >> "CfgVehicles" >> typeOf _itemObject >> "displayName"), + if (_itemObject isEqualType "") then {getText (configfile >> "CfgVehicles" >> typeOf _itemObject >> "displayName")} else {_itemObject getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> typeOf _itemObject >> "displayName")]}, getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName") ], 3 diff --git a/addons/cargo/functions/fnc_renameObject.sqf b/addons/cargo/functions/fnc_renameObject.sqf new file mode 100644 index 00000000000..ebd73556252 --- /dev/null +++ b/addons/cargo/functions/fnc_renameObject.sqf @@ -0,0 +1,66 @@ +#include "script_component.hpp" +/* + * Author: JasperRab + * Shows rename UI and renames object once completed + * + * Arguments: + * 0: Target + * + * Return Value: + * None + * + * Example: + * [crate_7] call ace_cargo_fnc_renameObject; + * + * Public: Yes + */ + +params ["_target"]; + +GVAR(renameTarget) = _target; + +disableSerialization; +private _display = findDisplay 46 createDisplay "RscDisplayEmpty"; +_display displayAddEventHandler ["Unload", { + params ["_display", "_exitCode"]; + if (_exitCode isEqualTo 1) then { // only set if pressed on "Ok" the button + private _ctrlText = ctrlText (((allControls _display) select {ctrlClassName _x isEqualTo "RscEdit"}) select 0); + [[LSTRING(renamedObject), _ctrlText], 3] call EFUNC(common,displayTextStructured); + GVAR(renameTarget) setVariable ["ace_cargo_customName", _ctrlText, true]; + }; +}]; + +// add Background +private _ctrlBackground = _display ctrlCreate ["RscStructuredText", -1]; +_ctrlBackground ctrlSetStructuredText parseText "Set New Name: "; +_ctrlBackground ctrlSetBackgroundColor [0,0,0,0.5]; +_ctrlBackground ctrlSetPosition [ + safeZoneX + 0.4 * safeZoneW - 0.025, + safeZoneY + 0.3 * safeZoneH - 0.025, + safeZoneW * 0.2 + 0.05, + safeZoneH * 0.04 + 0.05 +]; +_ctrlBackground ctrlCommit 0; + +// add Edit Field +private _ctrlEdit = _display ctrlCreate ["RscEdit", -1]; +_ctrlEdit ctrlSetText (_target getVariable ["ace_cargo_customName", getText (configfile >> "CfgVehicles" >> typeOf _target >> "displayName")]); +_ctrlEdit ctrlSetBackgroundColor [0,0,0,1]; +_ctrlEdit ctrlSetPosition [ + safeZoneX + 0.4 * safeZoneW, + safeZoneY + 0.3 * safeZoneH + 0.02, + safeZoneW * 0.2, + safeZoneH * 0.03 +]; +_ctrlEdit ctrlCommit 0; + +// add Save Button +private _ctrlButton = _display ctrlCreate ["RscButton", 1]; // 1 = Ok btn +_ctrlButton ctrlSetText "Save Name"; +_ctrlButton ctrlSetPosition [ + safeZoneX + 0.4 * safeZoneW - 0.025, + safeZoneY + 0.3 * safeZoneH + (safeZoneH * 0.04 + 0.04), + safeZoneW * 0.2 + 0.05, + safeZoneH * 0.03 +]; +_ctrlButton ctrlCommit 0; diff --git a/addons/cargo/functions/fnc_startLoadIn.sqf b/addons/cargo/functions/fnc_startLoadIn.sqf index 7cc79236963..bed76654c6e 100644 --- a/addons/cargo/functions/fnc_startLoadIn.sqf +++ b/addons/cargo/functions/fnc_startLoadIn.sqf @@ -42,13 +42,13 @@ if ([_object, _vehicle] call FUNC(canLoadItemIn)) then { GVAR(loadTimeCoefficient) * _size, [_object, _vehicle], { - TRACE_1("load finish",_this); + TRACE_1("load finish",_this); [objNull, _this select 0 select 0, true] call EFUNC(common,claim); ["ace_loadCargo", _this select 0] call CBA_fnc_localEvent; }, { TRACE_1("load fail",_this); - [objNull, _this select 0 select 0, true] call EFUNC(common,claim) + [objNull, _this select 0 select 0, true] call EFUNC(common,claim); }, localize LSTRING(LoadingItem), { @@ -60,7 +60,7 @@ if ([_object, _vehicle] call FUNC(canLoadItemIn)) then { ] call EFUNC(common,progressBar); _return = true; } else { - private _displayName = getText (configFile >> "CfgVehicles" >> typeOf _object >> "displayName"); + private _displayName = if (_object isEqualType "") then {getText (configfile >> "CfgVehicles" >> typeOf _object >> "displayName")} else {_object getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> typeOf _object >> "displayName")]}; [[LSTRING(LoadingFailed), _displayName], 3] call EFUNC(common,displayTextStructured); }; diff --git a/addons/cargo/functions/fnc_startUnload.sqf b/addons/cargo/functions/fnc_startUnload.sqf index 5e7ada82c5a..13cf7d0b293 100644 --- a/addons/cargo/functions/fnc_startUnload.sqf +++ b/addons/cargo/functions/fnc_startUnload.sqf @@ -77,7 +77,7 @@ if ([_item, GVAR(interactionVehicle), ACE_player] call FUNC(canUnloadItem)) then localize LSTRING(UnloadingItem), { (_this select 0) params ["_item", "_target", "_player"]; - + (alive _target) && {locked _target < 2} && {([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} @@ -87,7 +87,7 @@ if ([_item, GVAR(interactionVehicle), ACE_player] call FUNC(canUnloadItem)) then ] call EFUNC(common,progressBar); } else { private _itemClass = if (_item isEqualType "") then {_item} else {typeOf _item}; - private _displayName = getText (configFile >> "CfgVehicles" >> _itemClass >> "displayName"); + private _displayName = if (_item isEqualType "") then {getText (configfile >> "CfgVehicles" >> _itemClass >> "displayName")} else {_item getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> _itemClass >> "displayName")]}; [[LSTRING(UnloadingFailed), _displayName], 3] call EFUNC(common,displayTextStructured); }; diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml index 9e6e708e39f..1e33c783bb8 100644 --- a/addons/cargo/stringtable.xml +++ b/addons/cargo/stringtable.xml @@ -33,6 +33,12 @@ 卸载 Boşalt + + Rename + + + Renamed to:<br/>%1 + Cargo Fracht @@ -239,6 +245,12 @@ %1<br/>无法被卸载 %1<br/> kargo boşaltılamadı + + Custom Name + + + Set a custom cargo name used in the cargo interface + Cargo Space Frachtraum From 621052c36d2e197d11b7a70f24b65de8d3d2e5b0 Mon Sep 17 00:00:00 2001 From: Jasper Date: Sun, 29 Nov 2020 22:23:08 +0100 Subject: [PATCH 02/16] Add extra stringtable Forgot to add the UI to the stringtable. --- addons/cargo/functions/fnc_renameObject.sqf | 2 +- addons/cargo/stringtable.xml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/cargo/functions/fnc_renameObject.sqf b/addons/cargo/functions/fnc_renameObject.sqf index ebd73556252..07a234c6c17 100644 --- a/addons/cargo/functions/fnc_renameObject.sqf +++ b/addons/cargo/functions/fnc_renameObject.sqf @@ -32,7 +32,7 @@ _display displayAddEventHandler ["Unload", { // add Background private _ctrlBackground = _display ctrlCreate ["RscStructuredText", -1]; -_ctrlBackground ctrlSetStructuredText parseText "Set New Name: "; +_ctrlBackground ctrlSetStructuredText parseText (["", localize LSTRING(renameObjectUI), ""] joinString ""); _ctrlBackground ctrlSetBackgroundColor [0,0,0,0.5]; _ctrlBackground ctrlSetPosition [ safeZoneX + 0.4 * safeZoneW - 0.025, diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml index 1e33c783bb8..f4f3a9d792d 100644 --- a/addons/cargo/stringtable.xml +++ b/addons/cargo/stringtable.xml @@ -39,6 +39,9 @@ Renamed to:<br/>%1 + + Set New Name: + Cargo Fracht From 00f4427725afc2de4c6f982bd2db62dd03c141b1 Mon Sep 17 00:00:00 2001 From: Jasper Date: Sun, 29 Nov 2020 22:33:04 +0100 Subject: [PATCH 03/16] Update fnc_renameObject.sqf fixing tabs --- addons/cargo/functions/fnc_renameObject.sqf | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/addons/cargo/functions/fnc_renameObject.sqf b/addons/cargo/functions/fnc_renameObject.sqf index 07a234c6c17..577dfb568d5 100644 --- a/addons/cargo/functions/fnc_renameObject.sqf +++ b/addons/cargo/functions/fnc_renameObject.sqf @@ -22,12 +22,12 @@ GVAR(renameTarget) = _target; disableSerialization; private _display = findDisplay 46 createDisplay "RscDisplayEmpty"; _display displayAddEventHandler ["Unload", { - params ["_display", "_exitCode"]; - if (_exitCode isEqualTo 1) then { // only set if pressed on "Ok" the button - private _ctrlText = ctrlText (((allControls _display) select {ctrlClassName _x isEqualTo "RscEdit"}) select 0); - [[LSTRING(renamedObject), _ctrlText], 3] call EFUNC(common,displayTextStructured); - GVAR(renameTarget) setVariable ["ace_cargo_customName", _ctrlText, true]; - }; + params ["_display", "_exitCode"]; + if (_exitCode isEqualTo 1) then { // only set if pressed on "Ok" the button + private _ctrlText = ctrlText (((allControls _display) select {ctrlClassName _x isEqualTo "RscEdit"}) select 0); + [[LSTRING(renamedObject), _ctrlText], 3] call EFUNC(common,displayTextStructured); + GVAR(renameTarget) setVariable ["ace_cargo_customName", _ctrlText, true]; + }; }]; // add Background @@ -35,10 +35,10 @@ private _ctrlBackground = _display ctrlCreate ["RscStructuredText", -1]; _ctrlBackground ctrlSetStructuredText parseText (["", localize LSTRING(renameObjectUI), ""] joinString ""); _ctrlBackground ctrlSetBackgroundColor [0,0,0,0.5]; _ctrlBackground ctrlSetPosition [ - safeZoneX + 0.4 * safeZoneW - 0.025, - safeZoneY + 0.3 * safeZoneH - 0.025, - safeZoneW * 0.2 + 0.05, - safeZoneH * 0.04 + 0.05 + safeZoneX + 0.4 * safeZoneW - 0.025, + safeZoneY + 0.3 * safeZoneH - 0.025, + safeZoneW * 0.2 + 0.05, + safeZoneH * 0.04 + 0.05 ]; _ctrlBackground ctrlCommit 0; @@ -47,10 +47,10 @@ private _ctrlEdit = _display ctrlCreate ["RscEdit", -1]; _ctrlEdit ctrlSetText (_target getVariable ["ace_cargo_customName", getText (configfile >> "CfgVehicles" >> typeOf _target >> "displayName")]); _ctrlEdit ctrlSetBackgroundColor [0,0,0,1]; _ctrlEdit ctrlSetPosition [ - safeZoneX + 0.4 * safeZoneW, - safeZoneY + 0.3 * safeZoneH + 0.02, - safeZoneW * 0.2, - safeZoneH * 0.03 + safeZoneX + 0.4 * safeZoneW, + safeZoneY + 0.3 * safeZoneH + 0.02, + safeZoneW * 0.2, + safeZoneH * 0.03 ]; _ctrlEdit ctrlCommit 0; @@ -58,9 +58,9 @@ _ctrlEdit ctrlCommit 0; private _ctrlButton = _display ctrlCreate ["RscButton", 1]; // 1 = Ok btn _ctrlButton ctrlSetText "Save Name"; _ctrlButton ctrlSetPosition [ - safeZoneX + 0.4 * safeZoneW - 0.025, - safeZoneY + 0.3 * safeZoneH + (safeZoneH * 0.04 + 0.04), - safeZoneW * 0.2 + 0.05, - safeZoneH * 0.03 + safeZoneX + 0.4 * safeZoneW - 0.025, + safeZoneY + 0.3 * safeZoneH + (safeZoneH * 0.04 + 0.04), + safeZoneW * 0.2 + 0.05, + safeZoneH * 0.03 ]; _ctrlButton ctrlCommit 0; From dd086b206198e794df6af270982f32e207515686 Mon Sep 17 00:00:00 2001 From: Jasper Date: Sat, 24 Apr 2021 11:56:47 +0200 Subject: [PATCH 04/16] Show custom name only behind Added new function "getNameItem" that will get the items name. Put the custom name behind the original name between brackets "[...]". --- addons/cargo/CfgEden.hpp | 2 +- addons/cargo/XEH_PREP.hpp | 1 + addons/cargo/XEH_postInit.sqf | 4 +-- addons/cargo/functions/fnc_getNameItem.sqf | 32 +++++++++++++++++++++ addons/cargo/functions/fnc_onMenuOpen.sqf | 2 +- addons/cargo/functions/fnc_paradropItem.sqf | 2 +- addons/cargo/functions/fnc_renameObject.sqf | 2 +- addons/cargo/functions/fnc_startLoadIn.sqf | 3 +- addons/cargo/functions/fnc_startUnload.sqf | 3 +- 9 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 addons/cargo/functions/fnc_getNameItem.sqf diff --git a/addons/cargo/CfgEden.hpp b/addons/cargo/CfgEden.hpp index 03f8f265380..5b387707e3a 100644 --- a/addons/cargo/CfgEden.hpp +++ b/addons/cargo/CfgEden.hpp @@ -10,7 +10,7 @@ class Cfg3DEN { control = "Edit"; expression = QUOTE(_this setVariable [ARR_3(QQGVAR(customName), _value, true)];); - defaultValue = QUOTE(getText(configFile >> 'CfgVehicles' >> typeOf _this >> 'displayName')); + defaultValue = "''"; condition = "objectHasInventoryCargo-objectVehicle"; typeName = "STRING"; diff --git a/addons/cargo/XEH_PREP.hpp b/addons/cargo/XEH_PREP.hpp index 7bd35d6f067..5a56bdd3e39 100644 --- a/addons/cargo/XEH_PREP.hpp +++ b/addons/cargo/XEH_PREP.hpp @@ -20,3 +20,4 @@ PREP(startUnload); PREP(unloadItem); PREP(validateCargoSpace); PREP(renameObject); +PREP(getNameItem); diff --git a/addons/cargo/XEH_postInit.sqf b/addons/cargo/XEH_postInit.sqf index 6f4b2fc6591..d0772cd6496 100644 --- a/addons/cargo/XEH_postInit.sqf +++ b/addons/cargo/XEH_postInit.sqf @@ -11,7 +11,7 @@ // Show hint as feedback private _hint = [LSTRING(LoadingFailed), LSTRING(LoadedItem)] select _loaded; - private _itemName = if (_item isEqualType "") then {getText (configfile >> "CfgVehicles" >> typeOf _item >> "displayName")} else {_item getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> typeOf _item >> "displayName")]}; + private _itemName = [_item, true] call FUNC(getNameItem); private _vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName"); [[_hint, _itemName, _vehicleName], 3.0] call EFUNC(common,displayTextStructured); @@ -32,7 +32,7 @@ // Show hint as feedback private _hint = [LSTRING(UnloadingFailed), LSTRING(UnloadedItem)] select _unloaded; - private _itemName = if (_item isEqualType "") then {getText (configfile >> "CfgVehicles" >> _itemClass >> "displayName")} else {_item getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> _itemClass >> "displayName")]}; + private _itemName = [_item, true] call FUNC(getNameItem); private _vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName"); [[_hint, _itemName, _vehicleName], 3.0] call EFUNC(common,displayTextStructured); diff --git a/addons/cargo/functions/fnc_getNameItem.sqf b/addons/cargo/functions/fnc_getNameItem.sqf new file mode 100644 index 00000000000..1d39a43fb32 --- /dev/null +++ b/addons/cargo/functions/fnc_getNameItem.sqf @@ -0,0 +1,32 @@ +#include "script_component.hpp" +/* + * Author: JasperRab + * Gets the name of the item, and alternatively the custom name if requested and available + * + * Arguments: + * 0: Target + * 1: Add custom name part + * + * Return Value: + * The display name + * + * Example: + * [crate_7] call ace_cargo_fnc_getNameItem; + * + * Public: Yes + */ + +params ["_object", ["_addCustomPart", false]]; + +private _class = if (_object isEqualType "") then {_object} else {typeOf _object}; +private _displayName = getText (configfile >> "CfgVehicles" >> _class >> "displayName"); + +if (!(_object isEqualType "") && _addCustomPart) then { + private _customPart = _object getVariable [QGVAR(customName), ""]; + + if (_customPart isNotEqualTo "") then { + _displayName = _displayName + " ["+_customPart+"]"; + }; +}; + +_displayName diff --git a/addons/cargo/functions/fnc_onMenuOpen.sqf b/addons/cargo/functions/fnc_onMenuOpen.sqf index ec9185c1ec0..bc56c0fb968 100644 --- a/addons/cargo/functions/fnc_onMenuOpen.sqf +++ b/addons/cargo/functions/fnc_onMenuOpen.sqf @@ -44,7 +44,7 @@ if (GVAR(interactionParadrop)) then { lbClear _ctrl; { private _class = if (_x isEqualType "") then {_x} else {typeOf _x}; - private _displayName = if (_x isEqualType "") then {getText (configfile >> "CfgVehicles" >> _class >> "displayName")} else {_x getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> _class >> "displayName")]}; + private _displayName = [_x, true] call FUNC(getNameItem); if (GVAR(interactionParadrop)) then { _ctrl lbAdd format ["%1 (%2s)", _displayName, GVAR(paradropTimeCoefficent) * ([_class] call FUNC(getSizeItem))]; } else { diff --git a/addons/cargo/functions/fnc_paradropItem.sqf b/addons/cargo/functions/fnc_paradropItem.sqf index 3ef70edcc25..19f8d385694 100644 --- a/addons/cargo/functions/fnc_paradropItem.sqf +++ b/addons/cargo/functions/fnc_paradropItem.sqf @@ -99,7 +99,7 @@ if (_showHint) then { [ [ LSTRING(UnloadedItem), - if (_itemObject isEqualType "") then {getText (configfile >> "CfgVehicles" >> typeOf _itemObject >> "displayName")} else {_itemObject getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> typeOf _itemObject >> "displayName")]}, + [_itemObject, true] call FUNC(getNameItem), getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName") ], 3 diff --git a/addons/cargo/functions/fnc_renameObject.sqf b/addons/cargo/functions/fnc_renameObject.sqf index 577dfb568d5..9b91b8cc03c 100644 --- a/addons/cargo/functions/fnc_renameObject.sqf +++ b/addons/cargo/functions/fnc_renameObject.sqf @@ -44,7 +44,7 @@ _ctrlBackground ctrlCommit 0; // add Edit Field private _ctrlEdit = _display ctrlCreate ["RscEdit", -1]; -_ctrlEdit ctrlSetText (_target getVariable ["ace_cargo_customName", getText (configfile >> "CfgVehicles" >> typeOf _target >> "displayName")]); +_ctrlEdit ctrlSetText (_target getVariable ["ace_cargo_customName", ""]); _ctrlEdit ctrlSetBackgroundColor [0,0,0,1]; _ctrlEdit ctrlSetPosition [ safeZoneX + 0.4 * safeZoneW, diff --git a/addons/cargo/functions/fnc_startLoadIn.sqf b/addons/cargo/functions/fnc_startLoadIn.sqf index bed76654c6e..b84ecd4df25 100644 --- a/addons/cargo/functions/fnc_startLoadIn.sqf +++ b/addons/cargo/functions/fnc_startLoadIn.sqf @@ -60,8 +60,7 @@ if ([_object, _vehicle] call FUNC(canLoadItemIn)) then { ] call EFUNC(common,progressBar); _return = true; } else { - private _displayName = if (_object isEqualType "") then {getText (configfile >> "CfgVehicles" >> typeOf _object >> "displayName")} else {_object getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> typeOf _object >> "displayName")]}; - + private _displayName = [_object, true] call FUNC(getNameItem); [[LSTRING(LoadingFailed), _displayName], 3] call EFUNC(common,displayTextStructured); }; diff --git a/addons/cargo/functions/fnc_startUnload.sqf b/addons/cargo/functions/fnc_startUnload.sqf index 13cf7d0b293..aa05b9f929e 100644 --- a/addons/cargo/functions/fnc_startUnload.sqf +++ b/addons/cargo/functions/fnc_startUnload.sqf @@ -86,8 +86,7 @@ if ([_item, GVAR(interactionVehicle), ACE_player] call FUNC(canUnloadItem)) then ["isNotSwimming"] ] call EFUNC(common,progressBar); } else { - private _itemClass = if (_item isEqualType "") then {_item} else {typeOf _item}; - private _displayName = if (_item isEqualType "") then {getText (configfile >> "CfgVehicles" >> _itemClass >> "displayName")} else {_item getVariable [QGVAR(customName), getText (configfile >> "CfgVehicles" >> _itemClass >> "displayName")]}; + private _displayName = [_item, true] call FUNC(getNameItem); [[LSTRING(UnloadingFailed), _displayName], 3] call EFUNC(common,displayTextStructured); }; From f315a8b1b769470b50d908c72fc333c7d115b4d4 Mon Sep 17 00:00:00 2001 From: Jasper Date: Sat, 24 Apr 2021 12:17:17 +0200 Subject: [PATCH 05/16] Added "Hide Rename Action" setting Also removed an unused _itemClass from postInit. --- addons/cargo/XEH_postInit.sqf | 3 +-- addons/cargo/initSettings.sqf | 9 +++++++++ addons/cargo/stringtable.xml | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/addons/cargo/XEH_postInit.sqf b/addons/cargo/XEH_postInit.sqf index d0772cd6496..c713b938b65 100644 --- a/addons/cargo/XEH_postInit.sqf +++ b/addons/cargo/XEH_postInit.sqf @@ -28,8 +28,6 @@ private _unloaded = [_item, _vehicle, _unloader] call FUNC(unloadItem); //returns true if sucessful - private _itemClass = if (_item isEqualType "") then {_item} else {typeOf _item}; - // Show hint as feedback private _hint = [LSTRING(UnloadingFailed), LSTRING(UnloadedItem)] select _unloaded; private _itemName = [_item, true] call FUNC(getNameItem); @@ -87,6 +85,7 @@ GVAR(objectActions)= [ { //IGNORE_PRIVATE_WARNING ["_target", "_player"]; GVAR(enable) && + !GVAR(hideRename) && {(_target getVariable [QGVAR(canLoad), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(canLoad))]) in [true, 1]} && {alive _target} && {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && diff --git a/addons/cargo/initSettings.sqf b/addons/cargo/initSettings.sqf index cbf0a121e58..63ea65641a5 100644 --- a/addons/cargo/initSettings.sqf +++ b/addons/cargo/initSettings.sqf @@ -24,3 +24,12 @@ true, {[QGVAR(paradropTimeCoefficent), _this, true] call EFUNC(common,cbaSettings_settingChanged)} ] call CBA_settings_fnc_init; + +[ + QGVAR(hideRename), "CHECKBOX", + [LSTRING(ModuleSettings_hideRename), LSTRING(ModuleSettings_hideRename_Description)], + [LELSTRING(OptionsMenu,CategoryLogistics), LLSTRING(openMenu)], + false, + false, + {[QGVAR(hideRename), _this, true] call EFUNC(common,cbaSettings_settingChanged)} +] call CBA_settings_fnc_init; diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml index f4f3a9d792d..a2c4b136c57 100644 --- a/addons/cargo/stringtable.xml +++ b/addons/cargo/stringtable.xml @@ -42,6 +42,12 @@ Set New Name: + + Hide Rename Action + + + Hides the rename action from renamable objects + Cargo Fracht From 6629151f5fee93915fd8e30744525e2dca8d4b1e Mon Sep 17 00:00:00 2001 From: Jasper Date: Sat, 24 Apr 2021 15:07:14 +0200 Subject: [PATCH 06/16] Apply suggestions from code review Co-authored-by: jonpas --- addons/cargo/CfgEden.hpp | 2 +- addons/cargo/functions/fnc_getNameItem.sqf | 8 ++++---- addons/cargo/functions/fnc_renameObject.sqf | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/cargo/CfgEden.hpp b/addons/cargo/CfgEden.hpp index f76cc44b764..4a64dee025a 100644 --- a/addons/cargo/CfgEden.hpp +++ b/addons/cargo/CfgEden.hpp @@ -12,7 +12,7 @@ class Cfg3DEN { expression = QUOTE(_this setVariable [ARR_3(QQGVAR(customName), _value, true)];); defaultValue = "''"; - condition = "objectHasInventoryCargo-objectVehicle"; + condition = "objectHasInventoryCargo - objectVehicle"; typeName = "STRING"; }; class GVAR(space) { diff --git a/addons/cargo/functions/fnc_getNameItem.sqf b/addons/cargo/functions/fnc_getNameItem.sqf index 1d39a43fb32..b071a383c04 100644 --- a/addons/cargo/functions/fnc_getNameItem.sqf +++ b/addons/cargo/functions/fnc_getNameItem.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: JasperRab - * Gets the name of the item, and alternatively the custom name if requested and available + * Gets the name of the item, and alternatively the custom name if requested and available. * * Arguments: * 0: Target @@ -11,7 +11,7 @@ * The display name * * Example: - * [crate_7] call ace_cargo_fnc_getNameItem; + * [crate_7] call ace_cargo_fnc_getNameItem * * Public: Yes */ @@ -19,13 +19,13 @@ params ["_object", ["_addCustomPart", false]]; private _class = if (_object isEqualType "") then {_object} else {typeOf _object}; -private _displayName = getText (configfile >> "CfgVehicles" >> _class >> "displayName"); +private _displayName = getText (configFile >> "CfgVehicles" >> _class >> "displayName"); if (!(_object isEqualType "") && _addCustomPart) then { private _customPart = _object getVariable [QGVAR(customName), ""]; if (_customPart isNotEqualTo "") then { - _displayName = _displayName + " ["+_customPart+"]"; + _displayName = _displayName + " [" + _customPart + "]"; }; }; diff --git a/addons/cargo/functions/fnc_renameObject.sqf b/addons/cargo/functions/fnc_renameObject.sqf index 9b91b8cc03c..a2a14e4610b 100644 --- a/addons/cargo/functions/fnc_renameObject.sqf +++ b/addons/cargo/functions/fnc_renameObject.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: JasperRab - * Shows rename UI and renames object once completed + * Shows rename UI and renames object once completed. * * Arguments: * 0: Target @@ -10,7 +10,7 @@ * None * * Example: - * [crate_7] call ace_cargo_fnc_renameObject; + * [crate_7] call ace_cargo_fnc_renameObject * * Public: Yes */ From 5aab8c04881f935fabf9624a8e54d01b68bf3e6a Mon Sep 17 00:00:00 2001 From: Jasper Date: Sat, 24 Apr 2021 15:16:22 +0200 Subject: [PATCH 07/16] Update AUTHORS.txt Added my name --- AUTHORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 20d2654f289..893ded01c9e 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -105,6 +105,7 @@ havena Hawkins Head Hybrid V +JasperRab john681611 Karneck Kavinsky From fa9a301ef4b109d7c24e154d3b90951e5de8f498 Mon Sep 17 00:00:00 2001 From: Jasper Date: Sun, 25 Apr 2021 13:45:41 +0200 Subject: [PATCH 08/16] Applied the sugesstions. --- addons/cargo/XEH_PREP.hpp | 4 +-- addons/cargo/XEH_postInit.sqf | 10 +++++--- addons/cargo/functions/fnc_getNameItem.sqf | 4 +-- addons/cargo/functions/fnc_renameObject.sqf | 27 +++++++++++---------- addons/cargo/initSettings.sqf | 8 +++--- addons/cargo/stringtable.xml | 8 +++--- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/addons/cargo/XEH_PREP.hpp b/addons/cargo/XEH_PREP.hpp index 5a56bdd3e39..aa1600b82db 100644 --- a/addons/cargo/XEH_PREP.hpp +++ b/addons/cargo/XEH_PREP.hpp @@ -3,6 +3,7 @@ PREP(addCargoVehiclesActions); PREP(canLoadItemIn); PREP(canUnloadItem); PREP(getCargoSpaceLeft); +PREP(getNameItem); PREP(getSizeItem); PREP(handleDeleted); PREP(handleDestroyed); @@ -13,11 +14,10 @@ PREP(moduleSettings); PREP(onMenuOpen); PREP(paradropItem); PREP(removeCargoItem); +PREP(renameObject); PREP(setSize); PREP(setSpace); PREP(startLoadIn); PREP(startUnload); PREP(unloadItem); PREP(validateCargoSpace); -PREP(renameObject); -PREP(getNameItem); diff --git a/addons/cargo/XEH_postInit.sqf b/addons/cargo/XEH_postInit.sqf index 821a38ed33f..15f04620b38 100644 --- a/addons/cargo/XEH_postInit.sqf +++ b/addons/cargo/XEH_postInit.sqf @@ -76,7 +76,7 @@ GVAR(vehicleAction) = [ } ] call EFUNC(interact_menu,createAction); -GVAR(objectActions)= [ +GVAR(objectActions) = [ [QGVAR(renameObject), localize LSTRING(renameObject), "", //TODO: add icon, maybe a pencil couldn't find it before. { params ["_target"]; @@ -85,7 +85,7 @@ GVAR(objectActions)= [ { //IGNORE_PRIVATE_WARNING ["_target", "_player"]; GVAR(enable) && - !GVAR(hideRename) && + {GVAR(enableRename)} && {(_target getVariable [QGVAR(canLoad), getNumber (configOf _target >> QGVAR(canLoad))]) in [true, 1]} && {alive _target} && {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && @@ -125,8 +125,10 @@ GVAR(initializedVehicleClasses) append _vehicleClassesAddAction; private _objectClassesAddAction = call (uiNamespace getVariable [QGVAR(initializedItemClasses), {[]}]); { - [_x, 0, ["ACE_MainActions"], GVAR(objectActions) select 0] call EFUNC(interact_menu,addActionToClass); - [_x, 0, ["ACE_MainActions"], GVAR(objectActions) select 1] call EFUNC(interact_menu,addActionToClass); + private _objectClass = _x; + { + [_objectClass, 0, ["ACE_MainActions"], _x] call EFUNC(interact_menu,addActionToClass); + } forEach GVAR(objectActions); } forEach _objectClassesAddAction; GVAR(initializedItemClasses) append _objectClassesAddAction; diff --git a/addons/cargo/functions/fnc_getNameItem.sqf b/addons/cargo/functions/fnc_getNameItem.sqf index b071a383c04..c493f3f0524 100644 --- a/addons/cargo/functions/fnc_getNameItem.sqf +++ b/addons/cargo/functions/fnc_getNameItem.sqf @@ -8,7 +8,7 @@ * 1: Add custom name part * * Return Value: - * The display name + * Item Name * * Example: * [crate_7] call ace_cargo_fnc_getNameItem @@ -21,7 +21,7 @@ params ["_object", ["_addCustomPart", false]]; private _class = if (_object isEqualType "") then {_object} else {typeOf _object}; private _displayName = getText (configFile >> "CfgVehicles" >> _class >> "displayName"); -if (!(_object isEqualType "") && _addCustomPart) then { +if (_addCustomPart && {!(_object isEqualType "")}) then { private _customPart = _object getVariable [QGVAR(customName), ""]; if (_customPart isNotEqualTo "") then { diff --git a/addons/cargo/functions/fnc_renameObject.sqf b/addons/cargo/functions/fnc_renameObject.sqf index a2a14e4610b..43510eb3d97 100644 --- a/addons/cargo/functions/fnc_renameObject.sqf +++ b/addons/cargo/functions/fnc_renameObject.sqf @@ -1,4 +1,5 @@ #include "script_component.hpp" +#include "\a3\ui_f\hpp\defineResincl.inc" /* * Author: JasperRab * Shows rename UI and renames object once completed. @@ -10,30 +11,29 @@ * None * * Example: - * [crate_7] call ace_cargo_fnc_renameObject + * [crate_7] spawn ace_cargo_fnc_renameObject * * Public: Yes */ params ["_target"]; -GVAR(renameTarget) = _target; - -disableSerialization; -private _display = findDisplay 46 createDisplay "RscDisplayEmpty"; +private _display = findDisplay IDD_MISSION createDisplay "RscDisplayEmpty"; _display displayAddEventHandler ["Unload", { params ["_display", "_exitCode"]; - if (_exitCode isEqualTo 1) then { // only set if pressed on "Ok" the button - private _ctrlText = ctrlText (((allControls _display) select {ctrlClassName _x isEqualTo "RscEdit"}) select 0); - [[LSTRING(renamedObject), _ctrlText], 3] call EFUNC(common,displayTextStructured); - GVAR(renameTarget) setVariable ["ace_cargo_customName", _ctrlText, true]; + if (_exitCode isEqualTo 1) then { // only set if pressed on the Save button + private _ctrlEdit = (((allControls _display) select {ctrlClassName _x isEqualTo "RscEdit"}) select 0); + private _ctrlEditText = ctrlText _ctrlEdit; + private _target = _ctrlEdit getVariable [QGVAR(renameTarget), objNull]; + [[LSTRING(renamedObject), _ctrlEditText], 3] call EFUNC(common,displayTextStructured); + _target setVariable [QGVAR(customName), _ctrlEditText, true]; }; }]; // add Background private _ctrlBackground = _display ctrlCreate ["RscStructuredText", -1]; _ctrlBackground ctrlSetStructuredText parseText (["", localize LSTRING(renameObjectUI), ""] joinString ""); -_ctrlBackground ctrlSetBackgroundColor [0,0,0,0.5]; +_ctrlBackground ctrlSetBackgroundColor [0, 0, 0, 0.5]; _ctrlBackground ctrlSetPosition [ safeZoneX + 0.4 * safeZoneW - 0.025, safeZoneY + 0.3 * safeZoneH - 0.025, @@ -44,19 +44,20 @@ _ctrlBackground ctrlCommit 0; // add Edit Field private _ctrlEdit = _display ctrlCreate ["RscEdit", -1]; -_ctrlEdit ctrlSetText (_target getVariable ["ace_cargo_customName", ""]); -_ctrlEdit ctrlSetBackgroundColor [0,0,0,1]; +_ctrlEdit ctrlSetText (_target getVariable [QGVAR(customName), ""]); +_ctrlEdit ctrlSetBackgroundColor [0, 0, 0, 1]; _ctrlEdit ctrlSetPosition [ safeZoneX + 0.4 * safeZoneW, safeZoneY + 0.3 * safeZoneH + 0.02, safeZoneW * 0.2, safeZoneH * 0.03 ]; +_ctrlEdit setVariable [QGVAR(renameTarget), _target]; _ctrlEdit ctrlCommit 0; // add Save Button private _ctrlButton = _display ctrlCreate ["RscButton", 1]; // 1 = Ok btn -_ctrlButton ctrlSetText "Save Name"; +_ctrlButton ctrlSetText localize ELSTRING(Common,Save); _ctrlButton ctrlSetPosition [ safeZoneX + 0.4 * safeZoneW - 0.025, safeZoneY + 0.3 * safeZoneH + (safeZoneH * 0.04 + 0.04), diff --git a/addons/cargo/initSettings.sqf b/addons/cargo/initSettings.sqf index 093cb861818..b048107daae 100644 --- a/addons/cargo/initSettings.sqf +++ b/addons/cargo/initSettings.sqf @@ -26,10 +26,10 @@ ] call CBA_fnc_addSetting; [ - QGVAR(hideRename), "CHECKBOX", - [LSTRING(ModuleSettings_hideRename), LSTRING(ModuleSettings_hideRename_Description)], + QGVAR(enableRename), "CHECKBOX", + [LSTRING(ModuleSettings_enableRename), LSTRING(ModuleSettings_enableRename_Description)], [LELSTRING(OptionsMenu,CategoryLogistics), LLSTRING(openMenu)], + true, false, - false, - {[QGVAR(hideRename), _this, true] call EFUNC(common,cbaSettings_settingChanged)} + {[QGVAR(enableRename), _this, true] call EFUNC(common,cbaSettings_settingChanged)} ] call CBA_fnc_addSetting; diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml index a2c4b136c57..8eff3eaf5fc 100644 --- a/addons/cargo/stringtable.xml +++ b/addons/cargo/stringtable.xml @@ -42,11 +42,11 @@ Set New Name: - - Hide Rename Action + + Enable Rename Action - - Hides the rename action from renamable objects + + Enables the rename action for renamable objects Cargo From 94c2926cbd5cd9d0c322efb6da38af3dbf8e6c4c Mon Sep 17 00:00:00 2001 From: Jasper Date: Sun, 25 Apr 2021 13:59:30 +0200 Subject: [PATCH 09/16] Fixed function crash --- addons/cargo/XEH_postInit.sqf | 2 +- addons/cargo/functions/fnc_renameObject.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/cargo/XEH_postInit.sqf b/addons/cargo/XEH_postInit.sqf index 15f04620b38..3c5814c8887 100644 --- a/addons/cargo/XEH_postInit.sqf +++ b/addons/cargo/XEH_postInit.sqf @@ -80,7 +80,7 @@ GVAR(objectActions) = [ [QGVAR(renameObject), localize LSTRING(renameObject), "", //TODO: add icon, maybe a pencil couldn't find it before. { params ["_target"]; - [_target] spawn FUNC(renameObject); + [{_this call FUNC(renameObject)}, [_target]] call CBA_fnc_execNextFrame; }, { //IGNORE_PRIVATE_WARNING ["_target", "_player"]; diff --git a/addons/cargo/functions/fnc_renameObject.sqf b/addons/cargo/functions/fnc_renameObject.sqf index 43510eb3d97..61eea4eec31 100644 --- a/addons/cargo/functions/fnc_renameObject.sqf +++ b/addons/cargo/functions/fnc_renameObject.sqf @@ -11,7 +11,7 @@ * None * * Example: - * [crate_7] spawn ace_cargo_fnc_renameObject + * [crate_7] call ace_cargo_fnc_renameObject * * Public: Yes */ From 84dd4c026c601e0631a3cd97aeb13fb0c6dd4729 Mon Sep 17 00:00:00 2001 From: Jasper Date: Sat, 31 Jul 2021 12:15:13 +0200 Subject: [PATCH 10/16] Moved to dialog. --- addons/cargo/XEH_postInit.sqf | 4 +- addons/cargo/config.cpp | 1 + addons/cargo/functions/fnc_getNameItem.sqf | 2 +- addons/cargo/functions/fnc_renameObject.sqf | 65 ++++------------ addons/cargo/renameMenu.hpp | 85 +++++++++++++++++++++ addons/cargo/stringtable.xml | 7 +- 6 files changed, 107 insertions(+), 57 deletions(-) create mode 100644 addons/cargo/renameMenu.hpp diff --git a/addons/cargo/XEH_postInit.sqf b/addons/cargo/XEH_postInit.sqf index 3c5814c8887..40fa8327c1d 100644 --- a/addons/cargo/XEH_postInit.sqf +++ b/addons/cargo/XEH_postInit.sqf @@ -79,8 +79,8 @@ GVAR(vehicleAction) = [ GVAR(objectActions) = [ [QGVAR(renameObject), localize LSTRING(renameObject), "", //TODO: add icon, maybe a pencil couldn't find it before. { - params ["_target"]; - [{_this call FUNC(renameObject)}, [_target]] call CBA_fnc_execNextFrame; + GVAR(interactionVehicle) = _target; + createDialog QGVAR(renameMenu); }, { //IGNORE_PRIVATE_WARNING ["_target", "_player"]; diff --git a/addons/cargo/config.cpp b/addons/cargo/config.cpp index 31f01ffd72d..2bdb3c7e659 100644 --- a/addons/cargo/config.cpp +++ b/addons/cargo/config.cpp @@ -19,3 +19,4 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" #include "menu.hpp" +#include "renameMenu.hpp" diff --git a/addons/cargo/functions/fnc_getNameItem.sqf b/addons/cargo/functions/fnc_getNameItem.sqf index c493f3f0524..ac97dd51dc6 100644 --- a/addons/cargo/functions/fnc_getNameItem.sqf +++ b/addons/cargo/functions/fnc_getNameItem.sqf @@ -5,7 +5,7 @@ * * Arguments: * 0: Target - * 1: Add custom name part + * 1: Add custom name part (default: false) * * Return Value: * Item Name diff --git a/addons/cargo/functions/fnc_renameObject.sqf b/addons/cargo/functions/fnc_renameObject.sqf index 61eea4eec31..a233199519d 100644 --- a/addons/cargo/functions/fnc_renameObject.sqf +++ b/addons/cargo/functions/fnc_renameObject.sqf @@ -1,67 +1,28 @@ #include "script_component.hpp" -#include "\a3\ui_f\hpp\defineResincl.inc" /* * Author: JasperRab - * Shows rename UI and renames object once completed. + * Renames object. * * Arguments: - * 0: Target + * None * * Return Value: * None * * Example: - * [crate_7] call ace_cargo_fnc_renameObject + * [] call ace_cargo_fnc_renameObject * * Public: Yes */ -params ["_target"]; - -private _display = findDisplay IDD_MISSION createDisplay "RscDisplayEmpty"; -_display displayAddEventHandler ["Unload", { - params ["_display", "_exitCode"]; - if (_exitCode isEqualTo 1) then { // only set if pressed on the Save button - private _ctrlEdit = (((allControls _display) select {ctrlClassName _x isEqualTo "RscEdit"}) select 0); - private _ctrlEditText = ctrlText _ctrlEdit; - private _target = _ctrlEdit getVariable [QGVAR(renameTarget), objNull]; - [[LSTRING(renamedObject), _ctrlEditText], 3] call EFUNC(common,displayTextStructured); - _target setVariable [QGVAR(customName), _ctrlEditText, true]; - }; -}]; - -// add Background -private _ctrlBackground = _display ctrlCreate ["RscStructuredText", -1]; -_ctrlBackground ctrlSetStructuredText parseText (["", localize LSTRING(renameObjectUI), ""] joinString ""); -_ctrlBackground ctrlSetBackgroundColor [0, 0, 0, 0.5]; -_ctrlBackground ctrlSetPosition [ - safeZoneX + 0.4 * safeZoneW - 0.025, - safeZoneY + 0.3 * safeZoneH - 0.025, - safeZoneW * 0.2 + 0.05, - safeZoneH * 0.04 + 0.05 -]; -_ctrlBackground ctrlCommit 0; - -// add Edit Field -private _ctrlEdit = _display ctrlCreate ["RscEdit", -1]; -_ctrlEdit ctrlSetText (_target getVariable [QGVAR(customName), ""]); -_ctrlEdit ctrlSetBackgroundColor [0, 0, 0, 1]; -_ctrlEdit ctrlSetPosition [ - safeZoneX + 0.4 * safeZoneW, - safeZoneY + 0.3 * safeZoneH + 0.02, - safeZoneW * 0.2, - safeZoneH * 0.03 -]; -_ctrlEdit setVariable [QGVAR(renameTarget), _target]; -_ctrlEdit ctrlCommit 0; +private _display = uiNamespace getVariable QGVAR(menuDisplay); +if (isNil "_display") exitWith {}; -// add Save Button -private _ctrlButton = _display ctrlCreate ["RscButton", 1]; // 1 = Ok btn -_ctrlButton ctrlSetText localize ELSTRING(Common,Save); -_ctrlButton ctrlSetPosition [ - safeZoneX + 0.4 * safeZoneW - 0.025, - safeZoneY + 0.3 * safeZoneH + (safeZoneH * 0.04 + 0.04), - safeZoneW * 0.2 + 0.05, - safeZoneH * 0.03 -]; -_ctrlButton ctrlCommit 0; +private _ctrlEditText = ctrlText 100; +if (_ctrlEditText isEqualTo "") then { // custom name has been removed + [LSTRING(clearedCustomName), 3] call EFUNC(common,displayTextStructured); +} else { + [[LSTRING(renamedObject), _ctrlEditText], 3] call EFUNC(common,displayTextStructured); +}; +//[[LSTRING(renamedObject), _ctrlEditText], 3] call EFUNC(common,displayTextStructured); +GVAR(interactionVehicle) setVariable [QGVAR(customName), _ctrlEditText, true]; \ No newline at end of file diff --git a/addons/cargo/renameMenu.hpp b/addons/cargo/renameMenu.hpp new file mode 100644 index 00000000000..b6cf45f5f0b --- /dev/null +++ b/addons/cargo/renameMenu.hpp @@ -0,0 +1,85 @@ +#include "\z\ace\addons\common\define.hpp" + +class GVAR(renameMenu) { + idd = 314615; + movingEnable = 0; + onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(menuDisplay)),_this select 0)];); + onUnload = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(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 = "2.9 * ((((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 = 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(renameObjectUI); + }; + class edit: ACE_gui_editBase { + onLoad = QUOTE((_this select 0) ctrlSetText (GVAR(interactionVehicle) getVariable [ARR_2(QUOTE(QGVAR(customName)), '')])); + idc = 100; + canModify = 1; + x = "13.1 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)"; + y = "2.3 * ((((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 = "1.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; + SizeEx = "1.5 * (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 0.7)"; + } + 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 = "3.9 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)"; + w = "5 * (((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 btnSave: btnCancel { + text = ECSTRING(Common,Save); + idc = 12; + x = "20.9 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)"; + action = QUOTE(closeDialog 1; call FUNC(renameObject)); + }; + }; +}; diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml index 8eff3eaf5fc..f96989e7660 100644 --- a/addons/cargo/stringtable.xml +++ b/addons/cargo/stringtable.xml @@ -39,6 +39,9 @@ Renamed to:<br/>%1 + + Custom name has been cleared. + Set New Name: @@ -46,7 +49,7 @@ Enable Rename Action - Enables the rename action for renamable objects + Enables the rename action for renamable objects. Cargo @@ -258,7 +261,7 @@ Custom Name - Set a custom cargo name used in the cargo interface + Set a custom cargo name used in the cargo interface. Cargo Space From f276f23bdbba7fb9e0214afa16a727cad1dabe55 Mon Sep 17 00:00:00 2001 From: Jasper Date: Sat, 31 Jul 2021 12:19:01 +0200 Subject: [PATCH 11/16] Removed unused comment/code --- addons/cargo/functions/fnc_renameObject.sqf | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/cargo/functions/fnc_renameObject.sqf b/addons/cargo/functions/fnc_renameObject.sqf index a233199519d..df542a38519 100644 --- a/addons/cargo/functions/fnc_renameObject.sqf +++ b/addons/cargo/functions/fnc_renameObject.sqf @@ -24,5 +24,4 @@ if (_ctrlEditText isEqualTo "") then { // custom name has been removed } else { [[LSTRING(renamedObject), _ctrlEditText], 3] call EFUNC(common,displayTextStructured); }; -//[[LSTRING(renamedObject), _ctrlEditText], 3] call EFUNC(common,displayTextStructured); GVAR(interactionVehicle) setVariable [QGVAR(customName), _ctrlEditText, true]; \ No newline at end of file From 9ad40cc822e7a4d3efe863504ac0b49e6918a3ca Mon Sep 17 00:00:00 2001 From: Jasper Date: Fri, 6 Aug 2021 16:14:49 +0200 Subject: [PATCH 12/16] Update renameMenu.hpp Fixed tabs to spaces. --- addons/cargo/renameMenu.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/cargo/renameMenu.hpp b/addons/cargo/renameMenu.hpp index b6cf45f5f0b..2ca7666c68d 100644 --- a/addons/cargo/renameMenu.hpp +++ b/addons/cargo/renameMenu.hpp @@ -15,7 +15,7 @@ class GVAR(renameMenu) { h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; text = "#(argb,8,8,3)color(0,0,0,0)"; }; - class CenterBackground: HeaderBackground { + 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 = "2.9 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; text = "#(argb,8,8,3)color(0,0,0,0.8)"; @@ -39,16 +39,16 @@ class GVAR(renameMenu) { 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(renameObjectUI); }; - class edit: ACE_gui_editBase { + class edit: ACE_gui_editBase { onLoad = QUOTE((_this select 0) ctrlSetText (GVAR(interactionVehicle) getVariable [ARR_2(QUOTE(QGVAR(customName)), '')])); - idc = 100; - canModify = 1; - x = "13.1 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)"; + idc = 100; + canModify = 1; + x = "13.1 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)"; y = "2.3 * ((((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 = "1.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - SizeEx = "1.5 * (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 0.7)"; - } + SizeEx = "1.5 * (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 0.7)"; + } class btnCancel: ACE_gui_buttonBase { text = "$STR_DISP_CANCEL"; idc = 11; From 3866e42990e0c14a3da78ed0d58f97959662fa31 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 12 Oct 2021 15:00:25 -0500 Subject: [PATCH 13/16] Update renameMenu.hpp --- addons/cargo/renameMenu.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/cargo/renameMenu.hpp b/addons/cargo/renameMenu.hpp index 2ca7666c68d..de2f87d2694 100644 --- a/addons/cargo/renameMenu.hpp +++ b/addons/cargo/renameMenu.hpp @@ -48,7 +48,7 @@ class GVAR(renameMenu) { w = "12.8 * (((safezoneW / safezoneH) min 1.2) / 40)"; h = "1.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; SizeEx = "1.5 * (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 0.7)"; - } + }; class btnCancel: ACE_gui_buttonBase { text = "$STR_DISP_CANCEL"; idc = 11; From 4a7e4db69b7d2d941266a1e4f2da46f2f9d596ba Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 12 Oct 2021 15:32:34 -0500 Subject: [PATCH 14/16] move rename to common --- addons/arsenal/stringtable.xml | 16 ---------------- addons/arsenal/ui/RscAttributes.hpp | 2 +- addons/cargo/XEH_postInit.sqf | 2 +- addons/cargo/stringtable.xml | 3 --- addons/common/stringtable.xml | 16 ++++++++++++++++ 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/addons/arsenal/stringtable.xml b/addons/arsenal/stringtable.xml index 44bfd79a7bb..7b980ff3101 100644 --- a/addons/arsenal/stringtable.xml +++ b/addons/arsenal/stringtable.xml @@ -159,22 +159,6 @@ [Shift+Klik pro uložení jako standardního vybavení pro misi] [Shift+Click varsayılan kıyafetlere kaydet] - - Rename - Renombrar - Renommer - Umbenennen - Zmień nazwę - 改名 - Rinomina - 이름바꾸기 - 重新命名 - 重新命名 - Переименовать - Renomear - Přejmenovat - Yeniden adlandır - Rename the selected loadout Renombrar el equipamiento seleccionado diff --git a/addons/arsenal/ui/RscAttributes.hpp b/addons/arsenal/ui/RscAttributes.hpp index 8f291e4bb6d..7e4b2e6fe01 100644 --- a/addons/arsenal/ui/RscAttributes.hpp +++ b/addons/arsenal/ui/RscAttributes.hpp @@ -1005,7 +1005,7 @@ class GVAR(loadoutsDisplay) { class buttonRename: buttonSave { idc = IDC_buttonRename; x = QUOTE(32.5 * GRID_W); - text= CSTRING(buttonRenameText); + text= ECSTRING(common,rename) tooltip= CSTRING(buttonRenameTooltip); onButtonClick = QUOTE([ARR_2(ctrlParent (_this select 0), _this select 0)] call FUNC(buttonLoadoutsRename)); }; diff --git a/addons/cargo/XEH_postInit.sqf b/addons/cargo/XEH_postInit.sqf index 5f2800c6f32..8f4d1b4e826 100644 --- a/addons/cargo/XEH_postInit.sqf +++ b/addons/cargo/XEH_postInit.sqf @@ -88,7 +88,7 @@ GVAR(vehicleAction) = [ ] call EFUNC(interact_menu,createAction); GVAR(objectActions) = [ - [QGVAR(renameObject), localize LSTRING(renameObject), "", //TODO: add icon, maybe a pencil couldn't find it before. + [QGVAR(renameObject), LELSTRING(common,rename), "", //TODO: add icon, maybe a pencil couldn't find it before. { GVAR(interactionVehicle) = _target; createDialog QGVAR(renameMenu); diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml index dded8259e0a..01e19b50624 100644 --- a/addons/cargo/stringtable.xml +++ b/addons/cargo/stringtable.xml @@ -33,9 +33,6 @@ 卸载 Boşalt - - Rename - Renamed to:<br/>%1 diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index cb40f08fa1e..6c22243d3c3 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -1500,6 +1500,22 @@ Yok + + Rename + Renombrar + Renommer + Umbenennen + Zmień nazwę + 改名 + Rinomina + 이름바꾸기 + 重新命名 + 重新命名 + Переименовать + Renomear + Přejmenovat + Yeniden adlandır + Time left: %1s From c6c4da0f7491421f1db9210cb508ece5262c1571 Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 12 Oct 2021 22:49:12 +0200 Subject: [PATCH 15/16] Update addons/arsenal/ui/RscAttributes.hpp --- addons/arsenal/ui/RscAttributes.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/arsenal/ui/RscAttributes.hpp b/addons/arsenal/ui/RscAttributes.hpp index 7e4b2e6fe01..48451f163ea 100644 --- a/addons/arsenal/ui/RscAttributes.hpp +++ b/addons/arsenal/ui/RscAttributes.hpp @@ -1005,8 +1005,8 @@ class GVAR(loadoutsDisplay) { class buttonRename: buttonSave { idc = IDC_buttonRename; x = QUOTE(32.5 * GRID_W); - text= ECSTRING(common,rename) - tooltip= CSTRING(buttonRenameTooltip); + text = ECSTRING(common,rename); + tooltip = CSTRING(buttonRenameTooltip); onButtonClick = QUOTE([ARR_2(ctrlParent (_this select 0), _this select 0)] call FUNC(buttonLoadoutsRename)); }; class buttonLoad: buttonSave { From 4ec7fb170c8f06c75e12ce451cbce04b6a23104a Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 12 Oct 2021 17:36:04 -0500 Subject: [PATCH 16/16] style and use addActionToObject --- addons/cargo/functions/fnc_initObject.sqf | 10 ++++++---- addons/cargo/functions/fnc_renameObject.sqf | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/cargo/functions/fnc_initObject.sqf b/addons/cargo/functions/fnc_initObject.sqf index db614ffcebe..0df277c5203 100644 --- a/addons/cargo/functions/fnc_initObject.sqf +++ b/addons/cargo/functions/fnc_initObject.sqf @@ -41,11 +41,13 @@ if (_object getVariable [QGVAR(initObject),false]) exitWith {}; if (_canLoadConfig) then { GVAR(initializedItemClasses) pushBack _type; TRACE_1("Adding load cargo action to class", _type); - [_type, 0, ["ACE_MainActions"], GVAR(objectActions) select 0] call EFUNC(interact_menu,addActionToClass); - [_type, 0, ["ACE_MainActions"], GVAR(objectActions) select 1] call EFUNC(interact_menu,addActionToClass); + { + [_type, 0, ["ACE_MainActions"], _x] call EFUNC(interact_menu,addActionToClass); + } forEach GVAR(objectActions); } else { _object setVariable [QGVAR(initObject),true]; TRACE_1("Adding load cargo action to object", _object); - [_object, 0, ["ACE_MainActions"], GVAR(objectActions) select 0] call EFUNC(interact_menu,addActionToClass); - [_object, 0, ["ACE_MainActions"], GVAR(objectActions) select 1] call EFUNC(interact_menu,addActionToClass); + { + [_object, 0, ["ACE_MainActions"], _x] call EFUNC(interact_menu,addActionToObject); + } forEach GVAR(objectActions); }; diff --git a/addons/cargo/functions/fnc_renameObject.sqf b/addons/cargo/functions/fnc_renameObject.sqf index df542a38519..e9356200487 100644 --- a/addons/cargo/functions/fnc_renameObject.sqf +++ b/addons/cargo/functions/fnc_renameObject.sqf @@ -24,4 +24,4 @@ if (_ctrlEditText isEqualTo "") then { // custom name has been removed } else { [[LSTRING(renamedObject), _ctrlEditText], 3] call EFUNC(common,displayTextStructured); }; -GVAR(interactionVehicle) setVariable [QGVAR(customName), _ctrlEditText, true]; \ No newline at end of file +GVAR(interactionVehicle) setVariable [QGVAR(customName), _ctrlEditText, true];