Skip to content

Commit

Permalink
Fixed another case of elements not being selected properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Dec 20, 2024
1 parent 2bd198b commit e541b3f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ public override void StartUp()
this.ReactToStateSaveCategorySelected += MainVariableGridPlugin_ReactToStateSaveCategorySelected;
this.StateMovedToCategory += HandleStateMovedToCategory;
this.InstanceSelected += HandleInstanceSelected;
this.ElementSelected += HandleElementSelected;
this.BehaviorSelected += HandleBehaviorSelected;
}

private void HandleElementSelected(ElementSave save)
{
PropertyGridManager.Self.RefreshUI(force: true);
}

private void HandleBehaviorSelected(BehaviorSave save)
{
PropertyGridManager.Self.RefreshUI(force: true);
Expand Down
42 changes: 24 additions & 18 deletions Gum/ToolStates/SelectedState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ private void HandleElementSelected(ElementSave value)
snapshot.SelectedBehavior = null;
}
UpdateToSelectedElement(value);
}

if(value != null)
{
PluginManager.Self.ElementSelected(SelectedElement);
}
}

private void UpdateToSelectedElement(ElementSave element)
{
Expand Down Expand Up @@ -130,10 +134,7 @@ private void UpdateToSelectedElement(ElementSave element)
SelectionManager.Self.Refresh();

_menuStripManager.RefreshUI();

PluginManager.Self.ElementSelected(SelectedElement);
}

}

#endregion
Expand Down Expand Up @@ -409,6 +410,25 @@ public VariableSave SelectedBehaviorVariable

#endregion

#region Instance

private void HandleSelectedInstances(List<InstanceSave> value)
{
var instance = value?.FirstOrDefault();
if(instance != null)
{
var elementAfter = ObjectFinder.Self.GetElementContainerOf(instance);
var behaviorAfter = ObjectFinder.Self.GetBehaviorContainerOf(instance);

snapshot.SelectedElement = elementAfter;
snapshot.SelectedBehavior = behaviorAfter;
}

UpdateToSelectedInstances(value);
}

#endregion

private void UpdateToSetSelectedStackingMode(StateStackingMode value)
{
var isSame = snapshot.StateStackingMode == value;
Expand All @@ -429,20 +449,6 @@ private void UpdateToSetSelectedStateSaveCategory(StateSaveCategory selectedStat
}
}

private void HandleSelectedInstances(List<InstanceSave> value)
{
var instance = value?.FirstOrDefault();
if(instance != null)
{
var elementAfter = ObjectFinder.Self.GetElementContainerOf(instance);
var behaviorAfter = ObjectFinder.Self.GetBehaviorContainerOf(instance);

snapshot.SelectedElement = elementAfter;
snapshot.SelectedBehavior = behaviorAfter;
}

UpdateToSelectedInstances(value);
}

private void HandleStateSaveSelected(StateSave stateSave)
{
Expand Down

0 comments on commit e541b3f

Please sign in to comment.