mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Rearm - Use non-ambigious magazine names (#6761)
* Rearm - Use non-ambigious magazine names Close #6414 Also fix missing caliber for B_20mm_AP * Update fnc_getMagazineName.sqf
This commit is contained in:
parent
32ffe3243c
commit
6bee6d5cd8
@ -60,6 +60,9 @@ class CfgAmmo {
|
||||
class B_20mm : BulletBase {
|
||||
GVAR(caliber) = 20;
|
||||
};
|
||||
class B_20mm_AP: BulletBase {
|
||||
GVAR(caliber) = 20;
|
||||
};
|
||||
|
||||
class B_25mm : BulletBase {
|
||||
GVAR(caliber) = 25;
|
||||
|
@ -10,6 +10,7 @@ PREP(disable);
|
||||
PREP(dropAmmo);
|
||||
PREP(getAllRearmTurrets);
|
||||
PREP(getCaliber);
|
||||
PREP(getMagazineName);
|
||||
PREP(getMaxMagazines);
|
||||
PREP(getNeedRearmMagazines);
|
||||
PREP(getSupplyCount);
|
||||
|
@ -29,3 +29,6 @@ if (isServer) then {
|
||||
[QGVAR(rearmSuccessEH), LINKFUNC(rearmSuccess)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(rearmSuccessLocalEH), LINKFUNC(rearmSuccessLocal)] call CBA_fnc_addEventHandler;
|
||||
|
||||
|
||||
GVAR(magazineNameCache) = [] call CBA_fnc_createNamespace;
|
||||
GVAR(originalMagazineNames) = [];
|
||||
|
@ -60,7 +60,7 @@ private _vehicleActions = [];
|
||||
{
|
||||
private _action = [
|
||||
_x,
|
||||
getText(configFile >> "CfgMagazines" >> _x >> "displayName"),
|
||||
_x call FUNC(getMagazineName),
|
||||
getText(configFile >> "CfgMagazines" >> _x >> "picture"),
|
||||
{_this call FUNC(takeAmmo)},
|
||||
{true},
|
||||
|
@ -33,7 +33,7 @@ if (_tmpCal > 0) then {
|
||||
if (_tmpCal > 0) then {
|
||||
_cal = _tmpCal;
|
||||
} else {
|
||||
diag_log format ["[ACE] ERROR: Undefined Ammo [%1 : %2]", _ammo, inheritsFrom (configFile >> "CfgAmmo" >> _ammo)];
|
||||
diag_log format ["[ACE] ERROR: Undefined Ammo [%1 : %2]", _ammo, configName inheritsFrom (configFile >> "CfgAmmo" >> _ammo)];
|
||||
if (_ammo isKindOf "BulletBase") then {
|
||||
_cal = 8;
|
||||
} else {
|
||||
|
46
addons/rearm/functions/fnc_getMagazineName.sqf
Normal file
46
addons/rearm/functions/fnc_getMagazineName.sqf
Normal file
@ -0,0 +1,46 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Gets a non-ambigious display name for a magazine using displayNameShort (AP/HE)
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Magazine Classname <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Display Name <STRING>
|
||||
*
|
||||
* Example:
|
||||
* ["B_20mm_AP"] call ace_rearm_fnc_getMagazineName
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_className"];
|
||||
TRACE_1("getMagazineName",_className);
|
||||
|
||||
private _magName = GVAR(magazineNameCache) getVariable _className;
|
||||
if (isNil "_magName") then {
|
||||
private _displayName = getText(configFile >> "CfgMagazines" >> _className >> "displayName");
|
||||
if (_displayName == "") then {
|
||||
_displayName = _className;
|
||||
WARNING_1("Magazine is missing display name [%1]",_className);
|
||||
};
|
||||
|
||||
GVAR(magazineNameCache) setVariable [_className, _displayName];
|
||||
GVAR(originalMagazineNames) pushBack _displayName;
|
||||
TRACE_2("Adding to cache",_className,_displayName);
|
||||
|
||||
// go through all existing cache entries and update if there now are duplicates
|
||||
{
|
||||
private _xMagName = GVAR(magazineNameCache) getVariable _x;
|
||||
if ((_xMagName == _displayName) && {({_xMagName == _x} count GVAR(originalMagazineNames)) > 1}) then {
|
||||
private _xMagName = format ["%1: %2", _displayName, getText(configFile >> "CfgMagazines" >> _x >> "displayNameShort")];
|
||||
GVAR(magazineNameCache) setVariable [_x, _xMagName];
|
||||
TRACE_2("Using unique name",_x,_xMagName);
|
||||
};
|
||||
} forEach (allVariables GVAR(magazineNameCache));
|
||||
|
||||
_magName = GVAR(magazineNameCache) getVariable _className;
|
||||
};
|
||||
|
||||
_magName
|
@ -54,7 +54,7 @@ if (GVAR(supply) == 1) then {
|
||||
if !(isNil "_magazines") then {
|
||||
{
|
||||
_x params ["_magazineClass", "_rounds"];
|
||||
private _line = format ["%1: %2", getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"), _rounds];
|
||||
private _line = format ["%1: %2", _magazineClass call FUNC(getMagazineName), _rounds];
|
||||
_numChars = _numChars max (count _line);
|
||||
_text = format ["%1<br/>%2", _text, _line];
|
||||
_supply = _supply + 0.5;
|
||||
|
@ -36,11 +36,7 @@ if ((count _needRearmMagsOfClass) == 0) exitWith {ERROR_2("Could not find turret
|
||||
private _currentRearmableMag = _needRearmMagsOfClass select 0;
|
||||
_currentRearmableMag params ["", "_turretPath", "", "_pylon", "", "_magazineCount"];
|
||||
|
||||
private _magazineDisplayName = getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName");
|
||||
if (_magazineDisplayName == "") then {
|
||||
_magazineDisplayName = _magazineClass;
|
||||
ERROR_1("Magazine is missing display name [%1]",_magazineClass);
|
||||
};
|
||||
private _magazineDisplayName = _magazineClass call FUNC(getMagazineName);
|
||||
|
||||
[
|
||||
TIME_PROGRESSBAR(REARM_DURATION_REARM select _idx),
|
||||
|
@ -33,7 +33,7 @@ if (_pylon > 0) exitWith {
|
||||
TRACE_2("",_pylon,_magazineClass,_rounds);
|
||||
_vehicle setPylonLoadOut [_pylon, _magazineClass, true, _turretPath];
|
||||
[QEGVAR(common,displayTextStructured), [[LSTRING(Hint_RearmedTriple), _rounds,
|
||||
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
|
||||
_magazineClass call FUNC(getMagazineName),
|
||||
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], 3, _unit], [_unit]] call CBA_fnc_targetEvent;
|
||||
} else {
|
||||
// Fill only at most _numRounds
|
||||
@ -44,7 +44,7 @@ if (_pylon > 0) exitWith {
|
||||
_vehicle setPylonLoadOut [_pylon, _magazineClass, true, _turretPath];
|
||||
_vehicle setAmmoOnPylon [_pylon, _newCount];
|
||||
[QEGVAR(common,displayTextStructured), [[LSTRING(Hint_RearmedTriple), _numRounds,
|
||||
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
|
||||
_magazineClass call FUNC(getMagazineName),
|
||||
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], 3, _unit], [_unit]] call CBA_fnc_targetEvent;
|
||||
};
|
||||
};
|
||||
@ -64,12 +64,12 @@ if (_maxMagazines == 1) then {
|
||||
_vehicle setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
|
||||
[QEGVAR(common,displayTextStructured), [[LSTRING(Hint_RearmedTriple), _rounds,
|
||||
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
|
||||
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], 3, _unit], [_unit]] call CBA_fnc_targetEvent;
|
||||
_magazineClass call FUNC(getMagazineName)], 3, _unit], [_unit]] call CBA_fnc_targetEvent;
|
||||
} else {
|
||||
// Fill only at most _numRounds
|
||||
_vehicle setMagazineTurretAmmo [_magazineClass, ((_vehicle magazineTurretAmmo [_magazineClass, _turretPath]) + _numRounds) min _rounds, _turretPath];
|
||||
[QEGVAR(common,displayTextStructured), [[LSTRING(Hint_RearmedTriple), _numRounds,
|
||||
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
|
||||
_magazineClass call FUNC(getMagazineName),
|
||||
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], 3, _unit], [_unit]] call CBA_fnc_targetEvent;
|
||||
};
|
||||
} else {
|
||||
@ -92,7 +92,7 @@ if (_maxMagazines == 1) then {
|
||||
_vehicle setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds, _turretPath];
|
||||
};
|
||||
[QEGVAR(common,displayTextStructured), [[LSTRING(Hint_RearmedTriple), _numRounds,
|
||||
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
|
||||
_magazineClass call FUNC(getMagazineName),
|
||||
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], 3, _unit], [_unit]] call CBA_fnc_targetEvent;
|
||||
} else {
|
||||
// Fill current magazine completely and fill next magazine partially
|
||||
@ -102,7 +102,7 @@ if (_maxMagazines == 1) then {
|
||||
_vehicle setMagazineTurretAmmo [_magazineClass, _currentRounds, _turretPath];
|
||||
};
|
||||
[QEGVAR(common,displayTextStructured), [[LSTRING(Hint_RearmedTriple), _rounds,
|
||||
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
|
||||
_magazineClass call FUNC(getMagazineName),
|
||||
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], 3, _unit], [_unit]] call CBA_fnc_targetEvent;
|
||||
};
|
||||
};
|
||||
|
@ -21,6 +21,8 @@ params ["_truck", "_unit"];
|
||||
private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull];
|
||||
if (isNull _attachedDummy) exitwith {};
|
||||
|
||||
private _magazineClass = _attachedDummy getVariable [QGVAR(magazineClass), "#noVar"];
|
||||
|
||||
[
|
||||
TIME_PROGRESSBAR(5),
|
||||
[_unit, _truck, _attachedDummy],
|
||||
@ -31,7 +33,7 @@ if (isNull _attachedDummy) exitwith {};
|
||||
[_unit, true, true] call FUNC(dropAmmo);
|
||||
},
|
||||
"",
|
||||
format [localize LSTRING(StoreAmmoAction), getText(configFile >> "CfgMagazines" >> (_attachedDummy getVariable QGVAR(magazineClass)) >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _truck) >> "displayName")],
|
||||
format [localize LSTRING(StoreAmmoAction), _magazineClass call FUNC(getMagazineName), getText(configFile >> "CfgVehicles" >> (typeOf _truck) >> "displayName")],
|
||||
{true},
|
||||
["isnotinside"]
|
||||
] call EFUNC(common,progressBar);
|
||||
|
@ -32,7 +32,7 @@ REARM_HOLSTER_WEAPON;
|
||||
[_unit, _magazineClass, _truck],
|
||||
FUNC(takeSuccess),
|
||||
"",
|
||||
format [localize LSTRING(TakeAction), getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")],
|
||||
format [localize LSTRING(TakeAction), _magazineClass call FUNC(getMagazineName), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")],
|
||||
{true},
|
||||
["isnotinside"]
|
||||
] call EFUNC(common,progressBar);
|
||||
|
Loading…
Reference in New Issue
Block a user