Disable categories unusable for the current character in gift context
This commit is contained in:
parent
524e3555a3
commit
79b1cff97a
@ -37,13 +37,13 @@ screen inventory():
|
||||
|
||||
at navigation_subtabs_show
|
||||
|
||||
textbutton _("Gifts") action [SetScreenVariable("category", "gift"), SetScreenVariable("menu_items", inventory.get_instances_of_type("gift")), SetScreenVariable("selected_item", None)] selected (category=="gift") at navigation_tabs
|
||||
textbutton _("Books") action [SetScreenVariable("category", "book"), SetScreenVariable("menu_items", inventory.get_instances_of_type("book")), SetScreenVariable("selected_item", None)] selected (category=="book") at navigation_tabs
|
||||
textbutton _("Scrolls") action [SetScreenVariable("category", "scroll"), SetScreenVariable("menu_items", inventory.get_instances_of_type("scroll")), SetScreenVariable("selected_item", None)] selected (category=="scroll") at navigation_tabs
|
||||
textbutton _("Ingredients") action [SetScreenVariable("category", "ingredient"), SetScreenVariable("menu_items", inventory.get_instances_of_type("ingredient")), SetScreenVariable("selected_item", None)] selected (category=="ingredient") at navigation_tabs
|
||||
textbutton _("Potions") action [SetScreenVariable("category", "potion"), SetScreenVariable("menu_items", inventory.get_instances_of_type("potion")), SetScreenVariable("selected_item", None)] selected (category=="potion") at navigation_tabs
|
||||
textbutton _("Decorations") action [SetScreenVariable("category", "decoration"), SetScreenVariable("menu_items", inventory.get_instances_of_type("decoration")), SetScreenVariable("selected_item", None)] selected (category=="decoration") at navigation_tabs
|
||||
textbutton _("Consumables") action [SetScreenVariable("category", "quest"), SetScreenVariable("menu_items", inventory.get_instances_of_type("quest")), SetScreenVariable("selected_item", None)] selected (category=="quest") at navigation_tabs
|
||||
textbutton _("Gifts") action [SetScreenVariable("category", "gift"), SetScreenVariable("menu_items", inventory.get_instances_of_type("gift")), SetScreenVariable("selected_item", None)] selected (category=="gift") sensitive (inventory_mode==0 or inventory.is_givable_type("gift")) at navigation_tabs
|
||||
textbutton _("Books") action [SetScreenVariable("category", "book"), SetScreenVariable("menu_items", inventory.get_instances_of_type("book")), SetScreenVariable("selected_item", None)] selected (category=="book") sensitive (inventory_mode==0 or inventory.is_givable_type("book")) at navigation_tabs
|
||||
textbutton _("Scrolls") action [SetScreenVariable("category", "scroll"), SetScreenVariable("menu_items", inventory.get_instances_of_type("scroll")), SetScreenVariable("selected_item", None)] selected (category=="scroll") sensitive (inventory_mode==0 or inventory.is_givable_type("scroll")) at navigation_tabs
|
||||
textbutton _("Ingredients") action [SetScreenVariable("category", "ingredient"), SetScreenVariable("menu_items", inventory.get_instances_of_type("ingredient")), SetScreenVariable("selected_item", None)] selected (category=="ingredient") sensitive (inventory_mode==0 or inventory.is_givable_type("ingredient")) at navigation_tabs
|
||||
textbutton _("Potions") action [SetScreenVariable("category", "potion"), SetScreenVariable("menu_items", inventory.get_instances_of_type("potion")), SetScreenVariable("selected_item", None)] selected (category=="potion") sensitive (inventory_mode==0 or inventory.is_givable_type("potion")) at navigation_tabs
|
||||
textbutton _("Decorations") action [SetScreenVariable("category", "decoration"), SetScreenVariable("menu_items", inventory.get_instances_of_type("decoration")), SetScreenVariable("selected_item", None)] selected (category=="decoration") sensitive (inventory_mode==0 or inventory.is_givable_type("decoration")) at navigation_tabs
|
||||
textbutton _("Consumables") action [SetScreenVariable("category", "quest"), SetScreenVariable("menu_items", inventory.get_instances_of_type("quest")), SetScreenVariable("selected_item", None)] selected (category=="quest") sensitive (inventory_mode==0 or inventory.is_givable_type("quest")) at navigation_tabs
|
||||
null height 35
|
||||
textbutton _("Return") action [SetScreenVariable("navigation_last_frame_atl", navigation_last_frame_hide), SetScreenVariable("navigation_atl", navigation_hide), SetScreenVariable("navigation_exit", True)] keysym ["inventory", "game_menu"] at navigation_tabs
|
||||
|
||||
|
@ -15,6 +15,17 @@ init python:
|
||||
def get_instances_of_type(self, type):
|
||||
return sorted([x for x in self.get_instances() if x.type == type], key=lambda y: natsort_key(y.name))
|
||||
|
||||
def _get_givables(self, type):
|
||||
return any(x.givable for x in self.get_instances_of_type(type))
|
||||
|
||||
def _get_usables(self, type, char):
|
||||
return any(char in x.usable_on for x in self.get_instances_of_type(type))
|
||||
|
||||
def is_givable_type(self, type, char=None):
|
||||
if not char:
|
||||
char = states.active_girl
|
||||
return self._get_givables(type) and self._get_usables(type, char)
|
||||
|
||||
class Item(object):
|
||||
def __init__(self, id, type, name, price=0, desc="", unlocked=True, use_func=None, use_label=None, give_func=None, give_label=None, limit=100, image="default", givable=False, currency="gold", use_caption=_("Use"), give_caption=_("Give"), owned=0, infinite=False, usable_on=[]):
|
||||
self.id = id
|
||||
@ -32,11 +43,11 @@ init python:
|
||||
self.limit = limit
|
||||
self.image = f"interface/icons/{self.id}.webp" if image == "default" else image
|
||||
self.currency = currency
|
||||
self.givable = bool(self.give_func or self.give_label)
|
||||
self.usable = bool(self.use_func or self.use_label)
|
||||
self.used = False
|
||||
self.infinite = infinite
|
||||
self.usable_on = usable_on
|
||||
self.givable = bool(self.give_func or self.give_label or self.usable_on)
|
||||
self.usable = bool(self.use_func or self.use_label)
|
||||
|
||||
self._owned = owned
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user