Skip to content

Proposal: "auto" cleaning cutin in script #3352

@guilherme-gm

Description

@guilherme-gm

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:

  1. Simplify this clean up (we need 3 lines for that!)
  2. 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:

  1. We make it explicit that this cutin is related to the dialog and should be closed (or should not) automatically
  2. close and close2 can be used as always for their normal usage, with no worries about cutins
  3. No breaking changes

Cons:

  1. Initial conversion is a bit more cumbersome (can't simply do a RegExp and call it a day)
  2. 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:

  1. Add a 3rd parameter "auto close" (or not auto close)
  2. 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:

  1. Same command
  2. close and close2 can be used as always for their normal usage, with no worries about cutins

Cons:

  1. Somewhat more verbose, specially if we chose that we need to be explicit about auto-closing
  2. Introduces a breaking change if we chose that auto-closing is implicit
  3. Initial conversion is a bit more cumbersome (can't simply do a RegExp and call it a day)
  4. 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:

  1. Show close button and set a flag in the script execution
  2. 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:

  1. No need to convert between emulators
  2. Very straightforward to implement (a simple RegExp should be able to do it)

Cons:

  1. If you need to do close2, you will have to clean up manually
  2. The cutin clean up becomes "implicit" into the close command, while not bad, it is a detail to remember

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions