Add shareware support and spawn correctly for difficulty levels

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-14 17:01:01 +01:00
parent 690ac1e7e6
commit 278c73a256
19 changed files with 383 additions and 238 deletions

View File

@@ -2,9 +2,16 @@ import 'package:flutter/material.dart';
import 'package:wolf_dart/features/difficulty/difficulty.dart';
import 'package:wolf_dart/features/renderer/renderer.dart';
class DifficultyScreen extends StatelessWidget {
class DifficultyScreen extends StatefulWidget {
const DifficultyScreen({super.key});
@override
State<DifficultyScreen> createState() => _DifficultyScreenState();
}
class _DifficultyScreenState extends State<DifficultyScreen> {
bool isShareware = true; // Default to Shareware (WL1)
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -14,9 +21,9 @@ class DifficultyScreen extends StatelessWidget {
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const WolfRenderer(
builder: (_) => WolfRenderer(
difficulty: Difficulty.bringEmOn,
isDemo: false,
isShareware: isShareware,
showSpriteGallery: true,
),
),
@@ -37,35 +44,59 @@ class DifficultyScreen extends StatelessWidget {
fontFamily: 'Courier',
),
),
const SizedBox(height: 40),
const SizedBox(height: 20),
// --- Version Toggle ---
Theme(
data: ThemeData(unselectedWidgetColor: Colors.grey),
child: CheckboxListTile(
title: const Text(
"Play Shareware Version (WL1)",
style: TextStyle(color: Colors.white),
),
value: isShareware,
onChanged: (bool? value) {
setState(() {
isShareware = value ?? true;
});
},
controlAffinity: ListTileControlAffinity.leading,
contentPadding: const EdgeInsets.symmetric(horizontal: 100),
),
),
const SizedBox(height: 20),
// --- Difficulty Buttons ---
ListView.builder(
shrinkWrap: true,
itemCount: Difficulty.values.length,
itemBuilder: (context, index) {
final Difficulty difficulty = Difficulty.values[index];
return ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueGrey[900],
foregroundColor: Colors.white,
minimumSize: const Size(300, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4),
),
),
onPressed: () {
// Push the renderer and pass the selected difficulty
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (_) => WolfRenderer(
difficulty: difficulty,
isDemo: false,
),
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueGrey[900],
foregroundColor: Colors.white,
minimumSize: const Size(300, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4),
),
);
},
child: Text(
difficulty.title,
style: const TextStyle(fontSize: 18),
),
onPressed: () {
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (_) => WolfRenderer(
difficulty: difficulty,
isShareware: isShareware,
),
),
);
},
child: Text(
difficulty.title,
style: const TextStyle(fontSize: 18),
),
),
);
},