From 8be5b93f87ba5230d21b777c3e88c5e970dae417 Mon Sep 17 00:00:00 2001 From: Paul Scott <8pscott@gmail.com> Date: Sun, 13 Jun 2021 14:09:02 -0400 Subject: [PATCH] v1.7.4 --- lib/logic/chess_piece_sprite.dart | 8 ++++++-- lib/main.dart | 4 ++-- lib/model/app_themes.dart | 16 ++++++++++++++++ pubspec.lock | 20 +++----------------- pubspec.yaml | 2 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/logic/chess_piece_sprite.dart b/lib/logic/chess_piece_sprite.dart index a5a8603..ac5e8ea 100644 --- a/lib/logic/chess_piece_sprite.dart +++ b/lib/logic/chess_piece_sprite.dart @@ -1,9 +1,9 @@ +import 'package:audioplayers/audioplayers.dart'; import 'package:en_passant/model/app_model.dart'; import 'package:en_passant/views/components/main_menu_view/game_options/side_picker.dart'; import 'package:flame/components.dart'; import 'package:flame/flame.dart'; import 'package:flame/sprite.dart'; -import 'package:flame_audio/flame_audio.dart'; import 'chess_piece.dart'; import 'shared_functions.dart'; @@ -18,6 +18,9 @@ class ChessPieceSprite { double offsetX = 0; double offsetY = 0; + AudioCache audioCache = AudioCache(); + AudioPlayer audioPlayer = AudioPlayer(); + ChessPieceSprite(ChessPiece piece, String pieceTheme) { this.tile = piece.tile; this.type = piece.type; @@ -62,7 +65,8 @@ class ChessPieceSprite { void playSound(double destX, double destY, AppModel appModel) async { if ((destX - spriteX).abs() <= 0.1 && (destY - spriteY).abs() <= 0.1) { if (appModel.soundEnabled) { - FlameAudio.play('piece_moved.mp3'); + final bytes = await (await audioCache.loadAsFile('audio/piece_moved.mp3')).readAsBytes(); + audioPlayer.playBytes(bytes); } } } diff --git a/lib/main.dart b/lib/main.dart index 510cf20..61c4aad 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,7 +18,7 @@ void main() { _loadFlameAssets(); } -void _loadFlameAssets() { +void _loadFlameAssets() async { List pieceImages = []; for (var theme in PIECE_THEMES) { for (var color in ['black', 'white']) { @@ -28,7 +28,7 @@ void _loadFlameAssets() { } } } - Flame.images.loadAll(pieceImages); + await Flame.images.loadAll(pieceImages); } class EnPassantApp extends StatelessWidget { diff --git a/lib/model/app_themes.dart b/lib/model/app_themes.dart index eac6e05..b124e32 100644 --- a/lib/model/app_themes.dart +++ b/lib/model/app_themes.dart @@ -325,6 +325,22 @@ List get themeList { latestMove: Color(0xaa2782b0), border: Color(0xffebc0c0), ), + AppTheme( + name: 'Cherry-Coloured Funk', + background: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Color(0xff434783), + Color(0xffdc3b39), + ], + ), + lightTile: Color(0xffdb5e5c), + darkTile: Color(0xff645183), + moveHint: Color(0xaabdacce), + latestMove: Color(0xaaf0b35d), + border: Color(0xff434783), + ), ]; themeList.sort((a, b) => a.name.compareTo(b.name)); return themeList; diff --git a/pubspec.lock b/pubspec.lock index 45f67cd..e6b525b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -23,7 +23,7 @@ packages: source: hosted version: "2.6.1" audioplayers: - dependency: transitive + dependency: "direct main" description: name: audioplayers url: "https://pub.dartlang.org" @@ -106,13 +106,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0-releasecandidate.11" - flame_audio: - dependency: "direct main" - description: - name: flame_audio - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0-rc.1" flutter: dependency: "direct main" description: flutter @@ -350,13 +343,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" - synchronized: - dependency: transitive - description: - name: synchronized - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.0" term_glyph: dependency: transitive description: @@ -440,7 +426,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "2.0.5" xdg_directories: dependency: transitive description: @@ -463,5 +449,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.13.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index ff8add8..e3c3ef2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,8 +25,8 @@ dependencies: sdk: flutter provider: ^5.0.0 flame: ^1.0.0-releasecandidate.11 - flame_audio: ^1.0.0-rc.1 url_launcher: ^6.0.2 + audioplayers: ^0.19.0 shared_preferences: async: