Add data structs to support multiple folders

This commit is contained in:
2021-07-17 15:53:20 +10:00
parent fa2cbd7137
commit 24324ec3ed
2 changed files with 39 additions and 21 deletions

View File

@ -6,7 +6,7 @@ init python:
persistent.autoup = False persistent.autoup = False
if persistent.updateWebServer is None: if persistent.updateWebServer is None:
persistent.updateWebServer = "http://updates.snootgame.xyz/updates.json" persistent.updateWebServer = "http://updates.snootgame.xyz/updates.json"
def UpdateCheck(): def UpdateCheck():
# WHY YES I ONLY ALLOW PEOPLE USING MY FRAMEWORK TO CHECK FOR AN UPDATE EVERY SIX FUCKING HOURS HOW DID YOU KNOW # WHY YES I ONLY ALLOW PEOPLE USING MY FRAMEWORK TO CHECK FOR AN UPDATE EVERY SIX FUCKING HOURS HOW DID YOU KNOW
# NOPE check_interval=5 (5 SECONDS) FUCK YOU # NOPE check_interval=5 (5 SECONDS) FUCK YOU
@ -684,7 +684,7 @@ screen updates():
button: button:
key_events True key_events True
if input_on: if input_on:
input: input:
default "[persistent.updateWebServer!t]" size 24 color '#FFFFFF' default "[persistent.updateWebServer!t]" size 24 color '#FFFFFF'
value FieldInputValue(persistent, 'updateWebServer') value FieldInputValue(persistent, 'updateWebServer')
length 49 length 49

View File

@ -9,15 +9,30 @@ init python:
DEFAULT_HEIGHT_SCALE_RATIO = round(float(PREFERRED_HEIGHT) / float(1080), 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) 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"]
CG_PATHS = "images/cgs/" CG_PATHS = [
{ 'path': "images/cgs/", 'name': "CG", 'eval': None
}, #CG doesn't really make sense
{ 'path': "images/animations/", 'name': "Animations", 'eval': None
},
{ 'path': "images/NotForKids!/", 'name': "Lewd",
'eval': 'presistent.lewd == True'
}
]
#path: folder, name: shows up in gallery, eval: runs eval() on string
# GALLERY ITEMS """
# Data structure that holds the data for each cg and button Data structure that holds the data for each cg and button
# item is the key in the Gallery item is name, fn is fullpath
# ext is the file extension ext is the file extension
# { item: string; cg: Displayable; ext: string }[] { item: string; fn: string, cg: Displayable; ext: string }[]
"""
galleryItems = [] galleryItems = []
# key dict pair, cg <-> cgs' galleryitems []
gallery_dic = {} #
for cp in CG_PATHS:
gallery_dic[cp['name']] = [] #
# Make a scaled cg button # Make a scaled cg button
# (cg: string; ext: string; w: float; h: float # (cg: string; ext: string; w: float; h: float
def cg(fname, ext, w, h): def cg(fname, ext, w, h):
@ -34,19 +49,20 @@ init python:
# Add each image to the gallery # Add each image to the gallery
for str in list_img: for str in list_img:
_str = CG_PATHS+str+"."+ACCEPTED_EXTENSIONS[0] for cp in CG_PATHS:
if renpy.loadable(_str): #brute force path = cp['path']
image = renpy.image_size(Image(_str)) _str = path+str+"."+ACCEPTED_EXTENSIONS[0]
#addGalleryItem(str, ACCEPTED_EXTENSIONS[0], image[0], image[1]) if renpy.loadable(_str): #brute force
image = renpy.image_size(Image(_str))
# Create an object in g:Gallery, add to galleryItems # Create an object in g:Gallery, add to galleryItems
# (imageName: string; ext: string; w: float; h: float) -> None # (imageName: string; ext: string; w: float; h: float) -> None
galleryItems.append({ gallery_dic[cp['name']] += [{
"item": str, "item": str,
"fn": _str, "fn": _str,
"cg": cg(_str, ACCEPTED_EXTENSIONS[0], image[0], image[1]), "cg": cg(_str, ACCEPTED_EXTENSIONS[0], image[0], image[1]),
"ext": ACCEPTED_EXTENSIONS[0] "ext": ACCEPTED_EXTENSIONS[0]
}) }]
return return
# (xy) -> { x: float; y: float } # (xy) -> { x: float; y: float }
@ -78,6 +94,7 @@ screen cg_gallery(__yoffset = 0):
add gui.game_menu_background add gui.game_menu_background
python: python:
galleryItems = gallery_dic["CG"]
items = len(galleryItems) items = len(galleryItems)
galleryRows = (items / GALLERY_COLS) + 1 galleryRows = (items / GALLERY_COLS) + 1
extraSpaces = GALLERY_COLS - (items % GALLERY_COLS) extraSpaces = GALLERY_COLS - (items % GALLERY_COLS)
@ -97,11 +114,12 @@ screen cg_gallery(__yoffset = 0):
grid GALLERY_COLS galleryRows: grid GALLERY_COLS galleryRows:
for item in galleryItems: for item in galleryItems:
# Should properly fix with actual margin difference but good
# enough or the actual position
python: python:
item_counter += 1 item_counter += 1
yoffset = item_counter / 3 * PREFERRED_HEIGHT * 1.15 yoffset = item_counter / 3 * PREFERRED_HEIGHT * 1.15
yoffset = int( yoffset + (PREFERRED_HEIGHT * 1.15)) yoffset = int( yoffset + (PREFERRED_HEIGHT * 1.15))
# should properly fix with actual margin difference but good enough or the actual position
use flag_button(item, yoffset) use flag_button(item, yoffset)