Auto-generate avatars.less
PR Description:
Fixes #2651
Summary:
This PR addresses the issue of dynamically generating and loading avatars for creatures in the game, specifically focusing on automating the generation of the avatars.less file and ensuring correct avatar references during the build process. However, the creature avatars are still not being displayed in the summon grid and top bar despite the assets being preloaded correctly.
Changes Made:
1. Created generateAvatar.js script to auto-generate avatars.less:
Automatically generates the avatars.less file during the build process, containing CSS classes for all avatars.
This eliminates the need to manually update avatars.less when new avatars are added to the game.
2. Updated webpack.config.js to handle avatar assets correctly:
Ensured that avatar images like Chimera.jpg are served with their original filenames by modifying the assetModuleFilename configuration, avoiding file hashing for avatars.
This makes sure that the avatars can be referenced by their base key or cardboard key.
3. Refactored assets.ts to properly load avatar assets:
Explicitly loads both the base key and cardboard key for each avatar.
This ensures that both the top bar and summon grid use the correct avatar images.
4. Cleaned up avatars.less:
Removed the outdated method of managing avatars and now rely on the auto-generated avatars.less file to ensure that all avatars are correctly mapped to CSS classes.
The file is always up-to-date with the latest avatars, and changes to the avatars are handled automatically.
Current Status:
The avatar grid is now automatically generated and the assets are preloaded correctly.
However, the creature avatars are still not being displayed in the summon grid and top bar.
Avatars are being loaded into Phaser, but the actual rendering logic (for the summon grid and top bar) isn’t correctly referencing or displaying the avatars as expected.
PR Objective:
This PR successfully automates avatar generation, ensuring that new avatars are correctly added to the game and preloaded into Phaser. However, the issue of creature avatars not being displayed in the summon grid and top bar still needs to be resolved. The next step is to address the rendering logic that displays these avatars.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Updated (UTC) |
|---|---|---|---|
| ancientbeast | ✅ Ready (Inspect) | Visit Preview | Mar 23, 2025 0:45am |
Hi @DreadKnight ,
I noticed my PR was marked as a draft. Could you please let me know if there’s anything that needs to be updated or fixed before it can be merged? I’m happy to make any changes as needed.
Thanks for reviewing!
@yousefsassy Heya! Because I've tested it and it has the exact same problem as the other PR that poked at this issue. As you mentioned; hence why it's not ready for it to be merged, as there's no point in adding something to the game that cause regressions, so I'm waiting for it to get patched more and I'll test again and then go from there. Waiting on that 🐻
@DreadKnight I was actually quite happy when I saw that the auto-generated avatar grid worked as expected! 🎉 But then I got a bit upset when another issue popped up regarding the creatures' avatars not displaying properly. It seems like there’s still a bug that needs to be worked through before the PR can be fully merged.
I might shift focus to another issue for now, but I’ll definitely come back to this and try again once I have some more time to tackle it. Thanks for your patience!
@yousefsassy Any progress on this one? I've unassigned you from #2651 unless I hear that you're still on it 🐻
@DreadKnight im still on it as I told you before I have my final exams these weeks so I won't be online that much 🐻