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