Esempio n. 1
0
 private static void DrawControls(MVCEditor editor, MvcConfig config)
 {
     if (GUILayout.Button(IsShowingView ? "Hide views" : "Show views"))
     {
         IsShowingView = !IsShowingView;
     }
 }
Esempio n. 2
0
        private static void RenderGeneral(MVCEditor editor)
        {
            EditorGUILayout.LabelField(
                "General Settings", CategoryLabelStyle
                );

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Select a scene object to use as a parent for MVC view instances.");
            editor.I.ViewParent = (GameObject)RenkoEditorLayout.SceneObjectField(
                "ViewParent", editor.I.ViewParent, typeof(GameObject)
                );

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Whether the initial view should be shown on awake.\n" +
                                       "If false, you'll have to show it manually via code.");
            EditorGUILayout.PropertyField(
                editor.InitializeViewOnAwake, new GUIContent("InitializeViewOnAwake")
                );

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Determines how disposed views will be handled by default.");
            EditorGUILayout.PropertyField(
                editor.UiLifecycleMethod, new GUIContent("UiLifecycleMethod")
                );
            if (editor.UiLifecycleMethod.enumValueIndex == 0)
            {
                editor.UiLifecycleMethod.enumValueIndex = 1;
            }
        }
Esempio n. 3
0
        private static void RenderAdvancedView(MVCEditor editor)
        {
            EditorGUILayout.HelpBox(
                "Advanced view settings should NOT be touched in general cases.\nUnless you have full understanding" +
                "of this framework's process, it's highly recommended to just leave the settings as-is.",
                MessageType.Warning
                );

            RenderSpace();

            EditorGUILayout.LabelField(
                "Current workspace directory: " + NyanPath.EditorRelativePath(MvcWorkspace.WorkspacePath)
                );
            EditorGUILayout.HelpBox(
                "If you change the workspace directory, you must move/delete script files already created in " +
                "the previous directory.",
                MessageType.Warning
                );
            if (GUILayout.Button("Change workspace directory"))
            {
                MVCEditor.SelectWorkspaceDirectory();
            }

            RenderSpace();

            EditorGUILayout.LabelField("Default base class of MVC views.");
            Config.SetBaseClassName(EditorGUILayout.TextField(
                                        "BaseClassName",
                                        Config.BaseClassName
                                        ));
        }
Esempio n. 4
0
        private static void RenderScreen(MVCEditor editor)
        {
            EditorGUILayout.LabelField(
                "Screen Settings", CategoryLabelStyle
                );

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Set base (or desired) resolution of your UI.");
            EditorGUILayout.PropertyField(
                editor.BaseResolution, new GUIContent("BaseResolution")
                );

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Set default scaling mode for all views.");
            EditorGUILayout.PropertyField(
                editor.RescaleMode, new GUIContent("RescaleMode")
                );
            editor.RescaleMode.enumValueIndex = ClampRescaleModeValue(editor.RescaleMode.enumValueIndex);
            EditorGUILayout.HelpBox(
                GetRescaleModeHelMessage(editor.RescaleMode.enumValueIndex),
                MessageType.Info
                );

            EditorGUILayout.Space();
        }
Esempio n. 5
0
        /// <summary>
        /// Renders list of config views on custom editor.
        /// </summary>
        public static void Render(MVCEditor editor, MvcConfig config)
        {
            ConfigViewEditorFlags.Setup(config);

            DrawControls(editor, config);
            DrawViews(editor, config);
        }
Esempio n. 6
0
 /// <summary>
 /// Renders editor gui.
 /// </summary>
 public static void Render(MVCEditor editor)
 {
     RenderGeneral(editor);
     RenderSpace();
     RenderScreen(editor);
     RenderSpace();
     RenderView(editor);
 }
