-
Notifications
You must be signed in to change notification settings - Fork 766
Description
Posting here to see if I can get some feedback before implementing it
Is your feature request related to a problem? Please describe.
This is a proposal to try to improve cutin
cleanup in scripts. Today, when using cutin
in a dialog, we must remember to remove them at the end of the dialog, on every close
(unless, in the very very very few cases that we might want to keep it, we know some scripts in the wild abuse that to make new stuff).
For example:
cutin("fly_felrock", 2);
mes("[Tarlock]");
mes("I am Tarlock,");
close2();
cutin("", 255);
end;
Today, we have about 700 occurrences of that pattern (in a quick RegExp find through herc folder).
My proposal is to provide a way to:
- Simplify this clean up (we need 3 lines for that!)
- If possible, make it harder to forget a clean up
I think someone at rAthena also noticed that, as they currently have close3
command, which does basically the close2 + cutin + end in a single command (more on that in Solutions)
Solutions
I thought about 3 possible solutions, I will write them below and the pros/cons I could think of.
(My preferred) Solution 1. dlgcutin
script command
In this solution, we would introduce a new command: dlgcutin("<file name>", <position>)
This command would be an alias to cutin
, but when used would set a flag in the script execution telling it should clear the cutin up after a close. Rewriting the previous example:
dlgcutin("fly_felrock", 2);
mes("[Tarlock]");
mes("I am Tarlock,");
close(); //<== close2(); could also have been used if we had something to do here, e.g.: warp
If cutin
were to be used after dlgcutin
, the flag would be cleared up -- this would allow scripters freedom to switch between auto closing or not based on their needs.
Pros:
- We make it explicit that this cutin is related to the dialog and should be closed (or should not) automatically
close
andclose2
can be used as always for their normal usage, with no worries about cutins- No breaking changes
Cons:
- Initial conversion is a bit more cumbersome (can't simply do a RegExp and call it a day)
- Conversion between rA and Herc now has one different command to take care of
Solution 2. Extending cutin
Going back to the cutin
syntax:
cutin("<filename>", <position>)
where position:
0 - bottom left corner
1 - bottom middle
2 - bottom right corner
3 - middle of screen in a movable window with an empty title bar
4 - middle of screen without the window header, but still movable
255 - remove
For this solution, my proposal is to either:
- Add a 3rd parameter "auto close" (or not auto close)
- Add a bit flag to the position (like
position | 512
means auto close -- or not auto close)
One thing that would need to be discussed here is whether the default would be to auto close, as is probably used in 99% of the cases, but would introduce a silent breaking change, or require us to explicitly say it should auto close -- and we will have to update every place with the 3rd parameter.
Rewriting the example from before:
cutin("fly_felrock", 2, true);
// or: cutin("fly_felrock", 2 | CUTIN_AUTOCLOSE);
mes("[Tarlock]");
mes("I am Tarlock,");
close(); //<== close2(); could also have been used if we had something to do here, e.g.: warp
Pros:
- Same command
close
andclose2
can be used as always for their normal usage, with no worries about cutins
Cons:
- Somewhat more verbose, specially if we chose that we need to be explicit about auto-closing
- Introduces a breaking change if we chose that auto-closing is implicit
- Initial conversion is a bit more cumbersome (can't simply do a RegExp and call it a day)
- Conversion between rA and Herc now has one different command to take care of
Solution 3. (My least preferred) close3
script command
This would copy how rAthena did it, a new command, close3()
which would:
- Show close button and set a flag in the script execution
- Once player presses the close button, the cutin would be removed
It would be exactly like the close2
+ cutin
+ end
, but in a single command.
Example:
cutin("fly_felrock", 2);
mes("[Tarlock]");
mes("I am Tarlock,");
close3();
Pros:
- No need to convert between emulators
- Very straightforward to implement (a simple RegExp should be able to do it)
Cons:
- If you need to do
close2
, you will have to clean up manually - The cutin clean up becomes "implicit" into the close command, while not bad, it is a detail to remember