Discworld-style, fixed mouseover descriptions

Started by Huw Dawson, Sat 12/02/2005 21:28:11

Previous topic - Next topic

Huw Dawson

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?  ???
Post created from the twisted mind of Huw Dawson.
Not suitible for under-3's due to small parts.
Contents may vary.

strazer

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

Code: ags

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 next time.

Oh, and Welcome to the forums! :)

Huw Dawson

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.  :)
Post created from the twisted mind of Huw Dawson.
Not suitible for under-3's due to small parts.
Contents may vary.

strazer

#3
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:

Code: ags

  //...

  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.

Huw Dawson

#4
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
Post created from the twisted mind of Huw Dawson.
Not suitible for under-3's due to small parts.
Contents may vary.

strazer

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.:

Code: ags

  //...
  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.

Huw Dawson

So, In total:

Code: ags

  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);
Post created from the twisted mind of Huw Dawson.
Not suitible for under-3's due to small parts.
Contents may vary.

SSH

Also, the Description module 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...
12

SMF spam blocked by CleanTalk