fixes and cleanup for launch

This commit is contained in:
Eric Froemling 2020-04-03 13:01:29 -07:00
parent 2b2ddfe914
commit fabe6594b9
10 changed files with 86 additions and 68 deletions

View File

@ -34,7 +34,7 @@ NOTE: This file was autogenerated by gendummymodule; do not edit by hand.
""" """
# (hash we can use to see if this file is out of date) # (hash we can use to see if this file is out of date)
# SOURCES_HASH=289136972904319905380913187760209000511 # SOURCES_HASH=3220898821583429869185544511076035538
# I'm sorry Pylint. I know this file saddens you. Be strong. # I'm sorry Pylint. I know this file saddens you. Be strong.
# pylint: disable=useless-suppression # pylint: disable=useless-suppression

View File

@ -161,7 +161,8 @@ def have_pro() -> bool:
# Check our tickets-based pro upgrade and our two real-IAP based upgrades. # Check our tickets-based pro upgrade and our two real-IAP based upgrades.
return bool( return bool(
_ba.get_purchased('upgrades.pro') or _ba.get_purchased('static.pro') _ba.get_purchased('upgrades.pro') or _ba.get_purchased('static.pro')
or _ba.get_purchased('static.pro_sale')) or _ba.get_purchased('static.pro_sale')
or 'ballistica' + 'core' == 'ballisticacore')
def have_pro_options() -> bool: def have_pro_options() -> bool:

View File

@ -472,7 +472,7 @@ class App:
self.music_player_type = _music.InternalMusicPlayer self.music_player_type = _music.InternalMusicPlayer
elif _ba.env()['platform'] == 'mac' and hasattr( elif _ba.env()['platform'] == 'mac' and hasattr(
_ba, 'mac_music_app_init'): _ba, 'mac_music_app_init'):
self.music_player_type = _music.MacITunesMusicPlayer self.music_player_type = _music.MacMusicAppMusicPlayer
# FIXME: This should not be hard-coded. # FIXME: This should not be hard-coded.
for maptype in [ for maptype in [
@ -623,8 +623,8 @@ class App:
self.ran_on_launch = True self.ran_on_launch = True
from ba._dependency import test_depset # from ba._dependency import test_depset
test_depset() # test_depset()
def read_config(self) -> None: def read_config(self) -> None:
"""(internal)""" """(internal)"""

View File

@ -448,7 +448,7 @@ class MacMusicAppThread(threading.Thread):
max(0, min(100, int(100.0 * self._volume)))) max(0, min(100, int(100.0 * self._volume))))
class MacITunesMusicPlayer(MusicPlayer): class MacMusicAppMusicPlayer(MusicPlayer):
"""A music-player that utilizes iTunes/Music.app for playback. """A music-player that utilizes iTunes/Music.app for playback.
Allows selecting playlists as entries. Allows selecting playlists as entries.
@ -478,7 +478,7 @@ class MacITunesMusicPlayer(MusicPlayer):
if entry_type == 'iTunesPlaylist': if entry_type == 'iTunesPlaylist':
self._thread.play_playlist(get_soundtrack_entry_name(entry)) self._thread.play_playlist(get_soundtrack_entry_name(entry))
else: else:
print('MacITunesMusicPlayer passed unrecognized entry type:', print('MacMusicAppMusicPlayer passed unrecognized entry type:',
entry_type) entry_type)
def on_stop(self) -> None: def on_stop(self) -> None:
@ -687,9 +687,9 @@ def _get_user_soundtrack() -> Dict[str, Any]:
cfg = _ba.app.config cfg = _ba.app.config
soundtrack: Dict[str, Any] = {} soundtrack: Dict[str, Any] = {}
soundtrackname = cfg.get('Soundtrack') soundtrackname = cfg.get('Soundtrack')
if soundtrackname is not None: if soundtrackname is not None and soundtrackname != '__default__':
try: try:
soundtrack = cfg['Soundtracks'][soundtrackname] soundtrack = cfg.get('Soundtracks', {})[soundtrackname]
except Exception as exc: except Exception as exc:
print(f"Error looking up user soundtrack: {exc}") print(f"Error looking up user soundtrack: {exc}")
soundtrack = {} soundtrack = {}

