tooltip on a overlay
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- jack_norton
- Lemma-Class Veteran
- Posts: 4087
- Joined: Mon Jul 21, 2008 5:41 pm
- Completed: Too many! See my homepage
- Projects: A lot! See www.winterwolves.com
- Tumblr: winterwolvesgames
- Contact:
tooltip on a overlay
I'm at good point with the interface of my new game but I have one problem with the tooltip class pytom wrote me some months ago: it doesn't display on a overlay
I'm using a overlay to display the bottom interface on the screen, but using normal tooltip the text is hidden under it. I tried adding a ui.layer("overlay") but didn't work either. So was wondering if there is a solution to this?
I'm using a overlay to display the bottom interface on the screen, but using normal tooltip the text is hidden under it. I tried adding a ui.layer("overlay") but didn't work either. So was wondering if there is a solution to this?
- killdream
- Veteran
- Posts: 325
- Joined: Wed Nov 05, 2008 1:05 pm
- Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
- Deviantart: robotlolita
- Github: robotlolita
- Location: World's End (aka Brazil)
- Contact:
Re: tooltip on a overlay
Probably it's being rendered first than the interface, so it'll be under it. If you call a function for this, you should call it after the interface is rendered. Not sure, tho, since I don't have idea of what the source of the tooltip looks like.
- jack_norton
- Lemma-Class Veteran
- Posts: 4087
- Joined: Mon Jul 21, 2008 5:41 pm
- Completed: Too many! See my homepage
- Projects: A lot! See www.winterwolves.com
- Tumblr: winterwolvesgames
- Contact:
Re: tooltip on a overlay
Well I managed to make a sort of tooltip but the problem is with the unhovered function of the imagebutton (or any button).
If you have 1 button only is fine. But if you have 2-3 the unhover doesn't work for tooltips at all, since if I call it to hide the tooltip, it hides even the others.
A bit hard to explain I know!
In practice with just 1 button:
mouse goes over button1->show text
mouse off button1->hide text
with 2 buttons (or more)
mouse goes over button1->show text ? NO, because mouse is unhover button2!
mouse goes over button2->show text ? NO, because mouse is unhover button1!
so the way it works is impossible to have a real tooltip, I managed to display the text of the last hovered button, without "clearing" it everytime (otherwise wasn't showing anything).
Here is the full script anyway (without tooltip class):
If you have 1 button only is fine. But if you have 2-3 the unhover doesn't work for tooltips at all, since if I call it to hide the tooltip, it hides even the others.
A bit hard to explain I know!
In practice with just 1 button:
mouse goes over button1->show text
mouse off button1->hide text
with 2 buttons (or more)
mouse goes over button1->show text ? NO, because mouse is unhover button2!
mouse goes over button2->show text ? NO, because mouse is unhover button1!
so the way it works is impossible to have a real tooltip, I managed to display the text of the last hovered button, without "clearing" it everytime (otherwise wasn't showing anything).
Here is the full script anyway (without tooltip class):
Code: Select all
init python:
import time
v1=0;v2=0;v3=0;buildmode=0;ingame=False;Help="";HelpA=0
GHelp=("Headquarters are very important.","Military city blocks help the defenses","Science labs are useful to research new techs","Bio-Hospitals improve your citizen life quality","Commercial hubs makes good money","Residential blocks are essential for your city to expand.")
init python:
def increase():
global v1,v2,v3
v1+=renpy.random.randint(1, 3)
v2+=renpy.random.randint(1, 3)
v3+=renpy.random.randint(1, 3)
def overlays():
global v1,v2,v3,buildmode,HelpA
if ingame==True:
HelpA=0
#top
ui.frame(xpos=5,ypos=5,xminimum=300,yminimum=32)
ui.vbox()
ui.text("var1: ("+str(v1)+") var2: "+str(v2)+"var3: ("+str(v3)+")")
ui.close()
##bottom
ui.frame(xpos=0,ypos=566,xminimum=1024,yminimum=202,background="gfx/bottom.png")
ui.fixed()
if buildmode==1:
ui.textbutton("{color=#FFF}Briefing{/color}",style="newbutt",ypos=2,xpos=40,xminimum=154,yminimum=40,role="selected_")
else:
ui.textbutton("{color=#FFF}Briefing{/color}",style="newbutt",ypos=2,xpos=40,xminimum=154,yminimum=40,clicked=ui.callsinnewcontext("setmode",1))
if buildmode==2:
ui.textbutton("{color=#FFF}Resources{/color}",style="newbutt",ypos=2,xpos=220,xminimum=154,yminimum=40,role="selected_")
else:
ui.textbutton("{color=#FFF}Resources{/color}",style="newbutt",ypos=2,xpos=220,xminimum=154,yminimum=40,clicked=ui.callsinnewcontext("setmode",2))
if buildmode==3:
ui.textbutton("{color=#FFF}Vehicles{/color}",style="newbutt",ypos=2,xpos=400,xminimum=154,yminimum=40,role="selected_")
else:
ui.textbutton("{color=#FFF}Vehicles{/color}",style="newbutt",ypos=2,xpos=400,xminimum=154,yminimum=40,clicked=ui.callsinnewcontext("setmode",3))
if buildmode==4:
ui.textbutton("{color=#FFF}Buildings{/color}",style="newbutt",ypos=2,xpos=580,xminimum=154,yminimum=40,role="selected_")
else:
ui.textbutton("{color=#FFF}Buildings{/color}",style="newbutt",ypos=2,xpos=580,xminimum=154,yminimum=40,clicked=ui.callsinnewcontext("setmode",4))
ui.close()
#the various panels
if buildmode==4:
for i in range(6):
ui.imagebutton(ImageReference("Sicon"+str(i)), ImageReference("icon"+str(i)), hovered=ui.callsinnewcontext("showhelp",i), clicked=ui.callsinnewcontext("showhelp",i),xpos=2+i*128,ypos=620)
ui.text(Help,xpos=770,ypos=620,xmaximum=200)
config.overlay_functions.append(overlays)
label setmode(m):
$ buildmode=m
return
label showhelp(h):
$ Help=GHelp[h]
return
label start:
$ renpy.music.stop(fadeout=1.5)
scene bg with dissolve
python:
ingame=True
start = time.time()
while True:
if time.time() - start >= 2:
start = time.time()
increase()
es=[[1,6],[4,4],[6,2],[0,0],[7,5]
]
map = [[0 for i in range(32)] for i in range(32)]
for x,y in es:
ui.imagebutton("gfx/place.png","gfx/place.png",clicked=ui.jumps("online"),xpos=x*128,ypos=y*64)
renpy.pause(0.1)
- jack_norton
- Lemma-Class Veteran
- Posts: 4087
- Joined: Mon Jul 21, 2008 5:41 pm
- Completed: Too many! See my homepage
- Projects: A lot! See www.winterwolves.com
- Tumblr: winterwolvesgames
- Contact:
Re: tooltip on a overlay
Just wanted to add that probably for doing such complex stuff the only solution would be to use pygame inside renpy, since that way could use the mouse coordinates and it would solve the problem
-
- Veteran
- Posts: 284
- Joined: Fri Dec 28, 2007 5:47 am
- Location: Where the Dragons rule!
- Contact:
Re: tooltip on a overlay
Why don't you use it then?
Angels of paradise, angels of sacrifice
Please let me be under your wings...
Please let me be under your wings...
- killdream
- Veteran
- Posts: 325
- Joined: Wed Nov 05, 2008 1:05 pm
- Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
- Deviantart: robotlolita
- Github: robotlolita
- Location: World's End (aka Brazil)
- Contact:
Re: tooltip on a overlay
Not quite, I guess Ren'Py it's better to do it than go for pygame. Just create a class for every tooltip and assign it to a button. This class will be responsible to show/hide the tooltip.jack_norton wrote:Just wanted to add that probably for doing such complex stuff the only solution would be to use pygame inside renpy, since that way could use the mouse coordinates and it would solve the problem
like:
Code: Select all
class TTooltip:
def __init__(self, text):
self.text = text
self.hovered = False
def show(self, at):
if not self.hovered: # show only if the mouse is over the button that owns this tooltip
return
ui.at(at) # just to position it properly (you could set the position in the init or so, though)
ui.text(self.text)
Code: Select all
def create_button(idle_image, hover_image, tooltip_text, clicked):
tooltip = TTooltip(tooltip_text) # create a instance of tooltip for this button
def hovered():
tooltip.hovered = True
def unhovered():
tooltip.hovered = False
ui.imagebutton(idle_image, hover_image, hovered=hovered, unhovered=unhovered, clicked=clicked)
- jack_norton
- Lemma-Class Veteran
- Posts: 4087
- Joined: Mon Jul 21, 2008 5:41 pm
- Completed: Too many! See my homepage
- Projects: A lot! See www.winterwolves.com
- Tumblr: winterwolvesgames
- Contact:
Re: tooltip on a overlay
Ah true didn't think about that possibility! Going to make some tests now, thanks!
- jack_norton
- Lemma-Class Veteran
- Posts: 4087
- Joined: Mon Jul 21, 2008 5:41 pm
- Completed: Too many! See my homepage
- Projects: A lot! See www.winterwolves.com
- Tumblr: winterwolvesgames
- Contact:
Re: tooltip on a overlay
Nope, tried your code but doesn't work, nothing is shown
PyTom tooltip was perfect but in my particular case I can't find a way to display a text OVER all other overlays/layers (always in forefront).
PyTom tooltip was perfect but in my particular case I can't find a way to display a text OVER all other overlays/layers (always in forefront).
- jack_norton
- Lemma-Class Veteran
- Posts: 4087
- Joined: Mon Jul 21, 2008 5:41 pm
- Completed: Too many! See my homepage
- Projects: A lot! See www.winterwolves.com
- Tumblr: winterwolvesgames
- Contact:
Re: tooltip on a overlay
Well, if I have to use pygame with a loop etc I might as well just go back to my old C engine! I was using renpy/python to have a good high level language to make games faster. Of course not renpy fault since it's an engine geared towards VN, and is the best in its field. I am trying to do something that is really not a VNEvilDragon wrote:Why don't you use it then?
-
- Veteran
- Posts: 284
- Joined: Fri Dec 28, 2007 5:47 am
- Location: Where the Dragons rule!
- Contact:
Re: tooltip on a overlay
Just a thought: have you tried something called z-order of the layers that are currently displayed?
Angels of paradise, angels of sacrifice
Please let me be under your wings...
Please let me be under your wings...
- jack_norton
- Lemma-Class Veteran
- Posts: 4087
- Joined: Mon Jul 21, 2008 5:41 pm
- Completed: Too many! See my homepage
- Projects: A lot! See www.winterwolves.com
- Tumblr: winterwolvesgames
- Contact:
Re: tooltip on a overlay
Well I don't know how to access it, I know there are several layers, but I don't know if I can add a layer that goes OVER the "overlay" layer. I tried using in the tooltip class ui.layer("overlay") which IN THEORY should do the next ui. functions in the specified layer (so in the overlay itself) but somehow wouldn't work (don't know why).
I found a fun solution for now: I added a giant imagebutton of the size of the whole background so if you move over it, clears the tooltip string value seems to work even if I have to try on slower machines!
I found a fun solution for now: I added a giant imagebutton of the size of the whole background so if you move over it, clears the tooltip string value seems to work even if I have to try on slower machines!
- killdream
- Veteran
- Posts: 325
- Joined: Wed Nov 05, 2008 1:05 pm
- Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
- Deviantart: robotlolita
- Github: robotlolita
- Location: World's End (aka Brazil)
- Contact:
Re: tooltip on a overlay
Hm, my fault. You have to catch all the instances in a list and show them in after you show the overlay buttons (forgot about this part xD).jack_norton wrote:Nope, tried your code but doesn't work, nothing is shown
PyTom tooltip was perfect but in my particular case I can't find a way to display a text OVER all other overlays/layers (always in forefront).
Like:
Code: Select all
def create_button(...):
(...) # create tooltip
global list_of_tooltips
list_of_tooltips.append(tooltip)
(...) # create button
def overlay_function():
(...) # draw the image buttons here
for index, tooltip in enumerate(list_of_tooltips):
tooltip.show(Position(xpos=i*200))
Who is online
Users browsing this forum: Ahrefs [Bot], SONTSE