more overlay suggestions

Started by stuh505, Thu 10/03/2005 00:53:00

Previous topic - Next topic

stuh505

I'm scripting a GUI like that used in NWN.  For those of you who aren't familiar, let me explain:

Right clicking brings up a series of evenly spaced globes in a circle around the current mouse location.  There is a globe for each possible option that can be chosen based on what was clicked.  At this time, the cursor disappears and is replaced with a line going from the origin to the current mouse position.  Releasing over one of the globes selects it.  If there is a sub-menu, that menu will open; else the option corresponding to that globe is executed.  When a globe is moused-over, the title appears below this option menu.

There are a few things I don't know how to do:

The biggest problem for me right now is having the ray which goes from the origin to the current mouse position.  I can't use an overlay to draw a line for some reason which would be really nice.  Instead I have to use RawDrawLine -- whenever the GUI is up, I save and restore the screen continuously so as to allow the line to move.  But the problem with this is that I can only save 1 screen!  So when I close down the option box, I've still got a line left!

It would be nice if I could create graphic overlays for all the same things I can do with RawDraw.  It would also be nice if there was not a limit of 1 saved RawScreen.  I think maybe sometime in the future you'll be able to rotate an Overlay which would solve the problem but I can't do that now.

So it seems that my only option is to create something like 50 or so sprites depicting a line at each angle and then compute the angle between the origin and current mouse position (using a math plugin) and use that to choose which sprite to display!

strazer

QuoteBut the problem with this is that I can only save 1 screen!  So when I close down the option box, I've still got a line left!

You only have to save the screen once. Only restore the screen continously.
If you save the screen continously, of course the drawn stuff will be saved too.

QuoteIt would be nice if I could create graphic overlays for all the same things I can do with RawDraw.

http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=413

stuh505

#2
QuoteYou only have to save the screen once. Only restore the screen continously.
If you save the screen continously, of course the drawn stuff will be saved too.

Actually...I think it is better to save the screen continuosly, because many screens involve animations...and your method would freeze all animations while the GUI is up.Ã,  My logic previously was a bit flawed....I've got it working now with continuous screen-saving (with animated background and no trace-line left).

New question on this same topic:

1) any way to check if there is a mouse-over of a character or overlay, or do I need to check this by coordinates?

2) any way to check for mouse-released, or do all my events have to be based on mouse click?

Gilbert

1.  no and GetCharacterAt(). (That's because overlays were not intended for "interactive" stuff, you have to use coordinates, etc. to check for mouse over overlays).
2. I think you can just track the mouse button status, if the button's on last game loop and off this game loop you can say it's a "mouse release".

strazer

QuoteI think it is better to save the screen continuosly, because many screens involve animations...and your method would freeze all animations while the GUI is up.

True.

2) You can check if a mouse button has been released over a GUI in the on_event function (GUI_MUP).

If you want it for all interactions, you could do something like this:

Code: ags

int buttondown;
int buttonreleased;

function on_mouse_click(int button) {

  if (button == LEFT) {
    if (button == buttonreleased) {
      buttondown = 0;
      buttonreleased = 0;
      ProcessClick(mouse.x, mouse.y, GetCursorMode());
    }
    else buttondown = button;
  }
  else if (button == RIGHT) {
    SetNextCursorMode();
  }

}

function repeatedly_execute() {

  if (buttondown != 0) {
    if (IsButtonDown(buttondown) == 0) {
      buttonreleased = buttondown;
      on_mouse_click(buttonreleased);
    }
  }

}

stuh505

strazer,

you're not answering the right question...but it's only due to my poor wording.  im trying to detect mouse release over a character or overlay, not an AGS GUI.  i said GUI because my graphical user interface is composed of those makeshift parts :P

by the way...how does this part make sense?

Quoteif (button == LEFT) {
    if (button == buttonreleased) {

And another overlay suggestion is I think it would be great if we could animate overlays with a loop like we can everything else

strazer

#6
QuoteI'm trying to detect mouse release over a character or overlay, not an AGS GUI.

I know, my first remark was only a reminder for anyone else reading this.

Quotehow does this part make sense?

The part after the first if-clause is run when the button is pressed down.
The code after the second if-clause only gets run when on_mouse_click is called via repeatedly_execute (mouse released).

It may not be the best solution, hence "something like this". But I have quickly tested it and it seemed to work fine. It obviously needs some more work.

Edit:

I've played around a bit:

Code: ags

int buttondown;
int buttonreleased;

function on_mouse_click(int button) {

  if (button == LEFT) {

    if (GetCharacterAt(mouse.x, mouse.y) == YOURCHARACTER) { // if mouse is over character
      if (button == buttonreleased) ProcessClick(mouse.x, mouse.y, GetCursorMode()); // or do some other stuff
    }
    else { // if mouse is over anything else
      if (button != buttonreleased) ProcessClick(mouse.x, mouse.y, GetCursorMode());
    }

    if (button == buttonreleased) { buttondown = 0; buttonreleased = 0; }
    else buttondown = button;

  }
  else if (button == RIGHT) {
    SetNextCursorMode();
  }

}

function repeatedly_execute() {

  if (buttondown != 0) {
    if (IsButtonDown(buttondown) == 0) {
      buttonreleased = buttondown;
      on_mouse_click(buttonreleased);
    }
  }

}


This runs YOURCHARACTER's interaction only when the mouse button was released. All other interactions run when the mouse is pressed down.

Is this what you're looking for?

stuh505

ok, but "button", "LEFT", and "buttonreleased" must all be of type int.  So how could button==buttonreleased if we just determined that button==LEFT

strazer

LEFT is defined as 1, so button can be LEFT (1), so can buttonreleased.

(I've edited my previous post in case you didn't notice.)

SMF spam blocked by CleanTalk