Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored actions logic into it's own component #25

Merged
merged 3 commits into from
Mar 25, 2019

Conversation

kkjamie
Copy link
Contributor

@kkjamie kkjamie commented Mar 22, 2019

Resolves issue #22

Key points:

  • Moved code into a new component, The same APIs exist they just call the inner componnet's functions.
  • Back & Folder characters are now serialized rather than a static property (Breaking API change)
  • Exposed UseNavigation for public read, so the new component can access it

private DebugMenuItemNode rootNode;
private DebugMenuItemNode currentPageNode;

private void Awake()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't get the awake call right away since this object is disabled to begin with, we must manually initialize it

@@ -59,19 +57,22 @@ public static DebugMenu Instance
private Button actionButtonTemplate;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be removed as it was moved to the other file


if (ButtonPathExists(path))
{
throw new Exception($"Cannot add button at {path}. A button/folder already exists!");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent with previous two lines (one line throw).


if (!ButtonPathExists(path))
{
throw new Exception($"Cannot remove the button {path}. It does not exist.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same. Inconsistent with the previous line (one line throw).

{
if (currentNode.ContainsChild(part))
{
currentNode = currentNode.GetChild(part);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it faster if you just GetChild then do a null check, rather than check ContainsChild first then GetChild?

@kkjamie kkjamie merged commit 3efd76e into development Mar 25, 2019
{
var backButton = Instantiate(actionButtonTemplate, actionButtonTemplate.transform.parent, false);
backButton.GetComponentInChildren<Text>().text = $"{backCharacter} Back";
backButton.onClick.AddListener(() => { SetupPage(node.Parent); });
Copy link
Contributor

@borntocompile borntocompile Apr 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor:
You can do backButton.onClick.AddListener(() => SetupPage(node.Parent));

}

var label = actionButton.GetComponentInChildren<Text>();
label.text = button.Name + (button.IsFolder ? $" {folderArrowCharacter}" : "");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer string.Empty over "", for me it adds intent to it so I know its not a mistake.

label.text = button.Name + (button.IsFolder ? $" {folderArrowCharacter}" : "");
actionButton.gameObject.SetActive(true);

firstChild = (firstChild != null) ? firstChild : actionButton.gameObject;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parenthesis are redundent

currentNode.AddFolder(part);
}
}
actionsPage.AddButton(path, action,hideDebugMenuOnClick);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a space after the second comma

@kkjamie kkjamie mentioned this pull request Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants