Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions schemas/Manual.meta.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
"description": "Enable the generation of puml diagram of your apworld region and locations for debug purposes",
"type": "boolean",
"default": false
},
"sort_items_alphabetically": {
"description": "Sort items alphabetically in the Client UI",
"type": "boolean",
"default": true
},
"sort_locations_alphabetically": {
"description": "Sort locations alphabetically in the Client UI",
"type": "boolean",
"default": true
}
},
"definitions": {
Expand Down
39 changes: 26 additions & 13 deletions src/ManualClient.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
import time
import sys
from typing import Any, Optional
from typing import Any, Dict, List, Optional
import typing
from worlds import AutoWorldRegister, network_data_package
import json
Expand Down Expand Up @@ -237,7 +237,7 @@ def handle_connection_loss(self, msg: str) -> None:

if tracker_error:
self._messagebox_connection_loss = self.gui_error(
"A Universal Tracker error has occurred. Please ensure that your version of UT matches your version of Archipelago.",
"A Universal Tracker error has occurred. Please ensure that your version of UT matches your version of Archipelago.",
formatted_tb)
else:
self._messagebox_connection_loss = self.gui_error(msg, formatted_tb)
Expand Down Expand Up @@ -377,7 +377,7 @@ def build(self) -> Layout:
def clear_lists(self):
self.listed_items = {"(No Category)": []}
self.item_categories = ["(No Category)"]
self.listed_locations = {"(No Category)": [], "(Hinted)": []}
self.listed_locations: Dict[str, List[int]] = {"(No Category)": [], "(Hinted)": []}
self.location_categories = ["(No Category)", "(Hinted)"]

def set_active_item_accordion(self, instance):
Expand Down Expand Up @@ -525,8 +525,14 @@ def build_tracker_and_locations_table(self):
if not victory_categories:
victory_categories.add("(No Category)")

for category in self.listed_locations:
self.listed_locations[category].sort(key=self.ctx.location_names.lookup_in_game)
if getattr(AutoWorldRegister.world_types[self.ctx.game], "sort_locations_alphabetically", True):
# sort by location name
for category in self.listed_locations:
self.listed_locations[category].sort(key=self.ctx.location_names.lookup_in_game)
else:
# sort by location ID
for category in self.listed_locations:
self.listed_locations[category].sort()

items_length = len(self.ctx.items_received)
tracker_panel_scrollable = TrackerLayoutScrollable(do_scroll=(False, True), bar_width=10)
Expand Down Expand Up @@ -610,12 +616,12 @@ def update_tracker_and_locations_table(self, update_highlights=False):

if self.ctx.search_term:
items_length = len([
i for i in self.ctx.items_received
i for i in self.ctx.items_received
if self.ctx.search_term.lower() in self.ctx.item_names.lookup_in_game(i.item).lower()
])

locations_length = len([
l for l in self.ctx.missing_locations
l for l in self.ctx.missing_locations
if self.ctx.search_term.lower() in self.ctx.location_names.lookup_in_game(l).lower()
])

Expand Down Expand Up @@ -685,9 +691,16 @@ def update_tracker_and_locations_table(self, update_highlights=False):
self.listed_items[category_name].clear()

# Label (for all item listings)
sorted_items_received = sorted([
i.item for i in self.ctx.items_received
], key=self.ctx.item_names.lookup_in_game)
if getattr(AutoWorldRegister.world_types[self.ctx.game], "sort_items_alphabetically", True):
# sort by item name
sorted_items_received = sorted([
i.item for i in self.ctx.items_received
], key=self.ctx.item_names.lookup_in_game)
else:
# sort by item ID
sorted_items_received = sorted([
i.item for i in self.ctx.items_received
])

for network_item in sorted_items_received:
item_name = self.ctx.item_names.lookup_in_game(network_item)
Expand Down Expand Up @@ -776,7 +789,7 @@ def hide_button_during_search(btn: TreeViewButton):
if location_button.text not in (self.ctx.location_table or AutoWorldRegister.world_types[self.ctx.game].location_name_to_location):
# if the player is searching for text and the location name doesn't contain it, hide and disable it
if self.ctx.search_term and not self.ctx.search_term.lower() in location_button.text.lower():
hide_button_during_search(location_button)
hide_button_during_search(location_button)
else:
show_button_during_search(location_button)
category_count += 1
Expand Down Expand Up @@ -804,10 +817,10 @@ def hide_button_during_search(btn: TreeViewButton):

# if the player is searching for text and the location name doesn't contain it, hide and disable it
if self.ctx.search_term and not self.ctx.search_term.lower() in location_button.text.lower():
hide_button_during_search(location_button)
hide_button_during_search(location_button)
else:
show_button_during_search(location_button)

if was_reachable:
reachable_count += 1

Expand Down
3 changes: 3 additions & 0 deletions src/Meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ def set_world_webworld(web: WebWorld) -> WebWorld:
world_webworld: ManualWeb = set_world_webworld(ManualWeb())

enable_region_diagram = bool(meta_table.get("enable_region_diagram", False))

sort_items_alphabetically = bool(meta_table.get("sort_items_alphabetically", True))
sort_locations_alphabetically = bool(meta_table.get("sort_locations_alphabetically", True))
7 changes: 5 additions & 2 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from .Data import item_table, location_table, region_table, category_table, meta_table
from .Game import game_name, filler_item_name, starting_items
from .Meta import world_description, world_webworld, enable_region_diagram
from .Meta import world_description, world_webworld, enable_region_diagram, sort_items_alphabetically, sort_locations_alphabetically
from .Locations import location_id_to_name, location_name_to_id, location_name_to_location, location_name_groups, victory_names
from .Items import item_id_to_name, item_name_to_id, item_name_to_item, item_name_groups
from .DataValidation import runGenerationDataValidation, runPreFillDataValidation
Expand Down Expand Up @@ -67,6 +67,9 @@ class ManualWorld(World):
location_name_groups = location_name_groups
victory_names = victory_names

sort_items_alphabetically = sort_items_alphabetically
sort_locations_alphabetically = sort_locations_alphabetically

# UT (the universal-est of trackers) can now generate without a YAML
ut_can_gen_without_yaml = True

Expand Down Expand Up @@ -460,7 +463,7 @@ def __init__(self, display_name: str, script_name: Optional[str] = None, func: O
self.version = version

def add_client_to_launcher() -> None:
version = 2024_11_22 # YYYYMMDD
version = 2024_12_10 # YYYYMMDD
found = False

if "manual" not in icon_paths:
Expand Down