Page 1 of 1

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

Posted: Sat Mar 21, 2015 5:33 pm
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!

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

Posted: Sat Mar 21, 2015 7:15 pm
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.

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

Posted: Sun Mar 22, 2015 7:37 am
by Alex

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

Posted: Sun Feb 18, 2018 8:43 am
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.