[SOLVED] Centering text in textbox?
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.
- Lumen_Astrum
- Dystopian Princess
- Posts: 1662
- Joined: Mon Nov 08, 2010 8:01 am
- Completed: Soul and Heart, Twin Faces
- Projects: Soul and Heart Replay; The Court of the Two Sides (tentative title)
- Organization: Lion Box Studios
- Tumblr: lumenizampel
- Location: Philippines
- Contact:
[SOLVED] Centering text in textbox?
EDIT: Issue solved. Thanks so much to those who helped!
Okay, so. Firstly, this is a mock-up of the textbox I wanted: I had actually thought of an idea for the name tag (making separate textboxes for each character mentioned), but I don't have any idea how to center the text in the textbox. I did try to search about it, without success. Does anyone know what part of the code do I have to tinker, or is there anything I should add in it?
Also: there's the quick menu in the bottom. I wanted something like that, but not specifically those buttons; just any quick menu will do. XD I always see a quick menu similar to that in the tutorial game, but I don't see it anywhere mine, even though I removed my quick menu. Even if I make it appear, I have no idea how to center it :\
Help is appreciated, thank you so much in advance! :3
Okay, so. Firstly, this is a mock-up of the textbox I wanted: I had actually thought of an idea for the name tag (making separate textboxes for each character mentioned), but I don't have any idea how to center the text in the textbox. I did try to search about it, without success. Does anyone know what part of the code do I have to tinker, or is there anything I should add in it?
Also: there's the quick menu in the bottom. I wanted something like that, but not specifically those buttons; just any quick menu will do. XD I always see a quick menu similar to that in the tutorial game, but I don't see it anywhere mine, even though I removed my quick menu. Even if I make it appear, I have no idea how to center it :\
Help is appreciated, thank you so much in advance! :3
Last edited by Lumen_Astrum on Fri Nov 02, 2012 2:11 am, edited 1 time in total.
- Lumen_Astrum
- Dystopian Princess
- Posts: 1662
- Joined: Mon Nov 08, 2010 8:01 am
- Completed: Soul and Heart, Twin Faces
- Projects: Soul and Heart Replay; The Court of the Two Sides (tentative title)
- Organization: Lion Box Studios
- Tumblr: lumenizampel
- Location: Philippines
- Contact:
Re: Centering text in textbox?
xalign 0.5 shall help thou, for ye seekin' truth.
You can also achieve great knowledge by looking there:
http://lemmasoft.renai.us/forums/viewto ... =51&t=9233
and properly asking The One You Verily Cannot Hide Anything From (not really):
http://www.google.ru/search?&q=site%3Al ... enter+text
You can also achieve great knowledge by looking there:
http://lemmasoft.renai.us/forums/viewto ... =51&t=9233
and properly asking The One You Verily Cannot Hide Anything From (not really):
http://www.google.ru/search?&q=site%3Al ... enter+text
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.
Re: Centering text in textbox?
I'm not sure how to center all the things, but I'll still play around with it and try to figure it out. To change the placing of your Quick Menu, go to your screens.rpy and find the code for the Quick Menu. Should look like this:
Just change the align at the top to 0.5 and that will center it on the bottom. With the style.quick_button_text things you can change the size, colour, and padding of it to make it bigger.
Code: Select all
# Quick Menu
#
# A screen that's included by the default say screen, and adds quick access to
# several useful functions.
screen quick_menu:
# Add an in-game quick menu.
hbox:
style_group "quick"
xalign 1.0
yalign 1.0
textbutton _("Q.Save") action QuickSave()
textbutton _("Q.Load") action QuickLoad()
textbutton _("Save") action ShowMenu('save')
textbutton _("Skip") action Skip()
textbutton _("Auto") action Preference("auto-forward", "toggle")
textbutton _("Prefs") action ShowMenu('preferences')
init -2 python:
style.quick_button.set_parent('default')
style.quick_button.background = None
style.quick_button.xpadding = 5
style.quick_button_text.set_parent('default')
style.quick_button_text.size = 12
style.quick_button_text.idle_color = "#8888"
style.quick_button_text.hover_color = "#ccc"
style.quick_button_text.selected_idle_color = "#cc08"
style.quick_button_text.selected_hover_color = "#cc0"
style.quick_button_text.insensitive_color = "#4448"
# Set a default value for the auto-forward time, and note that AFM is
# turned off by default.
config.default_afm_time = 10
config.default_afm_enable = False
"There’s no shame in pleasure, Mr. Gray. You see, man just wants to be happy, but society wants him to be good. And when he’s good, man is rarely happy, and when he’s happy he is always good."
- Lumen_Astrum
- Dystopian Princess
- Posts: 1662
- Joined: Mon Nov 08, 2010 8:01 am
- Completed: Soul and Heart, Twin Faces
- Projects: Soul and Heart Replay; The Court of the Two Sides (tentative title)
- Organization: Lion Box Studios
- Tumblr: lumenizampel
- Location: Philippines
- Contact:
Re: Centering text in textbox?
I tried that, but it also centers text in NVL scenes :\Levrex wrote:xalign 0.5 shall help thou, for ye seekin' truth.
You can also achieve great knowledge by looking there:
http://lemmasoft.renai.us/forums/viewto ... =51&t=9233
and properly asking The One You Verily Cannot Hide Anything From (not really):
http://www.google.ru/search?&q=site%3Al ... enter+text
Thank you so much! It worked wonders~Aedin wrote:I'm not sure how to center all the things, but I'll still play around with it and try to figure it out. To change the placing of your Quick Menu, go to your screens.rpy and find the code for the Quick Menu. Should look like this:
Just change the align at the top to 0.5 and that will center it on the bottom. With the style.quick_button_text things you can change the size, colour, and padding of it to make it bigger.Code: Select all
# Quick Menu # # A screen that's included by the default say screen, and adds quick access to # several useful functions. screen quick_menu: # Add an in-game quick menu. hbox: style_group "quick" xalign 1.0 yalign 1.0 textbutton _("Q.Save") action QuickSave() textbutton _("Q.Load") action QuickLoad() textbutton _("Save") action ShowMenu('save') textbutton _("Skip") action Skip() textbutton _("Auto") action Preference("auto-forward", "toggle") textbutton _("Prefs") action ShowMenu('preferences') init -2 python: style.quick_button.set_parent('default') style.quick_button.background = None style.quick_button.xpadding = 5 style.quick_button_text.set_parent('default') style.quick_button_text.size = 12 style.quick_button_text.idle_color = "#8888" style.quick_button_text.hover_color = "#ccc" style.quick_button_text.selected_idle_color = "#cc08" style.quick_button_text.selected_hover_color = "#cc0" style.quick_button_text.insensitive_color = "#4448" # Set a default value for the auto-forward time, and note that AFM is # turned off by default. config.default_afm_time = 10 config.default_afm_enable = False
- OokamiKasumi
- Eileen-Class Veteran
- Posts: 1779
- Joined: Thu Oct 14, 2010 3:53 am
- Completed: 14 games released -- and Counting.
- Organization: DarkErotica Games
- Deviantart: OokamiKasumi
- Location: NC, USA
- Contact:
Re: Centering text in textbox?
What you're looking for is here --> http://lemmasoft.renai.us/forums/viewto ... 765#p78222Lumen_Astrum wrote:... I don't have any idea how to center the text in the textbox.
You will have to doctor this code to suit your needs, maybe like this...?
Code: Select all
define c = Character(Charles,
color="#ffffff",
outlines = [(1, "#333333", 0, 0)],
show_two_window = True,
what_xalign=0.5,
what_text_align=0.5,)
To do ALL your text-boxes centered, go to your options.rpy page and look for this:
Code: Select all
## These let you customize the default FONTs used for text in Ren'Py.
Code: Select all
## Centers the Text in your textbox.
style.default.xalign = 0.5
Code: Select all
style.say_label.xalign = 0.5
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed:
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
Most recent Games Completed:
- The Walk[Psychological][NanoWinter] ~ PG New!
- Trap! [ModernFantasy][VN] ~ PG16
- The Adventures of Prince Ivan [Fant/Adv/VN] ~ PG
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
- Lumen_Astrum
- Dystopian Princess
- Posts: 1662
- Joined: Mon Nov 08, 2010 8:01 am
- Completed: Soul and Heart, Twin Faces
- Projects: Soul and Heart Replay; The Court of the Two Sides (tentative title)
- Organization: Lion Box Studios
- Tumblr: lumenizampel
- Location: Philippines
- Contact:
Re: Centering text in textbox?
It also centers NVL text :\ I only wanted ADV-mode text centered... I tried the method by using the Style Inspector to specifically center ADV text, but somehow it went weird.
- Arowana
- Miko-Class Veteran
- Posts: 531
- Joined: Thu May 31, 2012 11:17 pm
- Completed: a2 ~a due~
- Projects: AXIOM.01, The Pirate Mermaid
- Organization: Variable X, Navigame
- Tumblr: navigame-media
- itch: navigame
- Contact:
Re: Centering text in textbox?
Do you want the centered textbox for the entire game? If the Styles aren't working out, you could try modifying your "say" screen directly. Something like this seems to work for me (might not need all the xaligns and text_aligns I put in, but just in case):
If you only want to center the textbox for certain characters, you could probably switch to a modified "say" screen for them using "show_" similar to this example (let me know if you're interested in that - I won't bore you with it if not, lol).
Code: Select all
### snippet from the "say" screen ###
# The one window variant.
window:
id "window"
has vbox:
style "say_vbox"
xalign 0.5 ### centers textbox
if who:
text who id "who" xalign 0.5 ### centers name
text what id "what" text_align 0.5 ### centers long text
else:
# The two window variant.
vbox:
style "say_two_window_vbox"
if who:
window:
style "say_who_window"
xalign 0.5 ### centers namebox
text who:
id "who" xalign 0.5 ### centers name
window:
id "window"
has vbox:
style "say_vbox"
xalign 0.5 ### centers textbox
text what id "what" text_align 0.5 ### centers long text
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)
- Lumen_Astrum
- Dystopian Princess
- Posts: 1662
- Joined: Mon Nov 08, 2010 8:01 am
- Completed: Soul and Heart, Twin Faces
- Projects: Soul and Heart Replay; The Court of the Two Sides (tentative title)
- Organization: Lion Box Studios
- Tumblr: lumenizampel
- Location: Philippines
- Contact:
Re: Centering text in textbox?
Ah, it works perfectly! Thank you!
I know this may be another question to ask, but... I tried formatting the name label like how it was said so in Aleema's tutorial, but it also formatted the name label in NVL mode Is there anyway to format just the name label in ADV, like doing it specifically in the "say" screen directly? I know nothing about screen language
I know this may be another question to ask, but... I tried formatting the name label like how it was said so in Aleema's tutorial, but it also formatted the name label in NVL mode Is there anyway to format just the name label in ADV, like doing it specifically in the "say" screen directly? I know nothing about screen language
- Arowana
- Miko-Class Veteran
- Posts: 531
- Joined: Thu May 31, 2012 11:17 pm
- Completed: a2 ~a due~
- Projects: AXIOM.01, The Pirate Mermaid
- Organization: Variable X, Navigame
- Tumblr: navigame-media
- itch: navigame
- Contact:
Re: Centering text in textbox?
Yay, glad it worked! Yeah, you can modify the name label in the "say" screen directly if you'd like.
Here's where the name/name labels are on the "say" screen:
What things in particular are you looking to format? If you want to change the name text, for instance, here's all the screen language properties for text. Lots of things you can do! For instance, if you wanted to set the size, font, and color, you could write something like:
Here's where the name/name labels are on the "say" screen:
Code: Select all
### snippet from the "say" screen ###
# The one window variant.
window:
id "window"
has vbox:
style "say_vbox"
xalign 0.5 ### centers textbox
if who:
text who id "who" xalign 0.5 ### centers name #<---------------name label text
text what id "what" text_align 0.5 ### centers long text
else:
# The two window variant.
vbox:
style "say_two_window_vbox"
if who:
window: #<-----------------------------------------------------namebox
style "say_who_window"
xalign 0.5 ### centers namebox
text who: #<------------------------------------------------name label text
id "who" xalign 0.5 ### centers name
window:
id "window"
has vbox:
style "say_vbox"
xalign 0.5 ### centers textbox
text what id "what" text_align 0.5 ### centers long text
Code: Select all
text who:
xalign 0.5 #centers name
size 40
color "#000000"
font "myfont.ttf"
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)
- Lumen_Astrum
- Dystopian Princess
- Posts: 1662
- Joined: Mon Nov 08, 2010 8:01 am
- Completed: Soul and Heart, Twin Faces
- Projects: Soul and Heart Replay; The Court of the Two Sides (tentative title)
- Organization: Lion Box Studios
- Tumblr: lumenizampel
- Location: Philippines
- Contact:
Re: Centering text in textbox?
I got an error:
Block of code in issue:
I was pretty sure I followed your format, and that I executed the format well in the outlines too, but I don't know how to fix it
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
File "game/screens.rpy", line 28: Expected screen language statement.
font "B.ttf"
^
Ren'Py Version: Ren'Py 6.13.7.1646
Code: Select all
if who:
text who id "who" xalign 0.5 ### centers name
font "B.ttf"
size 30
outlines (1, "#000000", 0, 0)
- Arowana
- Miko-Class Veteran
- Posts: 531
- Joined: Thu May 31, 2012 11:17 pm
- Completed: a2 ~a due~
- Projects: AXIOM.01, The Pirate Mermaid
- Organization: Variable X, Navigame
- Tumblr: navigame-media
- itch: navigame
- Contact:
Re: Centering text in textbox?
I think it's complaining about the indentation. All the properties of the text element "text who" have to be lined up and indented underneath it. (Alternatively, you can put them all on the same line, but that gets long and hard to read).
Try:
(also note that you need the square brackets around the "outlines" tuple)
Try:
Code: Select all
if who:
text who:
id "who"
xalign 0.5 ### centers name
font "B.ttf"
size 30
outlines [(1, "#000000", 0, 0)]
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)
- Lumen_Astrum
- Dystopian Princess
- Posts: 1662
- Joined: Mon Nov 08, 2010 8:01 am
- Completed: Soul and Heart, Twin Faces
- Projects: Soul and Heart Replay; The Court of the Two Sides (tentative title)
- Organization: Lion Box Studios
- Tumblr: lumenizampel
- Location: Philippines
- Contact:
Re: Centering text in textbox?
Ah, there! It works perfectly now~ Thank you so much for your help!
Re: Centering text in textbox?
This was just what I needed for my current project, thanks
Who is online
Users browsing this forum: No registered users