fullbody images

This commit is contained in:
2022-11-07 12:07:43 +11:00
parent 12d3ca9068
commit 2587b4724f
3 changed files with 140 additions and 59 deletions

View File

@@ -1,6 +1,7 @@
init python:
init 2 python:
import json
# CONST PARAMS
ALLOW_ZOOM = False
@@ -36,15 +37,20 @@ init python:
for cp in CG_PATHS:
gallery_dic[cp['name']] = [] #
# Make a scaled cg button
# (cg: string; ext: string; w: float
def cg_(fname, ext, w):
scale = PREFERRED_WIDTH / w
#scale = box_ratio(wh)
#image = im.FactorScale(fname, scale, scale, True)
image = im.FactorScale(fname, scale, scale, True)
#return Image(fname, zoom=scale)
return image
if type(fname) is str:
image = im.FactorScale(fname, scale, scale, True)
return image
else:
return Transform(fname, zoom=scale)
#return Transform(fname, crop=(0,0,1920,1080), zoom=scale)
# Reads /images/cgs dir for all image files
# Populates galleryItems
@@ -147,6 +153,66 @@ init python:
pass
"""
renpy.image( fullbody_fangguitar = Composite(
(1920, 1080),
(0, 0), 'fangroom',
(0, 0), 'fangguitar'))
"""
def jsonloadandpop():
#CACHE_PATH = config.basedir.replace("\\","/") + "/game/cache/"
FILENAME = os.path.join(config.basedir, 'game/src/gallery_dataset.json')
#CACHE_PATH = config.basedir.replace("\\","/") + "/game/cache/"
fp = open(FILENAME)
data = json.load(fp)
list_img = renpy.list_images()
for x in data['tabs']:
tab_name = x['tab_name']
_eval = None
if 'eval' in x.keys():
_eval = x['eval']
CG_PATHS.append({'path': None, 'name': tab_name, 'eval': _eval})
gallery_dic[tab_name] = []
#gallery_dataset
if 'items' in x.keys():
for y in x['items']:
name = y["name"]
cg = y["image"]
rcg = renpy.get_registered_image(cg)
#print(rcg.get_size())
image_dimensions = (1920, 1080) #renpy.image_size(rcg)
item = {
"item": name,
"fn": rcg,
"cg": cg_(rcg, None, image_dimensions[0]),
"ext": None,
"wh": image_dimensions
}
gallery_dic[tab_name].append(item)
else: #folders
for str in list_img:
for cp in x['folders']:
for ext in ACCEPTED_EXTENSIONS:
path = cp #cp['path']
_str = path+str+"."+ext
print(_str)
if renpy.loadable(_str): #brute force
add_(str, _str, ext, tab_name) #cp['name'])
print(data)
pass
jsonloadandpop()
pass
@@ -231,7 +297,7 @@ screen cg_gallery(flag, __yoffset = 0, origin = 'CG'):
ycenter 0.525
vpgrid id "vpg":
yinitial __yoffset
#yinitial __yoffset
scrollbars "vertical"
mousewheel True
draggable True
@@ -265,7 +331,7 @@ if/else flow control & extra parameters for Buttons
"""
screen flag_button(item, yoffset, origin):
python:
flag = renpy.seen_image(item['item'])
flag = True #renpy.seen_image(item['item'])
if flag:
button:
@@ -310,8 +376,9 @@ screen view_image(item, _origin, zoom = zoom_arr.index(1.0), flag='a'):
zoom_b_f = ShowMenu('view_image_'+flag, item, _origin, zoom_b)
tag menu
key "game_menu" action _origin
key "button_alternate" action _origin
key "game_menu" action [Hide('view_image'), Show('cg_gallery_0')] #_origin
key "button_alternate" action [Hide('view_image'), Show('cg_gallery_0')]
#key "button_alternate" action _origin
# mousewheel & insert+delete
if (ALLOW_ZOOM):