314 lines
10 KiB
Dart
314 lines
10 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:nes_ui/nes_ui.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:shitman/game/shitman_game.dart';
|
|
import 'package:shitman/settings/app_settings.dart';
|
|
|
|
class InGameUI extends StatelessWidget with AppSettings {
|
|
static const String overlayID = 'InGameUI';
|
|
final ShitmanGame game;
|
|
|
|
InGameUI(this.game, {super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Material(
|
|
color: Colors.transparent,
|
|
child: Stack(
|
|
children: [
|
|
// Top HUD
|
|
Positioned(
|
|
top: 20,
|
|
left: 20,
|
|
right: 20,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
// Stealth indicator
|
|
NesContainer(
|
|
backgroundColor: Colors.black87,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.visibility_off, size: 16),
|
|
SizedBox(width: 8),
|
|
Text('gameplay.hidden'.tr(), style: TextStyle(color: Colors.green)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
// Mission objective
|
|
NesContainer(
|
|
backgroundColor: Colors.black87,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Text('gameplay.find_target'.tr(), style: TextStyle(color: Colors.white)),
|
|
),
|
|
),
|
|
// Pause button
|
|
IconButton(
|
|
icon: Icon(Icons.pause, color: Colors.white),
|
|
onPressed: () => game.overlays.add(PauseMenuUI.overlayID),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// Bottom controls hint
|
|
Positioned(
|
|
bottom: 20,
|
|
left: 20,
|
|
right: 20,
|
|
child: NesContainer(
|
|
backgroundColor: Colors.black54,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text('controls.move'.tr(), style: TextStyle(color: Colors.white)),
|
|
Text('controls.place_bag'.tr(), style: TextStyle(color: Colors.white)),
|
|
Text('controls.ring_bell'.tr(), style: TextStyle(color: Colors.white)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class MainMenuUI extends StatelessWidget with AppSettings {
|
|
static const String overlayID = 'MainMenu';
|
|
final ShitmanGame game;
|
|
|
|
MainMenuUI(this.game, {super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Material(
|
|
color: Colors.black,
|
|
child: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
// Game title
|
|
Text(
|
|
'game.title'.tr(),
|
|
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
|
color: Colors.orange,
|
|
fontSize: 48,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
SizedBox(height: 8),
|
|
Text(
|
|
'game.subtitle'.tr(),
|
|
style: TextStyle(color: Colors.white70, fontSize: 16),
|
|
),
|
|
SizedBox(height: 40),
|
|
|
|
// Menu buttons
|
|
Column(
|
|
children: [
|
|
NesButton(
|
|
type: NesButtonType.primary,
|
|
onPressed: () {
|
|
game.overlays.remove(MainMenuUI.overlayID);
|
|
game.overlays.add(InGameUI.overlayID);
|
|
game.startGame();
|
|
},
|
|
child: Text('menu.start_mission'.tr()),
|
|
),
|
|
SizedBox(height: 16),
|
|
NesButton(
|
|
type: NesButtonType.normal,
|
|
onPressed: () {
|
|
game.overlays.remove(MainMenuUI.overlayID);
|
|
game.overlays.add(SettingsUI.overlayID);
|
|
},
|
|
child: Text('menu.settings'.tr()),
|
|
),
|
|
SizedBox(height: 16),
|
|
NesButton(
|
|
type: NesButtonType.normal,
|
|
onPressed: () => game.startInfiniteMode(),
|
|
child: Text('menu.infinite_mode'.tr()),
|
|
),
|
|
],
|
|
),
|
|
|
|
SizedBox(height: 40),
|
|
Text(
|
|
'game.description'.tr(),
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(color: Colors.white54, fontSize: 12),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class SettingsUI extends StatelessWidget with AppSettings {
|
|
static const String overlayID = 'Settings';
|
|
final ShitmanGame game;
|
|
|
|
SettingsUI(this.game, {super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Material(
|
|
color: Colors.black87,
|
|
child: Center(
|
|
child: NesContainer(
|
|
backgroundColor: Colors.black,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'menu.settings'.tr(),
|
|
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
IconButton(
|
|
icon: Icon(Icons.close, color: Colors.white),
|
|
onPressed: () {
|
|
game.overlays.remove(SettingsUI.overlayID);
|
|
game.overlays.add(MainMenuUI.overlayID);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 24),
|
|
|
|
// Language selector
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text('Language / Sprog / Sprache:', style: TextStyle(color: Colors.white)),
|
|
DropdownButton<String>(
|
|
value: context.locale.languageCode,
|
|
dropdownColor: Colors.black,
|
|
style: TextStyle(color: Colors.white),
|
|
items: [
|
|
DropdownMenuItem(value: 'en', child: Text('English', style: TextStyle(color: Colors.white))),
|
|
DropdownMenuItem(value: 'da', child: Text('Dansk', style: TextStyle(color: Colors.white))),
|
|
DropdownMenuItem(value: 'de', child: Text('Deutsch', style: TextStyle(color: Colors.white))),
|
|
],
|
|
onChanged: (String? newValue) {
|
|
if (newValue != null) {
|
|
context.setLocale(Locale(newValue));
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
|
|
SizedBox(height: 16),
|
|
|
|
// Debug mode toggle
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text('ui.debug_mode'.tr(), style: TextStyle(color: Colors.white)),
|
|
NesCheckBox(
|
|
value: false, // TODO: Connect to settings
|
|
onChange: (value) {
|
|
// TODO: Update settings
|
|
},
|
|
),
|
|
],
|
|
),
|
|
|
|
SizedBox(height: 40),
|
|
Center(
|
|
child: NesButton(
|
|
type: NesButtonType.primary,
|
|
onPressed: () {
|
|
game.overlays.remove(SettingsUI.overlayID);
|
|
game.overlays.add(MainMenuUI.overlayID);
|
|
},
|
|
child: Text('menu.back_to_menu'.tr()),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class PauseMenuUI extends StatelessWidget {
|
|
static const String overlayID = 'PauseMenu';
|
|
final ShitmanGame game;
|
|
|
|
const PauseMenuUI(this.game, {super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Material(
|
|
color: Colors.black54,
|
|
child: Center(
|
|
child: NesContainer(
|
|
backgroundColor: Colors.black,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
'ui.paused'.tr(),
|
|
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
SizedBox(height: 24),
|
|
|
|
NesButton(
|
|
type: NesButtonType.primary,
|
|
onPressed: () => game.overlays.remove(PauseMenuUI.overlayID),
|
|
child: Text('menu.resume'.tr()),
|
|
),
|
|
SizedBox(height: 12),
|
|
NesButton(
|
|
type: NesButtonType.normal,
|
|
onPressed: () {
|
|
game.overlays.remove(PauseMenuUI.overlayID);
|
|
game.overlays.remove(InGameUI.overlayID);
|
|
game.overlays.add(SettingsUI.overlayID);
|
|
},
|
|
child: Text('menu.settings'.tr()),
|
|
),
|
|
SizedBox(height: 12),
|
|
NesButton(
|
|
type: NesButtonType.warning,
|
|
onPressed: () {
|
|
game.overlays.remove(PauseMenuUI.overlayID);
|
|
game.overlays.remove(InGameUI.overlayID);
|
|
game.overlays.add(MainMenuUI.overlayID);
|
|
game.stopGame();
|
|
},
|
|
child: Text('menu.main_menu'.tr()),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|