Skip to content

Commit

Permalink
Fix TreeView not being reopened by tab after closing via mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
falko17 committed Jan 25, 2024
1 parent 3ee13aa commit 347fa6d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
11 changes: 10 additions & 1 deletion Assets/SEE/Controls/Actions/ShowTree.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Cysharp.Threading.Tasks;
using SEE.Game;
using SEE.Game.City;
Expand Down Expand Up @@ -76,14 +78,21 @@ async UniTaskVoid SetupManager()

/// <summary>
/// Close all tree view windows.
/// It is assumed that this method is called from a toggle action.
/// </summary>
private void HideCodeView()
{
// If none of the windows were actually closed, we should instead open them.
bool anyClosed = false;
foreach (string city in treeWindows.Keys)
{
space.CloseWindow(treeWindows[city]);
anyClosed |= space.CloseWindow(treeWindows[city]);
}
treeWindows.Clear();
if (!anyClosed)
{
ShowCodeView();
}
}

private void Update()
Expand Down
2 changes: 1 addition & 1 deletion Assets/SEE/Controls/WindowSpaceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void UpdateSpaceFromValueObject(string playerName, WindowSpace.WindowSpac
}

// Close windows which are no longer open
closedWindows.ForEach(windowSpaces[playerName].CloseWindow);
closedWindows.ForEach(x => windowSpaces[playerName].CloseWindow(x));

// Set active window if it changed
if (windowSpaces[playerName].ActiveWindow.Title != valueObject.ActiveWindow.Title)
Expand Down
10 changes: 4 additions & 6 deletions Assets/SEE/UI/Window/WindowSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,14 @@ public void AddWindow(BaseWindow window)
/// </summary>
/// <param name="window">The window which should be closed.</param>
/// <exception cref="ArgumentNullException">If the given <paramref name="window"/> is <c>null</c>.</exception>
public void CloseWindow(BaseWindow window)
/// <returns><c>true</c> if the window was closed, <c>false</c> otherwise.</returns>
public bool CloseWindow(BaseWindow window)
{
if (window == null)
if (ReferenceEquals(window, null))
{
throw new ArgumentNullException(nameof(window));
}
else if (windows.Contains(window))
{
windows.Remove(window);
}
return windows.Remove(window);
}

/// <summary>
Expand Down

0 comments on commit 347fa6d

Please sign in to comment.