Skip to content

Commit

Permalink
feat(Menu): added Repaint and Close methods in DMContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Iam1337 committed Dec 21, 2021
1 parent 91188d1 commit 0696a86
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
24 changes: 12 additions & 12 deletions Assets/extDebug/Scripts/Menu/DM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ public struct ColorScheme
};

// Container
public readonly static DMContainer RootContainer = new DMContainer("Debug Menu");
public readonly static DMContainer Container = new DMContainer("Debug Menu");

public static DMBranch Root => RootContainer.Root;
public static DMBranch Root => Container.Root;

public static bool IsVisible => RootContainer.IsVisible;
public static bool IsVisible => Container.IsVisible;

public static IDMInput Input
{
get => RootContainer.Input;
set => RootContainer.Input = value;
get => Container.Input;
set => Container.Input = value;
}

public static IDMRender Render
{
get => RootContainer.Render;
set => RootContainer.Render = value;
get => Container.Render;
set => Container.Render = value;
}

// Notice
Expand All @@ -83,11 +83,11 @@ static DM()
Hooks.OnGUI += OnGUI;
}

public static void Open() => RootContainer.Open();
public static void Open() => Container.Open();

public static void Open(DMBranch branch) => RootContainer.Open(branch);
public static void Open(DMBranch branch) => Container.Open(branch);

public static void Back() => RootContainer.Back();
public static void Back() => Container.Back();

public static void Notify(DMItem item, Color? nameColor = null, Color? valueColor = null) => Notice?.Notify(item, nameColor, valueColor);

Expand Down Expand Up @@ -163,12 +163,12 @@ static DM()

private static void Update()
{
RootContainer.Update();
Container.Update();
}

private static void OnGUI()
{
RootContainer.OnGUI();
Container.OnGUI();
}

#endregion
Expand Down
25 changes: 22 additions & 3 deletions Assets/extDebug/Scripts/Menu/DMContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,34 @@ public void Open(DMBranch branch)

IsVisible = true;
}


public void Close()
{
while (_previousBranch != null)
{
_currentBranch.SendEvent(EventArgs.CloseBranch);
_currentBranch = _previousBranch;

_branchesStack.Pop();
}

_currentBranch.RequestRepaint();

IsVisible = false;
}

public void Repaint()
{
_currentBranch.RequestRepaint();
}

public void Back()
{
if (_previousBranch != null)
{
_currentBranch.SendEvent(EventArgs.CloseBranch);

_currentBranch = _previousBranch;
_currentBranch.SendEvent(EventArgs.OpenBranch);
//_currentBranch.SendEvent(EventArgs.OpenBranch); // INFO: Is required?
_currentBranch.RequestRepaint();

_branchesStack.Pop();
Expand Down

0 comments on commit 0696a86

Please sign in to comment.