mirror of
https://git.cavemanon.xyz/Cavemanon/SnootGame.git
synced 2025-03-13 20:19:25 +01:00
gallery opened cg panning vol1, code cleanup
This commit is contained in:
parent
3441dbdbf5
commit
dfc3a2263e
1 changed files with 25 additions and 10 deletions
|
@ -11,8 +11,8 @@ init python:
|
|||
GALLERY_CGS_PER_PAGE = 6
|
||||
PREFERRED_WIDTH = 432 #px (1920 * 0.225)
|
||||
PREFERRED_HEIGHT = 243 #px (1080 * 0.225)
|
||||
DEFAULT_WIDTH_SCALE_RATIO = round(float(PREFERRED_WIDTH) / float(1920), 5)
|
||||
DEFAULT_HEIGHT_SCALE_RATIO = round(float(PREFERRED_HEIGHT) / float(1080), 5)
|
||||
DEFAULT_WIDTH_SCALE_RATIO = round(float(PREFERRED_WIDTH) / float(1920), 4)
|
||||
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)
|
||||
ACCEPTED_EXTENSIONS = ["jpg", "png"]
|
||||
|
||||
|
@ -31,12 +31,21 @@ init python:
|
|||
# (fname: string): None
|
||||
def unlockCg(fname):
|
||||
unlocked = fname in persistent.cggallery
|
||||
if not unlocked:
|
||||
persistent.cggallery.append(fname)
|
||||
renpy.persistent.save()
|
||||
for i in range(0, len(galleryItems) - 1):
|
||||
# TODO: raise Exception(galleryItems[i])
|
||||
if unlocked:
|
||||
return
|
||||
|
||||
# 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
|
||||
# (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):
|
||||
g.button(imageName)
|
||||
g.image(imageName)
|
||||
g.transform(Pan((w - 1920, h - 1080), (0, h - 1080), 30.0)) #TODO: niceify
|
||||
|
||||
if unlocked:
|
||||
g.unlock(imageName)
|
||||
|
@ -61,10 +71,11 @@ init python:
|
|||
|
||||
galleryItems.append({
|
||||
"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
|
||||
# Appends extra spaces at the end
|
||||
# (): None
|
||||
|
@ -76,8 +87,12 @@ init python:
|
|||
workingDirPath = getcwd().replace("\\", "/")
|
||||
cgDirPath = workingDirPath + "/game/" + cgPath
|
||||
|
||||
# Add each image to the gallery
|
||||
# Reset gallery
|
||||
galleryItems = []
|
||||
g = Gallery()
|
||||
g.transition = dissolve
|
||||
|
||||
# Add each image to the gallery
|
||||
for cgFile in listdir(cgDirPath):
|
||||
filePath = join(cgDirPath, cgFile)
|
||||
if isfile(filePath):
|
||||
|
|
Loading…
Reference in a new issue