public static void RegisterSystemIdChange(string srcSystemFullName, string dstSystemFullName) { var name = dstSystemFullName.Substring(dstSystemFullName.LastIndexOf(".", StringComparison.Ordinal) + 1); var type = new UTinySystem.Reference(UTinyId.Generate(dstSystemFullName), name); Register(UTinyId.Generate(srcSystemFullName), new SystemIdChange(type)); }
static UTinyUpdater() { // @TODO Move registration to an external class // Move into Math module RegisterTypeIdChange("UTiny.Core.Vector2f", "UTiny.Math.Vector2"); RegisterTypeIdChange("UTiny.Core.Vector3f", "UTiny.Math.Vector3"); RegisterTypeIdChange("UTiny.Core.Vector4f", "UTiny.Math.Vector4"); RegisterTypeIdChange("UTiny.Core.Matrix3x3f", "UTiny.Math.Matrix3x3"); RegisterTypeIdChange("UTiny.Core.Matrix4x4f", "UTiny.Math.Matrix4x4"); RegisterTypeIdChange("UTiny.Core.Quaternionf", "UTiny.Math.Quaternion"); RegisterTypeIdChange("UTiny.Core.Rectf", "UTiny.Math.Rect"); RegisterTypeIdChange("UTiny.Core.RectInt", "UTiny.Math.RectInt"); // moves into Core2D module RegisterTypeIdChange("UTiny.Core.DisplayOrientation", "UTiny.Core2D.DisplayOrientation"); RegisterTypeIdChange("UTiny.Core.DisplayInfo", "UTiny.Core2D.DisplayInfo"); RegisterTypeIdChange("UTiny.Core.MouseState", "UTiny.Core2D.MouseState"); RegisterTypeIdChange("UTiny.Core.Camera2D", "UTiny.Core2D.Camera2D"); RegisterTypeIdChange("UTiny.Core.Image2D", "UTiny.Core2D.Image2D"); RegisterTypeIdChange("UTiny.Core.Sprite2D", "UTiny.Core2D.Sprite2D"); RegisterTypeIdChange("UTiny.Core.Sprite2DRenderer", "UTiny.Core2D.Sprite2DRenderer"); RegisterTypeIdChange("UTiny.Core.Transform", "UTiny.Core2D.Transform"); // System renames RegisterSystemIdChange("UTiny.HTML.HTMLService.InputHandler", "UTiny.HTML.InputHandler"); RegisterSystemIdChange("UTiny.HTML.HTMLService.Renderer", "UTiny.HTML.Renderer"); // ColorRGBA is migrated to Color Register(UTinyId.Generate("UTiny.Core.ColorRGBA"), new ColorRGBAUpdater()); }
/// <summary> /// Loads the utmodule at the given file path /// </summary> /// <param name="moduleFile">Relative path to the .utmodule file</param> public static void LoadModule(string moduleFile) { Assert.IsFalse(EditorApplication.isPlayingOrWillChangePlaymode); var context = new UTinyContext(); var registry = context.Registry; UTinyPersistence.LoadModule(moduleFile, registry); var module = registry.FindAllBySource(UTinyRegistry.DefaultSourceIdentifier).OfType <UTinyModule>().First(); Assert.IsNotNull(module); module.Name = Path.GetFileNameWithoutExtension(moduleFile); SetupModule(registry, module); var project = registry.CreateProject(UTinyId.Generate(KWorkspaceProjectName), KWorkspaceProjectName); project.Module = (UTinyModule.Reference)module; var editorContext = new UTinyEditorContext((UTinyProject.Reference)project, EditorContextType.Module, context, UTinyEditorPrefs.LoadWorkspace(project.PersistenceId)); LoadContext(editorContext, isChanged: false); }
/// <summary> /// Creates and loads a new .utmodule /// @NOTE The module only exists in memory until Save() is called /// </summary> public static void NewModule() { var context = new UTinyContext(); var registry = context.Registry; UTinyPersistence.LoadAllModules(registry); // Create a `workspace` project to host the module for editing purposes var project = registry.CreateProject(UTinyId.Generate(KWorkspaceProjectName), KWorkspaceProjectName); // Create objects for the new module var module = registry.CreateModule(UTinyId.New(), "NewModule"); // Setup initial state for the module module.Namespace = "module"; SetupModule(registry, module); project.Module = (UTinyModule.Reference)module; var workspace = new UTinyEditorWorkspace(); UTinyEditorPrefs.SaveWorkspace(workspace); var editorContext = new UTinyEditorContext((UTinyProject.Reference)project, EditorContextType.Module, context, workspace); LoadContext(editorContext, isChanged: true); }
/// <summary> /// Trys to loads the last saved temp file /// </summary> public static void LoadTemp() { Assert.IsFalse(EditorApplication.isPlayingOrWillChangePlaymode); if (!UTinyTemp.Exists()) { return; } var context = new UTinyContext(); var registry = context.Registry; string persistenceId; if (!UTinyTemp.Accept(registry, out persistenceId)) { LoadPersistenceId(persistenceId); return; } var project = registry.FindAllByType <UTinyProject>().FirstOrDefault(); UTinyEditorContext editorContext = null; if (project != null) { SetupProject(registry, project); editorContext = new UTinyEditorContext((UTinyProject.Reference)project, EditorContextType.Project, context, UTinyEditorPrefs.LoadLastWorkspace()); } else { var module = registry.FindAllBySource(UTinyRegistry.DefaultSourceIdentifier).OfType <UTinyModule>().First(); SetupModule(registry, module); if (null != module) { project = registry.CreateProject(UTinyId.Generate(KWorkspaceProjectName), KWorkspaceProjectName); project.Module = (UTinyModule.Reference)module; editorContext = new UTinyEditorContext((UTinyProject.Reference)project, EditorContextType.Module, context, UTinyEditorPrefs.LoadLastWorkspace()); } } Assert.IsNotNull(project); LoadContext(editorContext, true); }
static UTinyUpdater() { // @TODO Move registration to an external class // Move into Math module RegisterTypeIdChange("UTiny.Core.Vector2f", "UTiny.Math.Vector2"); RegisterTypeIdChange("UTiny.Core.Vector3f", "UTiny.Math.Vector3"); RegisterTypeIdChange("UTiny.Core.Vector4f", "UTiny.Math.Vector4"); RegisterTypeIdChange("UTiny.Core.Matrix3x3f", "UTiny.Math.Matrix3x3"); RegisterTypeIdChange("UTiny.Core.Matrix4x4f", "UTiny.Math.Matrix4x4"); RegisterTypeIdChange("UTiny.Core.Quaternionf", "UTiny.Math.Quaternion"); RegisterTypeIdChange("UTiny.Core.Rectf", "UTiny.Math.Rect"); RegisterTypeIdChange("UTiny.Core.RectInt", "UTiny.Math.RectInt"); // moves into Core2D module RegisterTypeIdChange("UTiny.Core.DisplayOrientation", "UTiny.Core2D.DisplayOrientation"); RegisterTypeIdChange("UTiny.Core.DisplayInfo", "UTiny.Core2D.DisplayInfo"); RegisterTypeIdChange("UTiny.Core.MouseState", "UTiny.Core2D.MouseState"); RegisterTypeIdChange("UTiny.Core.Camera2D", "UTiny.Core2D.Camera2D"); RegisterTypeIdChange("UTiny.Core.Image2D", "UTiny.Core2D.Image2D"); RegisterTypeIdChange("UTiny.Core.Sprite2D", "UTiny.Core2D.Sprite2D"); RegisterTypeIdChange("UTiny.Core.Sprite2DRenderer", "UTiny.Core2D.Sprite2DRenderer"); RegisterTypeIdChange("UTiny.Core.Transform", "UTiny.Core2D.Transform"); // Type renames RegisterTypeIdChange("UTiny.Core2D.Sprite2DRendererTiling", "UTiny.Core2D.Sprite2DRendererOptions"); // System renames RegisterSystemIdChange("UTiny.HTML.HTMLService.InputHandler", "UTiny.HTML.InputHandler"); RegisterSystemIdChange("UTiny.HTML.HTMLService.Renderer", "UTiny.HTML.Renderer"); RegisterSystemIdChange("UTiny.Core2D.InputFence", "UTiny.Shared.InputFence"); RegisterSystemIdChange("UTiny.Core2D.RenderingFence", "UTiny.Shared.RenderingFence"); RegisterSystemIdChange("UTiny.Core2D.PlatformRenderingFence", "UTiny.Shared.PlatformRenderingFence"); // ColorRGBA is migrated to Color Register(UTinyId.Generate("UTiny.Core.ColorRGBA"), new ColorRGBAUpdater()); Register(new UTinyId(new Guid("e9c46111504a470885988383d2091dc2")), new CharToIntTypeUpdater()); }