It must by something incredibly basic or incredibly complex. I couldn´t find solution trough entire forum. :)
Basicly... I want to show name of Hotspot, Object, Character and Inventory item when mouse scroll over it. The text should be locked on side of cursor and should dissapear when mouse leave current object.
This feature should give player feedback that he is just pointing on sometnhing interactive and not just background. I´ve seen it in many games and i would like to have this feature in my own.
So i ask.
Is there any way to do it? I was looking for some Module but unsuccesfuly.
If you are willing to share your own solution, i would be eternaly grateful.
Thanks ;)
Nearest Iv'e seen is FloatingHotspot in the modules/plugins quite a while back..
Similar to Overhotspots feature of AGS but descriptions show near mouse cursor.
There are lots of threads about this already since that question gets posted about once per month.
Basically, create a small GUI (~ 100 x 10 pixels, visibility: Normal, on) with border and background color 0 (= transparent) and put a label on it.
To have it always next to the cursor, reposition it in the Globalscript.asc's repeatedly_execute function. If you called the GUI gLocationName, the code should be:
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);
(There's also the @OVERHOTSPOT@ token which if put as text of the label will always show the name, too, but afaik this doesn't work for inv items.)
Quote from: Khris on Thu 12/04/2012 23:48:58
(There's also the @OVERHOTSPOT@ token which if put as text of the label will always show the name, too, but afaik this doesn't work for inv items.)
Pretty sure it does, in fact.
@OVERHOTSPOT@ will display the name of whatever the mouse is over (including inventory items), but (I'm pretty sure) you can't customize the text with cursor-based verbiage (e.g., "Walk to Roger"). It definitely doesn't allow you to easily replace the name of the item the mouse is over dynamically, for example if you have a custom variable to store changed hotspot names (since Hotspot.Name can't be changed at run-time).
This would be a good area for improvement. In fact, if you could assign a translateable string to each mouse cursor and then set a label to something like "@MODETEXT@ @MOUSEOVER@" it would save a lot of trouble for the end-user (especially the newbie!).
Thanks guys. Works fine.
Yet there is one problem.
When i scroll mouse over lower edge of screen, the game crushes. It writes: "GUI.Y: co-ordinates specified are ou t of range."
I´m not experienced enough to fix this bug myself. Can you help me with that?
If you're using my code, put this above the last line:
if (y > System.ViewportHeight) y = mouse.y - 5;
Thanks Khris. It helps a little but not entirely.
It´s interesting. Sometimes when i scroll lower edge it works just fine. No error at all. But sometimes it crash anyway. I tried to find why is that but i didn´t found legality... ???
You can change the check before the .SetPosition command, for instance:
y = mouse.y - 5;
int y_limit = System.ViewportHeight - 10;
if (y > y_limit) y = y_limit;
You are miracle Khris. :) Problem solved
Quote from: Khris on Thu 12/04/2012 23:48:58There are lots of threads about this already since that question gets posted about once per month.
Basically, create a small GUI (~ 100 x 10 pixels, visibility: Normal, on) with border and background color 0 (= transparent) and put a label on it.
To have it always next to the cursor, reposition it in the Globalscript.asc's repeatedly_execute function. If you called the GUI gLocationName, the code should be:
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);
(There's also the @OVERHOTSPOT@ token which if put as text of the label will always show the name, too, but afaik this doesn't work for inv items.)
hi, I tried to insert this into my Tumbleweed style code, but it doesn't work.. it gives me error
Quote from: zeta_san on Sat 30/12/2023 19:49:23hi, I tried to insert this into my Tumbleweed style code, but it doesn't work.. it gives me error
Hello. Please always post the relevant piece of code and tell what the error message is. It's difficult to answer questions without knowing that.
That code needs to go inside the repeatedly_execute function, you cannot paste it directly into a script.
It also requires the existence of a GUI called gLocationName that has a label as its first control (i.e. the ID is 0)
sorry
@Crimson Wizard you're right
@KhrisI placed the code in the repeatedly_execute function in globalscript.asc
I made the GUI called gLocationName with a label as you described.
The mistake is
Local variable cannot have the same name as an import