Esempio n. 7
0
 /// <summary>
 /// Renders editor gui.
 /// </summary>
 public static void Render(MVCEditor editor)
 {
     GUILayout.Label("Select a new or existing MVC workspace.");
     if (GUILayout.Button("Select directory"))
     {
         MVCEditor.SelectWorkspaceDirectory();
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Renders editor gui.
 /// </summary>
 public static void Render(MVCEditor editor)
 {
     GUILayout.Label("Something went wrong in the Resources folder.");
     GUILayout.Space(15);
     GUILayout.Label("Please do NOT delete, move, or modify auto-generated " +
                     "folders and files.\nI will not be responsible for any losses in your project!");
     GUILayout.Space(15);
     if (GUILayout.Button("Fix"))
     {
         OnFix();
     }
 }
Esempio n. 9
0
        public static void Render(MVCEditor editor, MvcConfig config)
        {
            if (GUILayout.Button(IsShowingWarning ? "Hide warnings" : "Show warnings"))
            {
                IsShowingWarning = !IsShowingWarning;
            }

            if (IsShowingWarning)
            {
                RenderNoInitialView(config);
                RenderMissingPrefab(editor, config);
            }
        }
Esempio n. 10
0
        private static void RenderView(MVCEditor editor)
        {
            EditorGUILayout.LabelField(
                "View Settings", CategoryLabelStyle
                );

            EditorGUILayout.Space();

            EditorColors.SetBackgroundColor(Color.green);
            {
                if (GUILayout.Button("Apply configuration"))
                {
                    if (Config.IsConfigValid())
                    {
                        ConfigSynchronizer.Sync(Config);
                    }
                }
            }
            EditorColors.ResetBackgroundColor();

            EditorGUILayout.HelpBox("Click the button above whenever you make changes in this area.", MessageType.Info);

            EditorGUILayout.Space();

            if (GUILayout.Button("Generate prefabs"))
            {
                if (Config.IsConfigValid() && !EditorApplication.isCompiling)
                {
                    MvcPrefabMaker.CreatePrefabs(editor.I, Config);
                }
            }

            EditorGUILayout.Space();

            WarningView.Render(editor, Config);

            EditorGUILayout.Space();

            ConfigViewLayout.Render(editor, Config);

            EditorGUILayout.Space();

            if (GUILayout.Button(isAdvancedViewSettings ? "Hide advanced settings" : "Show advnaced settings"))
            {
                isAdvancedViewSettings = !isAdvancedViewSettings;
            }
            if (isAdvancedViewSettings)
            {
                RenderAdvancedView(editor);
            }
        }
Esempio n. 11
0
 private static void RenderMissingPrefab(MVCEditor editor, MvcConfig config)
 {
     for (int i = 0; i < config.Views.Count; i++)
     {
         var view = config.Views[i];
         if (!File.Exists(MvcResources.GetViewPrefabPath(view, view.GetViewName(), true)))
         {
             DisplayWarning(string.Format(
                                "Missing prefab for view ({0}) at path: Resources/{1}",
                                view.Name,
                                MvcResources.GetViewPrefabPath(view, view.GetViewName())
                                ));
         }
     }
 }
Esempio n. 12
0
        private static void DrawViews(MVCEditor editor, MvcConfig config)
        {
            if (!IsShowingView)
            {
                return;
            }

            GUILayout.BeginVertical("GroupBox");

            for (int i = 0; i < config.Views.Count; i++)
            {
                if (ConfigViewEditorFlags.IsOpen[i])
                {
                    DrawOpenedView(editor, config, config.Views[i], i);
                }
                else
                {
                    DrawClosedView(editor, config, config.Views[i], i);
                }
            }

            EditorColors.SetBackgroundColor(Color.green);
            {
                if (GUILayout.Button("Create View"))
                {
                    config.Views.Add(new MvcConfig.View(config)
                    {
                        Name = "View" + config.Views.Count
                    });

                    ConfigViewEditorFlags.Setup(config);
                    ConfigViewEditorFlags.SetOpen(config.Views.Count - 1);
                    SetEdit(config.Views.GetLast());
                }
            }
            EditorColors.ResetBackgroundColor();

            GUILayout.EndVertical();
        }
Esempio n. 13
0
        private static void DrawClosedView(MVCEditor editor, MvcConfig config, MvcConfig.View view, int index)
        {
            GUILayout.BeginHorizontal("GroupBox");

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Label(view.Name + " : " + view.GetBaseClass());
            GUILayout.Label(view.LifeType.ToString() + " on dispose.");
            if (view.IsInitial)
            {
                GUILayout.Label("Initial view");
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            if (GUILayout.Button("Edit"))
            {
                ConfigViewEditorFlags.SetOpen(index);
                SetEdit(view);
            }

            GUILayout.EndHorizontal();
        }
Esempio n. 14
0
        private static void DrawOpenedView(MVCEditor editor, MvcConfig config, MvcConfig.View view, int index)
        {
            GUILayout.BeginVertical("LightmapEditorSelectedHighlight");

            editingName = ViewNameTrim(
                EditorGUILayout.TextField("View name", editingName)
                );
            editingBaseClassName = EditorGUILayout.TextField("Custom base class", editingBaseClassName);
            editingLifeType      = (MvcLifeType)EditorGUILayout.EnumPopup("Custom lifecycle", editingLifeType);
            editingRescaleMode   = (MvcRescaleType)EditorGUILayout.EnumPopup("View rescale mode", editingRescaleMode);
            editingInitial       = EditorGUILayout.Toggle("Is initial view?", editingInitial);

            if (GUILayout.Button("Save & Close"))
            {
                if (ApplyEdit(config, view))
                {
                    ConfigViewEditorFlags.ResetFlags();
                }
            }

            EditorColors.SetBackgroundColor(Color.red);
            {
                if (GUILayout.Button("Danger Zone!"))
                {
                    ConfigViewEditorFlags.IsDeleteOpen ^= true;
                }
            }
            EditorColors.ResetBackgroundColor();

            if (ConfigViewEditorFlags.IsDeleteOpen)
            {
                GUILayout.BeginVertical("GroupBox");

                EditorGUILayout.HelpBox(
                    "It is highly recommended to apply configurations first before performing any actions here.",
                    MessageType.Warning
                    );

                // Red background for danger zone buttons
                EditorColors.SetBackgroundColor(Color.red);
                {
                    if (GUILayout.Button("Delete config"))
                    {
                        if (EditorDialog.OpenAlert(
                                "Delete view configuration.",
                                "Are you sure you want to delete this view's configuration? " + DeleteWarning,
                                "Yes", "No"))
                        {
                            // Remove view from views list.
                            MvcViewRemover.RemoveFromConfig(config.Views, index);
                            ConfigViewEditorFlags.Setup(config);
                            ConfigViewEditorFlags.ResetFlags();
                        }
                    }

                    // If loaded from resources, the user must've already created a prefab or at least scripts.
                    if (view.IsFromResources)
                    {
                        EditorGUILayout.Space();

                        if (GUILayout.Button("Delete prefab"))
                        {
                            // Confirm prefab deletion
                            if (EditorDialog.OpenAlert(
                                    "Delete view prefab",
                                    "Are you sure you want to delete this view's prefab? " + DeleteWarning,
                                    "Yes", "No"))
                            {
                                MvcViewRemover.RemovePrefab(view);
                            }
                        }

                        EditorGUILayout.Space();

                        if (GUILayout.Button("Delete all"))
                        {
                            // Confirm deletion of all view-related things
                            if (EditorDialog.OpenAlert(
                                    "Delete view config, scripts, prefab",
                                    "Are you sure you want to delete this view's config, scripts, and prefab?" + DeleteWarning,
                                    "Yes", "No"))
                            {
                                MvcViewRemover.RemoveFromConfig(config.Views, index);
                                MvcViewRemover.RemoveScripts(view);
                                MvcViewRemover.RemovePrefab(view);
                                MvcViewRemover.Finalize(config);

                                ConfigViewEditorFlags.Setup(config);
                                ConfigViewEditorFlags.ResetFlags();
                            }
                        }
                    }
                }
                EditorColors.ResetBackgroundColor();

                GUILayout.EndVertical();
            }

            GUILayout.EndVertical();
        }