deep-entertainment / issues

Issue tracker for deep Entertainment projects
1 stars 0 forks source link

New feature: Allow mouse actions while playing Parrot dialog #23

Closed ThmsKnz closed 2 years ago

ThmsKnz commented 2 years ago

Please make sure you talk to the community before creating an issue.

Project:

Is your feature request related to a problem? Please describe. Many Carol Reed games contain an 'action' scene where there is a dialog playing and you have to perform some hotspot action while a dialog is being played. EgoVenture does not support this as LeftMouse clicks are used to skip the dialog.

Describe the solution you'd like I'm proposing a solution how I've extended Parrot (and EgoVenture) to support mouse actions while playing a dialog.

_1) parrotdialog.gd extension

Adding a new boolean parameter 'no_skip'.

# Parrot extension - ignore input events if set to true
var no_skip = false

and modifying the _input event that the event is ignored when no_skip is set:

# Skip the line on ui_skip action
func _input(event):
    if _dialog_playing and event.is_action_released("ui_skip") and \
            (_timer_length - $Timer.time_left) > DURATION_NO_SKIP and \
            !no_skip:
        advance()
        get_tree().set_input_as_handled()

2) Helper function that I've added to core.gd

This is to enable and disable 'actions' while playing a dialog. It introduces a new game state (default = false) which is important for loading. This helper function could of course get embedded to Parrot directly. I just wanted to keep the modification as minimal as possible.

# Function to let Parrot ignore mouse events (needed in action scene)
func set_parrot_ignore_input_events(state: bool):
    (EgoVenture.state as GameState).parrot_ignore_input_events = state
    if state:
        Parrot.no_skip = true
        Parrot.get_node("VBox").mouse_filter = Control.MOUSE_FILTER_IGNORE
        Parrot.get_node("VBox/Spacer").mouse_filter = Control.MOUSE_FILTER_IGNORE
        Parrot.get_node("VBox/Skip").mouse_filter = Control.MOUSE_FILTER_IGNORE
        Parrot.get_node("VBox/Skip/Panel").mouse_filter = Control.MOUSE_FILTER_IGNORE
    else:
        Parrot.no_skip = false
        Parrot.get_node("VBox").mouse_filter = Control.MOUSE_FILTER_PASS
        Parrot.get_node("VBox/Spacer").mouse_filter = Control.MOUSE_FILTER_STOP
        Parrot.get_node("VBox/Skip").mouse_filter = Control.MOUSE_FILTER_STOP
        Parrot.get_node("VBox/Skip/Panel").mouse_filter = Control.MOUSE_FILTER_STOP

3. Set the 'parrot action mode' when loading a game I used the _on_load function in core.gd to set mode when loading a new game.

func _on_load():
    # set Parrot mode when loading a game
    set_parrot_ignore_input_events((EgoVenture.state as GameState).parrot_ignore_input_events)

It would be nice if you could include this into Parrot and EgoVenture accordingly. Maybe Carol will face such an 'action scene' in one of the upcoming adventures. :-)

dploeger commented 2 years ago

I've implented this in the branch named "issue-23". Could you kindly try that branch out. I've changed the code and naming a bit. You can use Egoventure.set_parrot_skip_enabled to false to disable skipping.

Thanks

ThmsKnz commented 2 years ago

I've tested it, but encountered some situations after loading where the dialog from the previous scene wasn't properly canceled. I then remembered that there was another small parrot change needed that I missed to mention above (sorry about that). The parameter _dialog_playing needs to get reset when canceling a dialog (which is called when loading a new game).

# Cancel the currently running dialog
func cancel():
    $Voice.stop()
    $VBox.hide()
    $Timer.stop()
    # Parrot extension: sets _dialog_playing to false when new game is loaded
    _dialog_playing = false
dploeger commented 2 years ago

Ah, you're right. I've added a commit with that fix. Can you try again please?

ThmsKnz commented 2 years ago

Perfect. Works like a charm.

dploeger commented 2 years ago

Awesome. Thanks. Merged.