diff --git a/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java b/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java new file mode 100644 index 0000000..752fc18 --- /dev/null +++ b/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java @@ -0,0 +1,25 @@ +// Generated file. +// +// If you wish to remove Flutter's multidex support, delete this entire file. +// +// Modifications to this file should be done in a copy under a different name +// as this file may be regenerated. + +package io.flutter.app; + +import android.app.Application; +import android.content.Context; +import androidx.annotation.CallSuper; +import androidx.multidex.MultiDex; + +/** + * Extension of {@link android.app.Application}, adding multidex support. + */ +public class FlutterMultiDexApplication extends Application { + @Override + @CallSuper + protected void attachBaseContext(Context base) { + super.attachBaseContext(base); + MultiDex.install(this); + } +} diff --git a/assets/audio/091_Heartbound_OST_Windup_Wonders.mp3 b/assets/audio/091_Heartbound_OST_Windup_Wonders.mp3 new file mode 100644 index 0000000..c5e6666 Binary files /dev/null and b/assets/audio/091_Heartbound_OST_Windup_Wonders.mp3 differ diff --git a/assets/audio/100 Heartbound OST Meandering Shadows.mp3 b/assets/audio/100 Heartbound OST Meandering Shadows.mp3 new file mode 100644 index 0000000..64dbbc5 Binary files /dev/null and b/assets/audio/100 Heartbound OST Meandering Shadows.mp3 differ diff --git a/assets/audio/check1.aac b/assets/audio/check1.aac new file mode 100644 index 0000000..6256ea5 Binary files /dev/null and b/assets/audio/check1.aac differ diff --git a/assets/audio/check2.aac b/assets/audio/check2.aac new file mode 100644 index 0000000..050d7ba Binary files /dev/null and b/assets/audio/check2.aac differ diff --git a/assets/audio/click.aac b/assets/audio/click.aac new file mode 100644 index 0000000..c7ce704 Binary files /dev/null and b/assets/audio/click.aac differ diff --git a/lib/audio/audio_controller.dart b/lib/audio/audio_controller.dart deleted file mode 100644 index 8b13789..0000000 --- a/lib/audio/audio_controller.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/audio/songs.dart b/lib/audio/songs.dart deleted file mode 100644 index c9d64f5..0000000 --- a/lib/audio/songs.dart +++ /dev/null @@ -1,19 +0,0 @@ -const Set songs = { - Song('091_Heartbound_OST_Windup_Wonders.mp3', 'Windup_Wonders', - artist: 'Pirate Software'), - Song('100_Heartbound_OST_Meandering_Shadows.mp3.mp3', 'Meandering_Shadows', - artist: 'Pirate Software'), -}; - -class Song { - final String filename; - - final String name; - - final String? artist; - - const Song(this.filename, this.name, {this.artist}); - - @override - String toString() => 'Song<$filename>'; -} diff --git a/lib/level_selection/game_selection.dart b/lib/level_selection/game_selection.dart index 9b2847b..0630cc2 100644 --- a/lib/level_selection/game_selection.dart +++ b/lib/level_selection/game_selection.dart @@ -3,9 +3,14 @@ import 'package:ant_new/style/palette.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -class GameSelectionScreen extends StatelessWidget { +class GameSelectionScreen extends StatefulWidget { const GameSelectionScreen({super.key}); + @override + State createState() => _GameSelectionScreenState(); +} + +class _GameSelectionScreenState extends State { @override Widget build(BuildContext context) { Palette palette = Palette(); diff --git a/lib/main_menu/main_menu_screen.dart b/lib/main_menu/main_menu_screen.dart index 6a6e0d1..1f913f1 100644 --- a/lib/main_menu/main_menu_screen.dart +++ b/lib/main_menu/main_menu_screen.dart @@ -3,6 +3,7 @@ import 'package:ant_new/style/palette.dart'; import 'package:ant_new/style/responsive_screen.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; +import 'package:just_audio/just_audio.dart'; class MainMenuScreen extends StatefulWidget { const MainMenuScreen({super.key}); @@ -14,6 +15,65 @@ class MainMenuScreen extends StatefulWidget { class _MainMenuScreenState extends State { Palette palette = Palette(); static const _gap = SizedBox(height: 10); + AudioPlayer _audioPlayer = AudioPlayer(); + + @override + void initState() { + super.initState(); + playMusic(); + } + + void playMusic() { + _audioPlayer = AudioPlayer(); + _audioPlayer.setVolume(0.5); + _audioPlayer + .setAudioSource(AudioSource.asset( + 'assets/audio/100 Heartbound OST Meandering Shadows.mp3')) + // ignore: body_might_complete_normally_catch_error + .catchError((error) { + debugPrint("Error in audio main_menu_screen $error"); + }); + _audioPlayer.play(); + } + + void play() { + _audioPlayer.play(); + } + + void pause() { + _audioPlayer.pause(); + } + + Widget _playerButton(PlayerState playerState) { + final processingState = playerState.processingState; + if (_audioPlayer.playing != true) { + return IconButton( + icon: const Icon(Icons.volume_off), + iconSize: 30.0, + onPressed: _audioPlayer.play, + ); + } else if (processingState != ProcessingState.completed) { + return IconButton( + icon: const Icon(Icons.volume_up), + iconSize: 30.0, + onPressed: _audioPlayer.pause, + ); + } else { + _audioPlayer.seek(Duration.zero); + _audioPlayer.play(); + return IconButton( + icon: const Icon(Icons.replay), + iconSize: 30.0, + onPressed: () => _audioPlayer.seek(Duration.zero), + ); + } + } + + @override + void dispose() { + _audioPlayer.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { @@ -38,15 +98,12 @@ class _MainMenuScreenState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ MyButton( - onPressed: () => GoRouter.of(context).push('/play'), + onPressed: () { + GoRouter.of(context).push('/play'); + }, child: const Text('Play'), ), _gap, - MyButton( - onPressed: () => GoRouter.of(context).push('/manage'), - child: const Text('Manage'), - ), - _gap, MyButton( onPressed: () => GoRouter.of(context).push('/store'), child: const Text('store'), @@ -56,7 +113,19 @@ class _MainMenuScreenState extends State { onPressed: () => GoRouter.of(context).push('/settings'), child: const Text('Settings'), ), - _gap, + Center( + child: StreamBuilder( + stream: _audioPlayer.playerStateStream, + builder: (context, snapshot) { + final playerState = snapshot.data; + return _playerButton(playerState!); + }, + ), + ), + const Text( + "\"Music by Pirate Software\"", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.bold), + ) ], ), ), diff --git a/lib/router.dart b/lib/router.dart index 4fd871b..73973d3 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -2,6 +2,7 @@ import 'package:ant_new/level_selection/game_selection.dart'; import 'package:ant_new/main_menu/main_menu_screen.dart'; import 'package:ant_new/scene/Card.dart'; import 'package:ant_new/scene/Scout.dart'; +import 'package:ant_new/settings/settings_screen.dart'; import 'package:ant_new/style/my_transition.dart'; import 'package:ant_new/style/palette.dart'; import 'package:flutter/foundation.dart'; @@ -33,6 +34,11 @@ final router = GoRouter( pageBuilder: (context, state) => buildMyTransition( child: const CardPage(), color: palette.backgroundMain), ), + GoRoute( + path: 'settings', + pageBuilder: (context, state) => buildMyTransition( + child: const SettingsScreen(), color: palette.backgroundSettings), + ) ], ), ], diff --git a/lib/scene/Scout.dart b/lib/scene/Scout.dart index 0e7ed61..55a223c 100644 --- a/lib/scene/Scout.dart +++ b/lib/scene/Scout.dart @@ -55,6 +55,11 @@ class _ScoutPageState extends State { utils.generateEnemies(global.totalEnemyCount); } + @override + void dispose() { + super.dispose(); + } + int collectableCount = 0; int randomNumGenerator(int max) { diff --git a/lib/settings/settings_screen.dart b/lib/settings/settings_screen.dart index b07afdf..8b952a0 100644 --- a/lib/settings/settings_screen.dart +++ b/lib/settings/settings_screen.dart @@ -1,5 +1,7 @@ +import 'package:ant_new/router.dart'; +import 'package:ant_new/style/my_button.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; +import 'package:go_router/go_router.dart'; class SettingsScreen extends StatefulWidget { const SettingsScreen({super.key}); @@ -9,10 +11,38 @@ class SettingsScreen extends StatefulWidget { } class _SettingsScreenState extends State { + static const _gap = SizedBox(height: 60); + @override Widget build(BuildContext context) { - return const Scaffold( - body: Text('Settings Page'), + double deviceHeight = MediaQuery.of(context).size.height; + double deviceWidth = MediaQuery.of(context).size.width; + return Scaffold( + backgroundColor: palette.backgroundSettings, + body: Center( + child: SizedBox( + height: deviceHeight * 0.5, + width: deviceWidth * 0.8, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + const Text( + 'Settings', + textAlign: TextAlign.center, + style: TextStyle( + fontFamily: 'Permanent Marker', + fontSize: 55, + height: 1, + ), + ), + _gap, + MyButton( + onPressed: () => GoRouter.of(context).go('/'), + child: const Text('Back')) + ], + ), + ), + ), ); } } diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index cccf817..df18b27 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,12 @@ import FlutterMacOS import Foundation +import audio_session +import just_audio +import path_provider_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin")) + JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin")) + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index b468e77..b403972 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -33,6 +33,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + audio_session: + dependency: transitive + description: + name: audio_session + sha256: "6fdf255ed3af86535c96452c33ecff1245990bb25a605bfb1958661ccc3d467f" + url: "https://pub.dev" + source: hosted + version: "0.1.18" boolean_selector: dependency: transitive description: @@ -105,6 +113,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + url: "https://pub.dev" + source: hosted + version: "2.1.0" file: dependency: transitive description: @@ -113,6 +129,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -200,6 +224,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.7" + just_audio: + dependency: "direct main" + description: + name: just_audio + sha256: b607cd1a43bac03d85c3aaee00448ff4a589ef2a77104e3d409889ff079bf823 + url: "https://pub.dev" + source: hosted + version: "0.9.36" + just_audio_platform_interface: + dependency: transitive + description: + name: just_audio_platform_interface + sha256: c3dee0014248c97c91fe6299edb73dc4d6c6930a2f4f713579cd692d9e47f4a1 + url: "https://pub.dev" + source: hosted + version: "4.2.2" + just_audio_web: + dependency: transitive + description: + name: just_audio_web + sha256: "134356b0fe3d898293102b33b5fd618831ffdc72bb7a1b726140abdf22772b70" + url: "https://pub.dev" + source: hosted + version: "0.4.9" lints: dependency: transitive description: @@ -272,6 +320,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.3" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668" + url: "https://pub.dev" + source: hosted + version: "2.2.2" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + platform: + dependency: transitive + description: + name: platform + sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" + url: "https://pub.dev" + source: hosted + version: "3.1.4" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" pool: dependency: transitive description: @@ -288,6 +400,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + rxdart: + dependency: transitive + description: + name: rxdart + sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb" + url: "https://pub.dev" + source: hosted + version: "0.27.7" shelf: dependency: transitive description: @@ -349,6 +469,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" stack_trace: dependency: transitive description: @@ -413,6 +541,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + uuid: + dependency: transitive + description: + name: uuid + sha256: cd210a09f7c18cbe5a02511718e0334de6559871052c90a90c0cca46a4aa81c8 + url: "https://pub.dev" + source: hosted + version: "4.3.3" vector_math: dependency: transitive description: @@ -461,6 +597,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + win32: + dependency: transitive + description: + name: win32 + sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8" + url: "https://pub.dev" + source: hosted + version: "5.2.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d + url: "https://pub.dev" + source: hosted + version: "1.0.4" yaml: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index ec7599b..bb9c338 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: cupertino_icons: ^1.0.2 go_router: ^13.2.0 flutter_card_swiper: ^7.0.0 + just_audio: ^0.9.36 dev_dependencies: flutter_test: @@ -48,6 +49,7 @@ flutter: assets: - assets/images/ + - assets/audio/ fonts: - family: Permanent Marker