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):
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)