Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Huw Dawson on Sat 12/02/2005 21:28:11

Title: Discworld-style, fixed mouseover descriptions
Post by: Huw Dawson on Sat 12/02/2005 21:28:11
Ok. My personal two favorite adventure games are Discworld 1 and 2. In them, when you rolled over a thing you could look at or interact with (even a person or item) it would display a piece of text over the object (like if I were looking at a house, rolling the mouse over the house would make the words "house" appear in the middle of the house hotspot)

I want to emulate this. How?  ???
Title: Re: Dispaying text by rolling over object/hotspot
Post by: strazer on Sat 12/02/2005 22:17:30
Create a new GUI, put a Label control on it, change the label's text to @OVERHOTSPOT@, uncheck the GUI's "Clickable" checkbox and put


SetGUIPosition(THENEWGUISNAME, mouse.x, mouse.y);


in the repeatedly_execute function (menu "Script" -> "repeatedly_execute").

This has been asked many times before, try a forum search (http://www.adventuregamestudio.co.uk/yabb/index.php?action=search) next time.

Oh, and Welcome to the forums! :)
Title: Re: Dispaying text by rolling over object/hotspot
Post by: Huw Dawson on Sun 13/02/2005 15:33:50
That's not really what I asked for. I want to have the text at a specific place on the hot spot when I roll over it, not moving with the mouse.

And I did search. I found nothing so I posted.  :)
Title: Re: Dispaying text by rolling over object/hotspot
Post by: strazer on Sun 13/02/2005 15:57:09
Ah, I didn't know Discworld does it like that.
Ok, then I would do all of the above except the rep_ex part, then:
Create two custom number properties, for example "descx" and "descy" where you can enter where the GUI should appear for each hotspot/character/object, then in repeatedly_execute:


  //...

  int newguix, newguiy; // declare variables that will hold the GUI's new position

  int overwhat = GetLocationType(mouse.x, mouse.y); // get what the mouse cursor is over

  if (overwhat == 1) { // if mouse is over a hotspot
    // get this hotspot's gui position values from its properties:
    newguix = GetHotspotProperty(GetHotspotAt(mouse.x, mouse.y), "descx");
    newguiy = GetHotspotProperty(GetHotspotAt(mouse.x, mouse.y), "descy");
  }
  else if (overwhat == 2) { // if mouse is over a character
    newguix = GetCharacterProperty(GetCharacterAt(mouse.x, mouse.y), "descx");
    newguiy = GetCharacterProperty(GetCharacterAt(mouse.x, mouse.y), "descy");
  }
  else if (overwhat == 3) { // if mouse is over an object
    newguix = GetObjectProperty(GetObjectAt(mouse.x, mouse.y), "descx");
    newguiy = GetObjectProperty(GetObjectAt(mouse.x, mouse.y), "descy");
  }

  SetGUIPosition(THENEWGUISNAME, newguix, newguiy);

  //...


Edit: Fixed typos, added indentation.
Title: Re: Dispaying text by rolling over object/hotspot
Post by: Huw Dawson on Sun 13/02/2005 16:41:56
How do I get it to display OVER the hotspot rather than at the top-left of the screen?

EDIT:

I've done it. Just modify the two numbers on the box after you click off the "properties box, right? Thanks a million.  ;D
Title: Re: Dispaying text by rolling over object/hotspot [SOLVED]
Post by: strazer on Mon 14/02/2005 14:19:04
Hm, since objects and characters can move around, it's probably better not to use fixed positions for the gui but rather use descx/descy as offsets from the object's/character's current position, i.e.:


  //...
  else if (overwhat == 2) { // if mouse is over a character
    int charid = GetCharacterAt(mouse.x, mouse.y);
    newguix = character[charid].x + (GetCharacterProperty(thechar, "descx"));
    newguiy = character[charid].y + (GetCharacterProperty(GetCharacterAt(mouse.x, mouse.y), "descy"));
  }
  else if (overwhat == 3) { // if mouse is over an object
    int objid = GetObjectAt(mouse.x, mouse.y);
    newguix = GetObjectX(objid) + (GetObjectProperty(objid, "descx"));
    newguiy = GetObjectY(objid) + (GetObjectProperty(objid, "descy"));
  }
  //...


Edit: Added code for objects.
Title: Re: Dispaying text by rolling over object/hotspot [SOLVED]
Post by: Huw Dawson on Mon 14/02/2005 21:23:51
So, In total:


  int newguix, newguiy; // declare variables that will hold the GUI's new position

  int overwhat = GetLocationType(mouse.x, mouse.y); // get what the mouse cursor is over

  if (overwhat == 1) { // if mouse is over a hotspot
    // get this hotspot's gui position values from its properties:
    newguix = GetHotspotProperty(GetHotspotAt(mouse.x, mouse.y), "descx");
    newguiy = GetHotspotProperty(GetHotspotAt(mouse.x, mouse.y), "descy");
  }
  else if (overwhat == 2) { // if mouse is over a character
    int charid = GetCharacterAt(mouse.x, mouse.y);
    newguix = character[charid].x + (GetCharacterProperty(GetCharacterAt(mouse.x, mouse.y), "descx"));
    newguiy = character[charid].y + (GetCharacterProperty(GetCharacterAt(mouse.x, mouse.y), "descy"));
  }
  else if (overwhat == 3) { // if mouse is over an object
    int objid = GetObjectAt(mouse.x, mouse.y);
    newguix = GetObjectX(objid) + (GetObjectProperty(objid, "descx"));
    newguiy = GetObjectY(objid) + (GetObjectProperty(objid, "descy"));
  }

  SetGUIPosition(THEGUINAME, newguix, newguiy);
Title: Re: Discworld-style, fixed mouseover descriptions
Post by: SSH on Tue 02/05/2006 16:12:54
Also, the Description module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26306.0) now does something liek this with its "Sticky" mode. If anyone would like a different functionality to be more Discworldly, please let me know details...