localization

This commit is contained in:
GenZmeY 2022-08-24 18:29:25 +03:00
parent e07e98020b
commit cb19485ea2
4 changed files with 86 additions and 12 deletions

View File

@ -0,0 +1,73 @@
class CTI_LocalMessage extends Object
abstract;
var const String SyncItemsDefault;
var private localized String SyncItems;
var const String SyncFinishedDefault;
var private localized String SyncFinished;
var const String WaitingGRIDefault;
var private localized String WaitingGRI;
var const String IncompatibleGRIDefault;
var private localized String IncompatibleGRI;
var const String DisconnectDefault;
var private localized String Disconnect;
var const String SecondsShortDefault;
var private localized String SecondsShort;
enum E_CTI_LocalMessageType
{
CTI_SyncItems,
CTI_SyncFinished,
CTI_WaitingGRI,
CTI_IncompatibleGRI,
CTI_Disconnect,
CTI_SecondsShort
};
public static function String GetLocalizedString(
E_LogLevel LogLevel,
E_CTI_LocalMessageType LMT,
optional String String1,
optional String String2,
optional String String3)
{
`Log_TraceStatic();
switch (LMT)
{
case CTI_SyncItems:
return (default.SyncItems != "" ? default.SyncItems : default.SyncItemsDefault);
case CTI_SyncFinished:
return (default.SyncFinished != "" ? default.SyncFinished : default.SyncFinishedDefault);
case CTI_WaitingGRI:
return (default.WaitingGRI != "" ? default.WaitingGRI : default.WaitingGRIDefault);
case CTI_IncompatibleGRI:
return (default.IncompatibleGRI != "" ? default.IncompatibleGRI : default.IncompatibleGRIDefault);
case CTI_Disconnect:
return (default.Disconnect != "" ? default.Disconnect : default.DisconnectDefault);
case CTI_SecondsShort:
return (default.SecondsShort != "" ? default.SecondsShort : default.SecondsShortDefault);
}
return "";
}
defaultproperties
{
SyncItemsDefault = "Sync items:"
SyncFinishedDefault = "Sync finished."
WaitingGRIDefault = "Waiting GRI..."
IncompatibleGRIDefault = "Incompatible GRI:"
DisconnectDefault = "Disconnect..."
SecondsShortDefault = "s"
}

View File

@ -1,6 +1,7 @@
class CTI_RepInfo extends ReplicationInfo;
const Trader = class'Trader';
const Trader = class'Trader';
const LocalMessage = class'CTI_LocalMessage';
var public bool PendingSync;
@ -119,7 +120,7 @@ private simulated function ShowReadyButton()
}
}
private simulated function UpdateNotification(String Title, String Downloading, String Remainig, int Percent)
private simulated function UpdateNotification(String Title, String Left, String Right, int Percent)
{
`Log_Trace();
@ -128,8 +129,8 @@ private simulated function UpdateNotification(String Title, String Downloading,
Notification.SetString("itemName", Title);
Notification.SetFloat("percent", Percent);
Notification.SetInt("queue", 0);
Notification.SetString("downLoading", Downloading);
Notification.SetString("remaining", Remainig);
Notification.SetString("downLoading", Left);
Notification.SetString("remaining", Right);
Notification.SetObject("notificationInfo", Notification);
Notification.SetVisible(true);
}
@ -164,8 +165,9 @@ private reliable client function ClientSync(class<KFWeaponDefinition> WeapDef, o
Recieved = RemoveItems.Length + AddItems.Length;
NotificationLeftText = WeapDef.static.GetItemName();
NotificationRightText = Recieved @ "/" @ SyncSize @ "(" $ (Remove ? "remove" : "add") $ ")";
NotificationHeaderText = (Remove ? "-" : "+") @ WeapDef.static.GetItemName();
NotificationLeftText = LocalMessage.static.GetLocalizedString(LogLevel, CTI_SyncItems);
NotificationRightText = Recieved @ "/" @ SyncSize;
if (SyncSize != 0)
{
NotificationPercent = (float(Recieved) / float(SyncSize)) * 100;
@ -199,8 +201,8 @@ private simulated reliable client function ClientSyncFinished()
if (WorldInfo.GRI == None)
{
`Log_Debug("ClientSyncFinished: Waiting GRI");
NotificationHeaderText = "Waiting for GameReplicationInfo...";
NotificationLeftText = String(++WaitingGRI) $ "s";
NotificationHeaderText = LocalMessage.static.GetLocalizedString(LogLevel, CTI_WaitingGRI);
NotificationLeftText = String(++WaitingGRI) $ LocalMessage.static.GetLocalizedString(LogLevel, CTI_SecondsShort);
NotificationRightText = "";
SetTimer(1.0f, false, nameof(ClientSyncFinished));
return;
@ -212,15 +214,15 @@ private simulated reliable client function ClientSyncFinished()
`Log_Fatal("Incompatible Replication info:" @ String(WorldInfo.GRI));
ClearTimer(nameof(KeepNotification));
UpdateNotification(
"Incompatible GRI:" @ String(WorldInfo.GRI),
"Disconnect...", "", 0);
LocalMessage.static.GetLocalizedString(LogLevel, CTI_IncompatibleGRI) @ String(WorldInfo.GRI),
LocalMessage.static.GetLocalizedString(LogLevel, CTI_Disconnect), "", 0);
Cleanup();
ConsoleCommand("Disconnect");
SafeDestroy();
return;
}
NotificationHeaderText = "Sync finished";
NotificationHeaderText = LocalMessage.static.GetLocalizedString(LogLevel, CTI_SyncFinished);
NotificationLeftText = "";
NotificationRightText = "";
NotificationPercent = 0;
@ -285,7 +287,6 @@ defaultproperties
PendingSync = false
Recieved = 0
NotificationHeaderText = "Sync trader items, please wait..."
NotificationPercent = 0
WaitingGRI = 0
}

BIN
Localization/INT/CTI.int Normal file

Binary file not shown.

BIN
Localization/RUS/CTI.rus Normal file

Binary file not shown.