2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2019-01-31 00:31:01 +00:00
|
|
|
/*
|
2024-06-05 06:32:41 +00:00
|
|
|
* Author: PabstMirror, johnb43
|
|
|
|
* Gets a non-ambigious display name for a magazine using displayNameShort (AP/HE).
|
2019-01-31 00:31:01 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Magazine Classname <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Display Name <STRING>
|
|
|
|
*
|
|
|
|
* Example:
|
2024-06-05 06:32:41 +00:00
|
|
|
* "60Rnd_20mm_AP_shells" call ace_rearm_fnc_getMagazineName
|
2019-01-31 00:31:01 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_className"];
|
|
|
|
TRACE_1("getMagazineName",_className);
|
|
|
|
|
2024-06-05 06:32:41 +00:00
|
|
|
GVAR(magazineNameCache) getOrDefaultCall [_className, {
|
|
|
|
private _cfgMagazines = configFile >> "CfgMagazines";
|
|
|
|
private _displayName = getText (_cfgMagazines >> _className >> "displayName");
|
|
|
|
|
2019-01-31 00:31:01 +00:00
|
|
|
if (_displayName == "") then {
|
|
|
|
_displayName = _className;
|
|
|
|
WARNING_1("Magazine is missing display name [%1]",_className);
|
|
|
|
};
|
|
|
|
|
2024-06-05 06:32:41 +00:00
|
|
|
// [CSW] prefix is localised
|
|
|
|
if (["ace_csw"] call EFUNC(common,isModLoaded)) then {
|
|
|
|
_displayName = trim (_displayName regexReplace [LELSTRING(csw,regex), ""]);
|
|
|
|
};
|
2019-07-05 22:57:22 +00:00
|
|
|
|
2024-06-05 06:32:41 +00:00
|
|
|
// If the display name exists already, add displayNameShort to the existing entry
|
|
|
|
private _existingClassname = GVAR(usedMagazineNames) get _displayName;
|
2019-01-31 00:31:01 +00:00
|
|
|
|
2024-06-05 06:32:41 +00:00
|
|
|
if (!isNil "_existingClassname") then {
|
|
|
|
GVAR(magazineNameCache) set [_existingClassname, format ["%1: %2", _displayName, getText (_cfgMagazines >> _existingClassname >> "displayNameShort")]];
|
2019-01-31 00:31:01 +00:00
|
|
|
|
2024-06-05 06:32:41 +00:00
|
|
|
_displayName = format ["%1: %2", _displayName, getText (_cfgMagazines >> _className >> "displayNameShort")];
|
|
|
|
};
|
|
|
|
|
|
|
|
GVAR(usedMagazineNames) set [_displayName, _className];
|
|
|
|
TRACE_2("Adding to cache",_className,_displayName);
|
2019-01-31 00:31:01 +00:00
|
|
|
|
2024-06-05 06:32:41 +00:00
|
|
|
_displayName
|
|
|
|
}, true] // return
|