Add CG Menu & Zoom control

This commit is contained in:
Nutbuster 2021-07-18 12:10:58 +10:00
parent c4f95dd7c6
commit 854ae7f546
1 changed files with 57 additions and 15 deletions

View File

@ -1,5 +1,4 @@
init python: init python:
# CONST PARAMS # CONST PARAMS
GALLERY_COLS = 3 GALLERY_COLS = 3
PREFERRED_WIDTH = 432 #px (1920 * 0.225) PREFERRED_WIDTH = 432 #px (1920 * 0.225)
@ -14,7 +13,7 @@ init python:
{ 'path': "images/cgs/", 'name': "CG", 'eval': None }, { 'path': "images/cgs/", 'name': "CG", 'eval': None },
#{ 'path': "images/animations/", 'name': "Animations", 'eval': None }, #{ 'path': "images/animations/", 'name': "Animations", 'eval': None },
{ 'path': "images/NotForKids!/", 'name': "Lewd", { 'path': "images/NotForKids!/", 'name': "Lewd",
'eval': 'presistent.lewd == True' 'eval': 'persistent.lewd == True'
} }
] ]
#path: folder, name: shows up in gallery, eval: runs eval() on string #path: folder, name: shows up in gallery, eval: runs eval() on string
@ -80,10 +79,25 @@ init python:
# Call to loading the gallery # Call to loading the gallery
loadGallery() loadGallery()
#for zooming in and out
zoom_arr = []
for x in range(1,5):
_zoom = 1.0
_zoom *= 1+(x*0.25)
zoom_arr.append(_zoom)
for y in range(9,1,-1):
_zoom = 1.0
_zoom *= (y*0.125)
zoom_arr.append(_zoom)
zoom_arr.sort()
""" """
'Recursive' / Loopable / Roundtrip Screens 'Recursive' / Loopable / Roundtrip Screens
_0 <-> _1 _0 <-> _1
""" """
#There is renpy.restart_interaction but since I wrote all this, it's too late
#screen cg_gallery(flag, __yoffset = 0, origin = 'CG'):
screen cg_gallery_0(__yoffset = 0, origin = 'CG'): screen cg_gallery_0(__yoffset = 0, origin = 'CG'):
tag menu tag menu
use cg_gallery('1', __yoffset, origin) use cg_gallery('1', __yoffset, origin)
@ -91,6 +105,13 @@ screen cg_gallery_1( __yoffset = 0, origin = 'CG'):
tag menu tag menu
use cg_gallery('0', __yoffset, origin) use cg_gallery('0', __yoffset, origin)
#screen view_image(fn, _origin, zoom=1):
screen view_image_a(fn, _origin, zoom):
tag menu
use view_image(fn, _origin, zoom, 'b')
screen view_image_b(fn, _origin, zoom):
tag menu
use view_image(fn, _origin, zoom, 'a')
""" """
CG Gallery screen - A screen that shows the image gallery CG Gallery screen - A screen that shows the image gallery
Basically Gallery Object has terrible defaults, so I just wrote my own stuff Basically Gallery Object has terrible defaults, so I just wrote my own stuff
@ -146,14 +167,20 @@ screen cg_gallery(flag, __yoffset = 0, origin = 'CG'):
spacing gui.navigation_spacing spacing gui.navigation_spacing
for cp in CG_PATHS: for cp in CG_PATHS:
#gallery_dic[cp['name']] = [] # #define gui.button_text_idle_color = gui.idle_color
if cp['name'] is origin: #define gui.button_text_hover_color = gui.hover_color
textbutton _(cp['name']) #define gui.button_text_selected_color = gui.selected_color
#define gui.button_text_insensitive_color = gui.insensitive_color
if cp['name'] == origin:
textbutton _(cp['name']) text_color gui.selected_color
else: else:
textbutton _(cp['name']) action ShowMenu('cg_gallery_'+flag, 0, cp['name']) if cp['eval'] is None:
#textbutton _(cp['name']) action set_reflow(origin, cp['name'], gallery_rows, empty_spaces) textbutton _(cp['name']) action ShowMenu('cg_gallery_'+flag, 0, cp['name'])
elif eval(cp['eval']):
textbutton _(cp['name']) action ShowMenu('cg_gallery_'+flag, 0, cp['name'])
else:
textbutton _(cp['name'])
textbutton _("Return") action ShowMenu('main_menu') textbutton _("Return") action ShowMenu('main_menu')
if _in_replay: if _in_replay:
@ -163,17 +190,16 @@ screen cg_gallery(flag, __yoffset = 0, origin = 'CG'):
label "Gallery" label "Gallery"
""" """
if/else flow control & extra parameters for Buttons if/else flow control & extra parameters for Buttons
""" """
screen flag_button(item, yoffset, origin): screen flag_button(item, yoffset, origin):
python: python:
flag = renpy.seen_image(item['item']) flag = renpy.seen_image(item['item'])
if flag: if flag:
button: button:
action ShowMenu('view_image', item['fn'], ShowMenu('cg_gallery_0', yoffset, origin)) action ShowMenu('view_image_a', item['fn'], ShowMenu('cg_gallery_0', yoffset, origin), 0.0)
xcenter 0.5 ycenter 0.5 xcenter 0.5 ycenter 0.5
vbox: vbox:
text item["item"] xalign 0.5 text item["item"] xalign 0.5
@ -188,14 +214,30 @@ screen flag_button(item, yoffset, origin):
""" """
view_image, Loads the image in fullscreen with viewport control. view_image, Loads the image in fullscreen with viewport control.
""" """
screen view_image(fn, _origin): screen view_image(fn, _origin, zoom=0.0, flag='a'):
python:
if zoom == 0.0:
zoom = zoom_arr.index(1.0)
zoom_a = zoom+1
zoom_a_f = ShowMenu('view_image_'+flag, fn, _origin, zoom_a)
zoom_b = zoom-1
zoom_b_f = ShowMenu('view_image_'+flag, fn, _origin, zoom_b)
tag menu tag menu
key "game_menu" action _origin key "game_menu" action _origin
viewport:
# mousewheel & insert+delete
if zoom_a < len(zoom_arr):
key 'mousedown_4' action zoom_a_f
key 'K_INSERT' action zoom_a_f
if zoom_b > 0:
key 'mousedown_5' action zoom_b_f
key 'K_DELETE' action zoom_b_f
viewport id "vie":
#Ren'Py is isn't smart enough to not edgescroll while pressed, so we'll have to disable this for mobile #Ren'Py is isn't smart enough to not edgescroll while pressed, so we'll have to disable this for mobile
edgescroll (300, 1800) edgescroll (300, 1800)
draggable True draggable True
arrowkeys True arrowkeys True
pagekeys True pagekeys True
#edgescroll 1.0 add fn zoom zoom_arr[zoom] anchor (0.5, 0.5)
add fn