[NEWBIE] Aligning screen labels

Questions, skill improvement, and respectful critique involving game writing.
Post Reply
Message
Author
User avatar
Milkymalk
Miko-Class Veteran
Posts: 754
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

[NEWBIE] Aligning screen labels

#1 Post by Milkymalk »

I'm still confused about how to format and align various elements in various places of the game; it feels like I need a different method for every place.

Code: Select all

hbox:
    label "blablabla" xalign .5
This works, but it places the left edge of the label text at .5 instead of centering it. How do I place the center of the label text at .5? To align the whole frame inside the screen I use "xcenter", but that doesn't work here.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Saphrot
Newbie
Posts: 15
Joined: Thu Jan 26, 2012 7:37 pm
Projects: Mimik, 30 Days
Location: Germany
Contact:

Re: [NEWBIE] Aligning screen labels

#2 Post by Saphrot »

Hi, don't worry about it, it gets easier, once you get used to it. ^.^

If I understand you correctly you want to center the label exactly in the middle, right?
Try this:

Code: Select all

label "blablabla" xanchor 'center' xalign .5
xanchor sets the point, the label uses as an anchor directly in the center of the label.
'left' sets the anchor on the left side and is the default, 'right' would set the anchor on the right side of the label.
yanchor works the same way, only on the y-axis and with 'top', 'center' and 'bottom'.

I hope this helps.
30 Days
Mimik
Mystery, Kinetic Novel
RPG, H
V 0.0 (50%)
V 0.0 (90%)

User avatar
Milkymalk
Miko-Class Veteran
Posts: 754
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: [NEWBIE] Aligning screen labels

#3 Post by Milkymalk »

That's what I thought too, but it doesn't work. I copypasted your line directly into my script to make sure I hadn't just mistyped anything when I tried it, and it doesn't align anything :-(
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Saphrot
Newbie
Posts: 15
Joined: Thu Jan 26, 2012 7:37 pm
Projects: Mimik, 30 Days
Location: Germany
Contact:

Re: [NEWBIE] Aligning screen labels

#4 Post by Saphrot »

Could you post more of your code?
Then we could probably figure out why it's not working.

Edit: I just saw you used an hbox, as far as I know xanchor and xalign don't work in an hbox. You probably need to post more of the surrounding code.
30 Days
Mimik
Mystery, Kinetic Novel
RPG, H
V 0.0 (50%)
V 0.0 (90%)

User avatar
Milkymalk
Miko-Class Veteran
Posts: 754
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: [NEWBIE] Aligning screen labels

#5 Post by Milkymalk »

There's not really much of interest around it:

Code: Select all

screen getactionsfortoday:
    modal True
    python:
        def setactivetimeaction(active_day_action,actionnumber):
            global day_action
            day_action[active_day_action] = actionnumber
            renpy.restart_interaction()
            return
        sata = renpy.curry(setactivetimeaction)
    frame:
        xcenter .5
        ycenter .5
        vbox:
            text "Wähle deine Aktionen für heute:"
            text " "
            vbox:
                hbox:
                    label "Morgens" xminimum 200 xanchor 'center' xalign .5       # <-- THIS
                    label "Mittags" xminimum 200 xanchor 'center' xalign .5       # <-- THIS
                    label "Abends" xminimum 200 xanchor 'center' xalign .5       # <-- THIS
                hbox:
                    textbutton "[action_name[0]]" xminimum 200 action [sata(0, 0),SelectedIf(day_action[0]==0)]
                    textbutton "[action_name[0]]" xminimum 200 action [sata(1, 0),SelectedIf(day_action[1]==0)]
                    textbutton "[action_name[0]]" xminimum 200 action [sata(2, 0),SelectedIf(day_action[2]==0)]
                hbox:
                    textbutton "[action_name[1]]" xminimum 200 action [sata(0, 1),SelectedIf(day_action[0]==1)]
                    textbutton "[action_name[1]]" xminimum 200 action [sata(1, 1),SelectedIf(day_action[1]==1)]
                    textbutton "[action_name[1]]" xminimum 200 action [sata(2, 1),SelectedIf(day_action[2]==1)]

# ... and so on

            text " "
            textbutton "Fertig!" action Return([day_action[0],day_action[1],day_action[2]]) xcenter .5
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Saphrot
Newbie
Posts: 15
Joined: Thu Jan 26, 2012 7:37 pm
Projects: Mimik, 30 Days
Location: Germany
Contact:

Re: [NEWBIE] Aligning screen labels

#6 Post by Saphrot »

Just ignore the colors and size, but is this about right?
Attachments
Beispiel.png
30 Days
Mimik
Mystery, Kinetic Novel
RPG, H
V 0.0 (50%)
V 0.0 (90%)

User avatar
Milkymalk
Miko-Class Veteran
Posts: 754
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: [NEWBIE] Aligning screen labels

#7 Post by Milkymalk »

Yes, that's what I had in mind :D
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Saphrot
Newbie
Posts: 15
Joined: Thu Jan 26, 2012 7:37 pm
Projects: Mimik, 30 Days
Location: Germany
Contact:

Re: [NEWBIE] Aligning screen labels

#8 Post by Saphrot »

Okay, I did cheat a little with that, actually.

Code: Select all

    frame:
        xfill True # delete this if you don't want the frame to fill the whole screen side to side.
        xcenter .5
        yfill True # delete this if you don't want the frame to fill the whole screen top to bottom.
        ycenter .5
        label "Morgens" xanchor 'center' xalign .2
        label "Mittags" xanchor 'center' xalign .5
        label "Abends" xanchor 'center' xalign .8
        textbutton "action_name_0" xanchor 'center' xalign .2 ypos 50
        textbutton "action_name_0" xanchor 'center' xalign .5 ypos 50 
        textbutton "action_name_0" xanchor 'center' xalign .8  ypos 50 # For some reason, this is off to the left a bit.
        textbutton "action_name_1" xanchor 'center' xalign .2 ypos 100
        textbutton "action_name_1" xanchor 'center' xalign .5 ypos 100 
        textbutton "action_name_1" xanchor 'center' xalign .8 ypos 100 # For some reason, this is off to the left a bit xalign .85 might fit better.
As you can see, I used neither a vbox nor an hbox to position them. and I assumed you want the frame to fill the whole screen. Since I didn't use any boxes, I had to position the different buttons and labels one by one, which is more work, but gives you more freedom.

I played around a bit to get the evening/Abend actions aligned with the rest and xalign 0.833 has a pretty good fit.

P.S.: Wenn du willst kannst du mir eine PM schicken, dann kann ich es nochmal auf deutsch erklären.
30 Days
Mimik
Mystery, Kinetic Novel
RPG, H
V 0.0 (50%)
V 0.0 (90%)

Post Reply

Who is online

Users browsing this forum: No registered users