Fix window size shenanigans breaking the config

This commit is contained in:
John Gross
2019-02-28 13:44:14 -08:00
parent 5cf3ae1203
commit 295bbd62b8

View File

@@ -33,6 +33,9 @@ namespace Torch.Server
public TorchUI(TorchServer server) public TorchUI(TorchServer server)
{ {
WindowStartupLocation = WindowStartupLocation.CenterScreen;
Width = 800;
Height = 600;
_config = (TorchConfig)server.Config; _config = (TorchConfig)server.Config;
_server = server; _server = server;
//TODO: data binding for whole server //TODO: data binding for whole server
@@ -41,10 +44,10 @@ namespace Torch.Server
AttachConsole(); AttachConsole();
Left = _config.WindowPosition.X; //Left = _config.WindowPosition.X;
Top = _config.WindowPosition.Y; //Top = _config.WindowPosition.Y;
Width = _config.WindowSize.X; //Width = _config.WindowSize.X;
Height = _config.WindowSize.Y; //Height = _config.WindowSize.Y;
Chat.BindServer(server); Chat.BindServer(server);
PlayerList.BindServer(server); PlayerList.BindServer(server);
@@ -97,12 +100,14 @@ namespace Torch.Server
protected override void OnClosing(CancelEventArgs e) protected override void OnClosing(CancelEventArgs e)
{ {
var newSize = new Point((int)Width, (int)Height); // Can't save here or you'll persist all the command line arguments
_config.WindowSize = newSize; //
var newPos = new Point((int)Left, (int)Top); //var newSize = new Point((int)Width, (int)Height);
_config.WindowPosition = newPos; //_config.WindowSize = newSize;
//var newPos = new Point((int)Left, (int)Top);
//_config.WindowPosition = newPos;
_config.Save(); //you idiot //_config.Save(); //you idiot
if (_server?.State == ServerState.Running) if (_server?.State == ServerState.Running)
_server.Stop(); _server.Stop();