P2P host lobby: CONTINUE own save or NEW GAME (previous save backed up to MSCO_Saves, new world saved and sent to waiting players)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 19:44:25 +02:00
co-authored by Claude Opus 5.5
parent ba4a3d1b9a
commit e844446a21
5 changed files with 214 additions and 8 deletions
+60 -6
View File
@@ -153,8 +153,8 @@ namespace MSCO
void DrawP2P(MultiplayerManager mp)
{
GUILayout.Label("P2P", titleStyle);
GUILayout.Label("Host a game from your own save and invite up to " + (MultiplayerManager.MaxPlayers - 1) +
" friends through Steam.", textStyle);
GUILayout.Label("Host a game and invite up to " + (MultiplayerManager.MaxPlayers - 1) +
" friends through Steam - continue your own save or start a new game.", textStyle);
GUILayout.Space(18);
if (mp.SteamAvailable)
@@ -747,11 +747,62 @@ namespace MSCO
if (GUI.Button(new Rect(r.xMax - 32 - 170, r.yMax - 28 - 42, 170, 42), "OK", primaryStyle)) mp.ClearDisconnectNotice();
}
bool newGameConfirm;
/// <summary>Host: eigenen Spielstand weiterspielen oder ein neues Spiel anlegen (mit Sicherheitsabfrage).</summary>
void DrawHostStart(MultiplayerManager mp)
{
System.DateTime? saved = SaveSync.LocalSaveTime;
if (newGameConfirm)
{
GUILayout.BeginVertical(rowBox);
GUILayout.Space(6);
GUILayout.Label("START A NEW GAME?", captionStyle);
GUILayout.Label(saved != null
? "Your current save game is kept as a backup in MSCO_Saves - everyone starts in a fresh world."
: "Everyone starts in a fresh world.", textStyle);
GUILayout.Space(6);
GUILayout.BeginHorizontal();
if (GUILayout.Button("YES, NEW GAME", dangerStyle, GUILayout.Height(38), GUILayout.Width(170)))
{
newGameConfirm = false;
mp.StartHostNewGame();
}
GUILayout.Space(8);
if (GUILayout.Button("CANCEL", secondaryStyle, GUILayout.Height(38), GUILayout.Width(110))) newGameConfirm = false;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Space(6);
GUILayout.EndVertical();
return;
}
GUILayout.BeginHorizontal();
GUI.enabled = saved != null;
GUILayout.BeginVertical(GUILayout.Width(190));
if (GUILayout.Button("CONTINUE", primaryStyle, GUILayout.Height(42), GUILayout.Width(190)))
mp.StartHostGame();
GUILayout.Label(saved != null ? "saved " + saved.Value.ToString("dd.MM.yyyy HH:mm") : "no save game yet", captionStyle);
GUILayout.EndVertical();
GUI.enabled = true;
GUILayout.Space(10);
GUILayout.BeginVertical(GUILayout.Width(190));
if (GUILayout.Button("NEW GAME", secondaryStyle, GUILayout.Height(42), GUILayout.Width(190)))
{
if (saved != null) newGameConfirm = true;
else mp.StartHostNewGame();
}
GUILayout.Label("fresh world for everyone", captionStyle);
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
void DrawSession(MultiplayerManager mp)
{
GUILayout.Label(mp.IsHost ? "Hosting" : "Connected", titleStyle);
GUILayout.Label(mp.IsHost
? "Your game is open. Start when everyone has joined."
? "Your game is open. Continue your save or start a new game - friends can also join later."
: mp.IsDedicated || mp.IsConnectingToServer
? "Connected to the server - the world is loading" + (string.IsNullOrEmpty(mp.Status) ? "." : ": " + mp.Status)
: "Waiting for the host to start the game.", textStyle);
@@ -773,12 +824,15 @@ namespace MSCO
GUILayout.EndScrollView();
GUILayout.Space(14);
if (mp.IsHost)
{
DrawHostStart(mp);
GUILayout.Space(10);
}
GUILayout.BeginHorizontal();
if (mp.IsHost)
{
if (GUILayout.Button("START GAME", primaryStyle, GUILayout.Height(42), GUILayout.Width(150)))
mp.StartHostGame();
GUILayout.Space(10);
if (mp.IsSteamSession && mp.Players.Count < MultiplayerManager.MaxPlayers &&
GUILayout.Button("INVITE FRIENDS", secondaryStyle, GUILayout.Height(42), GUILayout.Width(150)))
mp.InviteFriends();