Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Innsmouthian

#1
Hello again adventure folks!

I've tried to implement a "floating" GUI to display the names of objects and characters, for what I've used the following code by Khris from this thread: https://www.adventuregamestudio.co.uk/forums/index.php?topic=45730.0

The code is the following, under the function repeatedly_execute section in the Global Script:

Code: ags

  int x = mouse.x + 3;
  int y = mouse.y + 5;
  InventoryItem*ii = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  Label*lbl = gLocationName.Controls[0].AsLabel;
  String text;
  if (ii) text = ii.Name;
  else text = Game.GetLocationName(mouse.x, mouse.y);
  if (x > 250) x = (x - 6) - GetTextWidth(text, lbl.Font);
  gLocationName.SetPosition(x, y);


For now, it has worked, but I find a little annoying problem: names display normally on the left side of the cursor, but happen to "flash" randomly on the right side, for less than a second. I'd like to know if it's possible to "block" the names on a fixed position relative to the cursor, so this flashing stops happening.

Thanks to Khris for the original code, and to everyone in advance for any tip! :)
#2
Quote from: Khris on Fri 08/02/2019 21:24:28
Right, I keep writing .x for some reason.

As for the initial position, I tried to set up my code in a way that it uses the position set in the GUI editor (line 10 in the snippet). Did you set the top property accordingly, or does that not suffice?

Yeah, I changed it in the Propierties tab of the GUI and now it starts down. This is awesome.  :cheesy:
#3
Yep! That did the trick, now it's completely functional for the game's purposes.

I had to change the "mouse.x > 650" in the second line for "mouse.y" but it's working flawlessly. Now I feel like I can overtake the project; thanks a lot! ;-D

For the final brushstroke... would it be possible to start the game with the GUI down? :=
#4
Quote from: Khris on Fri 08/02/2019 05:17:21
Yeah, that last line was for debugging and I forgot to remove it :-D

You can easily change the condition that makes the GUI appear, just try this:

Code: ags
  bool mouseIsOverMainGUI = GUI.GetAtScreenXY(mouse.x, mouse.y) == g && mouse.y > 1060;


Btw, the speed at which the GUI moves can be adjusted by changing the 0.4; smaller values make it move slower. Don't go above 1.0 though.

I was trying yesterday to mess up a bit with that line (something told me the option was there), but hadn't been able to get anything. Now with this, the GUI does exactly what I was asking. I just hope to gradually learn how to work with the code...as your help is being huge.

Now the GUI is almost perfect. What I'd like to add (I'm already trying to get it :-[) is an order to specify that, while it is full deployed, it keeps opened as long as you're interacting with it. I don't know if I'm explaining myself well: while with the first code you provided, it already worked that way, it had the inconvenient that it scrolled up as soon as the mouse was over the GUI. Now it deploys only when you go down, but the problem is that as soon as you move the mouse over the 1060 line, it goes down again, preventing the player to interact with the inventory, which is in the hidden part of the GUI.

Or in short: Would there be a way to get the GUI shown only when the mouse is at the bottom, as it does now with your last contribution, BUT not to hide again unless the mouse goes, say, to the 650 line? (which is the line where the full GUI 'ends').

I don't want to sound irritating, as I appreciate what you've already gave me should be more-than-enough for a persistent beginner like me.

So, thank you again Khris!  :)
#5
Incredible! Now it works and looks really the way I was looking for it to do!.  8-0

I had to delete the last line due to a compiling error, but once done it started fine. What was it for, though?.

Thank you very much. I see it's kind of a complex code (at least for me), but I'll keep it like it was gold now.

Just to be touchy :-D, would there be a way to "activate" the full GUI only in case the mouse went to the left bottom of the screen, not just by getting over the GUI, but reaching the, like, 1060 line?. In my desing, that would allow the player to use the action buttons without displaying the inventory every time.

But maybe it's enough for today. Sincerely, thanks again.
#6
Thanks a lot Khris!

I was having a bit of trouble implementing Crimson Wizard's script.

I used your code and now the GUI movement is there, with a nice fast-scrolling effect. But the Full GUI appears way upper in the screen, on the top left corner instead of the bottom left. When I move the mouse over it, it starts "bouncing" crazy between the bottom and its full position.

I guess I'm missing the way to tell the script the Y position of the full GUI, but, I'll do my best to understand the meaning of all the instructions so I can manage to put it back to its original position.  :grin:

In any case, the X position is correct.

EDIT: I've tried modyfing the values in y_full and y_down, but the only thing I get is a different "bouncing". Guess the problem has to be with the 'default' position of the GUI. Also tried changing the "Top" value in the GUI properties but no luck.

Cheers
#7
Thank you both for your answers!

I already had tried what Snarky proposes, but had no effect.

I'll start trying with your solution, Crimson Wizard. I'm a completely beginner with scripting as you may already have guessed but I assume it's the proper way to do things in AGS.

#8
Hello everybody!

First of all, I want to thank Chris Jones for creating and keeping AGS, such a wonderful invention. And secondly, thanks to this community for providing support and tips on projects.

I'd like to clarify that, although I've surfed this forum (also, of course, read the manual), I haven't found an answer to my question.

I'm using AGS 3.4.1

The thing is that I want to implement a show/hide "popup" GUI that contains both action buttons and the inventory (kind of a SCUMM-type). The GUI is intended to be placed in the bottom left corner. But I'm facing two problems:

- The first one is that I'm not able to even get the basic version of my purpose. Whenever I try to use the option "When mouse moves to top of screen", setting the "PopupYPos" in 1060 (the project resolution is 1920x1080), the only thing I get is a stuck GUI showing always and avoiding to interact with the rest of the game (the GUI itself works, however).

- The second problem, which I don't know if it's possible to resolve, is that I'd like to make the GUI hide in the bottom but not completely: 1/3 of it should be permanently visible, and once the mouse is over this area, the complete GUI would show up (pop up). I've found nothing in this regard in the manual nor in the forums.

This is a preview of the GUI -which is not yet definitive- showing the part that should keep visible on the bottom over the discontinued line.



Solvable or not, thanks in advance for any help or tip! :smiley:
SMF spam blocked by CleanTalk