add waiting GRI limit

This commit is contained in:
GenZmeY 2023-05-14 03:47:20 +03:00
parent 1af2ef0b80
commit 335ca77980
4 changed files with 68 additions and 44 deletions

View File

@ -4,17 +4,14 @@ class LTI_LocalMessage extends Object
var const String SyncItemsDefault; var const String SyncItemsDefault;
var private localized String SyncItems; var private localized String SyncItems;
var const String SyncFinishedDefault;
var private localized String SyncFinished;
var const String WaitingGRIDefault; var const String WaitingGRIDefault;
var private localized String WaitingGRI; var private localized String WaitingGRI;
var const String IncompatibleGRIDefault; var const String IncompatibleGRIDefault;
var private localized String IncompatibleGRI; var private localized String IncompatibleGRI;
var const String DisconnectDefault; var const String IncompatibleGRIWarningDefault;
var private localized String Disconnect; var private localized String IncompatibleGRIWarning;
var const String SecondsShortDefault; var const String SecondsShortDefault;
var private localized String SecondsShort; var private localized String SecondsShort;
@ -22,10 +19,9 @@ var private localized String SecondsShort;
enum E_LTI_LocalMessageType enum E_LTI_LocalMessageType
{ {
LTI_SyncItems, LTI_SyncItems,
LTI_SyncFinished,
LTI_WaitingGRI, LTI_WaitingGRI,
LTI_IncompatibleGRI, LTI_IncompatibleGRI,
LTI_Disconnect, LTI_IncompatibleGRIWarning,
LTI_SecondsShort LTI_SecondsShort
}; };
@ -43,17 +39,14 @@ public static function String GetLocalizedString(
case LTI_SyncItems: case LTI_SyncItems:
return (default.SyncItems != "" ? default.SyncItems : default.SyncItemsDefault); return (default.SyncItems != "" ? default.SyncItems : default.SyncItemsDefault);
case LTI_SyncFinished:
return (default.SyncFinished != "" ? default.SyncFinished : default.SyncFinishedDefault);
case LTI_WaitingGRI: case LTI_WaitingGRI:
return (default.WaitingGRI != "" ? default.WaitingGRI : default.WaitingGRIDefault); return (default.WaitingGRI != "" ? default.WaitingGRI : default.WaitingGRIDefault);
case LTI_IncompatibleGRI: case LTI_IncompatibleGRI:
return (default.IncompatibleGRI != "" ? default.IncompatibleGRI : default.IncompatibleGRIDefault); return (default.IncompatibleGRI != "" ? default.IncompatibleGRI : default.IncompatibleGRIDefault) @ String1;
case LTI_Disconnect: case LTI_IncompatibleGRIWarning:
return (default.Disconnect != "" ? default.Disconnect : default.DisconnectDefault); return (default.IncompatibleGRIWarning != "" ? default.IncompatibleGRIWarning : default.IncompatibleGRIWarningDefault);
case LTI_SecondsShort: case LTI_SecondsShort:
return (default.SecondsShort != "" ? default.SecondsShort : default.SecondsShortDefault); return (default.SecondsShort != "" ? default.SecondsShort : default.SecondsShortDefault);
@ -65,9 +58,8 @@ public static function String GetLocalizedString(
defaultproperties defaultproperties
{ {
SyncItemsDefault = "Sync items:" SyncItemsDefault = "Sync items:"
SyncFinishedDefault = "Sync finished."
WaitingGRIDefault = "Waiting GRI..." WaitingGRIDefault = "Waiting GRI..."
IncompatibleGRIDefault = "Incompatible GRI:" IncompatibleGRIDefault = "Incompatible GRI:"
DisconnectDefault = "Disconnect..." IncompatibleGRIWarningDefault = "You can enter the game, but the trader may not work correctly.";
SecondsShortDefault = "s" SecondsShortDefault = "s"
} }

View File

@ -25,6 +25,7 @@ var private String NotificationRightText;
var private int NotificationPercent; var private int NotificationPercent;
var private int WaitingGRI; var private int WaitingGRI;
var private int WaitingGRILimit;
replication replication
{ {
@ -74,6 +75,39 @@ private simulated function KFPlayerController GetKFPC()
return KFPC; return KFPC;
} }
public reliable client function WriteToChatLocalized(
E_LTI_LocalMessageType LMT,
optional String HexColor,
optional String String1,
optional String String2,
optional String String3)
{
`Log_Trace();
WriteToChat(LocalMessage.static.GetLocalizedString(LogLevel, LMT, String1, String2, String3), HexColor);
}
public reliable client function WriteToChat(String Message, optional String HexColor)
{
local KFGFxHudWrapper HUD;
`Log_Trace();
if (GetKFPC() == None) return;
if (KFPC.MyGFxManager.PartyWidget != None && KFPC.MyGFxManager.PartyWidget.PartyChatWidget != None)
{
KFPC.MyGFxManager.PartyWidget.PartyChatWidget.SetVisible(true);
KFPC.MyGFxManager.PartyWidget.PartyChatWidget.AddChatMessage(Message, HexColor);
}
HUD = KFGFxHudWrapper(KFPC.myHUD);
if (HUD != None && HUD.HUDMovie != None && HUD.HUDMovie.HudChatBox != None)
{
HUD.HUDMovie.HudChatBox.AddChatMessage(Message, HexColor);
}
}
private simulated function SetPartyInGameWidget() private simulated function SetPartyInGameWidget()
{ {
`Log_Trace(); `Log_Trace();
@ -189,47 +223,44 @@ private simulated reliable client function ClientSyncFinished()
`Log_Trace(); `Log_Trace();
NotificationLeftText = ""; if (WorldInfo.GRI == None && WaitingGRI++ < WaitingGRILimit)
{
`Log_Debug("ClientSyncFinished: Waiting GRI" @ WaitingGRI);
NotificationHeaderText = LocalMessage.static.GetLocalizedString(LogLevel, LTI_WaitingGRI);
NotificationLeftText = String(WaitingGRI) $ LocalMessage.static.GetLocalizedString(LogLevel, LTI_SecondsShort);
NotificationRightText = ""; NotificationRightText = "";
NotificationPercent = 0; NotificationPercent = 0;
if (WorldInfo.GRI == None)
{
`Log_Debug("ClientSyncFinished: Waiting GRI");
NotificationHeaderText = LocalMessage.static.GetLocalizedString(LogLevel, LTI_WaitingGRI);
NotificationLeftText = String(++WaitingGRI) $ LocalMessage.static.GetLocalizedString(LogLevel, LTI_SecondsShort);
NotificationRightText = "";
SetTimer(1.0f, false, nameof(ClientSyncFinished)); SetTimer(1.0f, false, nameof(ClientSyncFinished));
return; return;
} }
KFGRI = KFGameReplicationInfo(WorldInfo.GRI); NotificationHeaderText = "";
if (KFGRI == None)
{
`Log_Fatal("Incompatible Replication info:" @ String(WorldInfo.GRI));
ClearTimer(nameof(KeepNotification));
UpdateNotification(
LocalMessage.static.GetLocalizedString(LogLevel, LTI_IncompatibleGRI) @ String(WorldInfo.GRI),
LocalMessage.static.GetLocalizedString(LogLevel, LTI_Disconnect), "", 0);
Cleanup();
ConsoleCommand("Disconnect");
SafeDestroy();
return;
}
NotificationHeaderText = LocalMessage.static.GetLocalizedString(LogLevel, LTI_SyncFinished);
NotificationLeftText = ""; NotificationLeftText = "";
NotificationRightText = ""; NotificationRightText = "";
NotificationPercent = 0; NotificationPercent = 0;
Trader.static.ModifyTrader(KFGRI, RemoveItems, ReplaceMode, RemoveHRG, RemoveDLC, LogLevel); KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
if (KFGRI != None)
{
`Log_Debug("ClientSyncFinished: Trader.static.ModifyTrader"); `Log_Debug("ClientSyncFinished: Trader.static.ModifyTrader");
Trader.static.ModifyTrader(KFGRI, RemoveItems, ReplaceMode, RemoveHRG, RemoveDLC, LogLevel);
}
else
{
`Log_Error("Incompatible Replication info:" @ String(WorldInfo.GRI));
WriteToChatLocalized(
LTI_IncompatibleGRI,
class'KFLocalMessage'.default.InteractionColor,
WorldInfo.GRI == None ? "None" : String(WorldInfo.GRI.class));
WriteToChatLocalized(
LTI_IncompatibleGRIWarning,
class'KFLocalMessage'.default.InteractionColor);
}
ClearTimer(nameof(KeepNotification)); ClearTimer(nameof(KeepNotification));
ShowReadyButton(); ShowReadyButton();
Cleanup(); Cleanup();
SafeDestroy(); SafeDestroy();
} }
@ -279,4 +310,5 @@ defaultproperties
NotificationPercent = 0 NotificationPercent = 0
WaitingGRI = 0 WaitingGRI = 0
WaitingGRILimit = 15
} }

Binary file not shown.

Binary file not shown.