Click/RunInteraction extension to script API

Started by Crimson Wizard, Tue 18/11/2014 11:29:47

Previous topic - Next topic

Crimson Wizard

Hereby I state a proposal to add a bunch of clicking/interacting simulating functions to AGS, based on past user problems and suggestions.
E.g. this: http://www.adventuregamestudio.co.uk/forums/index.php?topic=48445.0

Mouse.Click(MouseButton)
Fires mouse click event. This should not do any extra tests, just make a click, as if human pressed mouse button.
For instance, this will also skip cutscenes and call on_mouse_click function.
Because of how AGS works this click will run only after current script has ended.
The click is performed at current mouse coordinates. Why: the on_mouse_click scripts use mouse.x and mouse.y to know where the click occured. If we let user define coordinates as well, the logic will be broken, so it is of little use.

ProcessClick -> Room.ProcessClick(x, y, mode)
Move global ProcessClick() function to Room class (as static method). This is not only further OO-ing, but will also make it more clear for users that this simulates only clicks on room contents (e.g. not on GUI).

GUI.ProcessClick(x, y, MouseButton)
Static method.
Simulates a mouse click on screen, but affects only GUI, as opposed to old (Room.)ProcessClick.
This should simulate click on GUI frames and their controls at given position.

GUI.Click(MouseButton), GUIButton.Click(MouseButton)
Object method.
Triggers OnClick event on GUI or GUIButton, if it is present. Compareable to RunInteraction.
Because of how AGS works the event functions will run only after current script has ended. RunInteraction() does the same. You may, however, queue multiple Clicks.

Gurok

I applaud the change from ProcessClick->Room.ProcessClick
Should GUI.OnClick() and GUIControl.OnClick() take a parameter for mouse button?
I understand you're following C# style syntax with OnClick, but to be honest, GUI.Click() and GUIControl.Click() are more immediately grokkable to me.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

Quote from: Gurok on Tue 18/11/2014 11:43:06
Should GUI.OnClick() and GUIControl.OnClick() take a parameter for mouse button?
Right, OnClick event has mouse button argument, so they shoould.

Quote from: Gurok on Tue 18/11/2014 11:43:06
I understand you're following C# style syntax with OnClick, but to be honest, GUI.Click() and GUIControl.Click() are more immediately grokkable to me.
No, I do not follow C# syntax... what is C# syntax? :)
Might go without "On" prefix, since this is not a delegate nor function pointer.

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Crimson Wizard

#4
Done, here's demo build:
http://www.mediafire.com/download/juxme6u8zds54uf/AGS-3.4.0.1--guiclicks-demo.zip
Code branch: https://github.com/ivan-mogilko/ags-refactoring/tree/feature-scapi-clicks

Based on 3.4.0.1 (.0.2 compilation has errors so I used lower version).
This will get to 3.4.0.3 release when its ready.

UPD: replaced package, fixing GUI.ProcessClick not activating inventory items.

Monsieur OUXX

Yes, yes, triple yes!

About the Click/OnClick debate: Is the function meant to simulate a click (as if the user clicked), or intercept a click?
If you simulate a click, then it sould be "Click". If you want to intercept a click and script some actions accordingly, it should be "OnClick"
 

abstauber

Whoops, almost forgot to add some praise to this thread. Hooray :D
Could this already make an appearance in AGS 3.4.0.3?

Crimson Wizard

Quote from: abstauber on Wed 03/12/2014 07:05:23
Whoops, almost forgot to add some praise to this thread. Hooray :D
Could this already make an appearance in AGS 3.4.0.3?
Yes, its already added to our code.
For 3.4.0.3 I will also add dialog extensions, but in order to release it we'd need fixes to monkey_05_06's Editor code. He seem to be busy with his school recently, but if he won't manage I'll try to make fixes myself.

Dualnames

So if i set mouse.position and use mouseclick, will it work perfectly as if i clicked myself on that position?
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Crimson Wizard

Quote from: Dualnames on Sat 06/12/2014 23:41:41
So if i set mouse.position and use mouseclick, will it work perfectly as if i clicked myself on that position?
Yes it should.
It uses same technique as Plugin API's SimulateMouseClick.

SMF spam blocked by CleanTalk