forked from mirror/Archipelago
core: If a user specifies --no-gui, don't show GUI messageboxes (#5514)
* move `gui_enabled` to Utils * docstring * If a user specified no-gui, don't use GUI messageboxes --------- Co-authored-by: alwaysintreble <mmmcheese158@gmail.com>
This commit is contained in:
@@ -24,7 +24,7 @@ if __name__ == "__main__":
|
|||||||
from MultiServer import CommandProcessor, mark_raw
|
from MultiServer import CommandProcessor, mark_raw
|
||||||
from NetUtils import (Endpoint, decode, NetworkItem, encode, JSONtoTextParser, ClientStatus, Permission, NetworkSlot,
|
from NetUtils import (Endpoint, decode, NetworkItem, encode, JSONtoTextParser, ClientStatus, Permission, NetworkSlot,
|
||||||
RawJSONtoTextParser, add_json_text, add_json_location, add_json_item, JSONTypes, HintStatus, SlotType)
|
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
|
||||||
from worlds import network_data_package, AutoWorldRegister
|
from worlds import network_data_package, AutoWorldRegister
|
||||||
import os
|
import os
|
||||||
import ssl
|
import ssl
|
||||||
@@ -35,9 +35,6 @@ if typing.TYPE_CHECKING:
|
|||||||
|
|
||||||
logger = logging.getLogger("Client")
|
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
|
@Utils.cache_argsless
|
||||||
def get_ssl_context():
|
def get_ssl_context():
|
||||||
|
|||||||
10
Utils.py
10
Utils.py
@@ -914,6 +914,13 @@ def open_directory(title: str, suggest: str = "") -> typing.Optional[str]:
|
|||||||
|
|
||||||
|
|
||||||
def messagebox(title: str, text: str, error: bool = False) -> None:
|
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():
|
if is_kivy_running():
|
||||||
from kvui import MessageBox
|
from kvui import MessageBox
|
||||||
MessageBox(title, text, error).open()
|
MessageBox(title, text, error).open()
|
||||||
@@ -949,6 +956,9 @@ def messagebox(title: str, text: str, error: bool = False) -> None:
|
|||||||
root.update()
|
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"))):
|
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."""
|
"""Sorts a sequence of text ignoring typical articles like "a" or "the" in the beginning."""
|
||||||
def sorter(element: Union[str, Dict[str, Any]]) -> str:
|
def sorter(element: Union[str, Dict[str, Any]]) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user