More descriptive error message if server ip/port is can't be resolved, updateinfobox automatic scroll

This commit is contained in:
Regalis
2015-10-08 22:55:33 +03:00
parent 709d4efde9
commit 4120cabd6e
8 changed files with 53 additions and 10 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ namespace Launcher
{ {
public partial class LauncherMain : Form 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 const string configPath = "config.xml";
private Subsurface.GameSettings settings; private Subsurface.GameSettings settings;
+4 -2
View File
@@ -22,7 +22,7 @@ namespace Launcher2
/// </summary> /// </summary>
public class LauncherMain : Game 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 const string configPath = "config.xml";
private Subsurface.GameSettings settings; private Subsurface.GameSettings settings;
@@ -440,7 +440,7 @@ namespace Launcher2
filesToDownload = UpdaterUtil.GetRequiredFiles(doc); filesToDownload = UpdaterUtil.GetRequiredFiles(doc);
string updaterVersion = ToolBox.GetAttributeString(doc.Root, "updaterversion", "1.0"); 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."); 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, Alignment.TopLeft, Alignment.TopLeft,
updateInfoBox, false, GUI.SmallFont); updateInfoBox, false, GUI.SmallFont);
textBlock.CanBeFocused = false; textBlock.CanBeFocused = false;
updateInfoBox.BarScroll = 1.0f;
WebClient webClient = new WebClient(); WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
+3 -1
View File
@@ -15,6 +15,8 @@ namespace Subsurface
public delegate bool OnPressedHandler(); public delegate bool OnPressedHandler();
public OnPressedHandler OnPressed; public OnPressedHandler OnPressed;
public bool CanBeSelected = true;
public bool Enabled { get; set; } public bool Enabled { get; set; }
public override Color Color public override Color Color
@@ -119,7 +121,7 @@ namespace Subsurface
{ {
if (OnClicked != null) if (OnClicked != null)
{ {
if (OnClicked(this, UserData)) state = ComponentState.Selected; if (OnClicked(this, UserData) && CanBeSelected) state = ComponentState.Selected;
} }
} }
} }
+40 -4
View File
@@ -82,12 +82,25 @@ namespace Subsurface.Networking
outmsg.Write(GameMain.SelectedPackage.MD5hash.Hash); outmsg.Write(GameMain.SelectedPackage.MD5hash.Hash);
outmsg.Write(name); 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 // Connect client, to ip previously requested from user
try 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); DebugConsole.ThrowError("Couldn't connect to "+hostIP+". Error message: "+e.Message);
Disconnect(); Disconnect();
@@ -108,7 +121,10 @@ namespace Subsurface.Networking
// Funtion that waits for connection approval info from server // Funtion that waits for connection approval info from server
if (reconnectBox==null) 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()); CoroutineManager.StartCoroutine(WaitForStartingInfo());
@@ -136,17 +152,35 @@ namespace Subsurface.Networking
return true; 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 // Before main looping starts, we loop here and wait for approval message
private IEnumerable<object> WaitForStartingInfo() private IEnumerable<object> WaitForStartingInfo()
{ {
connectCanceled = false;
// When this is set to true, we are approved and ready to go // When this is set to true, we are approved and ready to go
bool CanStart = false; bool CanStart = false;
DateTime timeOut = DateTime.Now + new TimeSpan(0,0,15); DateTime timeOut = DateTime.Now + new TimeSpan(0,0,15);
// Loop until we are approved // 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; yield return CoroutineStatus.Running;
if (DateTime.Now > timeOut) break; if (DateTime.Now > timeOut) break;
@@ -236,6 +270,8 @@ namespace Subsurface.Networking
reconnectBox = null; reconnectBox = null;
} }
if (connectCanceled) yield return CoroutineStatus.Success;
if (client.ConnectionStatus != NetConnectionStatus.Connected) if (client.ConnectionStatus != NetConnectionStatus.Connected)
{ {
var reconnect = new GUIMessageBox("CONNECTION FAILED", "Failed to connect to server.", new string[] { "Retry", "Cancel" }); var reconnect = new GUIMessageBox("CONNECTION FAILED", "Failed to connect to server.", new string[] { "Retry", "Cancel" });
@@ -184,6 +184,8 @@ namespace Subsurface
otherButton.Selected = false; otherButton.Selected = false;
} }
if (Screen.Selected != this) Select();
return true; return true;
} }
@@ -78,7 +78,8 @@ namespace Subsurface
GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.Style, menu); GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.Style, menu);
button.OnClicked = GameMain.MainMenuScreen.SelectTab; button.OnClicked = GameMain.MainMenuScreen.SelectTab;
button.CanBeSelected = false;
button.SelectedColor = button.Color;
refreshDisableTimer = DateTime.Now; refreshDisableTimer = DateTime.Now;
} }
+1 -1
View File
@@ -9,7 +9,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Subsurface</RootNamespace> <RootNamespace>Subsurface</RootNamespace>
<AssemblyName>Subsurface</AssemblyName> <AssemblyName>Barotrauma</AssemblyName>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
Binary file not shown.