gallery opened cg panning vol1, code cleanup
This commit is contained in:
parent
3441dbdbf5
commit
dfc3a2263e
|
@ -11,8 +11,8 @@ init python:
|
||||||
GALLERY_CGS_PER_PAGE = 6
|
GALLERY_CGS_PER_PAGE = 6
|
||||||
PREFERRED_WIDTH = 432 #px (1920 * 0.225)
|
PREFERRED_WIDTH = 432 #px (1920 * 0.225)
|
||||||
PREFERRED_HEIGHT = 243 #px (1080 * 0.225)
|
PREFERRED_HEIGHT = 243 #px (1080 * 0.225)
|
||||||
DEFAULT_WIDTH_SCALE_RATIO = round(float(PREFERRED_WIDTH) / float(1920), 5)
|
DEFAULT_WIDTH_SCALE_RATIO = round(float(PREFERRED_WIDTH) / float(1920), 4)
|
||||||
DEFAULT_HEIGHT_SCALE_RATIO = round(float(PREFERRED_HEIGHT) / float(1080), 5)
|
DEFAULT_HEIGHT_SCALE_RATIO = round(float(PREFERRED_HEIGHT) / float(1080), 4)
|
||||||
NOT_UNLOCKED_COVER = im.FactorScale("gui/gallery/unlocked_cg_button_cover.png", DEFAULT_WIDTH_SCALE_RATIO, DEFAULT_HEIGHT_SCALE_RATIO)
|
NOT_UNLOCKED_COVER = im.FactorScale("gui/gallery/unlocked_cg_button_cover.png", DEFAULT_WIDTH_SCALE_RATIO, DEFAULT_HEIGHT_SCALE_RATIO)
|
||||||
ACCEPTED_EXTENSIONS = ["jpg", "png"]
|
ACCEPTED_EXTENSIONS = ["jpg", "png"]
|
||||||
|
|
||||||
|
@ -31,12 +31,21 @@ init python:
|
||||||
# (fname: string): None
|
# (fname: string): None
|
||||||
def unlockCg(fname):
|
def unlockCg(fname):
|
||||||
unlocked = fname in persistent.cggallery
|
unlocked = fname in persistent.cggallery
|
||||||
if not unlocked:
|
if unlocked:
|
||||||
persistent.cggallery.append(fname)
|
return
|
||||||
renpy.persistent.save()
|
|
||||||
for i in range(0, len(galleryItems) - 1):
|
|
||||||
# TODO: raise Exception(galleryItems[i])
|
|
||||||
|
|
||||||
|
# Save to renpy persistent data
|
||||||
|
tmp = list(persistent.cggallery).copy()
|
||||||
|
tmp.append(fname)
|
||||||
|
persistent.cggallery = tmp
|
||||||
|
renpy.persistent.save()
|
||||||
|
# TODO: fix unlocking without game reset
|
||||||
|
|
||||||
|
# Rebuild the gallery
|
||||||
|
for i in range(0, len(galleryItems) - 1):
|
||||||
|
if fname != str(galleryItems[i]["item"]):
|
||||||
|
loadGallery()
|
||||||
|
return
|
||||||
|
|
||||||
# Make a scaled cg button
|
# Make a scaled cg button
|
||||||
# (cg: string; ext: string; w: float; h: float; unlocked?: boolean): Displayable
|
# (cg: string; ext: string; w: float; h: float; unlocked?: boolean): Displayable
|
||||||
|
@ -52,6 +61,7 @@ init python:
|
||||||
def addGalleryItem(imageName, ext, w, h, unlocked = False):
|
def addGalleryItem(imageName, ext, w, h, unlocked = False):
|
||||||
g.button(imageName)
|
g.button(imageName)
|
||||||
g.image(imageName)
|
g.image(imageName)
|
||||||
|
g.transform(Pan((w - 1920, h - 1080), (0, h - 1080), 30.0)) #TODO: niceify
|
||||||
|
|
||||||
if unlocked:
|
if unlocked:
|
||||||
g.unlock(imageName)
|
g.unlock(imageName)
|
||||||
|
@ -61,10 +71,11 @@ init python:
|
||||||
|
|
||||||
galleryItems.append({
|
galleryItems.append({
|
||||||
"item": imageName,
|
"item": imageName,
|
||||||
"cg": cg(imageName, ext, w, h, unlocked)
|
"cg": cg(imageName, ext, w, h, unlocked),
|
||||||
|
"ext": ext
|
||||||
})
|
})
|
||||||
|
|
||||||
# Reads /images/cgs dir for all .png files
|
# Reads /images/cgs dir for all image files
|
||||||
# Populates g:Gallery and galleryItems
|
# Populates g:Gallery and galleryItems
|
||||||
# Appends extra spaces at the end
|
# Appends extra spaces at the end
|
||||||
# (): None
|
# (): None
|
||||||
|
@ -76,8 +87,12 @@ init python:
|
||||||
workingDirPath = getcwd().replace("\\", "/")
|
workingDirPath = getcwd().replace("\\", "/")
|
||||||
cgDirPath = workingDirPath + "/game/" + cgPath
|
cgDirPath = workingDirPath + "/game/" + cgPath
|
||||||
|
|
||||||
# Add each image to the gallery
|
# Reset gallery
|
||||||
galleryItems = []
|
galleryItems = []
|
||||||
|
g = Gallery()
|
||||||
|
g.transition = dissolve
|
||||||
|
|
||||||
|
# Add each image to the gallery
|
||||||
for cgFile in listdir(cgDirPath):
|
for cgFile in listdir(cgDirPath):
|
||||||
filePath = join(cgDirPath, cgFile)
|
filePath = join(cgDirPath, cgFile)
|
||||||
if isfile(filePath):
|
if isfile(filePath):
|
||||||
|
|
Loading…
Reference in New Issue