From c698d28c75be69ee903af9202908514068e0b968 Mon Sep 17 00:00:00 2001 From: BrettMayson Date: Mon, 25 Nov 2024 22:42:33 -0600 Subject: [PATCH] Arsenal - Show DLC Requirement Image (#10506) * arsenal dlc requirement * fix merge, add file * Update addons/common/functions/fnc_getDLC.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Update addons/common/functions/fnc_getDLC.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Update addons/common/functions/fnc_getDLC.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * sort and fix duplicate * use getAssetDLCInfo * Update addons/common/functions/fnc_getDLC.sqf * params, header * Update addons/common/functions/fnc_getDLC.sqf Co-authored-by: Dart <59131299+DartRuffian@users.noreply.github.com> * Update addons/arsenal/initSettings.inc.sqf Co-authored-by: Dart <59131299+DartRuffian@users.noreply.github.com> * Update addons/common/functions/fnc_getDLC.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Update addons/common/functions/fnc_getDLC.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --------- Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: Dart <59131299+DartRuffian@users.noreply.github.com> --- .../arsenal/functions/fnc_addListBoxItem.sqf | 13 +++- .../arsenal/functions/fnc_fillLeftPanel.sqf | 2 +- addons/arsenal/initSettings.inc.sqf | 4 +- addons/arsenal/stringtable.xml | 16 +++++ addons/common/XEH_PREP.hpp | 1 + addons/common/functions/fnc_getDLC.sqf | 68 +++++++++++++++++++ docs/src/package-lock.json | 7 ++ docs/src/package.json | 3 + 8 files changed, 108 insertions(+), 6 deletions(-) create mode 100644 addons/common/functions/fnc_getDLC.sqf diff --git a/addons/arsenal/functions/fnc_addListBoxItem.sqf b/addons/arsenal/functions/fnc_addListBoxItem.sqf index 777b1efe875..b51a585a3b5 100644 --- a/addons/arsenal/functions/fnc_addListBoxItem.sqf +++ b/addons/arsenal/functions/fnc_addListBoxItem.sqf @@ -48,14 +48,21 @@ if (_skip) exitWith {}; private _configPath = ([configFile, campaignConfigFile, missionConfigFile] select _configRoot) >> _configCategory >> _className; private _dlcName = _configPath call EFUNC(common,getAddon); + // Get DLC requirements + ([_configPath] call EFUNC(common,getDLC)) params ["_dlcClass", "_dlcSteamID"]; + private _dlcPicture = ""; + if (_dlcClass != "") then { + _dlcPicture = getText (configFile >> "CfgMods" >> _dlcClass >> "logo"); + }; + // If _pictureEntryName is empty, then this item has no picture (e.g. faces) - [configName _configPath, getText (_configPath >> "displayName"), if (_pictureEntryName == "") then {""} else {getText (_configPath >> _pictureEntryName)}, if (_dlcName != "") then {(modParams [_dlcName, ["logo"]]) param [0, ""]} else {""}] -}, true]) params ["_className", "_displayName", "_itemPicture", "_modPicture"]; + [configName _configPath, getText (_configPath >> "displayName"), if (_pictureEntryName == "") then {""} else {getText (_configPath >> _pictureEntryName)}, if (_dlcName != "") then {(modParams [_dlcName, ["logo"]]) param [0, ""]} else {""}, _dlcPicture] +}, true]) params ["_className", "_displayName", "_itemPicture", "_modPicture", "_dlcPicture"]; private _lbAdd = _ctrlPanel lbAdd _displayName; _ctrlPanel lbSetData [_lbAdd, _className]; _ctrlPanel lbSetPicture [_lbAdd, _itemPicture]; -_ctrlPanel lbSetPictureRight [_lbAdd, ["", _modPicture] select GVAR(enableModIcons)]; +_ctrlPanel lbSetPictureRight [_lbAdd, ["", _modPicture, _dlcPicture] select GVAR(enableModIcons)]; _ctrlPanel lbSetTooltip [_lbAdd, format ["%1\n%2", _displayName, _className]]; if ((toLowerANSI _className) in GVAR(favorites)) then { diff --git a/addons/arsenal/functions/fnc_fillLeftPanel.sqf b/addons/arsenal/functions/fnc_fillLeftPanel.sqf index 1eb98d29eca..3c3f0c4831b 100644 --- a/addons/arsenal/functions/fnc_fillLeftPanel.sqf +++ b/addons/arsenal/functions/fnc_fillLeftPanel.sqf @@ -94,7 +94,7 @@ private _selectedItem = if (_idxVirt != -1) then { // Items _lbAdd = _ctrlPanel lbAdd _displayName; _ctrlPanel lbSetData [_lbAdd, _x]; _ctrlPanel lbSetTooltip [_lbAdd, format ["%1\n%2", _displayName, _x]]; - _ctrlPanel lbSetPictureRight [_lbAdd, ["", _modPicture] select GVAR(enableModIcons)]; + _ctrlPanel lbSetPictureRight [_lbAdd, ["", _modPicture, ""] select GVAR(enableModIcons)]; } forEach GVAR(faceCache); // HashMap, not array GVAR(currentFace) diff --git a/addons/arsenal/initSettings.inc.sqf b/addons/arsenal/initSettings.inc.sqf index bc093eb5228..535316b941a 100644 --- a/addons/arsenal/initSettings.inc.sqf +++ b/addons/arsenal/initSettings.inc.sqf @@ -10,10 +10,10 @@ private _category = LLSTRING(settingCategory); [ QGVAR(enableModIcons), - "CHECKBOX", + "LIST", [LSTRING(modIconsSetting), LSTRING(modIconsTooltip)], _category, - true + [[0, 1, 2], [ELSTRING(common,Disabled), ELSTRING(common,Enabled), LSTRING(DLCRequirement)], 1] ] call CBA_fnc_addSetting; [ diff --git a/addons/arsenal/stringtable.xml b/addons/arsenal/stringtable.xml index b204030487e..106f7fd3aa9 100644 --- a/addons/arsenal/stringtable.xml +++ b/addons/arsenal/stringtable.xml @@ -93,6 +93,22 @@ 无法开启 ACE 虚拟军火库 ACE Arsenal açılamıyor + + DLC Required + Vyžadováno DLC + DLC requis + Requiere DLC + DLC richiesto + Wymagane DLC + DLC necessário + Требуется DLC + DLC erforderlich + DLC 필요 + DLCが必要です + 需要DLC + 需要DLC + DLC gereklidir + Detonates on impact Détonation à l'impact diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index e6a2a042c09..f1726954595 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -73,6 +73,7 @@ PREP(getDefaultAnim); PREP(getDefinedVariable); PREP(getDefinedVariableDefault); PREP(getDefinedVariableInfo); +PREP(getDLC); PREP(getFiremodeIndex); PREP(getFirstObjectIntersection); PREP(getFirstTerrainIntersection); diff --git a/addons/common/functions/fnc_getDLC.sqf b/addons/common/functions/fnc_getDLC.sqf new file mode 100644 index 00000000000..cb2e8134bfb --- /dev/null +++ b/addons/common/functions/fnc_getDLC.sqf @@ -0,0 +1,68 @@ +#include "..\script_component.hpp" +/* + * Author: Brett Mayson + * Get the DLC information of a class. + * + * Arguments: + * 0: Classname or Config + * 1: Config root, searches if unspecified or null (default: configNull) + * + * Return Value: + * DLC Info + * 0: DLC Classname + * 1: Steam ID + * + * Example: + * "launch_NLAW_F" call ace_common_fnc_getDLC + * + * Public: Yes + */ + +params [["_class", configNull, ["", configNull]], ["_root", configNull, [configNull]]]; + +private _config = if (_class isEqualType configNull) then { + _class +} else { + if !(isNull _root) then { + _root >> _class + } else { + _class call CBA_fnc_getItemConfig + }; +}; +if (isNull _config) exitWith { + ["", 0] +}; + +if (getNumber (_config >> "ItemInfo" >> "type") == TYPE_UNIFORM) then { + _config = configFile >> "CfgVehicles" >> getText (_config >> "itemInfo" >> "uniformClass") +}; + +(getAssetDLCInfo getText (_config >> "model")) params [ + "_isDLC", "", "", "", "_id" +]; + +if (!_isDLC) exitWith { + ["", 0] +}; + +private _name = switch (_id) do { + case "1021790": { "Enoch" }; + case "395180": { "Expansion" }; + case "304380": { "Heli" }; + case "601670": { "Jets" }; + case "288520": { "Kart" }; + case "332350": { "Mark" }; + case "288520": { "Orange" }; + case "744950": { "Tacops" }; + case "798390": { "Tank" }; + case "1042220": { "GM" }; + case "1227700": { "VN" }; + case "1294440": { "CSLA" }; + case "1681170": { "WS" }; + case "1175380": { "SPE" }; + case "2647760": { "RF" }; + case "2647830": { "EF" }; + default { "" }; +}; + +[_name, _id] diff --git a/docs/src/package-lock.json b/docs/src/package-lock.json index d0d710b40bd..3a6483dcd79 100644 --- a/docs/src/package-lock.json +++ b/docs/src/package-lock.json @@ -7,6 +7,9 @@ "": { "name": "ace3", "version": "0.1.0", + "dependencies": { + "ace3": "file:" + }, "devDependencies": { "@rollup/plugin-terser": "^0.4.4", "node-sass": "^9.0.0", @@ -254,6 +257,10 @@ "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true }, + "node_modules/ace3": { + "resolved": "", + "link": true + }, "node_modules/acorn": { "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", diff --git a/docs/src/package.json b/docs/src/package.json index a8df663801b..9bbae686608 100644 --- a/docs/src/package.json +++ b/docs/src/package.json @@ -11,5 +11,8 @@ "rollup-plugin-scss": "^4.0.0", "rollup-plugin-svg-icons": "^2.1.2", "rollup-plugin-svg-sprite-loader": "^0.0.4" + }, + "dependencies": { + "ace3": "file:" } }