From e08bf59ac2d85ca0e87abb7a0ca3eb2867815c0d Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 23 Aug 2015 21:09:36 +0200 Subject: [PATCH 1/9] Removed 'Repair' word from sub-actions --- addons/repair/functions/fnc_addRepairActions.sqf | 4 ++-- addons/repair/stringtable.xml | 16 ++-------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 3503dff3f0..24ad3605ca 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -90,9 +90,9 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1; _text = format ["STR_ACE_Repair_%1", _x]; if (isLocalized _text) then { - _text = format [localize LSTRING(RepairHitpoint), localize _text]; + _text = localize _text; } else { - _text = format [localize LSTRING(RepairHitpoint), _x]; + _text = _x; }; _icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; diff --git a/addons/repair/stringtable.xml b/addons/repair/stringtable.xml index 48a40f5b49..0f045c064b 100644 --- a/addons/repair/stringtable.xml +++ b/addons/repair/stringtable.xml @@ -1,4 +1,4 @@ - + @@ -118,18 +118,6 @@ Who can perform a full repair on a vehicle? Kto może przeprowadzić pełną naprawę pojazdu? - - Repair %1 - Reparieren %1 - Reparación %1 - Réparer %1 - Napraw %1 - Opravit %1 - Reparar %1 - Ripara %1 - Szerelés %1 - Ремонт %1 - Repair >> Reparieren >> @@ -696,4 +684,4 @@ Przydziel klasę budynku naprawczego do jednego lub kilku budynków. - \ No newline at end of file + From 0fc9a33d384d3aaea7c128eedaf89800dbbe1db3 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 23 Aug 2015 21:11:45 +0200 Subject: [PATCH 2/9] Shortened sub-action text localization --- addons/repair/functions/fnc_addRepairActions.sqf | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 24ad3605ca..8f030d6e7f 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -88,12 +88,7 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1; _name = format ["Repair_%1", _x]; _text = format ["STR_ACE_Repair_%1", _x]; - - if (isLocalized _text) then { - _text = localize _text; - } else { - _text = _x; - }; + _text = if (isLocalized _text) then {localize _text} else {_x}; _icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; _selection = ""; From 396e01cd6ec6695a6a221a4ce259519e7e92ef5a Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 01:04:57 +0200 Subject: [PATCH 3/9] 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 From e368ae28f59aa649b174ef490695bff9e9df240b Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 01:13:42 +0200 Subject: [PATCH 4/9] Fixed localization on same type hitpoints --- addons/repair/functions/fnc_addRepairActions.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index db18e6f392..299466db60 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -95,6 +95,7 @@ _hitPointsAddedAmount = []; _name = format ["Repair_%1", _x]; + // Prepare first part of the string from stringtable _text = LSTRING(Hit); @@ -117,7 +118,7 @@ _hitPointsAddedAmount = []; // Use already added hitpoint if one found above and numerize if (_hitPointFoundIndex != -1) exitWith { - _text = (_hitPointsAddedNames select _hitPointFoundIndex) + " " + str(_hitPointsAddedAmount select _hitPointFoundIndex); + _text = localize (_hitPointsAddedStrings select _hitPointFoundIndex) + " " + str(_hitPointsAddedAmount select _hitPointFoundIndex); _hitPointsAddedAmount set [_hitPointFoundIndex, (_hitPointsAddedAmount select _hitPointFoundIndex) + 1]; // Set amount TRACE_2("Same hitpoint found",_toFind,_hitPointsAddedNames); }; @@ -145,7 +146,6 @@ _hitPointsAddedAmount = []; }; - _icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; _selection = ""; _condition = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(canRepair)}; From d33834261f88c8213db9a13ab8267dd7608d43d7 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 01:14:59 +0200 Subject: [PATCH 5/9] Removed debug --- addons/repair/functions/fnc_addRepairActions.sqf | 3 --- 1 file changed, 3 deletions(-) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 299466db60..10eb5ee01d 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -13,15 +13,12 @@ * * 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; From 6a1b8cc359d6d62a1b944f20f4a57df6cbd7bff5 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 01:25:00 +0200 Subject: [PATCH 6/9] Changed to LSTRING --- addons/repair/functions/fnc_addRepairActions.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 10eb5ee01d..c330086327 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -60,7 +60,7 @@ _hitPointsAddedAmount = []; // remove wheel action _name = format ["Remove_%1", _x]; - _text = localize "STR_ACE_Repair_RemoveWheel"; + _text = localize LSTRING(RemoveWheel); _condition = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(canRepair)}; _statement = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(repair)}; From 7f175bad5ff16840c6915758e97f3f611de94515 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 05:24:25 +0200 Subject: [PATCH 7/9] Added support for display messages --- addons/repair/functions/fnc_doRepair.sqf | 29 +++++++++++++++++++---- addons/repair/functions/fnc_repair.sqf | 30 ++++++++++++++++++++---- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/addons/repair/functions/fnc_doRepair.sqf b/addons/repair/functions/fnc_doRepair.sqf index dfc21830c9..1c1d47d189 100644 --- a/addons/repair/functions/fnc_doRepair.sqf +++ b/addons/repair/functions/fnc_doRepair.sqf @@ -33,14 +33,35 @@ _hitPointDamage = _hitPointDamage max ([_unit] call FUNC(getPostRepairDamage)); // display text message if enabled if (GVAR(DisplayTextOnRepair)) then { - private "_text"; - _text = format ["STR_ACE_Repair_%1", _hitPoint]; + private ["_text", "_toFind", "_combinedString"]; - if (isLocalized _text) then { - _text = format [localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointDamage > 0)), localize _text]; + // 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 + for "_i" from 0 to (count _x) do { + // Localize if localization found + _combinedString = _text + _toFind; + if (isLocalized _combinedString) exitWith { + _text = format [localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointDamage > 0)), localize _combinedString]; + }; + + // Cut off one character + _toFind = [_toFind, 0, count _toFind - 1] call CBA_fnc_substr; + }; + + // Don't display part name if no string is found in stringtable + if (_text == LSTRING(Hit)) then { _text = localize ([LSTRING(RepairedFully), LSTRING(RepairedPartially)] select (_hitPointDamage > 0)); }; + // Display text [_text] call EFUNC(common,displayTextStructured); }; diff --git a/addons/repair/functions/fnc_repair.sqf b/addons/repair/functions/fnc_repair.sqf index 92af5df80e..45ce756b06 100644 --- a/addons/repair/functions/fnc_repair.sqf +++ b/addons/repair/functions/fnc_repair.sqf @@ -164,15 +164,37 @@ _repairTime = if (isNumber (_config >> "repairingTime")) then { 0; }; -private ["_text", "_processText"]; +private ["_processText", "_text", "_toFind", "_combinedString"]; _processText = getText (_config >> "displayNameProgress"); -_text = format ["STR_ACE_Repair_%1", _hitPoint]; -if (isLocalized _text) then { - _text = format [_processText, localize _text]; + +// 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 +for "_i" from 0 to (count _x) do { + // Localize if localization found + _combinedString = _text + _toFind; + if (isLocalized _combinedString) exitWith { + _text = format [_processText, localize _combinedString]; + }; + + // Cut off one character + _toFind = [_toFind, 0, count _toFind - 1] call CBA_fnc_substr; +}; + +// Don't display part name if no string is found in stringtable +if (_text == LSTRING(Hit)) then { _text = _processText; }; + // Start repair [ _repairTime, From 97188835998bd182078360e4d8fef5b87ec4c1f6 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 20:58:54 +0200 Subject: [PATCH 8/9] Consolidated into 1 function --- addons/repair/XEH_preInit.sqf | 1 + .../repair/functions/fnc_addRepairActions.sqf | 57 ++---------- addons/repair/functions/fnc_doRepair.sqf | 32 ++----- .../functions/fnc_getHitPointString.sqf | 89 +++++++++++++++++++ addons/repair/functions/fnc_repair.sqf | 32 +------ 5 files changed, 104 insertions(+), 107 deletions(-) create mode 100644 addons/repair/functions/fnc_getHitPointString.sqf diff --git a/addons/repair/XEH_preInit.sqf b/addons/repair/XEH_preInit.sqf index ebf4c87537..91d576c373 100644 --- a/addons/repair/XEH_preInit.sqf +++ b/addons/repair/XEH_preInit.sqf @@ -15,6 +15,7 @@ PREP(doRepair); PREP(doRepairTrack); PREP(doReplaceTrack); PREP(doReplaceWheel); +PREP(getHitPointString); PREP(getPostRepairDamage); PREP(getWheelHitPointsWithSelections); PREP(hasItems); diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index c330086327..c4c995c0e2 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -88,60 +88,15 @@ _hitPointsAddedAmount = []; // add misc repair action - private ["_name", "_text", "_icon", "_selection", "_condition", "_statement", "_toFind", "_hitPointFoundIndex", "_combinedString"]; + private ["_name", "_icon", "_selection", "_condition", "_statement"]; _name = format ["Repair_%1", _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 = localize (_hitPointsAddedStrings 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; - }; - + // Find localized string and track those added for numerization + ([_x, "%1", _x, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_text", "_trackArray"]; + _hitPointsAddedNames = _trackArray select 0; + _hitPointsAddedStrings = _trackArray select 1; + _hitPointsAddedAmount = _trackArray select 2; _icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; _selection = ""; diff --git a/addons/repair/functions/fnc_doRepair.sqf b/addons/repair/functions/fnc_doRepair.sqf index 1c1d47d189..b086ab78d1 100644 --- a/addons/repair/functions/fnc_doRepair.sqf +++ b/addons/repair/functions/fnc_doRepair.sqf @@ -33,34 +33,12 @@ _hitPointDamage = _hitPointDamage max ([_unit] call FUNC(getPostRepairDamage)); // display text message if enabled if (GVAR(DisplayTextOnRepair)) then { - private ["_text", "_toFind", "_combinedString"]; + private ["_textLocalized", "_textDefault"]; - // 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 - for "_i" from 0 to (count _x) do { - // Localize if localization found - _combinedString = _text + _toFind; - if (isLocalized _combinedString) exitWith { - _text = format [localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointDamage > 0)), localize _combinedString]; - }; - - // Cut off one character - _toFind = [_toFind, 0, count _toFind - 1] call CBA_fnc_substr; - }; - - // Don't display part name if no string is found in stringtable - if (_text == LSTRING(Hit)) then { - _text = localize ([LSTRING(RepairedFully), LSTRING(RepairedPartially)] select (_hitPointDamage > 0)); - }; + // Find localized string + _textLocalized = localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointDamage > 0)); + _textDefault = localize ([LSTRING(RepairedFully), LSTRING(RepairedPartially)] select (_hitPointDamage > 0)); + ([_hitPoint, _textLocalized, _textDefault] call FUNC(getHitPointString)) params ["_text"]; // Display text [_text] call EFUNC(common,displayTextStructured); diff --git a/addons/repair/functions/fnc_getHitPointString.sqf b/addons/repair/functions/fnc_getHitPointString.sqf new file mode 100644 index 0000000000..c6e587db50 --- /dev/null +++ b/addons/repair/functions/fnc_getHitPointString.sqf @@ -0,0 +1,89 @@ +/* + * Author: Jonpas + * Finds the localized string of the given hitpoint name. + * + * Arguments: + * 0: Hitpoint + * 1: Localized Text + * 2: Default Text + * 3: Track Added Hitpoints (default: false) + * + * Return Value: + * 0: Text + * 1: Added Hitpoint (default: []) + * + * Example: + * [unit, vehicle, "hitpoint"] call ace_repair_fnc_getHitPointString + * + * Public: No + */ +#include "script_component.hpp" + +private ["_track", "_trackNames", "_trackStrings", "_trackAmount", "_text", "_toFind", "_trackIndex", "_combinedString"]; +params ["_hitPoint", "_textLocalized", "_textDefault", ["_trackArray", []]]; + +_track = if (count _trackArray > 0) then {true} else {false}; +_trackNames = []; +_trackStrings = []; +_trackAmount = []; + +if (_track) then { + _trackNames = _trackArray select 0; + _trackStrings = _trackArray select 1; + _trackAmount = _trackArray select 2; +}; + +// Prepare first part of the string from stringtable +_text = LSTRING(Hit); + +// Remove "Hit" from hitpoint name if one exists +_toFind = if (_hitPoint find "Hit" == 0) then { + [_hitPoint, 3] call CBA_fnc_substr +} else { + _hitPoint +}; + +// Loop through always shorter part of the hitpoint name to find the string from stringtable +for "_i" from 0 to (count _hitPoint) do { + if (_track) then { + // Loop through already added hitpoints and save index + _trackIndex = -1; + { + if (_x == _toFind) exitWith { + _trackIndex = _forEachIndex; + }; + } forEach _trackNames; + + // Use already added hitpoint if one found above and numerize + if (_trackIndex != -1) exitWith { + _text = localize (_trackStrings select _trackIndex) + " " + str(_trackAmount select _trackIndex); + _trackAmount set [_trackIndex, (_trackAmount select _trackIndex) + 1]; // Set amount + TRACE_2("Same hitpoint found",_toFind,_trackNames); + }; + }; + + + // Localize if localization found + _combinedString = _text + _toFind; + if (isLocalized _combinedString) exitWith { + _text = format [_textLocalized, localize _combinedString]; + TRACE_1("Hitpoint localized",_toFind); + + if (_track) then { + // Add hitpoint to the list + _trackNames pushBack _toFind; + _trackStrings pushBack _combinedString; + _trackAmount pushBack 2; + }; + }; + + // Cut off one character + _toFind = [_toFind, 0, count _toFind - 1] call CBA_fnc_substr; +}; + +// Don't display part name if no string is found in stringtable +if (_text == LSTRING(Hit)) then { + _text = _textDefault; +}; + +[_text, [_trackNames, _trackStrings, _trackAmount]] diff --git a/addons/repair/functions/fnc_repair.sqf b/addons/repair/functions/fnc_repair.sqf index 45ce756b06..8fa7f498bd 100644 --- a/addons/repair/functions/fnc_repair.sqf +++ b/addons/repair/functions/fnc_repair.sqf @@ -164,36 +164,10 @@ _repairTime = if (isNumber (_config >> "repairingTime")) then { 0; }; -private ["_processText", "_text", "_toFind", "_combinedString"]; +private ["_processText"]; +// Find localized string _processText = getText (_config >> "displayNameProgress"); - -// 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 -for "_i" from 0 to (count _x) do { - // Localize if localization found - _combinedString = _text + _toFind; - if (isLocalized _combinedString) exitWith { - _text = format [_processText, localize _combinedString]; - }; - - // Cut off one character - _toFind = [_toFind, 0, count _toFind - 1] call CBA_fnc_substr; -}; - -// Don't display part name if no string is found in stringtable -if (_text == LSTRING(Hit)) then { - _text = _processText; -}; - +([_hitPoint, _processText, _processText] call FUNC(getHitPointString)) params ["_text"]; // Start repair [ From e4123c97304bcba7e88a0d3afc72f623d4b7ba48 Mon Sep 17 00:00:00 2001 From: jonpas Date: Wed, 26 Aug 2015 22:44:30 +0200 Subject: [PATCH 9/9] Added 2 strings, changed 1 --- .../repair/functions/fnc_getHitPointString.sqf | 2 +- addons/repair/stringtable.xml | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/repair/functions/fnc_getHitPointString.sqf b/addons/repair/functions/fnc_getHitPointString.sqf index c6e587db50..1358e99595 100644 --- a/addons/repair/functions/fnc_getHitPointString.sqf +++ b/addons/repair/functions/fnc_getHitPointString.sqf @@ -1,6 +1,6 @@ /* * Author: Jonpas - * Finds the localized string of the given hitpoint name. + * Finds the localized string of the given hitpoint name or uses default text if none found. * * Arguments: * 0: Hitpoint diff --git a/addons/repair/stringtable.xml b/addons/repair/stringtable.xml index 1f0dc8b394..09759344f8 100644 --- a/addons/repair/stringtable.xml +++ b/addons/repair/stringtable.xml @@ -269,15 +269,18 @@ Static Port + + Ammo + - Main Turret + Turret Turm - Torreta príncipal + Torreta Tourelle Wieżyczka - Hlavní Věž - Torre principal - Torretta principale + Věž + Torre + Torretta Lövegtorony Башню @@ -293,6 +296,9 @@ Ágyú Пушку + + Missiles + Left Track Linke Kette