Suggestion about moving status bar

Started by BorisZ, Sat 02/10/2004 08:54:31

Previous topic - Next topic

BorisZ

I need a suggestion: What kind of scripting do you think is best for making follow-mouse status bar (you know, when you move moves over hotspot and name of object appearrs near cursor). Is it better done by setting empty string to an empty hotspot (one that covers all "uncovered areas"), or by GUIoff when cursor moves over them? Any other suggestions?

monkey0506

#1
You could try:

1. Read the manual.
2. Look for SetGUIPosition.
3. Reread the manual.
4. Don't post until after you have read the manual.
5. Try:

function repeatedly_execute(){
Ã,  SetGUIPosition(YOURGUINAMEHERE, mouse.x+10, mouse.y+10);
Ã,  }

6. Replace YOURGUINAMEHERE with the Name OR Number of your Status Bar GUI.
7. Correct the +10s to whatever offset of the mouse position you want the status bar to appear.
8. Read the manual.

Thank you for your time.

strazer

Yeah, and just put a label on that GUI with "@OVERHOTSPOT@" as its text.

monkey0506

I presumed he knew what code to use for that... Oh well. You didn't correct me, so I presume that means my code was correct. YAY!

Phemar


Or alternately you could do this: (with overlays. It comes from room script and I'm sure you could move it to global yourself.)

int over;string hot;
#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(int button) {
  if (button==LEFT) {
    ProcessClick (mouse.x,mouse.y,MODE_USE);}
  else if (button==RIGHT) {
    ProcessClick (mouse.x,mouse.y,MODE_LOOK);}
  ClaimEvent ();}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart repeatedly_execute  //DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute () {
    if (IsOverlayValid(over)) {
      GetLocationName(mouse.x,mouse.y,hot);
      SetTextOverlay (over,mouse.x+10,mouse.y-10,5,1,15,hot);}}
#sectionend repeatedly_execute  //DO NOT EDIT OR REMOVE THIS LINE
#sectionstart room_b  // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
  // script for room: Player enters screen (after fadein)
  GetLocationName (mouse.x,mouse.y,hot);
  over=CreateTextOverlay(mouse.x+10,mouse.y-10,5,1,15,hot);}
#sectionend room_b  // DO NOT EDIT OR REMOVE THIS LINE

That's all really.

TerranRich

Like monkey suggested, read the manual. Specifically, look under "GUI". It's all there.
Status: Trying to come up with some ideas...

BorisZ

Oh, my God! Please don't spank me! I know how to do all that: all I wanted to know is what do you suggest (AKA how's it ussualy done) if it's better to hide GUI's or set  blank variable if there is no object/hotspot.

monkey0506

Hah... Well, that's a different story now isn't it? I don't remember. Is it possible to post a poll in these forums? If so, that would probably have been the safest way to ask that kind of question... Anyways, I'd probably go with my script, not just because I came up with it, but also because it's shorter, and I don't see the benefit of using the overlay method...

TerranRich

Oh! I'm sorry, BorisZ, I misunderstood. I suggest keeping the GUI open but blank. Perhaps put some other info on the bar to justify keeping it open. But having it disappear everytime there are not hotspots under the mouse cursor would distract the player.

Was I right on?
Status: Trying to come up with some ideas...

BorisZ

well, it is fully transparent (except for label), I don't know how would it distract player if he doesn't see it. There is just one problem that I encountered, but I solved it already: once user moves cursor to bottom of screen, there is an error message- I just put status above the cursor if it is close to bottom.
Thanks for all replies!

Ashen

#10
QuoteThere is just one problem that I encountered, but I solved it already: once user moves cursor to bottom of screen, there is an error message- I just put status above the cursor if it is close to bottom.
I tried something similar, and had the same problem near the far right of the screen - GUI set to invalid co-ordinates. (See code below for my slightly more complicated solution.)

MINOR THREADJACK:
Don't know if this really belongs here, but it's not worth starting a new tread for. Let me know if it's a problem, and I'll edit it out.
I'm playing around with a new interface, using the moving Status GUI idea. Basically, all my cursors are the same plain grey arrow, but a GUI follows the cursor telling you what mode you're in and, if needed, what you're trying to use it on - for example in 'Talk' mode, it says 'Talk', and when you move over Roger, it changes to 'Talk to Roger', in 'Use Inv', it displays the name of the active inventory item, and changes to 'Use XX on YY' when you roll over a character, object or hotspot. Anyway, here's the code I'm using, I just wondered if anyone could see a way to condense it, as it seems a bit cumbersome to me:
Code: ags

function Tracker () {
Ã,  int width;
Ã,  int height;
Ã,  int mx;
Ã,  int my;
Ã,  string mode;
Ã,  string inv;
Ã,  string name;
Ã,  if (GetLocationType (mouse.x, mouse.y) == 0) {
Ã,  Ã,  if (GetCursorMode () == 0) StrFormat (mode, "Walk");
Ã,  Ã,  else if (GetCursorMode () == 1) StrFormat (mode, "Look");
Ã,  Ã,  else if (GetCursorMode () == 2) StrFormat (mode, "Use");
Ã,  Ã,  else if (GetCursorMode () == 3) StrFormat (mode, "Talk");
Ã,  Ã,  else if (GetCursorMode () == 4) GetInvName (character[GetPlayerCharacter ()].activeinv, mode);
Ã,  }
Ã,  else {
Ã,  Ã,  GetLocationName (mouse.x, mouse.y, name);
Ã,  Ã,  if (GetCursorMode () == 0) StrFormat (mode, "Walk to %s", name);
Ã,  Ã,  else if (GetCursorMode () == 1) StrFormat (mode, "Look at %s", name);
Ã,  Ã,  else if (GetCursorMode () == 2) StrFormat (mode, "Use %s", name);
Ã,  Ã,  else if (GetCursorMode () == 3) StrFormat (mode, "Talk to %s", name);
Ã,  Ã,  else if (GetCursorMode () == 4) {
Ã,  Ã,  Ã,  GetInvName (character[GetPlayerCharacter ()].activeinv, inv);
Ã,  Ã,  Ã,  StrFormat (mode, "Use %s on %s", inv, name);
Ã,  Ã,  }
Ã,  }
Ã,  SetLabelText (INVTRACK, 0, mode);
Ã,  width = GetTextWidth (mode, 0);
Ã,  height = GetTextHeight (mode, 0, width);
Ã,  if (mouse.x > 315 - width) {
Ã,  Ã,  mx = 315 - width;
Ã,  }
Ã,  else mx = mouse.x + 5;
Ã,  if (mouse.y > 235 - height) {
Ã,  Ã,  my = 235 - height;
Ã,  }
Ã,  else my = mouse.y + 5;
Ã,  
Ã,  SetGUIPosition (INVTRACK, mx, my);
}

NOTE: I put it in a custom function ( Tracker(); ) which I call in rep_ex, as it seemed easier to manage than having the whole thing in rep_ex.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk