From ad1935fdcfb8160bc6001e9df60b3b3ebc3ed7e2 Mon Sep 17 00:00:00 2001 From: juanjp600 Date: Thu, 22 Jun 2017 21:42:09 -0300 Subject: [PATCH] Added commands to change sub, shuttle, gamemode & mission Also fixed the exe icons --- BarotraumaClient/BarotraumaClient.csproj | 3 +- .../Source/Screens/NetLobbyScreen.cs | 3 +- BarotraumaServer/BarotraumaServer.csproj | 3 + BarotraumaServer/Source/DebugConsole.cs | 67 ++++++++++++-- BarotraumaServer/Source/Program.cs | 6 -- .../Source/Screens/NetLobbyScreen.cs | 88 +++++++++++++++++-- BarotraumaShared/Source/DebugConsole.cs | 2 +- BarotraumaShared/Source/Items/Item.cs | 7 +- 8 files changed, 152 insertions(+), 27 deletions(-) diff --git a/BarotraumaClient/BarotraumaClient.csproj b/BarotraumaClient/BarotraumaClient.csproj index 1e5bf3c1d..8bb6b1620 100644 --- a/BarotraumaClient/BarotraumaClient.csproj +++ b/BarotraumaClient/BarotraumaClient.csproj @@ -57,8 +57,7 @@ false - - + ..\BarotraumaShared\Icon.ico diff --git a/BarotraumaClient/Source/Screens/NetLobbyScreen.cs b/BarotraumaClient/Source/Screens/NetLobbyScreen.cs index 50d540681..a10cabde1 100644 --- a/BarotraumaClient/Source/Screens/NetLobbyScreen.cs +++ b/BarotraumaClient/Source/Screens/NetLobbyScreen.cs @@ -122,8 +122,7 @@ namespace Barotrauma get { return (int)missionTypeBlock.UserData; } set { missionTypeBlock.UserData = value; } } - - + public List JobPreferences { get diff --git a/BarotraumaServer/BarotraumaServer.csproj b/BarotraumaServer/BarotraumaServer.csproj index 87888d6b7..43ed4c3a3 100644 --- a/BarotraumaServer/BarotraumaServer.csproj +++ b/BarotraumaServer/BarotraumaServer.csproj @@ -48,6 +48,9 @@ MinimumRecommendedRules.ruleset true + + ..\BarotraumaShared\Icon.ico + False diff --git a/BarotraumaServer/Source/DebugConsole.cs b/BarotraumaServer/Source/DebugConsole.cs index b61ec7df7..72676c263 100644 --- a/BarotraumaServer/Source/DebugConsole.cs +++ b/BarotraumaServer/Source/DebugConsole.cs @@ -46,15 +46,70 @@ namespace Barotrauma break; case "say": case "msg": - string text = ""; - for (int i=1;i s.Name.ToLower() == string.Join(" ", commands.Skip(1)).ToLower()); + + if (sub != null) + { + GameMain.NetLobbyScreen.SelectedSub = sub; + } + sub = GameMain.NetLobbyScreen.SelectedSub; + DebugConsole.NewMessage("Selected sub: " + sub.Name + (sub.HasTag(SubmarineTag.Shuttle) ? " (shuttle)" : ""), Color.Cyan); + } + break; + case "shuttle": + { + Submarine shuttle = GameMain.NetLobbyScreen.GetSubList().Find(s => s.Name.ToLower() == string.Join(" ", commands.Skip(1)).ToLower()); + + if (shuttle != null) + { + GameMain.NetLobbyScreen.SelectedShuttle = shuttle; + } + shuttle = GameMain.NetLobbyScreen.SelectedShuttle; + DebugConsole.NewMessage("Selected shuttle: " + shuttle.Name + (shuttle.HasTag(SubmarineTag.Shuttle) ? "" : " (not shuttle)"), Color.Cyan); + } + break; case "startgame": case "startround": case "start": diff --git a/BarotraumaServer/Source/Program.cs b/BarotraumaServer/Source/Program.cs index 6fbb23630..46cf9171b 100644 --- a/BarotraumaServer/Source/Program.cs +++ b/BarotraumaServer/Source/Program.cs @@ -20,8 +20,6 @@ namespace Barotrauma /// public static class Program { - private static int restartAttempts; - /// /// The main entry point for the application. /// @@ -66,10 +64,6 @@ namespace Barotrauma { sb.AppendLine("Server (" + (GameMain.Server.GameStarted ? "Round had started)" : "Round hadn't been started)")); } - else if (GameMain.Client != null) - { - sb.AppendLine("Client (" + (GameMain.Client.GameStarted ? "Round had started)" : "Round hadn't been started)")); - } sb.AppendLine("\n"); sb.AppendLine("System info:"); diff --git a/BarotraumaServer/Source/Screens/NetLobbyScreen.cs b/BarotraumaServer/Source/Screens/NetLobbyScreen.cs index 675efd6ed..29764bee1 100644 --- a/BarotraumaServer/Source/Screens/NetLobbyScreen.cs +++ b/BarotraumaServer/Source/Screens/NetLobbyScreen.cs @@ -11,11 +11,48 @@ namespace Barotrauma { partial class NetLobbyScreen : Screen { - public Submarine SelectedSub; - public Submarine SelectedShuttle; + private Submarine selectedSub; + private Submarine selectedShuttle; + + public Submarine SelectedSub + { + get { return selectedSub; } + set { selectedSub = value; lastUpdateID++; } + } + public Submarine SelectedShuttle + { + get { return selectedShuttle; } + set { selectedShuttle = value; lastUpdateID++; } + } private GameModePreset[] GameModes; - public int SelectedModeIndex; + + private int selectedModeIndex; + public int SelectedModeIndex + { + get { return selectedModeIndex; } + set { + lastUpdateID++; + selectedModeIndex = Math.Max(0, Math.Min(GameModes.Count()-1, value)); + } + } + + public string SelectedModeName + { + get { return GameModes[SelectedModeIndex].Name; } + set + { + for (int i = 0; i < GameModes.Count(); i++) + { + if (GameModes[i].Name.ToLower() == value.ToLower()) + { + SelectedModeIndex = i; + break; + } + } + } + } + public GameModePreset SelectedMode { get { return GameModes[SelectedModeIndex]; } @@ -23,7 +60,41 @@ namespace Barotrauma public string ServerMessageText; - public int MissionTypeIndex; + private int missionTypeIndex; + public int MissionTypeIndex + { + get { return missionTypeIndex; } + set { + lastUpdateID++; + missionTypeIndex = Math.Max(0, Math.Min(Mission.MissionTypes.Count()-1, value)); + } + } + + public string MissionTypeName + { + get { return Mission.MissionTypes[MissionTypeIndex]; } + set + { + for (int i = 0; i < Mission.MissionTypes.Count(); i++) + { + if (Mission.MissionTypes[i].ToLower() == value.ToLower()) + { + MissionTypeIndex = i; + break; + } + } + } + } + + public void ChangeServerName(string n) + { + ServerName = n; lastUpdateID++; + } + + public void ChangeServerMessage(string m) + { + ServerMessageText = m; lastUpdateID++; + } public List JobPreferences { @@ -39,8 +110,13 @@ namespace Barotrauma subs = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)).ToList(); - SelectedSub = subs[0]; - SelectedShuttle = subs[0]; //TODO: don't use the same sub as a shuttle by default + if (subs == null || subs.Count()==0) + { + throw new Exception("No submarines are available."); + } + + selectedSub = subs.First(s => !s.HasTag(SubmarineTag.Shuttle)); + selectedShuttle = subs.First(s => s.HasTag(SubmarineTag.Shuttle)); DebugConsole.NewMessage("Selected sub: " + SelectedSub.Name, Color.White); DebugConsole.NewMessage("Selected shuttle: " + SelectedShuttle.Name, Color.White); diff --git a/BarotraumaShared/Source/DebugConsole.cs b/BarotraumaShared/Source/DebugConsole.cs index 53b5904c8..07d705435 100644 --- a/BarotraumaShared/Source/DebugConsole.cs +++ b/BarotraumaShared/Source/DebugConsole.cs @@ -68,7 +68,7 @@ namespace Barotrauma return commands.ToArray(); } - + public static void ExecuteCommand(string command, GameMain game) { if (string.IsNullOrWhiteSpace(command)) return; diff --git a/BarotraumaShared/Source/Items/Item.cs b/BarotraumaShared/Source/Items/Item.cs index 7098437a9..22087a01c 100644 --- a/BarotraumaShared/Source/Items/Item.cs +++ b/BarotraumaShared/Source/Items/Item.cs @@ -293,11 +293,11 @@ namespace Barotrauma public override string ToString() { -/*#if CLIENT +#if CLIENT return (GameMain.DebugDraw) ? Name + "(ID: " + ID + ")" : Name; -#elif SERVER*/ +#elif SERVER return Name + "(ID: " + ID + ")"; -//#endif +#endif } public List AllPropertyObjects @@ -1304,7 +1304,6 @@ namespace Barotrauma public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null) { - DebugConsole.NewMessage(ToString(), Color.Magenta); if (extraData == null || extraData.Length == 0 || !(extraData[0] is NetEntityEvent.Type)) { return;