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

Add support for custom text modifier using regex #7

Open
tianyume opened this issue Jun 30, 2019 · 3 comments
Open

Add support for custom text modifier using regex #7

tianyume opened this issue Jun 30, 2019 · 3 comments

Comments

@tianyume
Copy link

Add support for custom text modifier using regex, maybe with some examples. In different games, users can use different text modifiers to extract correct texts.

@tinyAdapter
Copy link
Member

I agree. And this is a flexible solution for any “regular” incorrect texts. But there still need some specs. What configuration process can be the most convenient for end-users? You know, if something is related to regex, things could become much more complicated.

As far as I'm concerned, here are the things to take into account:

  • what is the configuration format: an array as parameters for String.replace["/^a(one)b(another)c$/", "{$1}", "[$2]"] ?
  • how does a user test if its regex is OK for specific texts: hot reload middlewares when configuration file is saved, regenerate the last text after hot reload accomplish ?
  • what if something error happened: send error message to the next middleware and show it to the user as the final text ?

Then a big refactor comes...

@tianyume
Copy link
Author

For the configuration, I believe an array of dictionary may be better. For example:
[ { "matcher": "/(.{4,})\\1+/g", "replacer": "$1", "recursive": true // Maybe just use recursive as default } ]
Compared to using an array directly, it's easier to maintain and be validated. Also, if any further changes are needed, we can simply add some more fields to make it compatible to older versions.

For the error message and hot reload, I'd suggest to do the following step by step:

  1. Define the initial configuration format, loading configuration at the start time, add regex replacer feature into current middleware. Building an initial workable solution. (Non hot reload version)
  2. Add error message exposure to the users. Maybe something like adding a debug button, creating a new window displaying all the debug messages. I'm not sure what would be the best practice either. (Seems that the debug messages are either truncated in CMD or broken, I cannot get the full debug messages in CMD)
  3. Add hot reload configuration feature into the whole configuration system. If users can get the raw texts, like in step 2, they can test their regex online. This would be a good UX enhancement but not as urgent as the previous steps.

@tinyAdapter
Copy link
Member

OK, I think this is a feasible solution. But I have no enough time to implement it these days...You may see that there are so many plans in this repo, maybe after a month or two can I finish all my work and thus turn to implement these features. 😥

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

No branches or pull requests

2 participants