Exemplo n.º 1
0
        private void HandleNamedObjectSelect(NamedObjectSave namedObject)
        {
            if (showSettings)
            {
                AddOrShowSettingsGrid();
                settingsGrid.Instance = namedObject;
            }


            // If we are showing a NOS that comes from a file, don't show the grid.
            // Old Glue used to show the grid, but this introduces problems:
            // 1. This means that the variable showing code has to look at the file to
            //    get current values, rather than just at the ATI. This means we need new
            //    functionality in the plugin class for pulling values from files.
            // 2. The plugin class has to do some kind of intelligent caching to prevent
            //    hitting the disk for every property (which would be slow).
            // 3. The plugin will also have to respond to file changes and refresh the grid.
            // 4. This may confuse users who are expecting the changes in Glue to modify the original
            //    file, instead of them understanding that Glue overrides the file.
            // I think I'm going to keep it simple and only show the grid if it doesn't come from file:
            // Update Jan 24, 2019
            // I thought about this problem for a bit and realized that this can be solved in two steps.
            // 1. The problem is that if we show the values that come from the AssetTypeInfo on a from-file
            //    object, the default values in the ATI may not match the values of the object in the file, which
            //    has mislead developers in the past. That is why I opted to just not show a property grid at all.
            //    However, if we just didn't show any defaults at all, that would solve the problem! To do this, we
            //    just need to take the AssetTypeInfo, clone it, and make the default values for all variables be null.
            //    This should result in a property grid that shows the variables with blank boxes/UI so that the user can
            //    fill it in.
            // 2. Plugins could be given the copied ATI to fill in with values from-file. If plugins don't, then the values
            //    would be blank, but if the plugin does want to, then the values from-file would show up.
            // I'm not going to implement this solution just yet, but I thought of how it could be done and thought it would
            // be good to document it here for future reference.
            bool shouldShowVariables = namedObject.SourceType != SourceType.File;

            if (shouldShowVariables == false)
            {
                if (variableGrid != null)
                {
                    variableGrid.Visibility = System.Windows.Visibility.Collapsed;
                }
                if (variableTab != null)
                {
                    RemoveTab(variableTab);
                }
            }
            else
            {
                AddOrShowVariableGrid();
                variableGrid.Instance   = namedObject;
                variableGrid.Visibility = System.Windows.Visibility.Visible;

                NamedObjectVariableShowingLogic.UpdateShownVariables(variableGrid, namedObject,
                                                                     GlueState.Self.CurrentElement);
            }
        }
Exemplo n.º 2
0
        private void HandleNamedObjectSelect()
        {
            AddOrShowGrid();

            if (showSettings)
            {
                settingsGrid.Instance = GlueState.Self.CurrentNamedObjectSave;
            }
            variableGrid.Instance = GlueState.Self.CurrentNamedObjectSave;

            NamedObjectVariableShowingLogic.UpdateShownVariables(variableGrid, GlueState.Self.CurrentNamedObjectSave,
                                                                 GlueState.Self.CurrentElement);
        }