Translation additonal and bonus flash fix
This commit is contained in:
@ -1,15 +1,22 @@
|
||||
|
||||
init offset = -1
|
||||
|
||||
"""
|
||||
In absolute hindsight, this could have been done very similar to bonus flash image
|
||||
instead of the dynamic displayable stuff
|
||||
"""
|
||||
init python:
|
||||
list_langs_buttons = [
|
||||
['gui/flag/USofA.png', 'English', Language(None)],
|
||||
['gui/flag/spain.png', 'Español', Language('test')]
|
||||
{'image': 'gui/flag/USofA.png', 'name': 'English', 'value': None },
|
||||
{'image': 'gui/flag/spain.png', 'name': 'Español', 'value': 'test'}
|
||||
]
|
||||
|
||||
class LangCave: #todo: think of a better name
|
||||
FPS = 1/60 #todo: fetch the actual target render framerate
|
||||
GRID_ROWS_COLS_TUPLE = (2, 1)
|
||||
#GRID_ROWS_COLS_TUPLE = (4, (len(list_langs_buttons)//4))
|
||||
MAX_ITEMS_IN_ROW = 4 #column as well
|
||||
GRID_ROWS_COLS_TUPLE = (MAX_ITEMS_IN_ROW,
|
||||
len(list_langs_buttons)//MAX_ITEMS_IN_ROW + 1*((len(list_langs_buttons)%MAX_ITEMS_IN_ROW)>0))
|
||||
|
||||
lang_buttons = []
|
||||
final_displayable = None
|
||||
@ -17,9 +24,9 @@ init python:
|
||||
on_disable_interactable = False
|
||||
|
||||
LARGE_SIZE = (320, 240)
|
||||
LARGE_SPACING = 80
|
||||
SMALL_SIZE = (LARGE_SIZE[0]/2, LARGE_SIZE[1]/2)
|
||||
SMALL_SPACING = LARGE_SPACING/2
|
||||
LARGE_SPACING = (80, 40)
|
||||
SMALL_SIZE = (LARGE_SIZE[0]//3, LARGE_SIZE[1]//3)
|
||||
SMALL_SPACING = (LARGE_SPACING[0]//2, LARGE_SPACING[1]//2)
|
||||
|
||||
class LangButton(renpy.Displayable):
|
||||
def __init__(self, v, w, h, *childs, **kwargs):
|
||||
@ -34,16 +41,19 @@ init python:
|
||||
self.width = w
|
||||
self.height = h
|
||||
self.value = v
|
||||
self.hover = True #not/! breaks everything in renpy
|
||||
self.hover = True #renpy can't handle not/!
|
||||
self.selected = False
|
||||
|
||||
def render(self, width, height, st, at):
|
||||
root_render = renpy.Render(self.width, self.height) #overall size i think
|
||||
root_render = renpy.Render(self.width, self.height) #canvas
|
||||
|
||||
args = {}
|
||||
if (self.hover):
|
||||
args = {'matrixcolor': TintMatrix("#AAA")}
|
||||
|
||||
if (LangCave.on_disable_interactable == False and self.selected):
|
||||
args = {}
|
||||
|
||||
for ch in self.childs: #draw every child
|
||||
t = Transform(child=ch, **args)
|
||||
child_render = renpy.render(t, self.width, self.height, st, at)
|
||||
@ -58,13 +68,19 @@ init python:
|
||||
if ((ex > 0 and ey > 0) and (ex < self.width and ey < self.height)):
|
||||
self.hover = False
|
||||
if (renpy.map_event(ev, 'mouseup_1')): #1026
|
||||
for lb in LangCave.lang_buttons:
|
||||
lb.selected = False
|
||||
self.selected = True
|
||||
onclick_audio(True)
|
||||
self.value() #todo: change to function, as value doesn't make sense
|
||||
|
||||
if LangCave.on_disable_interactable:
|
||||
renpy.end_interaction(0)
|
||||
LangCave.on_disable_interactable = False
|
||||
recreate_lang_buttons_roulette_style(SMALL_SIZE) #mostly going to happen
|
||||
LangCave.recreate_lang_buttons_roulette_style(LangCave.SMALL_SIZE) #mostly going to happen
|
||||
renpy.end_interaction(0)
|
||||
|
||||
for lb in LangCave.lang_buttons:
|
||||
renpy.redraw(lb, 0)
|
||||
else:
|
||||
self.hover = True
|
||||
pass
|
||||
@ -96,39 +112,56 @@ init python:
|
||||
LangCave.lang_buttons.clear()
|
||||
|
||||
for llb in list_langs_buttons:
|
||||
tfi = Transform(Image(llb[0]), xysize=size, fit='contain', yalign=0.5)
|
||||
solid = Solid((22,22,22), xysize=size)
|
||||
_button = Fixed(solid, tfi, xysize=size)
|
||||
button = LangCave.LangButton(llb[2], *size, _button)
|
||||
tfi = Transform(Image(llb['image']), xysize=size, fit='contain', yalign=0.5)
|
||||
#solid = Solid((22,22,22), xysize=size)
|
||||
# = Solid((22,22,22), xysize=size)
|
||||
_button = Fixed(tfi, xysize=size)
|
||||
lang = Language(llb['value'])
|
||||
button = LangCave.LangButton(lang, *size, _button)
|
||||
LangCave.on_disable_interactable = True
|
||||
|
||||
text = Text(llb[1], outlines=[(2, "#000", 0, 0)], xalign=0.5)
|
||||
|
||||
|
||||
text = Text(llb['name'], outlines=[(2, "#000", 0, 0)], xalign=0.5)
|
||||
final = VBox(text, button, style_prefix="navigation")
|
||||
#LangCave.lang_buttons.append(LangCave.LangButton(llb[2], *size, tfi))
|
||||
LangCave.lang_buttons.append(final)
|
||||
LangCave.final_displayable = Grid(*LangCave.GRID_ROWS_COLS_TUPLE, *LangCave.lang_buttons, spacing=spacing)
|
||||
|
||||
#prevent underfill
|
||||
remainder = len(list_langs_buttons)%LangCave.MAX_ITEMS_IN_ROW
|
||||
for x in range(4-remainder):
|
||||
n = Null(*size)
|
||||
LangCave.lang_buttons.append(n)
|
||||
|
||||
LangCave.final_displayable = Grid(*LangCave.GRID_ROWS_COLS_TUPLE, *LangCave.lang_buttons,
|
||||
xspacing=spacing[0], yspacing=spacing[1])
|
||||
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def recreate_lang_buttons_roulette_style(size, spacing):
|
||||
def recreate_lang_buttons_roulette_style(size, spacing=0):
|
||||
global LangCave
|
||||
LangCave.lang_buttons.clear()
|
||||
|
||||
LangCave.on_disable_interactable = False
|
||||
|
||||
for llb in list_langs_buttons:
|
||||
tfi = Transform(Image(llb[0]), xsize=size[0], ysize=size[1], fit='contain', yalign=0.5)
|
||||
solid = Solid((22,22,22), xysize=(size))
|
||||
_button = Fixed(solid, tfi, xysize=(size))
|
||||
text = Text(llb[1], outlines=[(2, "#000", 0, 0)], xalign=0.5)
|
||||
penultimate = HBox(text, _button, style_prefix="navigation")
|
||||
tfi = Transform(Image(llb['image']), xsize=size[0], ysize=size[1], fit='contain', yalign=0.5)
|
||||
#solid = Solid((22,22,22), xysize=(size))
|
||||
_button = Fixed(tfi, xysize=(size))
|
||||
|
||||
button = LangCave.LangButton(llb[2], *size, _button)
|
||||
text = Text(llb['name'], outlines=[(2, "#000", 0, 0)], xalign=0.5, text_size=16, yalign=0.5) #todo: text_size away
|
||||
penultimate = HBox(text, _button, style_prefix="navigation", spacing=20)
|
||||
#print(dir(penultimate))
|
||||
|
||||
lang = Language(llb['value'])
|
||||
button = LangCave.LangButton(lang, *size, penultimate)
|
||||
|
||||
if (_preferences.language == llb['value']):
|
||||
button.selected = True
|
||||
|
||||
#final = VBox(text, button, style_prefix="navigation")
|
||||
#LangCave.lang_buttons.append(LangCave.LangButton(llb[2], *size, tfi))
|
||||
LangCave.lang_buttons.append(button)
|
||||
|
||||
LangCave.final_displayable = Vbox(*LangCave.lang_buttons, spacing=spacing)
|
||||
LangCave.final_displayable = VBox(*LangCave.lang_buttons, spacing=spacing)
|
||||
|
||||
pass
|
||||
|
||||
@ -178,21 +211,22 @@ screen translator_popup:
|
||||
|
||||
frame:
|
||||
#background gui.main_menu_background
|
||||
background Transform(gui.main_menu_background, matrixcolor=TintMatrix('#555'))
|
||||
background Transform(gui.main_menu_background, matrixcolor=TintMatrix('#222'))
|
||||
|
||||
padding (120, 40)
|
||||
vbox:
|
||||
style_prefix "navigation"
|
||||
hbox:
|
||||
label _("Choose Your Language")
|
||||
label _("Choose Your Language") text_size 80
|
||||
hbox:
|
||||
add Null(80, 40)
|
||||
add DynamicDisplayable(LangCave.render_langcave)
|
||||
|
||||
|
||||
screen translator_roulette:
|
||||
label _("Language")
|
||||
|
||||
vbox:
|
||||
label _("Language")
|
||||
style_prefix "check"
|
||||
add DynamicDisplayable(LangCave.render_langcave)
|
||||
|
||||
|
Reference in New Issue
Block a user