How to change alignment of text in the main menu buttons?

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.
Post Reply
Message
Author
rocket
Veteran
Posts: 373
Joined: Tue Jul 10, 2007 2:54 am
Projects: Starlight Ep0, Ep1
Location: San Fransisco
Contact:

How to change alignment of text in the main menu buttons?

#1 Post by rocket »

There was an old thread that suggested using config to address previously defined buttons, like so:

Code: Select all

$ config.button_text_properties["Start Game"] = dict(size=18, xalign = 0.0)
However that gives this runtime exception:

Code: Select all

While executing init code:
  File "game/script.rpy", line 4, in script
    init python:
  File "game/script.rpy", line 14, in <module>
    config.button_text_properties["Quit"] = dict(size=18, xalign = 0.0)
Exception: config.button_text_properties is not a known configuration variable.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 4, in script
    init python:
  File "/Users/adorablerocket/Documents/renpy-6.18.3-sdk/renpy/ast.py", line 785, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "/Users/adorablerocket/Documents/renpy-6.18.3-sdk/renpy/python.py", line 1382, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 14, in <module>
    config.button_text_properties["Quit"] = dict(size=18, xalign = 0.0)
  File "/Users/adorablerocket/Documents/renpy-6.18.3-sdk/renpy/defaultstore.py", line 74, in __getattr__
    raise Exception('config.%s is not a known configuration variable.' % (name))
Exception: config.button_text_properties is not a known configuration variable.

Darwin-14.1.0-x86_64-i386-64bit
Ren'Py 6.18.3.761
I also tried:

Code: Select all

style.mm_button.text_align = 0.0
and

Code: Select all

style.mm_button_text.text_align = 0.0
Which generated no errors, but did not change the text position.

Prior to using either I've declared my own main menu as follows:

Code: Select all

# Starlight - To boldly moé where no one has moéd before!
# Recovery version of E0.1

init python:
  config.main_menu = [    
    (u"How to play", "tutorial", "True"),
    (u"New Game ", "start", "True"),
    (u"Load Game", _intra_jumps("load_screen", "main_game_transition"), "True"),
    (u"Epilogue", "epilogue", persistent.ending1 and persistent.ending2 and persistent.ending3 ),
    (u"Preferences", _intra_jumps("preferences_screen", "main_game_transition"), "True"),
    (u"Quit", ui.jumps("_quit"), "True")
    ]

  #config.button_text_properties["Quit"] = dict(size=18, xalign = 0.0)
  #style.mm_button.text_align = 0.0
Any help much appreciated! Thanks!

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: How to change alignment of text in the main menu buttons

#2 Post by PyTom »

Honestly, that code is ancient. While you could probably get it to work with liberal application of config.script_version, I'd suggest that you ditch the existing menus and just grab the options.rpy and screens.rpy from a new game. There are a number good tutorials for screen language (please someone, drop some links) which is a far better way of customizing things.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom


User avatar
MilywayObree
Newbie
Posts: 17
Joined: Sun Jan 28, 2018 11:24 am
Completed: None so far, pending to be exact
Projects: DDLC, The notebook and other secret projects
Organization: Vocastin/Oriaa Pro-Creations
Deviantart: MexicoRPelino
Github: HizashiroTakahashi
Skype: PixelMINEGaming
Location: Philippines
Contact:

Re: How to change alignment of text in the main menu buttons?

#4 Post by MilywayObree »

This is possible..
To do this next to the textbutton like this:
textbutton _('Start") action Start() <------
type xpos and next to it a negative or positive value of your choice
and next to that value type ypos and another value of your choice
for me I will type for xpos "107" and for ypos "682"
It should show up like: textbutton _("Start") action Start() xpos 107 ypos 682
once applied the textbutton will show up at the bottom left corner of the screen.
Just Monika.

Post Reply

Who is online

Users browsing this forum: No registered users