From 396e01cd6ec6695a6a221a4ce259519e7e92ef5a Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 01:04:57 +0200 Subject: [PATCH] Added string checking for less needed string multiplicates --- .../repair/functions/fnc_addRepairActions.sqf | 62 +++++++++- addons/repair/stringtable.xml | 109 ++++++------------ 2 files changed, 97 insertions(+), 74 deletions(-) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 8f030d6e7f..db18e6f392 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -13,12 +13,15 @@ * * Public: No */ +#define DEBUG_MODE_FULL #include "script_component.hpp" #define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"] params ["_vehicle"]; TRACE_1("params", _vehicle); +if (typeOf _vehicle != "O_Heli_Transport_04_F") exitWith {}; // test + private ["_type", "_initializedClasses"]; _type = typeOf _vehicle; @@ -39,6 +42,11 @@ _wheelHitPointsWithSelections = [_vehicle] call FUNC(getWheelHitPointsWithSelect _wheelHitPoints = _wheelHitPointsWithSelections select 0; _wheelHitPointSelections = _wheelHitPointsWithSelections select 1; +private ["_hitPointsAddedNames", "_hitPointsAddedStrings", "_hitPointsAddedAmount"]; +_hitPointsAddedNames = []; +_hitPointsAddedStrings = []; +_hitPointsAddedAmount = []; + // add repair events to this vehicle class { if (_x in _wheelHitPoints) then { @@ -83,12 +91,60 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1; // add misc repair action - private ["_name", "_text", "_icon", "_selection", "_condition", "_statement"]; + private ["_name", "_text", "_icon", "_selection", "_condition", "_statement", "_toFind", "_hitPointFoundIndex", "_combinedString"]; _name = format ["Repair_%1", _x]; - _text = format ["STR_ACE_Repair_%1", _x]; - _text = if (isLocalized _text) then {localize _text} else {_x}; + // Prepare first part of the string from stringtable + _text = LSTRING(Hit); + + // Remove "Hit" from hitpoint name if one exists + _toFind = if (_x find "Hit" == 0) then { + [_x, 3] call CBA_fnc_substr + } else { + _x + }; + + // Loop through always shorter part of the hitpoint name to find the string from stringtable or use an already found one + for "_i" from 0 to (count _x) do { + // Loop through already added hitpoints and save index + _hitPointFoundIndex = -1; + { + if (_x == _toFind) exitWith { + _hitPointFoundIndex = _forEachIndex; + }; + } forEach _hitPointsAddedNames; + + // Use already added hitpoint if one found above and numerize + if (_hitPointFoundIndex != -1) exitWith { + _text = (_hitPointsAddedNames select _hitPointFoundIndex) + " " + str(_hitPointsAddedAmount select _hitPointFoundIndex); + _hitPointsAddedAmount set [_hitPointFoundIndex, (_hitPointsAddedAmount select _hitPointFoundIndex) + 1]; // Set amount + TRACE_2("Same hitpoint found",_toFind,_hitPointsAddedNames); + }; + + // Localize if localization found and save all variables for possible hitpoints of same type + _combinedString = _text + _toFind; + if (isLocalized _combinedString) exitWith { + // Add hitpoint to the list + _hitPointsAddedNames pushBack _toFind; + _hitPointsAddedStrings pushBack _combinedString; + _hitPointsAddedAmount pushBack 2; + + // Localize text + _text = localize _combinedString; + TRACE_1("Hitpoint localized",_toFind); + }; + + // Cut off one character + _toFind = [_toFind, 0, count _toFind - 1] call CBA_fnc_substr; + }; + + // Display part name directly if no string is found in stringtable + if (_text == LSTRING(Hit)) then { + _text = _x; + }; + + _icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; _selection = ""; diff --git a/addons/repair/stringtable.xml b/addons/repair/stringtable.xml index 0f045c064b..1f0dc8b394 100644 --- a/addons/repair/stringtable.xml +++ b/addons/repair/stringtable.xml @@ -230,6 +230,15 @@ Motor Двигатель + + Left Horizontal Stabilizer + + + Right Horizontal Stabilizer + + + Vertical Stabilizer + Fuel Tank Tank @@ -242,6 +251,24 @@ Üzemanyagtank Топливный бак + + Transmission + + + Gear + + + Starter + + + Tail + + + Pilot Tube + + + Static Port + Main Turret Turm @@ -451,77 +478,17 @@ Bal szélvédő Стекло (слава) - - Glass 1 - Scheibe 1 - Ventana 1 - Vitre 1 - Szyba 1 - Sklo 1 - Vidro 1 - Vetro 1 - Üveg 1 - Стекло 1 - - - Glass 2 - Scheibe 2 - Ventana 2 - Vitre 2 - Szyba 2 - Sklo 2 - Vidro 2 - Vetro 2 - Üveg 2 - Стекло 2 - - - Glass 3 - Scheibe 3 - Ventana 3 - Vitre 3 - Szyba 3 - Sklo 3 - Vidro 3 - Vetro 3 - Üveg 3 - Стекло 3 - - - Glass 4 - Scheibe 4 - Ventana 4 - Vitre 4 - Szyba 4 - Sklo 4 - Vidro 4 - Vetro 4 - Üveg 4 - Стекло 4 - - - Glass 5 - Scheibe 5 - Ventana 5 - Vitre 5 - Szyba 5 - Sklo 5 - Vidro 5 - Vetro 5 - Üveg 5 - Стекло 5 - - - Glass 6 - Scheibe 6 - Ventana 6 - Vitre 6 - Szyba 6 - Sklo 6 - Vidro 6 - Vetro 6 - Üveg 6 - Стекло 6 + + Glass + Scheibe + Ventana + Vitre + Szyba + Sklo + Vidro + Vetro + Üveg + Стекло Repair Settings