コード例 #1
0
ファイル: Engine.cs プロジェクト: Zicore/BlueSwitch
        public void LoadPrefabs()
        {
            var directory = EngineSettings.GetSettingsSubDirectory("Prefabs");
            var files     = Directory.GetFiles(directory, "*.bspref");

            CurrentProject.Prefabs.Clear();

            foreach (var file in files)
            {
                var prefab = JsonSerializable.Load <BlueSwitchProject>(file);
                CurrentProject.Prefabs.Add(new Prefab {
                    Project = prefab, Name = prefab.Name, Description = prefab.Description, FilePath = prefab.FilePath
                });
            }

            foreach (var p in CurrentProject.Prefabs)
            {
                PrefabSwitch sw = new PrefabSwitch();
                sw.Prefab = p;
                sw.InitializeMetaInformation(this);
                sw.Initialize(this);
                sw.AutoDiscoverDisabled = false;

                var available = AvailableSwitches.FirstOrDefault(x => x.GetType() == sw.GetType());

                // This should probably be refactored to a central spot for AvailableSwitches
                if (available != null)
                {
                    AvailableSwitches.Remove(available); // Refresh prefab switches from list
                }

                AvailableSwitches.Add(sw);
            }
        }
コード例 #2
0
 public void LoadSettings()
 {
     try
     {
         Settings = JsonSerializable.Load <EngineSettings>(EngineSettings.SettingsFilePath);
     }
     catch
     {
         Settings = new EngineSettings();
         Settings.Save(EngineSettings.SettingsFilePath);
     }
 }
コード例 #3
0
ファイル: Engine.cs プロジェクト: Zicore/BlueSwitch
 public void LoadProject(String filePath)
 {
     OnBeforeLoading();
     CurrentProject = new BlueSwitchProject();
     try
     {
         CurrentProject = JsonSerializable.Load <BlueSwitchProject>(filePath);
     }
     catch (Exception ex)
     {
         _log.Error(ex);
     }
     LoadPrefabs();
     CurrentProject.Initialize(this);
     OnProjectLoaded();
 }