Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 1 addition & 4 deletions CommonClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from MultiServer import CommandProcessor, mark_raw
from NetUtils import (Endpoint, decode, NetworkItem, encode, JSONtoTextParser, ClientStatus, Permission, NetworkSlot,
RawJSONtoTextParser, add_json_text, add_json_location, add_json_item, JSONTypes, HintStatus, SlotType)
from Utils import Version, stream_input, async_start
from Utils import gui_enabled, Version, stream_input, async_start
Copy link
Member

@NewSoupVi NewSoupVi Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your changes are sensible, but I'm a bit confused about this original Treble stuff.

Imo, there are two possibilities:

  1. This should be from Utils import gui_enabled as gui_enabled
  2. Clients are "meant" to switch over to from Utils import gui_enabled, in which case this should get an API Updates ping

Reason: Relying on implicit reexporting is bad™️ (It fails mypy, for example, i.e. this change would implicitly make mypy-compliant worlds fail mypy without their knowledge)

I would like us to be clear about what the intent is here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, 100% agree with that.

My gut prefers the second option?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree I think

from worlds import network_data_package, AutoWorldRegister
import os
import ssl
Expand All @@ -35,9 +35,6 @@

logger = logging.getLogger("Client")

# without terminal, we have to use gui mode
gui_enabled = not sys.stdout or "--nogui" not in sys.argv


@Utils.cache_argsless
def get_ssl_context():
Expand Down
10 changes: 10 additions & 0 deletions Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,13 @@ def open_directory(title: str, suggest: str = "") -> typing.Optional[str]:


def messagebox(title: str, text: str, error: bool = False) -> None:
if not gui_enabled:
if error:
logging.error(f"{title}: {text}")
else:
logging.info(f"{title}: {text}")
return

if is_kivy_running():
from kvui import MessageBox
MessageBox(title, text, error).open()
Expand Down Expand Up @@ -885,6 +892,9 @@ def messagebox(title: str, text: str, error: bool = False) -> None:
root.update()


gui_enabled = not sys.stdout or "--nogui" not in sys.argv
"""Checks if the user wanted no GUI mode and has a terminal to use it with."""

def title_sorted(data: typing.Iterable, key=None, ignore: typing.AbstractSet[str] = frozenset(("a", "the"))):
"""Sorts a sequence of text ignoring typical articles like "a" or "the" in the beginning."""
def sorter(element: Union[str, Dict[str, Any]]) -> str:
Expand Down
Loading