示例#1
0
 public ConfigDedicatedViewModel(MyConfigDedicated <MyObjectBuilder_SessionSettings> configDedicated)
 {
     _config = configDedicated;
     //_config.IgnoreLastSession = true;
     SessionSettings = new SessionSettingsViewModel(_config.SessionSettings);
     Task.Run(() => UpdateAllModInfosAsync());
 }
示例#2
0
        public void LoadDedicatedConfig(TorchConfig torchConfig)
        {
            MySandboxGame.Config = new MyConfig(MyPerServerSettings.GameNameSafe + ".cfg");
            var path = Path.Combine(torchConfig.InstancePath, "SpaceEngineers-Dedicated.cfg");

            if (!File.Exists(path))
            {
                DataContext = null;
                return;
            }

            Config = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(path);
            Config.Load(path);
            _configPath = path;

            _viewModel = new ConfigDedicatedViewModel(Config);
            var worldFolders = Directory.EnumerateDirectories(Path.Combine(torchConfig.InstancePath, "Saves"));

            foreach (var f in worldFolders)
            {
                _viewModel.WorldPaths.Add(f);
            }

            DataContext = _viewModel;
        }
示例#3
0
 public ConfigDedicatedViewModel(MyConfigDedicated <MyObjectBuilder_SessionSettings> configDedicated)
 {
     _config         = configDedicated;
     SessionSettings = new SessionSettingsViewModel(_config.SessionSettings);
     Administrators  = string.Join(Environment.NewLine, _config.Administrators);
     Banned          = string.Join(Environment.NewLine, _config.Banned);
     Mods            = string.Join(Environment.NewLine, _config.Mods);
 }
 public ConfigDedicatedViewModel(MyConfigDedicated <MyObjectBuilder_SessionSettings> configDedicated)
 {
     _config         = configDedicated;
     SessionSettings = new SessionSettingsViewModel(_config.SessionSettings);
     Administrators  = new ObservableCollection <string>(_config.Administrators);
     Banned          = new ObservableCollection <ulong>(_config.Banned);
     Mods            = new ObservableCollection <ulong>(_config.Mods);
 }
示例#5
0
        public void LoadInstance(string path, bool validate = true)
        {
            Log.Info($"Loading instance {path}");

            if (validate)
            {
                ValidateInstance(path);
            }

            MyFileSystem.Reset();
            MyFileSystem.Init("Content", path);
            //Initializes saves path. Why this isn't in Init() we may never know.
            MyFileSystem.InitUserSpecific(null);

            var configPath = Path.Combine(path, CONFIG_NAME);

            if (!File.Exists(configPath))
            {
                Log.Error($"Failed to load dedicated config at {path}");
                return;
            }

            var config = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(configPath);

            config.Load(configPath);

            DedicatedConfig = new ConfigDedicatedViewModel(config);

            var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.Config.InstancePath, "Saves"));

            foreach (var f in worldFolders)
            {
                try
                {
                    if (!string.IsNullOrEmpty(f) && File.Exists(Path.Combine(f, "Sandbox.sbc")))
                    {
                        DedicatedConfig.Worlds.Add(new WorldViewModel(f));
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("Failed to load world at path: " + f);
                    continue;
                }
            }

            if (DedicatedConfig.Worlds.Count == 0)
            {
                Log.Warn($"No worlds found in the current instance {path}.");
                return;
            }

            SelectWorld(DedicatedConfig.LoadWorld ?? DedicatedConfig.Worlds.First().WorldPath, false);

            InstanceLoaded?.Invoke(DedicatedConfig);
        }
示例#6
0
        public void LoadInstance(string path)
        {
            if (!Directory.Exists(path))
            {
                throw new FileNotFoundException($"Instance directory not found at '{path}'");
            }

            var configPath = Path.Combine(path, CONFIG_NAME);
            var config     = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(configPath);

            config.Load();
            DedicatedConfig = new ConfigDedicatedViewModel(config);
        }
示例#7
0
        /// <summary>
        /// Ensures that the given path is a valid server instance.
        /// </summary>
        private void ValidateInstance(string path)
        {
            Directory.CreateDirectory(Path.Combine(path, "Saves"));
            Directory.CreateDirectory(Path.Combine(path, "Mods"));
            var configPath = Path.Combine(path, CONFIG_NAME);

            if (File.Exists(configPath))
            {
                return;
            }

            var config = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(configPath);

            config.Save(configPath);
        }
示例#8
0
        public void LoadInstance(string path, bool validate = true)
        {
            if (validate)
            {
                ValidateInstance(path);
            }

            MyFileSystem.Reset();
            MyFileSystem.ExePath = Path.Combine(_filesystemManager.TorchDirectory, "DedicatedServer64");
            MyFileSystem.Init("Content", path);
            //Initializes saves path. Why this isn't in Init() we may never know.
            MyFileSystem.InitUserSpecific(null);

            var configPath = Path.Combine(path, CONFIG_NAME);

            if (!File.Exists(configPath))
            {
                Log.Error($"Failed to load dedicated config at {path}");
                return;
            }

            var config = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(configPath);

            config.Load(configPath);

            DedicatedConfig = new ConfigDedicatedViewModel(config);
            var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.Config.InstancePath, "Saves"));

            foreach (var f in worldFolders)
            {
                DedicatedConfig.WorldPaths.Add(f);
            }

            if (DedicatedConfig.WorldPaths.Count == 0)
            {
                Log.Warn($"No worlds found in the current instance {path}.");
                return;
            }

            ImportWorldConfig();

            /*
             * if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
             * {
             *  Log.Warn("No world specified, importing first available world.");
             *  SelectWorld(DedicatedConfig.WorldPaths[0], false);
             * }*/
        }
 public ConfigDedicatedViewModel(MyConfigDedicated <MyObjectBuilder_SessionSettings> configDedicated)
 {
     _config = configDedicated;
     _config.IgnoreLastSession = true;
     SessionSettings           = new SessionSettingsViewModel(_config.SessionSettings);
 }