#120
Post
by Rene » Sun Aug 09, 2015 3:30 am
For some reason, I can't get it working, though the code should be ok. I keep getting the following error:
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/gallery.rpy", line 43, in script
init +1 python:
File "game/gallery.rpy", line 48, in <module>
renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
Exception: Expected an image, but got a general displayable.
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/gallery.rpy", line 43, in script
init +1 python:
File "N:\Downloads\Programs\renpy-6.99.5-sdk\renpy\ast.py", line 797, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "N:\Downloads\Programs\renpy-6.99.5-sdk\renpy\python.py", line 1448, in py_exec_bytecode
exec bytecode in globals, locals
File "game/gallery.rpy", line 48, in <module>
renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
File "N:\Downloads\Programs\renpy-6.99.5-sdk\renpy\display\im.py", line 668, in __init__
im = image(im)
File "N:\Downloads\Programs\renpy-6.99.5-sdk\renpy\display\im.py", line 1564, in image
return image(arg.target, loose=loose, **properties)
File "N:\Downloads\Programs\renpy-6.99.5-sdk\renpy\display\im.py", line 1579, in image
raise Exception("Expected an image, but got a general displayable.")
Exception: Expected an image, but got a general displayable.
Windows-7-6.1.7601-SP1
Ren'Py 6.99.5.602
Mistress Elvira 0.0
Here's the code of the gallery, which was put in a seperate file (gallery.rpy)
Currently only BG's are to be displayed:
init python:
#Galleries settings - start
#list the CG gallery images here:
# gallery_cg_items = ["xinxin"]
#list the BG gallery images here (if a BG includes several variations, such as night version, include only one variation here):
gallery_bg_items = ["bg xinxin"]
#how many rows and columns in the gallery screens?
gal_rows = 3
gal_cols = 3
#thumbnail size in pixels:
thumbnail_x = 267
thumbnail_y = 150
#the setting above (267x150) will work well with 16:9 screen ratio. Make sure to adjust it, if your are using 4:3 or something else.
#Galleries settings - end
gal_cells = gal_rows * gal_cols
# g_cg = Gallery()
# for gal_item in gallery_cg_items:
# g_cg.button(gal_item + " butt")
# g_cg.image(gal_item)
# g_cg.unlock(gal_item)
# #if BGs have variations, such as night version, uncomment the lines below and include the code for each BG with variations
# if gal_item == "xinxin":
# g_cg.image("funhouse1")
# g_cg.unlock("funhouse1")
# g_cg.transition = fade
# cg_page=0
g_bg = Gallery()
for gal_item in gallery_bg_items:
g_bg.button(gal_item + " butt")
g_bg.image(gal_item)
g_bg.unlock(gal_item)
#if BGs have variations, such as night version, uncomment the lines below and include the code for each BG with variations
if gal_item == "bg xinxin":
g_bg.image("bg funhouse1")
g_bg.unlock("bg funhouse1")
g_bg.image("bg funhouse3")
g_bg.unlock("bg funhouse3")
g_bg.transition = fade
bg_page=0
init +1 python:
#Here we create the thumbnails. We create a grayscale thumbnail image for BGs, but we use a special "locked" image for CGs to prevent spoilers.
# for gal_item in gallery_cg_items:
# renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
for gal_item in gallery_bg_items:
renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
renpy.image (gal_item + " butt dis", im.Grayscale(ImageReference(gal_item + " butt")))
#screen cg_gallery:
# tag menu
# use navigation
# frame background None xpos 10:
# grid gal_rows gal_cols:
# ypos 10
# $ i = 0
# $ next_cg_page = cg_page + 1
# if next_cg_page > int(len(gallery_cg_items)/gal_cells):
# $ next_cg_page = 0
# for gal_item in gallery_cg_items:
# $ i += 1
# if i <= (cg_page+1)*gal_cells and i>cg_page*gal_cells:
# add g_cg.make_button(gal_item + " butt", gal_item + " butt", im.Scale("gallocked.png", thumbnail_x, thumbnail_y), xalign=0.5, yalign=0.5, idle_border=None, background=None, bottom_margin=24)
# for j in range(i, (cg_page+1)*gal_cells): #we need this to fully fill the grid
# null
# frame:
# yalign 0.97
# vbox:
# if len(gallery_cg_items)>gal_cells:
# textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]
screen bg_gallery:
#The BG gallery screen is more or less copy pasted from the CG screen above, I only changed "make_button" to include a grayscale thumbnail for locked items
tag menu
use navigation
frame background None xpos 10:
grid gal_rows gal_cols:
ypos 10
$ i = 0
$ next_bg_page = bg_page + 1
if next_bg_page > int(len(gallery_bg_items)/gal_cells):
$ next_bg_page = 0
for gal_item in gallery_bg_items:
$ i += 1
if i <= (bg_page+1)*gal_cells and i>bg_page*gal_cells:
add g_bg.make_button(gal_item + " butt", gal_item + " butt", gal_item + " butt dis", xalign=0.5, yalign=0.5, idle_border=None, background=None, bottom_margin=24)
for j in range(i, (bg_page+1)*gal_cells):
null
frame:
yalign 0.97
vbox:
if len(gallery_bg_items)>gal_cells:
textbutton _("Next Page") action [SetVariable('bg_page', next_bg_page), ShowMenu("bg_gallery")]
And in the script.rpy:
image bg xinxin = "images/gallery/xinxin/xinxin.png"
image bg funhouse1 = "images/backgrounds/funhouse_anasophie_xinxin_1.png"
image bg funhouse2 = "images/backgrounds/funhouse_anasophie_xinxin_2.png"
image bg funhouse3 = "images/backgrounds/funhouse_anasophie_xinxin_3.png"
image bg funhouse4 = "images/backgrounds/funhouse_anasophie_xinxin_4.png"
Also the BG Gallery option won't show in the main menu:
textbutton _("Start Game") action Start()
textbutton _("Load Game") action ShowMenu("load")
textbutton _("BG Gallery") action ShowMenu("bg_gallery")
textbutton _("Preferences") action ShowMenu("preferences")
textbutton _("Help") action Help()
textbutton _("Quit") action Quit(confirm=False)