Being the noob that I am, I still very, very much want to have a CG gallery in my game. So I follow the doc's instruction: https://www.renpy.org/doc/html/rooms.html#image-gallery and come up with this code:
Code: Select all
### Define the image ###
image CG1 = "CG/CG1.jpg"
image CG2_1 = "CG/CG2_1.jpg"
image CG2_2 = "CG/CG2_2.jpg"
### Create the gallery object ###
init python:
# Create the gallery object.
g = Gallery()
#Add buttons and images to the gallery.
# A button that contains an image.
g.button("Gallery_b_1")
g.unlock_image("CG1")
# This button has two images associated with it.
g.button("Gallery_b_2")
g.unlock_image("CG2_1")
g.unlock_image("CG2_2")
# The transition used when switching images.
g.transition = dissolve
### The gallery screen ###
screen gallery():
# Ensure this replaces the main menu.
tag menu
# The background.
add "gui/game_menu.png"
# A grid of buttons.
vbox:
#grid 1 2:
xfill True
yfill True
# Call make_button to show a particular button.
add g.make_button("Gallery_b_1", "CG/CGlock.jpg", xalign=0.5, yalign=0.5 )
add g.make_button("Gallery_b_2", "CG/CGlock.jpg", xalign=0.5, yalign=0.5 )
# The screen is responsible for returning to the main menu. It could also
# navigate to other gallery screens.
textbutton "Return" action Return() xalign 0.5 yalign 0.5
### Making the gallery accessible through an Extra screen ###
screen extra():
tag menu
use game_menu(_("Extra")):
style_prefix "extra"
vbox:
textbutton _("{size=50}Image Gallery{/size}") action ShowMenu("gallery") xpos 240 ypos 150
style extra_label is gui_label
style extra_label_text is gui_label_text
style extra_text is gui_text
style extra_label_text:
size gui.label_text_size
Let's get to the problem:
- With the code above, going into the gallery result in...: \(°ロ\)why??(/ロ°)/how??
Code: Select all
I'm sorry, but an uncaught exception occurred. While running game code: Exception: Grid overfull. -- Full Traceback ------------------------------------------------------------ Full traceback: File "renpy/common/_layout/screen_main_menu.rpym", line 28, in script python hide: File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\ast.py", line 814, in execute renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store) File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\python.py", line 1719, in py_exec_bytecode exec bytecode in globals, locals File "renpy/common/_layout/screen_main_menu.rpym", line 30, in <module> ui.interact() File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\ui.py", line 285, in interact rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs) File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2526, in interact repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs) File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2883, in interact_core self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn) File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\display\core.py", line 1955, in draw_screen renpy.config.screen_height, File "renpy/display/render.pyx", line 427, in renpy.display.render.render_screen (gen\renpy.display.render.c:6806) rv = render(root, width, height, 0, 0) File "renpy/display/render.pyx", line 196, in renpy.display.render.render (gen\renpy.display.render.c:2978) rv = d.render(widtho, heighto, st, at) File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 693, in render surf = render(child, width, height, cst, cat) File "renpy/display/render.pyx", line 110, in renpy.display.render.render (gen\renpy.display.render.c:3440) cpdef render(d, object widtho, object heighto, double st, double at): File "renpy/display/render.pyx", line 196, in renpy.display.render.render (gen\renpy.display.render.c:2978) rv = d.render(widtho, heighto, st, at) File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 693, in render surf = render(child, width, height, cst, cat) File "renpy/display/render.pyx", line 110, in renpy.display.render.render (gen\renpy.display.render.c:3440) cpdef render(d, object widtho, object heighto, double st, double at): File "renpy/display/render.pyx", line 196, in renpy.display.render.render (gen\renpy.display.render.c:2978) rv = d.render(widtho, heighto, st, at) File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 693, in render surf = render(child, width, height, cst, cat) File "renpy/display/render.pyx", line 110, in renpy.display.render.render (gen\renpy.display.render.c:3440) cpdef render(d, object widtho, object heighto, double st, double at): File "renpy/display/render.pyx", line 196, in renpy.display.render.render (gen\renpy.display.render.c:2978) rv = d.render(widtho, heighto, st, at) File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 623, in render child = renpy.display.render.render(self.child, w, h, st, at) File "renpy/display/render.pyx", line 110, in renpy.display.render.render (gen\renpy.display.render.c:3440) cpdef render(d, object widtho, object heighto, double st, double at): File "renpy/display/render.pyx", line 196, in renpy.display.render.render (gen\renpy.display.render.c:2978) rv = d.render(widtho, heighto, st, at) File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 693, in render surf = render(child, width, height, cst, cat) File "renpy/display/render.pyx", line 110, in renpy.display.render.render (gen\renpy.display.render.c:3440) cpdef render(d, object widtho, object heighto, double st, double at): File "renpy/display/render.pyx", line 196, in renpy.display.render.render (gen\renpy.display.render.c:2978) rv = d.render(widtho, heighto, st, at) File "D:\CHI\CHI_STUFF\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 409, in render raise Exception("Grid overfull.") Exception: Grid overfull. Windows-7-6.1.7601-SP1 Ren'Py 6.99.12.4.2187 Prototype 1.0
- Try getting rid of the grid and put vbox in instead: result in:
Code: Select all
screen gallery(): # Ensure this replaces the main menu. tag menu # The background. add "gui/game_menu.png" # A grid of buttons. vbox: xfill True yfill True # Call make_button to show a particular button. add g.make_button("Gallery_b_1", "CG/CGlock.jpg", xalign=0.5, yalign=0.5 ) add g.make_button("Gallery_b_2", "CG/CGlock.jpg", xalign=0.5, yalign=0.5 ) # The return button textbutton "Return" action Return() xalign 0.5 yalign 0.5
Clicking on the supposed buttons do nothing at all-nothing happens
Thank you so much in advance
P/S: I would like it this way:
1. As for the three images: One image will take the first button, the second and third will share the same button.
2. In terms of condition: All it required is the image be viewed at least once to be unlocked in the gallery. Plus: when an image is still locked, then its thumbnails in the gallery also show the "locked" image.
Edit: I solved the problem (I feel so silly for asking now), this post can be deleted now, but for those who may have the same problem, here it is:
Code: Select all
screen gallery():
# Ensure this replaces the main menu.
tag menu
# The background.
add "gui/game_menu.png"
# Do not use grid- it just did not work (for me at least).
vbox:
# Call make_button to show a particular button.
add g.make_button("Gallery_b_1", locked="CG/CGb_lock.jpg", unlocked= "CG/CGb_1.jpg", xpos = 200, ypos = 200, xsize= 200, ysize = 100)
add g.make_button("Gallery_b_2", locked="CG/CGb_lock.jpg", unlocked= "CG/CGb_2.jpg", xpos = 200, ypos = 400, xsize= 200, ysize = 100)
# The screen is responsible for returning to the main menu. It could also
# navigate to other gallery screens.
textbutton "Return" action Return() xpos 100 ypos -100