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.
-
dvemail
- Regular
- Posts: 35
- Joined: Sat May 28, 2016 1:50 pm
- Projects: Working on Patronus
- IRC Nick: dvemail
- Deviantart: ObdurateDemand
- Github: dvemail
-
Contact:
#1
Post
by dvemail » Wed Mar 22, 2017 9:49 pm
I'm using vertical bars in a grid, and the alignment appears to be to the left side in each element of the grid. I've tried xalign 0.5, but I don't see how to align the bar to the center of the grid element. Each grid element is set to xsize of 150 because of the labels in the row below, so ideally the bars would align at 75, but they dont
Code: Select all
grid 5 1:
xalign 0.5
yalign 0.5
spacing 10
bar range 100 value stat_object.rhetoric xsize 150 style "column_bar"
bar range 100 value stat_object.authoritas xsize 150 style "column_bar"
bar range 100 value stat_object.gravitas xsize 150 style "column_bar"
bar range 100 value stat_object.fides xsize 150 style "column_bar"
bar range 100 value stat_object.pietas xsize 150 style "column_bar"
grid 5 1:
xalign 0.5
yalign 0.5
spacing 10
label "{size=-12}Rhetoric " + str(stat_object.rhetoric) + "{/size}" xsize 150
label "{size=-12}Authoritas " + str(stat_object.authoritas) + "{/size}" xsize 150
label "{size=-12}Gravitas " + str(stat_object.gravitas) + "{/size}" xsize 150
label "{size=-12}Fides " + str(stat_object.fides) + "{/size}" xsize 150
label "{size=-12}Pietas " + str(stat_object.pietas) + "{/size}" xsize 150
The vertical bar have appropriate spacing for the labels below, but not correct centering.
Ideas?
-
Imperf3kt
- Lemma-Class Veteran
- Posts: 3636
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
-
Contact:
#2
Post
by Imperf3kt » Wed Mar 22, 2017 10:15 pm
Try adding anchor 0.5
xalign is for horizontal positioning. It sets both xpos and xanchor to the same value.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project:
GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
-
dvemail
- Regular
- Posts: 35
- Joined: Sat May 28, 2016 1:50 pm
- Projects: Working on Patronus
- IRC Nick: dvemail
- Deviantart: ObdurateDemand
- Github: dvemail
-
Contact:
#3
Post
by dvemail » Wed Mar 22, 2017 11:09 pm
That's not working as expected either. The way I would *like* it to work is for everything to use relative positioning inside the grid cells, the equivalent of formatting an excel cell with 'center' both for the bars and the labels.
I set the cell width to 150 just to get the spacing approximately correct in terms of layout on the screen, but I can't seem to understand the positioning *inside* the grid.
-
philat
- Eileen-Class Veteran
- Posts: 1853
- Joined: Wed Dec 04, 2013 12:33 pm
-
Contact:
#4
Post
by philat » Thu Mar 23, 2017 2:26 am
You don't seem to apply the xalign to the elements at all. The xalign 0.5 directly under grid 5 1: tells renpy where the GRID should be positioned, not where the elements should be positioned within the grid. (Unless you have the xalign hidden in the column_bar style.)
As an aside, I'm not sure why you have two 5 1 grids rather than one 5 2 grid -- or, for that matters, nested hbox/vboxes. Those are generally easier to deal with because they take box properties while grid cells don't.