Creating a Sierra-style interface with highlighting cursors

Started by Akril15, Thu 11/03/2010 09:56:16

Previous topic - Next topic

Akril15

Hello,

It's been a while since I've posted here. I'm creating a game that uses an interface that uses the Sierra-style icon bar with cursors that highlight over hotspots, characters and objects (sort of a hybrid between the King's Quest V/VI interface and the King's Quest VII interface). This was a lot harder than I thought it would be at first, but I think I'm close to success.

In my game, the standard Look, Interact and Talk cursors have a "grayed-out" appearance, and I've created three similar ones that are much more striking. In the following code, the lowercase modes are the grayed-out cursors and the all-caps ones are the highlighted cursors (except for the last part). Whenever the cursor moves over a character, the mouse cursor changes from the un-highlighted cursor to the highlighted one:

Code: ags

//highlight mouse if over a character
if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter)
{
if (mouse.Mode == eModeTouch){
 Mouse.SaveCursorUntilItLeaves();
mouse.Mode = eModeINTERACT;
}

if (mouse.Mode == eModeLookat){
 Mouse.SaveCursorUntilItLeaves();
mouse.Mode = eModeLOOK;
}

if (mouse.Mode == eModeTalkto){
 Mouse.SaveCursorUntilItLeaves();
mouse.Mode = eModeTALK;
}

if (mouse.Mode == eModeUseinv){
 Mouse.SaveCursorUntilItLeaves();
mouse.Mode = eModeactiveinv;
}
}//end


This code seems to work pretty well, but I've found that unhandled_event won't work if I try looking at, touching or talking to a hotspot, character, or object with no response message assigned to it (probably because I'm not using the standard cursors to interact with the game's elements).

I've also noticed that I can't scroll through all the icons if my current icon is highlighted. This is due to un-checking the highlighted icons' "Standard cursor mode" boxes -- checking them fixes this problem, but makes me scroll through both the highlighted and un-highlighted icons if my current icon is un-highlighted. I suppose DisableMode might be able to correct this, but I'm not quite sure how at the moment.

I also can't seem to get the cursor to highlight over the items in my custom inventory window (which is essentially an improved version of the AGS default inventory). I did a search on it and found that InventoryItem.GetAtScreenXY would fix that problem but wasn't able to get it to work. However, I decided that I could live without this since there doesn't seem to be a code that allows something to happen when the mouse is over a GUI button --  having the cursor highlight over inventory items but not the buttons on the inventory GUI (or any of the other GUIs' buttons) would seem a bit awkward.

Is there anything I can do to repair these fairly minor flaws, or better yet, is there a game template I might have overlooked that uses a similar system?

EDIT: I forgot to mention that I'm using AGS 2.72, and with this system I have to enter all of the custom interaction commands under "Any click on hotspot/character/object" in the Interaction Editor. In a way, this is actually a bit simpler than creating several new "Run Script" actions under the various interactions.

tzachs

There's already a built in functionality for cursor hovering in AGS. You don't need two cursor modes for each mode, remove the duplicate modes and stick with the original ones.
Look in the designer at the cursors, you will see there the ability to set two views, the normal view and the hovered view.
Simply create two views, each one with a single frame (one normal and the second hovered) and set them, and also set the Animate & Animate on hotspots to true.
That should do the trick...

Khris

True, but that wasn't implemented until one of the 3.x versions.

Apart from my usual advice in that case (Switch to the current version ASAP!):

Don't use additional cursor modes but rather change the cursor mode's sprite.
You can do that using
  mouse.ChangeModeGraphic(eModeLook, 10);  // change look cursor sprite permanently to slot 10

A fast way to do this is to use specific sprite numbers for the cursors.

eModeLook and it's colleagues are actually ints (the numbers in the list):

eModeLookat: 1
eModeInteract: 2
eModeTalkto: 3
eModeUseinv: 4

Simply use consecutive numbers for the sprites, using the order above, first the four standard images, then the highlighted ones.

Then use:
Code: ags
  int ci = FIRST_SPRITE_SLOT - 1;
  int mm = mouse.Mode;

  if (mm != eModeWalkto) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) mouse.ChangeModeGraphic(mm, mm + ci);
    else mouse.ChangeModeGraphic(mm, mm + ci + 4);
  }

Akril15

Well, I've been occasionally experimenting with AGS 3.1.2 for a while, but the new interface was so difficult for me to get used to that I decided to stick with AGS 2.72 until I absolutely had to upgrade...but it looks like that time is now.

And it's probably just as well that I'm finally switching over to version 3, since the template I was using was crammed full of obsolete code that would probably have ended up causing me problems even if I did stick with 2.72. Still, thank you very much for your advice, Kris.

The only problem I seem to have left is the matter of dealing with the inventory items. I decided to have the inventory cursors be small, black and white versions of the items they represented (again, like King's Quest V and VI), but since there are a lot of them, I tried implementing the two-cursor system I described earlier and having the activeinv cursor change to a sprite that was the highlighted version of whatever the useinv cursor was, like so:
Code: ags
//change highlighted cursor depending on which inventory item is selected
if (player.ActiveInventory == iRock) {
  Mouse.ChangeModeGraphic(eModeactiveinv, 2023);
  } //end

It seems like switching to the animated cursor mode means that I'll have to create a separate view for each inventory item, but since AGS offers you unlimited views, I won't mind spending a bit of time creating them.

Thanks again, you two.

SMF spam blocked by CleanTalk