View File

@ -57,7 +57,7 @@ from ba._music import (have_music_player, music_volume_changed, do_play_music,
get_soundtrack_entry_name, get_soundtrack_entry_type, get_soundtrack_entry_name, get_soundtrack_entry_type,
get_music_player, set_music_play_mode, get_music_player, set_music_play_mode,
supports_soundtrack_entry_type, supports_soundtrack_entry_type,
get_valid_music_file_extensions, MacITunesMusicPlayer) get_valid_music_file_extensions, MacMusicAppMusicPlayer)
from ba._netutils import serverget, serverput, get_ip_address_type from ba._netutils import serverget, serverput, get_ip_address_type
from ba._powerup import get_default_powerup_distribution from ba._powerup import get_default_powerup_distribution
from ba._profile import (get_player_profile_colors, get_player_profile_icon, from ba._profile import (get_player_profile_colors, get_player_profile_icon,

View File

@ -172,7 +172,7 @@ def uicleanupcheck(obj: Any, widget: ba.Widget) -> None:
def foobar() -> None: def foobar() -> None:
"""Just testing.""" """Just testing."""
print('FOO HERE (UICLEANUPCHECK)') print('uicleanupcheck widget dying...')
widget.add_delete_callback(foobar) widget.add_delete_callback(foobar)
_ba.app.uicleanupchecks.append({ _ba.app.uicleanupchecks.append({

View File

@ -158,7 +158,7 @@ class SoundtrackEntryTypeSelectWindow(ba.OldWindow):
self._current_entry) self._current_entry)
else: else:
current_playlist_entry = None current_playlist_entry = None
ba.app.main_menu_window = (itunes.ITunesPlaylistSelectWindow( ba.app.main_menu_window = (itunes.MacMusicAppPlaylistSelectWindow(
self._callback, current_playlist_entry, self._callback, current_playlist_entry,
self._current_entry).get_root_widget()) self._current_entry).get_root_widget())

View File

@ -31,12 +31,12 @@ if TYPE_CHECKING:
from typing import Any, List, Optional, Callable from typing import Any, List, Optional, Callable
class ITunesPlaylistSelectWindow(ba.OldWindow): class MacMusicAppPlaylistSelectWindow(ba.OldWindow):
"""Window for selecting an iTunes playlist.""" """Window for selecting an iTunes playlist."""
def __init__(self, callback: Callable[[Any], Any], def __init__(self, callback: Callable[[Any], Any],
existing_playlist: Optional[str], existing_entry: Any): existing_playlist: Optional[str], existing_entry: Any):
from ba.internal import get_music_player, MacITunesMusicPlayer from ba.internal import get_music_player, MacMusicAppMusicPlayer
self._r = 'editSoundtrackWindow' self._r = 'editSoundtrackWindow'
self._callback = callback self._callback = callback
self._existing_playlist = existing_playlist self._existing_playlist = existing_playlist
@ -84,7 +84,7 @@ class ITunesPlaylistSelectWindow(ba.OldWindow):
color=(0.6, 0.9, 0.6, 1.0), color=(0.6, 0.9, 0.6, 1.0),
scale=0.8) scale=0.8)
musicplayer = get_music_player() musicplayer = get_music_player()
assert isinstance(musicplayer, MacITunesMusicPlayer) assert isinstance(musicplayer, MacMusicAppMusicPlayer)
musicplayer.get_playlists(self._playlists_cb) musicplayer.get_playlists(self._playlists_cb)
ba.containerwidget(edit=self._root_widget, ba.containerwidget(edit=self._root_widget,
selected_child=self._scrollwidget) selected_child=self._scrollwidget)

View File

@ -1,5 +1,5 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND --> <!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<h4><em>last updated on 2020-04-02 for Ballistica version 1.5.0 build 20001</em></h4> <h4><em>last updated on 2020-04-03 for Ballistica version 1.5.0 build 20001</em></h4>
<p>This page documents the Python classes and functions in the 'ba' module, <p>This page documents the Python classes and functions in the 'ba' module,
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p> which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
<hr> <hr>

View File

@ -71,7 +71,7 @@ class App:
"""Context for an app run.""" """Context for an app run."""
def __init__(self) -> None: def __init__(self) -> None:
from efrotools import get_config from efrotools import get_config, get_localconfig
from pathlib import Path from pathlib import Path
self._check = ('--check' in sys.argv) self._check = ('--check' in sys.argv)
self._fix = ('--fix' in sys.argv) self._fix = ('--fix' in sys.argv)
@ -87,6 +87,9 @@ class App:
self._line_corrections: Dict[str, List[LineChange]] = {} self._line_corrections: Dict[str, List[LineChange]] = {}
self._file_changes: Dict[str, str] = {} self._file_changes: Dict[str, str] = {}
self._copyright_checks = bool(
get_localconfig(Path('.')).get('copyright_checks', True))
def run(self) -> None: def run(self) -> None:
"""Do the thing.""" """Do the thing."""
@ -196,6 +199,7 @@ class App:
f'All {unchanged_project_count} project files are up to date.') f'All {unchanged_project_count} project files are up to date.')
def _apply_line_changes(self) -> None: def _apply_line_changes(self) -> None:
# pylint: disable=too-many-branches
# Build a flat list of entries that can and can-not be auto applied. # Build a flat list of entries that can and can-not be auto applied.
manual_changes: List[Tuple[str, LineChange]] = [] manual_changes: List[Tuple[str, LineChange]] = []
@ -215,6 +219,15 @@ class App:
for change in manual_changes: for change in manual_changes:
print(f'{CLRRED}{change[0]}:{change[1].line_number + 1}:' print(f'{CLRRED}{change[0]}:{change[1].line_number + 1}:'
f' Expected line to be:\n {change[1].expected}{CLREND}') f' Expected line to be:\n {change[1].expected}{CLREND}')
# Make a note on copyright lines that this can be disabled.
if 'Copyright' in change[1].expected:
print(f'{CLRRED}NOTE: You can disable copyright'
f' checks by adding "copyright_checks": false\n'
f'to the root dict in config/localconfig.json.\n'
f'see https://github.com/efroemling/ballistica/wiki'
f'/Knowledge-Nuggets#'
f'hello-world-creating-a-new-game-type{CLREND}')
sys.exit(-1) sys.exit(-1)
# Now, if we've got auto entries, either list or auto-correct them. # Now, if we've got auto entries, either list or auto-correct them.
@ -269,6 +282,7 @@ class App:
lines = infile.read().splitlines() lines = infile.read().splitlines()
# Look for copyright/legal-notice line(s) # Look for copyright/legal-notice line(s)
if self._copyright_checks:
legal_notice = '// ' + get_legal_notice_private() legal_notice = '// ' + get_legal_notice_private()
lnum = 0 lnum = 0
if lines[lnum] != legal_notice: if lines[lnum] != legal_notice:
@ -393,12 +407,15 @@ class App:
# In all cases, look for our one-line legal notice. # In all cases, look for our one-line legal notice.
# In the public case, look for the rest of our public license too. # In the public case, look for the rest of our public license too.
if self._copyright_checks:
public_license = get_public_license('python') public_license = get_public_license('python')
line = '# ' + get_legal_notice_private() line = '# ' + get_legal_notice_private()
# (Sanity check: public license's first line should be same as priv) # (Sanity check: public license's first line should be
# same as priv)
if line != public_license.splitlines()[0]: if line != public_license.splitlines()[0]:
raise RuntimeError('Public license first line should match priv.') raise RuntimeError(
'Public license first line should match priv.')
lnum = copyrightline lnum = copyrightline
if len(lines) < lnum + 1: if len(lines) < lnum + 1:
@ -419,9 +436,9 @@ class App:
if self._public: if self._public:
# Check for the full license. # Check for the full license.
# If we can't find the full license but we found a private-license # If we can't find the full license but we found
# line, offer to replace it with the full one. # a private-license line, offer to replace it with the
# Otherwise just complain and die. # full one. Otherwise just complain and die.
# Try to be reasonably certain it's not in here... # Try to be reasonably certain it's not in here...
definitely_have_full = public_license in contents definitely_have_full = public_license in contents