Moved away from singleton pattern

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-17 20:24:39 +01:00
parent 4c28a66554
commit 55cf73f7f5
7 changed files with 70 additions and 47 deletions

View File

@@ -5,11 +5,11 @@ import 'package:wolf_3d_flutter/wolf_3d.dart';
import 'package:wolf_3d_renderer/wolf_3d_asset_painter.dart';
class SpriteGallery extends StatelessWidget {
final List<Sprite> sprites;
final Wolf3d wolf3d;
const SpriteGallery({super.key, required this.sprites});
const SpriteGallery({super.key, required this.wolf3d});
bool get isShareware => Wolf3d.I.activeGame.version == GameVersion.shareware;
bool get isShareware => wolf3d.activeGame.version == GameVersion.shareware;
@override
Widget build(BuildContext context) {
@@ -25,9 +25,8 @@ class SpriteGallery extends StatelessWidget {
crossAxisSpacing: 8,
mainAxisSpacing: 8,
),
itemCount: sprites.length,
itemCount: wolf3d.sprites.length,
itemBuilder: (context, index) {
// --- Check which enemy owns this sprite ---
String label = "Sprite Index: $index";
for (final enemy in EnemyType.values) {
if (enemy.claimsSpriteIndex(index, isShareware: isShareware)) {
@@ -36,14 +35,10 @@ class SpriteGallery extends StatelessWidget {
isShareware: isShareware,
);
// Appends the enum name (e.g., "guard", "dog")
label += "\n${enemy.name}";
// Appends the animation name
if (animation != null) {
label += "\n${animation.name}";
}
break;
}
}
@@ -61,7 +56,7 @@ class SpriteGallery extends StatelessWidget {
Expanded(
child: AspectRatio(
aspectRatio: 4 / 3,
child: WolfAssetPainter.sprite(sprites[index]),
child: WolfAssetPainter.sprite(wolf3d.sprites[index]),
),
),
],