add waiting GRI limit

This commit is contained in:
GenZmeY 2023-05-14 02:20:31 +03:00
parent 0cbd5deb47
commit 45d327fc81
4 changed files with 68 additions and 44 deletions

View File

@ -4,17 +4,14 @@ class CTI_LocalMessage extends Object
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 IncompatibleGRIWarningDefault;
var private localized String IncompatibleGRIWarning;
var const String SecondsShortDefault;
var private localized String SecondsShort;
@ -22,10 +19,9 @@ var private localized String SecondsShort;
enum E_CTI_LocalMessageType
{
CTI_SyncItems,
CTI_SyncFinished,
CTI_WaitingGRI,
CTI_IncompatibleGRI,
CTI_Disconnect,
CTI_IncompatibleGRIWarning,
CTI_SecondsShort
};
@ -43,17 +39,14 @@ public static function String GetLocalizedString(
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);
return (default.IncompatibleGRI != "" ? default.IncompatibleGRI : default.IncompatibleGRIDefault) @ String1;
case CTI_Disconnect:
return (default.Disconnect != "" ? default.Disconnect : default.DisconnectDefault);
case CTI_IncompatibleGRIWarning:
return (default.IncompatibleGRIWarning != "" ? default.IncompatibleGRIWarning : default.IncompatibleGRIWarningDefault);
case CTI_SecondsShort:
return (default.SecondsShort != "" ? default.SecondsShort : default.SecondsShortDefault);
@ -64,10 +57,9 @@ public static function String GetLocalizedString(
defaultproperties
{
SyncItemsDefault = "Sync items:"
SyncFinishedDefault = "Sync finished."
WaitingGRIDefault = "Waiting GRI..."
IncompatibleGRIDefault = "Incompatible GRI:"
DisconnectDefault = "Disconnect..."
SecondsShortDefault = "s"
SyncItemsDefault = "Sync items:"
WaitingGRIDefault = "Waiting GRI..."
IncompatibleGRIDefault = "Incompatible GRI:"
IncompatibleGRIWarningDefault = "You can enter the game, but the trader may not work correctly.";
SecondsShortDefault = "s"
}

View File

@ -27,6 +27,7 @@ var private String NotificationRightText;
var private int NotificationPercent;
var private int WaitingGRI;
var private int WaitingGRILimit;
replication
{
@ -78,6 +79,39 @@ private simulated function KFPlayerController GetKFPC()
return KFPC;
}
public reliable client function WriteToChatLocalized(
E_CTI_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()
{
`Log_Trace();
@ -200,47 +234,44 @@ private simulated reliable client function ClientSyncFinished()
`Log_Trace();
NotificationLeftText = "";
NotificationRightText = "";
NotificationPercent = 0;
if (WorldInfo.GRI == None)
if (WorldInfo.GRI == None && WaitingGRI++ < WaitingGRILimit)
{
`Log_Debug("ClientSyncFinished: Waiting GRI");
`Log_Debug("ClientSyncFinished: Waiting GRI" @ WaitingGRI);
NotificationHeaderText = LocalMessage.static.GetLocalizedString(LogLevel, CTI_WaitingGRI);
NotificationLeftText = String(++WaitingGRI) $ LocalMessage.static.GetLocalizedString(LogLevel, CTI_SecondsShort);
NotificationLeftText = String(WaitingGRI) $ LocalMessage.static.GetLocalizedString(LogLevel, CTI_SecondsShort);
NotificationRightText = "";
NotificationPercent = 0;
SetTimer(1.0f, false, nameof(ClientSyncFinished));
return;
}
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
if (KFGRI == None)
{
`Log_Fatal("Incompatible Replication info:" @ String(WorldInfo.GRI));
ClearTimer(nameof(KeepNotification));
UpdateNotification(
LocalMessage.static.GetLocalizedString(LogLevel, CTI_IncompatibleGRI) @ String(WorldInfo.GRI),
LocalMessage.static.GetLocalizedString(LogLevel, CTI_Disconnect), "", 0);
Cleanup();
ConsoleCommand("Disconnect");
SafeDestroy();
return;
}
NotificationHeaderText = LocalMessage.static.GetLocalizedString(LogLevel, CTI_SyncFinished);
NotificationHeaderText = "";
NotificationLeftText = "";
NotificationRightText = "";
NotificationPercent = 0;
Trader.static.ModifyTrader(KFGRI, RemoveItems, AddItems, ReplaceMode, RemoveHRG, RemoveDLC, LogLevel);
`Log_Debug("ClientSyncFinished: Trader.static.ModifyTrader");
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
if (KFGRI != None)
{
`Log_Debug("ClientSyncFinished: Trader.static.ModifyTrader");
Trader.static.ModifyTrader(KFGRI, RemoveItems, AddItems, ReplaceMode, RemoveHRG, RemoveDLC, LogLevel);
}
else
{
`Log_Error("Incompatible Replication info:" @ String(WorldInfo.GRI));
WriteToChatLocalized(
CTI_IncompatibleGRI,
class'KFLocalMessage'.default.InteractionColor,
WorldInfo.GRI == None ? "None" : String(WorldInfo.GRI.class));
WriteToChatLocalized(
CTI_IncompatibleGRIWarning,
class'KFLocalMessage'.default.InteractionColor);
}
ClearTimer(nameof(KeepNotification));
ShowReadyButton();
Cleanup();
SafeDestroy();
}
@ -295,4 +326,5 @@ defaultproperties
NotificationPercent = 0
WaitingGRI = 0
WaitingGRILimit = 15
}

Binary file not shown.

Binary file not shown.