adventuregamestudio / ags

AGS editor and engine source code
Other
708 stars 159 forks source link

Pass mouse position into "on_mouse_click" script callback #2470

Closed ivan-mogilko closed 4 months ago

ivan-mogilko commented 4 months ago

Resolves #2468

  1. Refactored "game events" code inside the engine. This is the first big commit, details may be found in commit's description. Functionality must remain the same, but the event parameters are stored more explicitly now.
  2. Added coordinate parameters to "on_mouse_click" callback, now it should be declared as:
    function on_mouse_click(MouseButton button, int mx, int my)
  3. Added similar parameters to "dialog_options_mouse_click", now it should be declared as:
    function dialog_options_mouse_click(DialogOptionsRenderingInfo *info, MouseButton button, int mx, int my)

    These changes are fully backwards compatible, as the engine was previously taught to skip trailing parameters if the script has declared these functions with less number of arguments.

ericoporto commented 4 months ago

The refactor changes are good and the other changes appear alright too. Later, is it needed to include position for the OnClick GUI/Button events, created by the editor, too?

ivan-mogilko commented 4 months ago

Later, is it needed to include position for the OnClick GUI/Button events, created by the editor, too?

I don't think so, the OnClick event are corresponding to the sole fact of control being interacted, not where (this corresponds to interaction events of characters and others).

We might need a separate event for mouse (or pointer device) being pressed down on a gui layer, or merge this in "on_mouse_click".