Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Generation Assets #432

Merged
merged 14 commits into from
Apr 23, 2020
Merged

Next Generation Assets #432

merged 14 commits into from
Apr 23, 2020

Conversation

AstraLuma
Copy link
Member

Or: If assetlib is so good, why isn't there assetlib 2?

This refactors/rewrites many aspects of assetlib to simplify implementations and better enable future asset features. (#373)

@AstraLuma AstraLuma marked this pull request as ready for review April 18, 2020 16:45
@AstraLuma AstraLuma requested a review from a team as a code owner April 18, 2020 16:45
@AstraLuma
Copy link
Member Author

Ok, did a quick docs fixup (although the page needs a real pass).

I think this is ready for review.

This was referenced Apr 18, 2020
Copy link
Collaborator

@pathunstrom pathunstrom left a comment

Choose a reason for hiding this comment

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

This feels super noisy, since the defining assets at module import time is what was pitched as the "right way". It also only seems to get printed when the system stops. Tested on mac, going to give it a shot from windows.

UserWarning: Using SDL2 binaries from pysdl2-dll 2.0.10
2020-04-22 18:15:50.419 Python[27769:4631736] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Waited on <Sound name='shooter/resources/sound/pickup.wav' loaded> before the engine began
Waited on <Sound name='shooter/resources/sound/laser.wav' loaded> before the engine began
Waited on <Sound name='shooter/resources/sound/laser2.wav' loaded> before the engine began
Waited on <Sound name='shooter/resources/sound/hit.wav' loaded> before the engine began
Waited on <Sound name='shooter/resources/sound/life-lost.wav' loaded> before the engine began
Waited on <Sound name='shooter/resources/sound/shield_down.wav' loaded> before the engine began
Waited on <Image name='shooter/resources/bullet.png' loaded> before the engine began
Waited on <Image name='shooter/resources/enemies/message.png' loaded> before the engine began
Waited on <Image name='shooter/resources/enemies/beacon.png' loaded> before the engine began
Waited on <Image name='shooter/resources/enemies/patrol.png' loaded> before the engine began
Waited on <Image name='shooter/resources/enemies/cargo.png' loaded> before the engine began
Waited on <Image name='shooter/resources/enemies/escort.png' loaded> before the engine began
Waited on <Image name='shooter/resources/enemies/zero.png' loaded> before the engine began
Waited on <Image name='shooter/resources/enemies/superiority.png' loaded> before the engine began
Waited on <Image name='shooter/resources/shield.png' loaded> before the engine began
Waited on <Sound name='shooter/resources/sound/enemy-alerted.wav' loaded> before the engine began
Waited on <Image name='shooter/resources/start.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/gun/7.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/gun/6.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/gun/5.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/gun/4.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/gun/3.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/gun/2.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/gun/1.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/gun/0.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/shield/sprite_7.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/shield/sprite_6.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/shield/sprite_5.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/shield/sprite_4.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/shield/sprite_3.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/shield/sprite_2.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/shield/sprite_1.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/shield/sprite_0.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/engine/sprite_7.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/engine/sprite_6.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/engine/sprite_5.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/engine/sprite_4.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/engine/sprite_3.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/engine/sprite_2.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/engine/sprite_1.png' loaded> before the engine began
Waited on <Image name='shooter/resources/powerup/engine/sprite_0.png' loaded> before the engine began
Waited on <Image name='shooter/resources/font/0.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g0e0.png' loaded> before the engine began
Waited on <Image name='shooter/resources/explosions/player/sprite_7.png' loaded> before the engine began
Waited on <Image name='shooter/resources/explosions/player/sprite_6.png' loaded> before the engine began
Waited on <Image name='shooter/resources/explosions/player/sprite_5.png' loaded> before the engine began
Waited on <Image name='shooter/resources/explosions/player/sprite_4.png' loaded> before the engine began
Waited on <Image name='shooter/resources/explosions/player/sprite_3.png' loaded> before the engine began
Waited on <Image name='shooter/resources/explosions/player/sprite_2.png' loaded> before the engine began
Waited on <Image name='shooter/resources/explosions/player/sprite_1.png' loaded> before the engine began
Waited on <Image name='shooter/resources/font/9.png' loaded> before the engine began
Waited on <Image name='shooter/resources/font/8.png' loaded> before the engine began
Waited on <Image name='shooter/resources/font/7.png' loaded> before the engine began
Waited on <Image name='shooter/resources/font/6.png' loaded> before the engine began
Waited on <Image name='shooter/resources/font/5.png' loaded> before the engine began
Waited on <Image name='shooter/resources/font/4.png' loaded> before the engine began
Waited on <Image name='shooter/resources/font/3.png' loaded> before the engine began
Waited on <Image name='shooter/resources/font/2.png' loaded> before the engine began
Waited on <Image name='shooter/resources/font/1.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g3e3.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g3e2.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g3e1.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g3e0.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g2e3.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g2e2.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g2e1.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g2e0.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g1e3.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g1e2.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g1e1.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g1e0.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g0e3.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g0e2.png' loaded> before the engine began
Waited on <Image name='shooter/resources/ship/g0e1.png' loaded> before the engine began
(.venv) ~/src/pathunstrom/shootergame$ ```

@@ -26,7 +106,7 @@ class AbstractAsset(abc.ABC):
real/file assets.
"""
@abc.abstractmethod
def load(self):
def load(self, timeout: float = None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this change. Going to be good when we move to externally fetched assets.

@AstraLuma
Copy link
Member Author

Umm... it really shouldn't be that noisy.

That warning that covers cases like #419, where someone tries to call .load() before the engine starts, which should result in deadlock.

Given that the lifespan of the executor should match the lifespan of the system, I'm not certain how this happened.

(I could, of course, refine the conditions in which the warning is given, but i'm still extremely puzzled as to why it happened.)

@pathunstrom
Copy link
Collaborator

My guess is that I define most of my assets at either the module level or the class attribute level, so when I import the first scene, it chains in basically everything else, and that happens before the engine starts?

@AstraLuma
Copy link
Member Author

The warnings came from FreeingMixin.__del__() conflicting BackgroundMixin.load()'s warning. There isn't a real fix without a more specific combination.

Fixed by shushing if the asset is already loaded.

Copy link
Collaborator

@pathunstrom pathunstrom left a comment

Choose a reason for hiding this comment

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

This looks good now.

bors r+

@bors bors bot merged commit 0bb3479 into ppb:master Apr 23, 2020
@AstraLuma AstraLuma deleted the assets2 branch April 23, 2020 17:40
bors bot added a commit that referenced this pull request Apr 23, 2020
435: Assets2: Background shapes r=pathunstrom a=astronouth7303

Depends on #432 

Moves rendering shapes to the background, using the mixins defined by assets2.

Co-authored-by: Jamie Bliss <jamie@ivyleav.es>
bors bot added a commit that referenced this pull request Apr 26, 2020
436: Assets 2: Chained assets r=pathunstrom a=astronouth7303

Depends on #432 

Implements chained assets: Assets that depend on other assets (such as how Text depends on Fonts)

Closes #373 

Co-authored-by: Jamie Bliss <jamie@ivyleav.es>
bors bot added a commit that referenced this pull request Apr 26, 2020
443: Text r=pathunstrom a=astronouth7303

Implements basic text rending. No wrapping or rich text supported.

Depends on #432, #436 

Closes #146 

Co-authored-by: Jamie Bliss <jamie@ivyleav.es>
bors bot added a commit that referenced this pull request Apr 26, 2020
443: Text r=pathunstrom a=astronouth7303

Implements basic text rending. No wrapping or rich text supported.

Depends on #432, #436 

Closes #146 

Co-authored-by: Jamie Bliss <jamie@ivyleav.es>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants