private bool TryBuildCommand(string arg) { if (GameCooker.IsRunning) { return(true); } if (arg == null) { return(true); } Editor.Log("Using CL build for \"" + arg + "\""); int dotPos = arg.IndexOf('.'); string presetName, targetName; if (dotPos == -1) { presetName = arg; targetName = string.Empty; } else { presetName = arg.Substring(0, dotPos); targetName = arg.Substring(dotPos + 1); } var settings = GameSettings.Load <BuildSettings>(); var preset = settings.GetPreset(presetName); if (preset == null) { Editor.LogWarning("Missing preset."); return(true); } if (string.IsNullOrEmpty(targetName)) { Windows.GameCookerWin.BuildAll(preset); } else { var target = preset.GetTarget(targetName); if (target == null) { Editor.LogWarning("Missing target."); return(true); } Windows.GameCookerWin.Build(target); } Windows.GameCookerWin.ExitOnBuildQueueEnd(); return(false); }
internal void EndInit() { EnsureState <LoadingState>(); Log("Editor end init"); // Change state StateMachine.GoToState <EditingSceneState>(); // Initialize modules (from front to back) for (int i = 0; i < _modules.Count; i++) { try { _modules[i].OnEndInit(); } catch (Exception ex) { LogWarning(ex); LogError("Failed to initialize editor module " + _modules[i]); } } _areModulesAfterInitEnd = true; InitializationEnd?.Invoke(); // Close splash and show main window CloseSplashScreen(); Assert.IsNotNull(Windows.MainWindow); if (!IsHeadlessMode) { Windows.MainWindow.Show(); Windows.MainWindow.Focus(); } // Load scene // TODO: loading last open scenes from Editor Cache { var defaultSceneAsset = ContentDatabase.Find(_projectInfo.DefaultSceneId); if (defaultSceneAsset is SceneItem) { Editor.Log("Loading default project scene"); Scene.OpenScene(_projectInfo.DefaultSceneId); // Use spawn point Windows.EditWin.Viewport.ViewRay = _projectInfo.DefaultSceneSpawn; } } }
internal void EndInit() { EnsureState <LoadingState>(); Log("Editor end init"); // Change state StateMachine.GoToState <EditingSceneState>(); // Initialize modules (from front to back) for (int i = 0; i < _modules.Count; i++) { _modules[i].OnEndInit(); } // Close splash and show main window CloseSplashScreen(); Assert.IsNotNull(Windows.MainWindow); if (!IsHeadlessMode) { Windows.MainWindow.Show(); Windows.MainWindow.Focus(); } // Load scene // TODO: loading last open scenes from Editor Cache { var defaultSceneAsset = ContentDatabase.Find(_projectInfo.DefaultSceneId); if (defaultSceneAsset is SceneItem) { Editor.Log("Loading default project scene"); Scene.OpenScene(_projectInfo.DefaultSceneId); // Use spawn point Windows.EditWin.Viewport.ViewPosition = _projectInfo.DefaultSceneSpawn.Position; Windows.EditWin.Viewport.ViewDirection = _projectInfo.DefaultSceneSpawn.Direction; } } }
internal void EndInit() { EnsureState <LoadingState>(); Log("Editor end init"); // Change state StateMachine.GoToState <EditingSceneState>(); // Initialize modules (from front to back) for (int i = 0; i < _modules.Count; i++) { try { _modules[i].OnEndInit(); } catch (Exception ex) { LogWarning(ex); LogError("Failed to initialize editor module " + _modules[i]); } } _areModulesAfterInitEnd = true; _lastAutoSaveTimer = Time.UnscaledGameTime; InitializationEnd?.Invoke(); // Close splash and show main window CloseSplashScreen(); Assert.IsNotNull(Windows.MainWindow); if (!IsHeadlessMode) { Windows.MainWindow.Show(); Windows.MainWindow.Focus(); } // Load scene var startupSceneMode = Options.Options.General.StartupSceneMode; if (startupSceneMode == GeneralOptions.StartupSceneModes.LastOpened && !ProjectCache.HasCustomData(ProjectDataLastScene)) { // Fallback to default project scene if nothing saved in the cache startupSceneMode = GeneralOptions.StartupSceneModes.ProjectDefault; } switch (startupSceneMode) { case GeneralOptions.StartupSceneModes.ProjectDefault: { var defaultScene = ContentDatabase.Find(_projectInfo.DefaultSceneId); if (defaultScene is SceneItem) { Editor.Log("Loading default project scene"); Scene.OpenScene(_projectInfo.DefaultSceneId); // Use spawn point Windows.EditWin.Viewport.ViewRay = _projectInfo.DefaultSceneSpawn; } break; } case GeneralOptions.StartupSceneModes.LastOpened: { if (ProjectCache.TryGetCustomData(ProjectDataLastScene, out var lastSceneIdName) && Guid.TryParse(lastSceneIdName, out var lastSceneId)) { var lastScene = ContentDatabase.Find(lastSceneId); if (lastScene is SceneItem) { Editor.Log("Loading last opened scene"); Scene.OpenScene(lastSceneId); // Restore view if (ProjectCache.TryGetCustomData(ProjectDataLastSceneSpawn, out var lastSceneSpawnName)) { Windows.EditWin.Viewport.ViewRay = JsonSerializer.Deserialize <Ray>(lastSceneSpawnName); } } } break; } } }
/// <summary> /// Loads the project from the specified file. /// </summary> /// <param name="path">The path.</param> /// <returns>The loaded project.</returns> public static ProjectInfo Load(string path) { // Try to reuse loaded file path = StringUtils.RemovePathRelativeParts(path); if (_projectsCache == null) { _projectsCache = new List <ProjectInfo>(); } for (int i = 0; i < _projectsCache.Count; i++) { if (_projectsCache[i].ProjectPath == path) { return(_projectsCache[i]); } } try { // Load var contents = File.ReadAllText(path); var project = JsonConvert.DeserializeObject <ProjectInfo>(contents); project.ProjectPath = path; project.ProjectFolderPath = StringUtils.NormalizePath(Path.GetDirectoryName(path)); // Process project data if (string.IsNullOrEmpty(project.Name)) { throw new Exception("Missing project name."); } if (project.Version == null) { project.Version = new Version(1, 0); } if (project.Version.Revision == 0) { project.Version = new Version(project.Version.Major, project.Version.Minor, project.Version.Build); } if (project.Version.Build == 0 && project.Version.Revision == -1) { project.Version = new Version(project.Version.Major, project.Version.Minor); } foreach (var reference in project.References) { string referencePath; if (reference.Name.StartsWith("$(EnginePath)")) { // Relative to engine root referencePath = Path.Combine(Globals.StartupFolder, reference.Name.Substring(14)); } else if (reference.Name.StartsWith("$(ProjectPath)")) { // Relative to project root referencePath = Path.Combine(project.ProjectFolderPath, reference.Name.Substring(15)); } else if (Path.IsPathRooted(reference.Name)) { // Relative to workspace referencePath = Path.Combine(Environment.CurrentDirectory, reference.Name); } else { // Absolute referencePath = reference.Name; } referencePath = StringUtils.RemovePathRelativeParts(referencePath); // Load referenced project reference.Project = Load(referencePath); } // Project loaded Editor.Log($"Loaded project {project.Name}, version {project.Version}"); _projectsCache.Add(project); return(project); } catch { // Failed to load project Editor.LogError("Failed to load project \"" + path + "\"."); throw; } }