forked from ArchipelagoMW/Archipelago
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sc2-next' of https://github.com/Ziktofel/Archipelago in…
…to sc2-next
- Loading branch information
Showing
11 changed files
with
262 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
Import this before importing client_gui.py to set window defaults from world settings. | ||
""" | ||
from .settings import Starcraft2Settings | ||
from typing import List | ||
|
||
def apply_window_defaults() -> List[str]: | ||
""" | ||
Set the kivy config keys from the sc2world user settings. | ||
Returns a list of warnings to be printed once the GUI is started. | ||
""" | ||
from . import SC2World | ||
# This is necessary to prevent kivy from failing because it got invalid command-line args, | ||
# or from spamming the logs. | ||
# Must happen before importing kivy.config | ||
import os | ||
os.environ["KIVY_NO_CONSOLELOG"] = "1" | ||
os.environ["KIVY_NO_FILELOG"] = "1" | ||
os.environ["KIVY_NO_ARGS"] = "1" | ||
os.environ["KIVY_LOG_ENABLE"] = "0" | ||
|
||
# validate settings | ||
warnings: List[str] = [] | ||
if isinstance(SC2World.settings.window_height, int) and SC2World.settings.window_height > 0: | ||
window_height = SC2World.settings.window_height | ||
else: | ||
warnings.append(f"Invalid value for options.yaml key sc2_options.window_height: '{SC2World.settings.window_height}'. Expected a positive integer.") | ||
window_height = Starcraft2Settings.window_height | ||
if isinstance(SC2World.settings.window_width, int) and SC2World.settings.window_width > 0: | ||
window_width = SC2World.settings.window_width | ||
else: | ||
warnings.append(f"Invalid value for options.yaml key sc2_options.window_width: '{SC2World.settings.window_width}'. Expected a positive integer.") | ||
window_width = Starcraft2Settings.window_width | ||
|
||
from kivy.config import Config | ||
Config.set('graphics', 'width', str(window_width)) | ||
Config.set('graphics', 'height', str(window_height)) | ||
if SC2World.settings.window_maximized: | ||
Config.set('graphics', 'window_state', 'maximized') | ||
return warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.