diff --git a/Launcher/Form1.cs b/Launcher/Form1.cs index 01d7e274a..dcd6df2a7 100644 --- a/Launcher/Form1.cs +++ b/Launcher/Form1.cs @@ -20,7 +20,7 @@ namespace Launcher { public partial class LauncherMain : Form { - string version = AssemblyName.GetAssemblyName("subsurface.exe").Version.ToString(); + string version = AssemblyName.GetAssemblyName("Barotrauma.exe").Version.ToString(); private const string configPath = "config.xml"; private Subsurface.GameSettings settings; diff --git a/Launcher2/LauncherMain.cs b/Launcher2/LauncherMain.cs index 0825c8119..e8002e933 100644 --- a/Launcher2/LauncherMain.cs +++ b/Launcher2/LauncherMain.cs @@ -22,7 +22,7 @@ namespace Launcher2 /// public class LauncherMain : Game { - string version = AssemblyName.GetAssemblyName("subsurface.exe").Version.ToString(); + string version = AssemblyName.GetAssemblyName("Barotrauma.exe").Version.ToString(); private const string configPath = "config.xml"; private Subsurface.GameSettings settings; @@ -440,7 +440,7 @@ namespace Launcher2 filesToDownload = UpdaterUtil.GetRequiredFiles(doc); string updaterVersion = ToolBox.GetAttributeString(doc.Root, "updaterversion", "1.0"); - if (updaterVersion!=UpdaterUtil.Version || true) + if (updaterVersion!=UpdaterUtil.Version) { ShowError("Warning", "The update may contain changes which can't be installed by the autoupdater. If you receive any error messages during the install, please download and install the update manually."); } @@ -510,6 +510,8 @@ namespace Launcher2 Alignment.TopLeft, Alignment.TopLeft, updateInfoBox, false, GUI.SmallFont); textBlock.CanBeFocused = false; + + updateInfoBox.BarScroll = 1.0f; WebClient webClient = new WebClient(); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed); diff --git a/Subsurface/Source/GUI/GUIButton.cs b/Subsurface/Source/GUI/GUIButton.cs index 6fdb8e972..7cff05c70 100644 --- a/Subsurface/Source/GUI/GUIButton.cs +++ b/Subsurface/Source/GUI/GUIButton.cs @@ -15,6 +15,8 @@ namespace Subsurface public delegate bool OnPressedHandler(); public OnPressedHandler OnPressed; + public bool CanBeSelected = true; + public bool Enabled { get; set; } public override Color Color @@ -119,7 +121,7 @@ namespace Subsurface { if (OnClicked != null) { - if (OnClicked(this, UserData)) state = ComponentState.Selected; + if (OnClicked(this, UserData) && CanBeSelected) state = ComponentState.Selected; } } } diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 63af4fe4d..10ea40173 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -82,12 +82,25 @@ namespace Subsurface.Networking outmsg.Write(GameMain.SelectedPackage.MD5hash.Hash); outmsg.Write(name); + + System.Net.IPEndPoint IPEndPoint = null; + try + { + IPEndPoint = new System.Net.IPEndPoint(NetUtility.Resolve(serverIP), Port); + } + catch (ArgumentNullException e) + { + new GUIMessageBox("Could not connect to server", "Failed to resolve address ''"+serverIP+":"+Port+"''. Please make sure you have entered a valid IP address."); + return; + } + + // Connect client, to ip previously requested from user try { - client.Connect(serverIP, Port, outmsg); + client.Connect(IPEndPoint, outmsg); } - catch (ArgumentNullException e) + catch (Exception e) { DebugConsole.ThrowError("Couldn't connect to "+hostIP+". Error message: "+e.Message); Disconnect(); @@ -108,7 +121,10 @@ namespace Subsurface.Networking // Funtion that waits for connection approval info from server if (reconnectBox==null) { - reconnectBox = new GUIMessageBox("CONNECTING", "Connecting to " + serverIP, new string[0]); + reconnectBox = new GUIMessageBox("CONNECTING", "Connecting to " + serverIP, new string[] { "Cancel" }); + + reconnectBox.Buttons[0].OnClicked += CancelConnect; + reconnectBox.Buttons[0].OnClicked += reconnectBox.Close; } CoroutineManager.StartCoroutine(WaitForStartingInfo()); @@ -136,17 +152,35 @@ namespace Subsurface.Networking return true; } + private bool connectCanceled; + + private bool CancelConnect(GUIButton button, object obj) + { + connectCanceled = true; + return true; + } + // Before main looping starts, we loop here and wait for approval message private IEnumerable WaitForStartingInfo() { + connectCanceled = false; // When this is set to true, we are approved and ready to go bool CanStart = false; DateTime timeOut = DateTime.Now + new TimeSpan(0,0,15); // Loop until we are approved - while (!CanStart) + while (!CanStart && !connectCanceled) { + int seconds = DateTime.Now.Second; + + string connectingText = "Connecting to " + serverIP; + for (int i = 0; i < 1 + (seconds % 3); i++ ) + { + connectingText += "."; + } + reconnectBox.Text = connectingText; + yield return CoroutineStatus.Running; if (DateTime.Now > timeOut) break; @@ -236,6 +270,8 @@ namespace Subsurface.Networking reconnectBox = null; } + if (connectCanceled) yield return CoroutineStatus.Success; + if (client.ConnectionStatus != NetConnectionStatus.Connected) { var reconnect = new GUIMessageBox("CONNECTION FAILED", "Failed to connect to server.", new string[] { "Retry", "Cancel" }); diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs index a9f02b5a2..e9661fb7d 100644 --- a/Subsurface/Source/Screens/MainMenuScreen.cs +++ b/Subsurface/Source/Screens/MainMenuScreen.cs @@ -184,6 +184,8 @@ namespace Subsurface otherButton.Selected = false; } + if (Screen.Selected != this) Select(); + return true; } diff --git a/Subsurface/Source/Screens/ServerListScreen.cs b/Subsurface/Source/Screens/ServerListScreen.cs index 384f0dc0a..66b287a9d 100644 --- a/Subsurface/Source/Screens/ServerListScreen.cs +++ b/Subsurface/Source/Screens/ServerListScreen.cs @@ -78,7 +78,8 @@ namespace Subsurface GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.Style, menu); button.OnClicked = GameMain.MainMenuScreen.SelectTab; - + button.CanBeSelected = false; + button.SelectedColor = button.Color; refreshDisableTimer = DateTime.Now; } diff --git a/Subsurface/Subsurface.csproj b/Subsurface/Subsurface.csproj index ff09d1ac4..6cfc53da0 100644 --- a/Subsurface/Subsurface.csproj +++ b/Subsurface/Subsurface.csproj @@ -9,7 +9,7 @@ WinExe Properties Subsurface - Subsurface + Barotrauma 512 false publish\ diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index b8a3af50c..3eaab0352 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