2 Button Interface

Started by Milo87, Mon 26/04/2010 16:29:11

Previous topic - Next topic

Milo87

I've been working on the interface for my reboot of Dark Lake, and I've got a fairly basic system up and running already. It's based on Revolution's interface (BASS, Broken Sword 1 & 2, etc...).

At the moment each different type of interaction changes the cursor to a default action: Pick up objects, interact with hotspots and talk to people, whilst the right mouse button looks at whatever. However, I'd like to make it slightly more advanced so the default interaction can be changed at runtime like the theodolite in BS 2, where only after distracting the surveyor guy can you pick it up rather than interact with it. I looked into custom properties but they can't be changed at runtime currently, if ever.

Anyone got any suggestions?

Khris

Since you seem to want a specific way of achieving that, I'd be useful to know how exactly you've implemented the interface.
Regardless, two possible ways:

-Use an array of flags and put the index in the custom property.
Leave it to 0 if there's no alternative cursor mode for the object/hotspot/etc.
If there is, set it to an index number specific to the object/hotspot.
In rep_ex, when setting the cursor, read the property and check flag[index], then change the cursor if it's true.
Then set the flag to true as long as the surveyor is distracted.
Downside: you have to keep a list of the indeces.

-Use a function that gets called with room number, hotspot type and number, determines the cursor and resturns it.
Code: ags
int Cursor(int room, LocationType lt, int n) {
  if (room == 2) {
    if (lt == eLocationObject && n == 3) {  // object 3 in room 2
      if (surveyor_is_distracted) return eMousePickup;
      else return eMouseInteract;
    }
    ...
  }
  ...
}

Milo87

At the moment all I have this, pretty simple stuff:

Code: ags

function repeatedly_execute() 
{
  if(GetLocationType(mouse.x, mouse.y) == eLocationHotspot) mouse.Mode = eModeInteract;
  
  else if(GetLocationType(mouse.x, mouse.y) == eLocationCharacter) mouse.Mode = eModeTalkto;
  
  else if(GetLocationType(mouse.x, mouse.y) == eLocationObject) mouse.Mode = eModePickup;
  
  else if(GetLocationType(mouse.x, mouse.y) == eLocationNothing)
  {
    mouse.Mode = eModeWalkto;
    ObjectName.Visible = false;
  }
  
  if(GetLocationType(mouse.x, mouse.y) != eLocationNothing) ObjectName.Visible = true;
  
  ObjectLabel.Text = Game.GetLocationName(mouse.x, mouse.y);
  ObjectName.SetPosition(mouse.x, mouse.y);
}


The way I figured was instead of the mouse.Mode = eModeBlahBlah, setting the mouse mode to the custom property of the hotspot/object/character. Except obviously that's irrelevant since you can't change the properties. I guess another way would be to set the mode according to a variable contained in the hotspot/object/character's code, if that's even possible.

The downside I see with the second option you suggested is that you'd need to code in every conditional statement "if x is y return mouseMode" in the game. A more streamlined solution would be to write a changeDefault() function that can be called with a specific target in mind at points in the script where required. So in the example with the theodolite, after you've got rid of the surveyor, call changeDefault(oTheodolite, eModePickUp).

Khris


Milo87

Ah, wonderful. This should do the trick! Cheers.

SMF spam blocked by CleanTalk