mirror of
https://git.cavemanon.xyz/Cavemanon/SnootGame.git
synced 2025-03-13 20:19:25 +01:00
Add data structs to support multiple folders
This commit is contained in:
parent
fa2cbd7137
commit
24324ec3ed
2 changed files with 39 additions and 21 deletions
|
@ -6,7 +6,7 @@ init python:
|
|||
persistent.autoup = False
|
||||
if persistent.updateWebServer is None:
|
||||
persistent.updateWebServer = "http://updates.snootgame.xyz/updates.json"
|
||||
|
||||
|
||||
def UpdateCheck():
|
||||
# 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
|
||||
|
@ -684,7 +684,7 @@ screen updates():
|
|||
button:
|
||||
key_events True
|
||||
if input_on:
|
||||
input:
|
||||
input:
|
||||
default "[persistent.updateWebServer!t]" size 24 color '#FFFFFF'
|
||||
value FieldInputValue(persistent, 'updateWebServer')
|
||||
length 49
|
||||
|
|
|
@ -9,15 +9,30 @@ init python:
|
|||
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"]
|
||||
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
|
||||
# item is the key in the Gallery
|
||||
# ext is the file extension
|
||||
# { item: string; cg: Displayable; ext: string }[]
|
||||
"""
|
||||
Data structure that holds the data for each cg and button
|
||||
item is name, fn is fullpath
|
||||
ext is the file extension
|
||||
{ item: string; fn: string, cg: Displayable; ext: string }[]
|
||||
"""
|
||||
galleryItems = []
|
||||
|
||||
# key dict pair, cg <-> cgs' galleryitems []
|
||||
gallery_dic = {} #
|
||||
for cp in CG_PATHS:
|
||||
gallery_dic[cp['name']] = [] #
|
||||
|
||||
# Make a scaled cg button
|
||||
# (cg: string; ext: string; w: float; h: float
|
||||
def cg(fname, ext, w, h):
|
||||
|
@ -34,19 +49,20 @@ init python:
|
|||
|
||||
# Add each image to the gallery
|
||||
for str in list_img:
|
||||
_str = CG_PATHS+str+"."+ACCEPTED_EXTENSIONS[0]
|
||||
if renpy.loadable(_str): #brute force
|
||||
image = renpy.image_size(Image(_str))
|
||||
#addGalleryItem(str, ACCEPTED_EXTENSIONS[0], image[0], image[1])
|
||||
for cp in CG_PATHS:
|
||||
path = cp['path']
|
||||
_str = path+str+"."+ACCEPTED_EXTENSIONS[0]
|
||||
if renpy.loadable(_str): #brute force
|
||||
image = renpy.image_size(Image(_str))
|
||||
|
||||
# Create an object in g:Gallery, add to galleryItems
|
||||
# (imageName: string; ext: string; w: float; h: float) -> None
|
||||
galleryItems.append({
|
||||
"item": str,
|
||||
"fn": _str,
|
||||
"cg": cg(_str, ACCEPTED_EXTENSIONS[0], image[0], image[1]),
|
||||
"ext": ACCEPTED_EXTENSIONS[0]
|
||||
})
|
||||
# Create an object in g:Gallery, add to galleryItems
|
||||
# (imageName: string; ext: string; w: float; h: float) -> None
|
||||
gallery_dic[cp['name']] += [{
|
||||
"item": str,
|
||||
"fn": _str,
|
||||
"cg": cg(_str, ACCEPTED_EXTENSIONS[0], image[0], image[1]),
|
||||
"ext": ACCEPTED_EXTENSIONS[0]
|
||||
}]
|
||||
return
|
||||
|
||||
# (xy) -> { x: float; y: float }
|
||||
|
@ -78,6 +94,7 @@ screen cg_gallery(__yoffset = 0):
|
|||
add gui.game_menu_background
|
||||
|
||||
python:
|
||||
galleryItems = gallery_dic["CG"]
|
||||
items = len(galleryItems)
|
||||
galleryRows = (items / GALLERY_COLS) + 1
|
||||
extraSpaces = GALLERY_COLS - (items % GALLERY_COLS)
|
||||
|
@ -97,11 +114,12 @@ screen cg_gallery(__yoffset = 0):
|
|||
|
||||
grid GALLERY_COLS galleryRows:
|
||||
for item in galleryItems:
|
||||
# Should properly fix with actual margin difference but good
|
||||
# enough or the actual position
|
||||
python:
|
||||
item_counter += 1
|
||||
yoffset = item_counter / 3 * 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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue