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

Support a secondary right-click action for items #15

Closed

Conversation

fleskesvor
Copy link
Collaborator

This commit enables a simple two-click interface by exposing a secondary action on items. The clicked() function in the game node takes a third parameter, which is the event.button_index when called from item nodes, but defaults to 1 (BUTTON_LEFT) when called from the other .gd scripts which calls the function (background.gd and global_vm.gd).

The example scene has been updated to support this interface, with the exception of the box item, which currently supports three actions, so the puzzle would need changing.

punto- and others added 25 commits August 10, 2016 07:42
fixed incorrect example using "global_set"
Merge from flossmanuals booksprint
Avoids having the TextureFrame/Control node to catch input events, thus allowing other node types to catch input events.
… items.

Create Area2D>CollisionPolygon2D structure and set script to item_background.gd to use
Needs definition of a mask image (transparent on masking areas, white elsewhere). Create a Light2D node (Mask mode), set its texture to the previous image and set the terrain node's nodepath. Also add a child 'front_pos' Position2D to define the Y position from which the player is hidden if behind the mask.
@fleskesvor
Copy link
Collaborator Author

I have also updated box.esc, since there's now only use+look actions, instead of the original pick_up+open+look, so trying to pick up the box or open the newspaper is no longer possible.

@fleskesvor
Copy link
Collaborator Author

Added an example event script that can be added to the box by setting "use" and "look" on "Action" and "Secondary Action".

New scripts for background items, input management and player masking
@StraToN
Copy link
Collaborator

StraToN commented Apr 20, 2017

Very interesting indeed, I like it, it seems to behave a bit more like SCUMM, which is cool.
I'll test this now.
edit: I've been busy with #4 so I couldn't test. Will do in the evening.

@fleskesvor
Copy link
Collaborator Author

I've found out that the secondary action is never applied when used on inventory items, so that needs sorting out. I'm not able to combine items in the inventory either, but I'm not sure yet if I've configured that correctly from the editor.

@StraToN
Copy link
Collaborator

StraToN commented Apr 21, 2017

@fleskesvor Do you want to correct it before I merge? Merging it now should affect Escoria a lot, but you can then start an issue and PR your correction later ;)

@fleskesvor
Copy link
Collaborator Author

I won't be able to make any corrections for several hours, but either way is fine with me. If you believe those effects are mostly beneficial, I'm fine with you merging it now. Otherwise, I'll try to get a new commit in tonight (CET).

@StraToN
Copy link
Collaborator

StraToN commented Apr 21, 2017

@fleskesvor Well, we're not in a hurry ;) Let's just wait so you can fix it nice and good.

@fleskesvor
Copy link
Collaborator Author

I added secondary action to inventory items and added an example event script to the ice cream in the inventory. Decided to give the extra parameter in interact() in game.gd an extra parameter rather than set the value from everywhere it's called, since that's a lot of places. Default values work exactly the same as in Python, right? I've tested, and can't see that I've broken anything, but there seems to be lots of corner case handling in the scripts that I haven't grasped fully yet.

Maybe it would be better if clicked() also took a default value of MOUSE_LEFT for the button_index parameter, since we're only passing on the action button_index from one of the places the function is called from anyway. If so, background.gd and global_vm.gd wouldn't have to be changed at all.

@fleskesvor
Copy link
Collaborator Author

fleskesvor commented Apr 22, 2017

Everything should be working now. However, I've removed the one-click actions on test.scn and inventory_items.scn from the commit, so to test, one needs to add 'pick_up' and 'look' as actions on the can and ice cream in the test scene, and 'use' and 'look' as actions on the can and ice cream in the inventory.

The reason why I removed the actions is that a left-click action ('Action') can not be defined on an item if a user wants to use a traditional verb interface, so it would only serve to confuse new users. However, it is possible to set a 'Secondary Action' while using a verb interface, which means a developer can choose to set a "short-cut" action on items while still using a verb interface, like some of the classics used to have.

@fleskesvor
Copy link
Collaborator Author

An issue that is more pronounced with this interface, that is already present in Escoria (on a fresh clone) with the standard verb interface, is that actions which trigger player dialogue needs an extra click to "reset", so to speak. Eg., if you look at the can with the look action enabled from the interface, you can't immediately look at the ice cream. You have to make the dialogue go away first. It feels a bit clunky once you're aware of it.

@fleskesvor
Copy link
Collaborator Author

I gave the new input variable "button_index" in game.gd's clicked() function a default value (BUTTON_LEFT), as I'd already done with interact(). I also moved the changes in test.scn plus some test scripts to a separate test branch, test/secondary-item-action, to reduce the number of changes in this PR, and thus make it easier to review.

eh-jogos and others added 4 commits June 11, 2017 14:33
Adjusting the markdown so the document is more readable, and code comments doesn't become text headers.
Improve Documentation's text formating with Markdown
* Merge item_background.gd into item.gd
@StraToN
Copy link
Collaborator

StraToN commented Sep 18, 2017

@fleskesvor Can you fix the conflict? I'll try to fix #4 so we can have it working on Godot 3.0. I'd love to have this PR merge soon after ^^.

@fleskesvor
Copy link
Collaborator Author

Yeah, I'll fix the conflict, tidy it up a bit and squash it into one commit. Sorry for forgetting about this one for so long.

@fleskesvor
Copy link
Collaborator Author

I've fixed the conflict and cleaned up the commit history. I'm going to check if it's working as intended now.

@fleskesvor
Copy link
Collaborator Author

I've updated my test branch too, and it works as intended in my testing.

One possible gotcha though, is that if 'use' is your secondary action, you must also use right-click to confirm that 'use' action when combining items, which might not be intuitive. It's the reason why I've defined 'look' as the secondary action and 'pick_up'/'use' as the primary action in my test branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants