Detecting when dialog intersects a GUI

Started by LeChuck, Mon 04/08/2008 19:39:53

Previous topic - Next topic

LeChuck

I have this optional GUI at the top of the screen that will sometimes show in front of the spoken dialogue if the player has a low y coordinate / standing high up on the screen. What I'm looking for is some way of detecting whether or not the dialog is crossing paths with this GUI so I can push the spoken dialogue further down or increase this GUI's transparency. Is there a way of doing this?

Edit: Thanks Khris, I'll experiment on your code once I get this damn cold out of my system...

Khris

#1
Hmm...

Code: ags
function repeatedly_execute_always() {
  if (IsInterfaceEnabled()) return;   // no talking, so exit the function
  int cc = Game.CharacterCount;
  bool doit = false;
  int i;
  Character*c;
  ViewFrame*vf;
  while (i < cc) {
    c = character[i];
    if (c.Room == player.Room && c.Speaking) {
      vf = Game.GetViewFrame(c.SpeechView, c.Loop, c.Frame);
      int y = c.y - Game.SpriteHeight[vf.Graphic] - 15;
      if (y < 40) doit = true;
    }
    i++;
  }
  if (doit) gGUI.Transparency = 60;
  else gGUI.Transparency = 0;
}


Not tested!

Edit: corrected typos.

LeChuck

Alright! The code you came up with almost seem greek to me!  :P

So I copy pasted into rep_exec_always, except for the very first line, the IsInterfaceEnabled line. I've made some heavy modifications to the interface.


I ended up with this error:

Error: run_rep_exec: error -6 (Error: Array index out of bounds (index:45, bounds: 0..44) in Global script (line 2957) running function 'repeatedly_execute_always'


Line 2957 is this line: c = character[cc];

Can you make any sense of it?


olafmoriarty

My guess is that this is a typo, as the cc variable seems a tiny bit misplaced here. I would change line 2957 to

Code: ags
c = character[i];


Also, change line 2963 to

Code: ags
i++;


My strongest apologies if this doesn't work.

LeChuck

Quote from: olafmoriarty on Wed 06/08/2008 23:52:04
My guess is that this is a typo, as the cc variable seems a tiny bit misplaced here. I would change line 2957 to

Code: ags
c = character[i];


Also, change line 2963 to

Code: ags
i++;


My strongest apologies if this doesn't work.

No need to apologize, it compiles and runs fine.

Now, the transparency increases if the player is standing far up on the screen, but the code doesn't seem to take the size of the spoken dialogue into consideration... For instance, the transparency will change regardless of whether the spoken dialogue is 1 colomns high or 3, as everything depends on the players y coordinate. Likewise, if the player is standing low down on the screen and there is a sentence which is four colomns, that transparency code won't happen.

Khris

QuoteSo I copy pasted into rep_exec_always, except for the very first line, the IsInterfaceEnabled line. I've made some heavy modifications to the interface.
So...? IsInterfaceEnabled() just checks whether there's a blocking thing going on, regardless of any modifications to the interface.

Quotebut the code doesn't seem to take the size of the spoken dialogue into consideration...
Hehe, yeah, well, one COULD use a custom Say function, store the text in a global variable, then in rep_ex_always determine it's height with GetTextHeight(), then use that to adjust the check. (Since unfortunately, there's no Character.GetCurrentUtterance.)
Still, this won't work with text from dialogs, so it's a bit pointless.

In short: there's no way to achieve what you want.

The alternative is to turn off the GUI whenever somebody is talking. That won't look pretty but at least be consistent.

LeChuck

Quote from: KhrisMUC on Thu 07/08/2008 07:59:47
In short: there's no way to achieve what you want.

The alternative is to turn off the GUI whenever somebody is talking. That won't look pretty but at least be consistent.

Cold, harsh and honest. Just how I like it  ;)

SMF spam blocked by CleanTalk