Exemplo n.º 1
0
        public TorchUI(TorchServer server)
        {
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            Width   = 800;
            Height  = 600;
            _config = (TorchConfig)server.Config;
            _server = server;
            //TODO: data binding for whole server
            DataContext = server;
            InitializeComponent();

            AttachConsole();

            //Left = _config.WindowPosition.X;
            //Top = _config.WindowPosition.Y;
            //Width = _config.WindowSize.X;
            //Height = _config.WindowSize.Y;

            Chat.BindServer(server);
            PlayerList.BindServer(server);
            Plugins.BindServer(server);
            LoadConfig((TorchConfig)server.Config);

            Themes.uiSource = this;
            Themes.SetConfig(_config);
            Title = $"{_config.InstanceName} - Torch {server.TorchVersion}, SE {server.GameVersion}";

            Loaded += TorchUI_Loaded;
        }
Exemplo n.º 2
0
        public void Run()
        {
            _server = new TorchServer(_config);

            if (_config.NoGui)
            {
                _server.Init();
                _server.Start();
            }
            else
            {
#if !DEBUG
                if (!_config.IndependentConsole)
                {
                    Console.SetOut(TextWriter.Null);
                    NativeMethods.FreeConsole();
                }
#endif

                var gameThread = new Thread(() =>
                {
                    _server.Init();

                    if (_config.Autostart)
                    {
                        _server.Start();
                    }
                });

                gameThread.Start();

                var ui = new TorchUI(_server);
                ui.ShowDialog();
            }
        }
Exemplo n.º 3
0
        public void Run()
        {
            _server = new TorchServer(_config);
            var init = Task.Run(() => _server.Init()).ContinueWith(x =>
            {
                if (!x.IsFaulted)
                {
                    return;
                }

                Log.Error("Error initializing server.");
                LogException(x.Exception);
            });

            if (!_config.NoGui)
            {
                if (_config.Autostart)
                {
                    init.ContinueWith(x => _server.Start());
                }

                Log.Info("Showing UI");
                Console.SetOut(TextWriter.Null);
                NativeMethods.FreeConsole();
                new TorchUI(_server).ShowDialog();
            }
            else
            {
                init.Wait();
                _server.Start();
            }
        }
Exemplo n.º 4
0
        public TorchUI(TorchServer server)
        {
            _config = (TorchConfig)server.Config;
            _server = server;
            InitializeComponent();
            _startTime         = DateTime.Now;
            _uiUpdate.Elapsed += UiUpdate_Elapsed;

            Chat.BindServer(server);
            PlayerList.BindServer(server);
            Plugins.BindServer(server);
        }
Exemplo n.º 5
0
        public TorchUI(TorchServer server)
        {
            _config = (TorchConfig)server.Config;
            _server = server;
            InitializeComponent();
            _startTime         = DateTime.Now;
            _uiUpdate.Elapsed += UiUpdate_Elapsed;

            Left   = _config.WindowPosition.X;
            Top    = _config.WindowPosition.Y;
            Width  = _config.WindowSize.X;
            Height = _config.WindowSize.Y;

            Chat.BindServer(server);
            PlayerList.BindServer(server);
            Plugins.BindServer(server);
        }
Exemplo n.º 6
0
        public TorchUI(TorchServer server)
        {
            _config = (TorchConfig)server.Config;
            _server = server;
            InitializeComponent();

            Left   = _config.WindowPosition.X;
            Top    = _config.WindowPosition.Y;
            Width  = _config.WindowSize.X;
            Height = _config.WindowSize.Y;

            //TODO: data binding for whole server
            DataContext = server;
            Chat.BindServer(server);
            PlayerList.BindServer(server);
            Plugins.BindServer(server);
            LoadConfig((TorchConfig)server.Config);
        }
Exemplo n.º 7
0
        /// <inheritdoc />
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);

            string configName = args.Length > 0 ? args[0] : "Torch.cfg";
            var    options    = new TorchConfig("Torch");

            if (File.Exists(configName))
            {
                options = TorchConfig.LoadFrom(configName);
            }
            else
            {
                options.Save(configName);
            }

            _server = new TorchServer(options);
            _server.Init();
            _server.RunArgs = args;
            Task.Run(() => _server.Start());
        }
Exemplo n.º 8
0
        public void Run()
        {
            _server = new TorchServer(_config);
            _server.Init();

            if (!_config.NoGui)
            {
                var ui = new TorchUI(_server);
                if (_config.Autostart)
                {
                    new Thread(_server.Start).Start();
                }
                ui.ShowDialog();
            }
            else
            {
                _server.Start();
            }

            _resolver?.Dispose();
        }