X Tutup
Skip to content

Added double click support#198

Merged
mapedorr merged 12 commits intocarenalgas:developfrom
anthonyirwin82:double-click
Apr 14, 2024
Merged

Added double click support#198
mapedorr merged 12 commits intocarenalgas:developfrom
anthonyirwin82:double-click

Conversation

@anthonyirwin82
Copy link
Contributor

I wanted to be able to use a double click function on hotspots to be able to have an exit hotspot instantly change rooms instead of having to wait for the character to walk there.

Added _on_double_click() to work the same as _on_click() and _on_right_click functions do.

Copy link
Collaborator

@mapedorr mapedorr left a comment

Choose a reason for hiding this comment

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

Just take this into account (I'm not asking you to fix it, since I've been doing some tests and the solution doesn't looks trivial):

The _on_click() is triggered before _on_double_click(), so if you have logic for the _on_click() and excecute a double click, both actions will be triggered. It might be better to introduce a small delay to ensure that the event to be triggered is indeed the double click. This is beneficial because we can use it to address issue #92 .

If you want to try something for this, go ahead. Otherwise, take the comments I did into account and I'll merge the PR once they are done. I can take care of fixing the triggering of both events.

@anthonyirwin82
Copy link
Contributor Author

anthonyirwin82 commented Apr 9, 2024

These changes seem to work fine and should be good to be reviewed again.

To avoid the character walking somewhere else when clicking on the screen when multiple say commands are run by the player I had to put the player say text into a cutscene.

@mapedorr
Copy link
Collaborator

mapedorr commented Apr 9, 2024

After making a couple of tests I'm gonna say I don't like the delay after clicking on things. I would like to see if we can reduce it to 0.1 or even lower. Additionally, with this approach, skipping the animation of the dialogue lines for characters when clicking anywhere on the screen stopped working. That causes the character to move while saying a dialogue line (and I don't like the idea of forcing players to use cutscenes).

Taking these changes as a starting point, I'd like to experiment a bit tomorrow to see if I can reach a solution. If I find that it's going to require many changes, I think the most appropriate course of action will be to remove the wait (and all the awaits related with the click/tap), merge the PR, and then spend more time solving the problem. Something tells me that the root cause lies in a recent change I made in how clicks are detected in PopochiuClickables.

@anthonyirwin82
Copy link
Contributor Author

anthonyirwin82 commented Apr 10, 2024

When I was looking at default millisecond delay and found that Windows was 500 milliseconds and tested that it was painful, that's why I lowered it. I tested what you said about making it 0.1 and found that I sometimes had a single click and double click event come through.

When I tested 0.2 as a value, I did not get any extra unwanted click events and did not notice any delay in movement.

Another thing to think about is we are going to need a click and hold event to have the verb coin interface where you click and hold on a hotspot then a verb coin pops up with the different interaction types.

People making touch screen games may also what a two finger tap and hold to show all the game hotspots. I have also seen single tap and hold on the player character show all the hotspots.

Other events people may want is to have wheel mouse up and down to show or hide the inventory bar.

This is all stuff that visionaire studio can do so is probably something to add at some point. I have attached a screenshot for settings of the mouse control options that I had for a verb coin game. This screen is the global defaults for controlling the game then you had the ability to access the different mouse events on individual hotspots to write custom actions to occur when executed on the hotspot.

visionaire-mouse-events

I have not used popochiu enough to know how the dialog text worked prior to me making changes for the double click. I am pretty sure other engines disable mouse clicking when dialog is playing unless they use a say_background() or something which allows normal gameplay to continue while text is being displayed. This allows a character locked in a jail cell to say something random like "please get me out of here", or a loudspeaker announcing things but does not stop the player from moving.

@mapedorr
Copy link
Collaborator

I tested the update, and 0.2 seconds feel better. We can keep that delay by now while we check if there is a way to avoid it.

We don't disable the mouse while the dialog lines are showing, the GUI just captures the click and stops its propagation. But with the delay that stopped working.

We'll have a say_background() in future versions because other devs have been asking for it. Meanwhile, and before merging your PR, I want to address the issue with the dialog lines. Perhaps after releasing version 2, we can add a configuration option where you can specify whether dialogue lines should or should not block the character's movement, but for now, I would like it to remain as it has worked so far. Here's an example of the desired behavior:

dialog_text_click_behavior.mp4

Another issue I found is that, if you move the cursor after clicking anywhere in the room, the target direction changes if one moves the cursor before the character starts walking:

click_delay_changes_movement_target.mov

…ed(event) instead of PopochiuUtils.is_click_or_touch(event)
… double click code and the delay for single click until better solution is found
… comment to the beginning of the duplicated functions
@mapedorr mapedorr merged commit 72105b9 into carenalgas:develop Apr 14, 2024
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.

2 participants

X Tutup