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

Cleanup TextTyper to use less state #2

Closed
edwardrowe opened this issue Dec 6, 2016 · 1 comment
Closed

Cleanup TextTyper to use less state #2

edwardrowe opened this issue Dec 6, 2016 · 1 comment
Labels

Comments

@edwardrowe
Copy link

edwardrowe commented Dec 6, 2016

The TextTyper has a couple bad smells that I'd like to get rid of:

  • It modifies the iterator (i) when applying tags in the loop
  • It modifies the displayedText member as it loops. This is critical for keeping track of what's been printed, but it can be cleaned up.

Instead I think we should add a function, SplitForTyping that would take a string and an index. It would return a struct that contains a string for the display text, a string for the hidden text, and a list of outstanding tags (which need to be applied but only if they haven't already been applied). Every loop the TextTyper would simply call this function, and act on the data accordingly.

It might not even be a function, but rather a complete class, and it should be unit tested.

edwardrowe added a commit that referenced this issue Mar 9, 2017
This adds a TypedTextGenerator that provides a pure function to return
the print string at a desired place in a line of dialogue. This
resolves some of the issues I had with mishandled state, namely
issue #7 and issue #5.
@edwardrowe
Copy link
Author

Added TypedTextGenerator which is used to generate the print text. I also added unit tests for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant