Skip to content

Commit

Permalink
fixed sprite texture address modein state not affecting values shown …
Browse files Browse the repository at this point in the history
…in property grid
  • Loading branch information
vchelaru committed Dec 29, 2023
1 parent 2017ad0 commit 2da0ef9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Gum/DataTypes/RecursiveVariableFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public RecursiveVariableFinder(InstanceSave instanceSave, ElementSave container)
// Vic asks - if the RFV is for an instance in a container, should the instance name be set on the
// elementWithState? The GetVariable method seems to expect that, so let's try that:
// Update - the reason this works this way is - if the ElementWithState has an instance, then the name
// of the instance is automatically used on the variable. In other words, if this is assigned, and we want
// of the instance is automatically used on the variable. In other words, if an instance is assigned, and we want
// the X value on the instance, then we sould ask the RecursiveVariableFinder for "X".
// If no instance is assigned, then we would ask for "InstanceName.X". However, since the
// constructor here explicitly assigns an instance, I think it's proper to assign the instance
Expand All @@ -88,12 +88,16 @@ public RecursiveVariableFinder(InstanceSave instanceSave, List<ElementWithState>

public RecursiveVariableFinder(List<ElementWithState> elementStack)
{
ContainerType = VariableContainerType.StateSave;


var last = elementStack.Last();
mStateSave = last.StateSave;
ElementStack = elementStack;

// technically the elementstack could include elements that have instances. However,
// the element stack could have a mix where some ElementWithStates have instances, and
// some do not. therefore, we can't assume the entire thing uses instances.
ContainerType = VariableContainerType.StateSave;
}

public RecursiveVariableFinder(StateSave stateSave)
Expand Down
11 changes: 10 additions & 1 deletion Gum/Logic/VariableSaveLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using Gum.Managers;
using Gum.Plugins;
using Gum.ToolStates;
using Gum.Wireframe;
using System.Collections.Generic;
using System.Linq;

namespace Gum.Logic
Expand Down Expand Up @@ -66,7 +68,14 @@ public static bool GetIfVariableIsActive(VariableSave defaultVariable, ElementSa
RecursiveVariableFinder rvf;
if (currentInstance != null)
{
rvf = new RecursiveVariableFinder(currentInstance, container);
//rvf = new RecursiveVariableFinder(currentInstance, container);
// this should respect the current state:

var elementWithState = new ElementWithState(container);
elementWithState.InstanceName = currentInstance?.Name;
elementWithState.StateName = GumState.Self.SelectedState.SelectedStateSave?.Name;
var stack = new List<ElementWithState>() { elementWithState };
rvf = new RecursiveVariableFinder(stack);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Gum.Managers;
using Gum.Plugins.BaseClasses;
using System.ComponentModel.Composition;
using System.Linq;

namespace Gum.PropertyGridHelpers.Excluders
{
Expand Down Expand Up @@ -33,6 +34,12 @@ private bool HandleVariableExcluded(DataTypes.Variables.VariableSave variable, D
{
prefix = nameOfInstanceOwningVariable + ".";
}

if(string.IsNullOrEmpty(prefix) && !string.IsNullOrEmpty( rvf.ElementStack.Last().InstanceName ))
{
prefix = rvf.ElementStack.Last().InstanceName + ".";

}

if (rootName == "Texture Top" || rootName == "Texture Left")
{
Expand Down

0 comments on commit 2da0ef9

Please sign in to comment.