Files
wolf_dart/apps/wolf_3d_gui/lib/screens/sprite_gallery.dart
2026-03-17 13:15:35 +01:00

72 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:wolf_3d_dart/wolf_3d_data_types.dart';
import 'package:wolf_3d_dart/wolf_3d_entities.dart';
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;
const SpriteGallery({super.key, required this.sprites});
bool get isShareware => Wolf3d.I.activeGame.version == GameVersion.shareware;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Sprite Gallery"),
automaticallyImplyLeading: true,
),
backgroundColor: Colors.black,
body: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 8,
crossAxisSpacing: 8,
mainAxisSpacing: 8,
),
itemCount: 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)) {
final EnemyAnimation? animation = enemy.getAnimationFromSprite(
index,
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;
}
}
return Card(
color: Colors.blueGrey,
child: Column(
spacing: 8,
children: [
Text(
label,
style: const TextStyle(color: Colors.white, fontSize: 10),
textAlign: TextAlign.center,
),
Expanded(
child: WolfAssetPainter.sprite(sprites[index]),
),
],
),
);
},
),
);
}
}