How do I Get Cursor Hotspot?

Started by meese72, Tue 26/04/2011 15:05:51

Previous topic - Next topic

meese72

Is there any current way to find out what a mouse mode's current hotspot coordinates are (x,y)? I only found ChangeModeHotspot.

Any help would be kind of you.

Khris

Not that I know of, what do you need that for? Are you coding a module?

Ryan Timothy B

Unfortunately no. I've had to make a nice fading mouse system for JOI where it would quickly fade the mouse mode graphic from one to another using GUI's and hiding the mouse during the transition.

I unfortunately had to manually script it like so:
Code: ags

  if (Mode == eModePickup)
  {
    this.hX=16;
    this.hY=36;
  }
  else if (Mode == eModeInteract)
  {
    this.hX=23;
    this.hY=23;
  }
  else //..  etc.. etc..


There really is no other way.

monkey0506

You could simply store the editor values in the script in game_start and then any time you actually use ChangeModeHotspot then update the script data. Not actually difficult really, but clearly not as friendly as a GetModeHotspotX/GetModeHotspotY function. You could even make some extender methods.

Code: ags
// GlobalScript.ash

import int GetModeHotspotX(this Mouse*, CursorMode mode);
import int GetModeHotspotY(this Mouse*, CursorMode mode);
import void ChangeModeHotspot2(this Mouse*, CursorMode mode, int x, int y);

// GlobalScript.asc

int MouseHotspotX[];
int MouseHotspotY[];

function game_start()
{
  MouseHotspotX = new int[Game.MouseCursorCount];
  MouseHotspotY = new int[Game.MouseCursorCount];
  // manually establish editor values
  MouseHotspotX[eModeWalkto] = 8;
  MouseHotspotY[eModeWalkto] = 8;
  MouseHotspotX[eModeInteract] = 9;
  MouseHotspotY[eModeInteract] = 10;
  // ..etc.
}

int GetModeHotspotX(this Mouse*, CursorMode mode)
{
  return MouseHotspotX[mode];
}

int GetModeHotspotY(this Mouse*, CursorMode mode)
{
  return MouseHotspotY[mode];
}

void ChangeModeHotspot2(this Mouse*, CursorMode mode, int x, int y)
{
  this.ChangeModeHotspot(mode, x, y);
  MouseHotspotX[mode] = x;
  MouseHotspotY[mode] = y;
}

// ..wherever..

// change mode hotspot

mouse.ChangeModeHotspot2(eModeWalkto, 10, 10);

// get mode hotspot

int x = mouse.GetModeHotspotX(eModeWalkto);
int y = mouse.GetModeHotspotY(eModeWalkto);

meese72

omg that looks complicated! LOL. I see the engine is going open source, is this something that can be added on someone's to-do list?

SMF spam blocked by CleanTalk