Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
-
Kinmoku
- Miko-Class Veteran
- Posts: 560
- Joined: Mon Aug 11, 2014 9:39 am
- Completed: One Night Stand
- Projects: Love IRL, Memories
- Tumblr: gamesbykinmoku
- itch: kinmoku
- Location: Germany
-
Contact:
#1
Post
by Kinmoku » Wed Apr 04, 2018 10:36 am
Hi all,
I've been trying to figure this out most of the afternoon but I'm not getting anywhere! I want to have slightly different preferences screens for each language (as the text sizes differ quite a lot per language).
Here's what I have in the preferences part of screens.rpy at the moment (this is just a small example):
Code: Select all
if Language is None:
vbox:
ypos 40
spacing 30
# etc
elif Language is "russian":
vbox:
ypos 44
spacing 35
# etc
else:
vbox:
ypos 50
spacing 55
# etc
The problem is, it's defaulting to "else" at the moment. Previously, I tried "if Language == None:" "elif Language == "russian":" and these defaulted to the first statement. Basically, I seem to have gotten the variables wrong.
Languages can be changed on the main menu like so:
Code: Select all
imagebutton idle "images/lang_english_off1.png" hover "uk_flag" selected_idle "images/lang_english_on.png" selected_hover "images/lang_english_on.png" action Language(None)
imagebutton idle "images/lang_russian_off1.png" hover "russia_flag" selected_idle "images/lang_russian_on.png" selected_hover "images/lang_russian_on.png" action Language("russian")
imagebutton idle "images/lang_french_off1.png" hover "france_flag" selected_idle "images/lang_french_on.png" selected_hover "images/lang_french_on.png" action Language("french")
and at the top of script.rpy, I have this:
Code: Select all
translate None python:
style.default.font = "IHATCS__.TTF"
translate russian python:
style.default.font = "neucha.otf"
translate french python: # this font is really big, hence all the changes!
style.default.size = 38
style.menu_choice.size = 34
style.mainmenu_choice.size = 34
style.mainmenu_choice.line_leading = -8
style.grey_choice.size = 34
style.file_picker.size = 24
style.gallery_ui.size = 24
style.yesno_label_text.size = 38
style.titles.size = 50
style.default.font = "Bromine.ttf"
Any ideas?
-
Ocelot
- Eileen-Class Veteran
- Posts: 1883
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#2
Post
by Ocelot » Wed Apr 04, 2018 11:21 am
1) What prevents you from defining style for your vbox and translating it?
Code: Select all
style my_vbox is whatever_style_it_was_using_before:
# default language
ypos 40
spacing 30
# . . .
vbox:
style my_vbox
# . . .
translate russian style my_vbox:
ypos 44
spacing 35
2) Do not use 'is' unless you do need it and its semantic.
"==" is equality. it means that two things have same properties.
Code: Select all
a = [ 2 ]
b = [ 2 ]
a == b # True, both are lists containing a single number 2
"is" is identity. It means that two things are actually same thing.
Code: Select all
a = [ 2 ]
b = [ 2 ]
a is b # False, those are different lists. if we append a number to list b, nothing will change for list a
c = a
a is c # True. Both are same list. append number to a and c will change too[code]
< < insert Rick Cook quote here > >
-
Kinmoku
- Miko-Class Veteran
- Posts: 560
- Joined: Mon Aug 11, 2014 9:39 am
- Completed: One Night Stand
- Projects: Love IRL, Memories
- Tumblr: gamesbykinmoku
- itch: kinmoku
- Location: Germany
-
Contact:
#3
Post
by Kinmoku » Thu Apr 05, 2018 3:31 am
Thanks for clarifying "is" and "==" Ocelot
1) What prevents you from defining style for your vbox and translating it?
I guess being smart ^^; I don't know how to use styles very well, but there's more than a vbox going on. Here's the whole thing I want to jiggle and adjust for each language:
Code: Select all
vbox:
xanchor 0.5
xpos 0.5
ypos 40
spacing 40 ##
text _("General Settings"):
style "titles"
xpos 475 ##
ypos 10 ##
hbox:
style_group "pref"
spacing 45 ##
text _("Display") ypos 40 xpos 12 ##
button:
action Preference("display", "window")
style "mainmenu_choice_button"
text _("Window") style "mainmenu_choice"
button:
action Preference("display", "fullscreen")
style "mainmenu_choice_button"
text _("Fullscreen") style "mainmenu_choice"
text _("Text") xpos 80 ypos 40
button:
xpos 75
action Preference("auto-forward", "toggle")
style "mainmenu_choice_button"
text _("Auto-play") style "mainmenu_choice"
hbox:
style_group "pref"
spacing 55 ##
xalign 0.5
text _("Music Volume") ypos 20
bar value Preference("music volume") ypos 22 ##
hbox:
style_group "pref"
spacing 55 ##
xalign 0.5
text _("Sound Volume") ypos 47
bar value Preference("sound volume") ypos 45 ##
hbox:
style_group "pref"
spacing 50 ##
xalign 0.5
ypos 52
vbox:
text _("Fast-Forward Settings"):
style "titles"
xpos 200
ypos 10
hbox:
style_group "pref"
spacing 55 ##
xalign 0.5
ypos 20
text _("Fast-Forward") ypos 40 xpos 12 ##
button:
action Preference("skip", "seen")
style "mainmenu_choice_button"
text _("Seen Text") style "mainmenu_choice"
button:
action Preference("skip", "all")
style "mainmenu_choice_button"
text _("All Text") style "mainmenu_choice"
hbox:
style_group "pref"
spacing 55 ##
xalign 0.5
ypos 48
text _("After Choices") yalign 0.5 xpos 8 ##
button:
action Preference("after choices", "stop")
style "mainmenu_choice_button"
text _("Stop FF") style "mainmenu_choice"
button:
action Preference("after choices", "skip")
style "mainmenu_choice_button"
text _("Continue FF") style "mainmenu_choice"
vbox:
text _("Progress Settings"):
style "titles"
ypos 10
button:
xalign 0.5
ypos 85
action Show("reset_popup")
style "mainmenu_choice_button"
text _("Reset Game") style "mainmenu_choice"
I managed it for the style above "titles", where the title is a little smaller in some languages than others, but that was much simpler than all the different spacing I have going on above. Everything that has different adjustments for each language is marked with ##. I feel it'd be much easier to change the whole screen depending on which language was active.
-
Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
-
Contact:
#4
Post
by Qlara » Tue Apr 10, 2018 10:02 pm
I'm "stealing" the following more or less from the default Ren'Py help screen in screens.rpy (I just changed variable names) as I think it's similar to what you want.
There, the variables are set slightly differently, perhaps you could try that:
Code: Select all
#your button code ...# action SetScreenVariable("Language", "Russian")
Code: Select all
screen preferences():
style_prefix "preferences"
default Language = None
vbox:
ypos 40
spacing 30
# etc
if Language == None:
use preferences
elif Language == "Russian":
use russian_preferences
elif Language == "French":
use french_preferences
screen russian_preferences():
vbox:
ypos 50
spacing 55
# etc
screen french_preferences():
vbox:
ypos 50
spacing 55
# etc
You could make detailed screen definitions like that or let the other language screens inherit the style of the preference screen automatically and then add styles for those parameters you want to change like this:
Code: Select all
screen preferences():
#...same as above...
screen russian_preferences():
style_prefix "russian_preferences"
vbox: # no further parameters for this vbox here
screen french_preferences():
style_prefix "french_preferences"
vbox: # no further parameters for this vbox here
style russian_preferences_vbox:
ypos 50
spacing 55
style french_preferences_vbox is russian_preferences_vbox # to inherit values from russian vbox, or (additionally)...
style french_preferences_vbox: #...to inherit everything that is not extra defined in the following block, to change individual values.
spacing 60 # ypos 50 will be inherited from russian
Last edited by
Qlara on Wed Apr 11, 2018 6:14 am, edited 1 time in total.
-
kivik
- Miko-Class Veteran
- Posts: 786
- Joined: Fri Jun 24, 2016 5:58 pm
-
Contact:
#5
Post
by kivik » Wed Apr 11, 2018 4:24 am
Just noticed this:
I think it needs to be:
-
Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
-
Contact:
#6
Post
by Qlara » Wed Apr 11, 2018 6:14 am
Yes, definitely, my mistake.
I fixed it.