Esempio n. 1
0
        /// <summary>
        ///  this is called every frame by the gui system, so we need to check if the button should be pressed, and
        ///  if user is switching to a new config, confirm if they wanted to
        /// </summary>
        public static bool ConfirmSwitchActiveButton(TemplateButtonEntry button)
        {
            // if this button is the same as our current selection then yes it should be pressed
            if (activeSelection == button)
            {
                return(true);
            }

            // if user has selected another config, prompt them to confirm that they actually want to switch
            if (activeConfigEditDirty)
            {
                if (EditorUtility.DisplayDialog(Loc.DIALOG_CONFIG_DIRTY_LOSECHANGES_TITLE,
                                                Loc.DIALOG_CONFIG_DIRTY_LOSECHANGES_MESSAGE,
                                                Loc.DIALOG_OK,
                                                Loc.DIALOG_CANCEL))
                {
                    // save changes
                    SaveConfigChanges();
                    // and switch to the new selection
                    SwitchActiveButton_Internal(button);
                    return(true);
                }
                else
                {
                    // cancel, don't save / don't change
                    return(false);
                }
            }
            else
            {
                // just switch to the new config
                SwitchActiveButton_Internal(button);
                return(true);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// resets our selection completely
 /// </summary>
 public static void ClearSelection()
 {
     SetActiveConfigDirty(false);
     activeSelection             = null;
     activeEntrySelection        = null;
     activeConfig                = null;
     configNameDirty             = false;
     configDescriptionDirty      = false;
     tempConfigDescriptionString = string.Empty;
     tempConfigNameString        = string.Empty;
 }
        protected void Reset()
        {
            // reset the controller
            Control.Reset();

            _folderEditScroll = Vector2.zero;
            _sceneEditScroll  = Vector2.zero;
            _templateScroll   = Vector2.zero;
            _sceneViewScroll  = Vector2.zero;

            /*
             * Generate our template buttons
             */

            // templates built into the package
            Control.defaultTemplateButtons.Clear();
            foreach (var template in Core.defaultTemplates)
            {
                // load the config
                var config = Core.LoadGenericConfig(template.path);
                var button = new TemplateButtonEntry
                {
                    config      = config,
                    displayName = config.name,
                    fileName    = template.fileName,
                    description = config.description,
                    path        = template.path,
                    type        = config.type,
                    isPressed   = false,
                    isBuiltIn   = true,
                };
                Control.defaultTemplateButtons.Add(button);
            }

            // templates in user-land project space
            Control.userTemplateButtons.Clear();
            foreach (var template in Core.userTemplates)
            {
                var config = Core.LoadGenericConfig(template.path);
                var button = new TemplateButtonEntry
                {
                    config      = config,
                    displayName = config.name,
                    fileName    = template.fileName,
                    description = config.description,
                    path        = template.path,
                    type        = config.type,
                    isPressed   = false,
                    isBuiltIn   = false,
                };
                Control.userTemplateButtons.Add(button);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// We've switched to a different config, let's reset and load that config
        /// </summary>
        /// <param name="newSelection"></param>
        public static void SetActiveSelection(TemplateButtonEntry newSelection)
        {
            ClearSelection();
            activeSelection = newSelection;
            // reset template file name for copies
            tempFileName = activeSelection.displayName + " Copy";

            // load the active config
            activeConfig = Core.LoadConfig(activeSelection.path);
            // cache these, they are used in the template editor
            tempConfigNameString        = activeConfig.name;
            tempConfigDescriptionString = activeConfig.description;
        }
Esempio n. 5
0
 /// <summary>
 /// make a radio button toggle out of our list of buttons
 /// </summary>
 /// <param name="activeButton"></param>
 public static void ClearOtherButtons(TemplateButtonEntry activeButton)
 {
     foreach (var button in defaultTemplateButtons)
     {
         if (button != activeButton)
         {
             button.isPressed = false;
         }
     }
     foreach (var button in userTemplateButtons)
     {
         if (button != activeButton)
         {
             button.isPressed = false;
         }
     }
 }
        /// <summary>
        /// Helper to generate controls in our list
        /// </summary>
        /// <param name="button"></param>
        protected void CreateTemplateButton(TemplateButtonEntry button)
        {
            var shortName  = button.displayName.Split('.')[0];
            var configPath = button.path;
            var config     = button.config;
            var type       = button.type;

            button.isPressed = GUILayout.Toggle(button.isPressed, new GUIContent(shortName, null, Loc.TOOLTIP_TEMPLATELIST_OPTIONS), "Button", GUILayout.MaxWidth(STANDARDBUTTONSIZE), GUILayout.MaxHeight(STANDARDBUTTONHEIGHT));
            if (button.isPressed)
            {
                var actuallySwitch = Control.ConfirmSwitchActiveButton(button);
                if (!actuallySwitch)
                {
                    button.isPressed = false;
                }
                else
                {
                    button.isPressed = true;
                }
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Internal call, actually switch active config
 /// </summary>
 /// <param name="button"></param>
 private static void SwitchActiveButton_Internal(TemplateButtonEntry button)
 {
     tempFileName = activeSelection + " copy";
     ClearOtherButtons(button);
     SetActiveSelection(button);
 }