Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: AndreasCapek on Tue 29/10/2019 12:43:03

Title: How to check which dialog option is highlighted?
Post by: AndreasCapek on Tue 29/10/2019 12:43:03
Hello!

I'm using AGS 3.4.1. with abstauber's LucasArts GUI - not sure if it makes any difference for my problem.

What I want to do is to check which dialog option the mouse is hovering over. I want to - in certain cases - play a specific animation depending on which option is highlighted.

Seeing as the dialog options can already be highlighted in a different color when the mouse hovers over them, it has to be possible, but I just can't figure it out. What is the variable I need? Do I have to use the dialog script? If yes, can I export it from there and use it in other scripts?

At the moment I just solved it by checking the y-coordinate of the mouse, but that's obviously not a very good solution and breaks apart as soon as the player scrolls down or an option is turned off.
Title: Re: How to check which dialog option is highlighted?
Post by: Khris on Tue 29/10/2019 13:21:13
Does the template use custom dialog options rendering? If not, you will have to implement it.
Next, from the  dialog_options_render  function, track the currently active  ActiveOptionID.

bool wasHoveringOption;

function handleAnim(Dialog* d, int i) {
  bool isHoveringOption = d == dStan && i == 3;
  if (isHoveringOption && !wasHoveringOption) {
    // mouse went over option
    // start animation
  }
  else if (wasHoveringOption && !isHoveringOption) {
    // mouse went left option
    // stop animation
  }
  wasHoveringOption = isHoveringOption;
}

function dialog_options_render(DialogOptionsRenderingInfo *info) {
  handleAnim(info.DialogToRender, info.ActiveOptionID);  // ADD THIS
  // rest of function
}
Title: Re: How to check which dialog option is highlighted?
Post by: AndreasCapek on Tue 29/10/2019 18:47:00
Yes, it does. Thanks a lot, I will try that!