コード例 #1
0
        // Replaced with ApplyDefaultState
        //static void SetVariablesRecursively(this GraphicalUiElement graphicalElement, ElementSave elementSave)
        //{
        //    graphicalElement.SetVariablesRecursively(elementSave, elementSave.DefaultState);
        //}

        public static void SetVariablesRecursively(this GraphicalUiElement graphicalElement, ElementSave elementSave, Gum.DataTypes.Variables.StateSave stateSave)
        {
            if (!string.IsNullOrEmpty(elementSave.BaseType))
            {
                var baseElementSave = Gum.Managers.ObjectFinder.Self.GetElementSave(elementSave.BaseType);
                if (baseElementSave != null)
                {
                    graphicalElement.SetVariablesRecursively(baseElementSave, baseElementSave.DefaultState);
                }
            }

            graphicalElement.ApplyState(stateSave);
        }
コード例 #2
0
        public static void SetGraphicalUiElement(this ElementSave elementSave, GraphicalUiElement toReturn, SystemManagers systemManagers)
        {
            // We need to set categories and states first since those are used below;
            toReturn.SetStatesAndCategoriesRecursively(elementSave);

            toReturn.CreateGraphicalComponent(elementSave, systemManagers);

            toReturn.AddExposedVariablesRecursively(elementSave);

            toReturn.CreateChildrenRecursively(elementSave, systemManagers);

            toReturn.Tag = elementSave;

            toReturn.SetVariablesRecursively(elementSave);
        }
コード例 #3
0
        public static void SetVariablesRecursively(this GraphicalUiElement graphicalElement, ElementSave elementSave, Gum.DataTypes.Variables.StateSave stateSave)
        {
            if (!string.IsNullOrEmpty(elementSave.BaseType))
            {
                var baseElementSave = Gum.Managers.ObjectFinder.Self.GetElementSave(elementSave.BaseType);
                if (baseElementSave != null)
                {
                    graphicalElement.SetVariablesRecursively(baseElementSave);
                }
            }

            foreach (var variable in stateSave.Variables.Where(item => item.SetsValue && item.Value != null))
            {
                graphicalElement.SetProperty(variable.Name, variable.Value);
            }
        }
コード例 #4
0
        public static void SetVariablesRecursively(this GraphicalUiElement graphicalElement, ElementSave elementSave, Gum.DataTypes.Variables.StateSave stateSave)
        {
            if (!string.IsNullOrEmpty(elementSave.BaseType))
            {
                var baseElementSave = Gum.Managers.ObjectFinder.Self.GetElementSave(elementSave.BaseType);
                if (baseElementSave != null)
                {
                    graphicalElement.SetVariablesRecursively(baseElementSave, baseElementSave.DefaultState);
                }
            }

            var variablesToSet = stateSave.Variables
                                 .Where(item => item.SetsValue && item.Value != null)
                                 // States should be applied first, then values may override states (order by sorts false first):
                                 .OrderBy(item => !item.IsState(elementSave))
                                 .ToList();

            foreach (var variable in variablesToSet)
            {
                // See below for explanation on why we don't set Parent here
                if (variable.GetRootName() != "Parent")
                {
                    graphicalElement.SetProperty(variable.Name, variable.Value);
                }
            }

            // Now set all parents
            // The reason for this is
            // because parents need to
            // be assigned in the order
            // of the instances in the .glux.
            // That way they are drawn in the same
            // order as they are defined.
            variablesToSet = variablesToSet.Where(item => item.GetRootName() == "Parent")
                             .OrderBy(item => elementSave.Instances.FindIndex(instance => instance.Name == item.SourceObject))
                             .ToList();

            foreach (var variable in variablesToSet)
            {
                graphicalElement.SetProperty(variable.Name, variable.Value);
            }
        }
コード例 #5
0
 static void SetVariablesRecursively(this GraphicalUiElement graphicalElement, ElementSave elementSave)
 {
     graphicalElement.SetVariablesRecursively(elementSave, elementSave.DefaultState);
 }