示例#1
0
 private static void SetEdit(MvcConfig.View view)
 {
     editingName          = view.Name;
     editingBaseClassName = view.GetBaseClass();
     editingLifeType      = view.LifeType;
     editingRescaleMode   = view.ViewRescaleMode;
     editingInitial       = view.IsInitial;
 }
示例#2
0
 /// <summary>
 /// Parses values from specified json object.
 /// </summary>
 public void Load(JsonObject json)
 {
     Version         = json["version"].AsInt(LatestVersion);
     OriginalName    = Name = json["name"].AsString();
     BaseClassName   = json["base_class_name"].AsString(BaseMvcView.ClassName);
     IsInitial       = json["is_initial"].AsBool(false);
     LifeType        = (MvcLifeType)json["life_type"].AsInt();
     ViewRescaleMode = (MvcRescaleType)json["rescale_mode"].AsInt((int)MvcRescaleType.Default);
 }
示例#3
0
        /// <summary>
        /// Instantiates the appropriate MVC life handler for specified type.
        /// </summary>
        IMvcLife GetLifeHandler(MvcLifeType lifeType)
        {
            switch (lifeType)
            {
            case MvcLifeType.Destroy:
                return(new MvcLifeDestroy());

            case MvcLifeType.Recycle:
                return(new MvcLifeRecycle());
            }
            return(null);
        }
示例#4
0
        public MvcViewMeta(MVC mvc, MvcLifeType lifeType, MvcRescaleType viewRescaleMode,
                           string resourcePath, GameObject viewParent)
        {
            this.ResourcePath = resourcePath;
            this.ViewParent   = viewParent;

            if (viewRescaleMode == MvcRescaleType.Default)
            {
                viewRescaleMode = mvc.RescaleMode;
            }
            this.viewRescaleMode = viewRescaleMode;

            mvcLifeHandler = GetLifeHandler(lifeType == MvcLifeType.Default ? mvc.UiLifeType : lifeType);
            mvcLifeHandler.Initialize(this);
        }
示例#5
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();
        }