Turn two actions into functions

technically not as correct, but works all the same and is relatively faster (but it will be replaced with better actions in the future anyway)
the pickle lock, if any, for removing them in the future, becomes easier to solve
This commit is contained in:
Gouvernathor 2023-11-17 02:15:31 +01:00
parent abe5d551fc
commit 6216b62ef9

View File

@ -15,30 +15,28 @@ init python:
return item
class __Sort(Action):
# TODO: replace with CycleVariable("current_sorting", ("A-z", "z-A", "Available", "Unavailable"))
def __call__(self):
global current_sorting
def __Sort():
# TODO: in 8.2, replace with CycleVariable("current_sorting", ("A-z", "z-A", "Available", "Unavailable"))
global current_sorting
if current_sorting == "A-z":
current_sorting = "z-A"
elif current_sorting == "z-A":
current_sorting = "Available"
elif current_sorting == "Available":
current_sorting = "Unavailable"
else:
current_sorting = "A-z"
if current_sorting == "A-z":
current_sorting = "z-A"
elif current_sorting == "z-A":
current_sorting = "Available"
elif current_sorting == "Available":
current_sorting = "Unavailable"
else:
current_sorting = "A-z"
class __Filter(Action):
# TODO: replace with CycleVariable("current_filter", ("Owned", None))
def __Filter():
# TODO: in 8.2, replace with CycleVariable("current_filter", ("Owned", None))
# (ToggleVariable would cause selectedness problems)
def __call__(self):
global current_filter
global current_filter
if current_filter is None:
current_filter = "Owned"
else:
current_filter = None
if current_filter is None:
current_filter = "Owned"
else:
current_filter = None
class __Actuate(Action):
def __call__(self):
@ -265,10 +263,10 @@ screen inventory_menu(xx, yy):
style_prefix gui.theme('achievements_filters')
pos (6, 384)
if current_filter is None:
textbutton "Show: All" action [__Filter(), __Actuate()]
textbutton "Show: All" action [__Filter, __Actuate()]
else:
textbutton "Show: [current_filter]" action [__Filter(), __Actuate()]
textbutton "Sort by: [current_sorting]" action [__Sort(), __Actuate()]
textbutton "Show: [current_filter]" action [__Filter, __Actuate()]
textbutton "Sort by: [current_sorting]" action [__Sort, __Actuate()]
screen inventory_menuitem(xx, yy):
window:
@ -305,13 +303,15 @@ screen inventory_menuitem(xx, yy):
idle gui.format("interface/frames/{}/arrow_up.webp")
if current_page > 0:
hover image_hover(gui.format("interface/frames/{}/arrow_up.webp"))
action SetVariable("current_page", current_page-1) # TODO: replace with IncrementVariable("current_page", -1)
action SetVariable("current_page", current_page-1)
# TODO: in 8.2, replace with IncrementVariable("current_page", -1)
imagebutton:
idle Transform(gui.format("interface/frames/{}/arrow_up.webp"), yzoom=-1)
if current_page < math.ceil((menu_items_length-1)/items_shown)-1:
hover Transform(image_hover(gui.format("interface/frames/{}/arrow_up.webp")), yzoom=-1)
action SetVariable("current_page", current_page+1) # TODO: replace with IncrementVariable("current_page")
action SetVariable("current_page", current_page+1)
# TODO: in 8.2, replace with IncrementVariable("current_page")
# Add items
grid 9 4: