Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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);
}
}
Binary file not shown.
Binary file not shown.
Binary file added assets/audio/check1.aac
Binary file not shown.
Binary file added assets/audio/check2.aac
Binary file not shown.
Binary file added assets/audio/click.aac
Binary file not shown.
1 change: 0 additions & 1 deletion lib/audio/audio_controller.dart

This file was deleted.

19 changes: 0 additions & 19 deletions lib/audio/songs.dart

This file was deleted.

7 changes: 6 additions & 1 deletion lib/level_selection/game_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<GameSelectionScreen> createState() => _GameSelectionScreenState();
}

class _GameSelectionScreenState extends State<GameSelectionScreen> {
@override
Widget build(BuildContext context) {
Palette palette = Palette();
Expand Down
83 changes: 76 additions & 7 deletions lib/main_menu/main_menu_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand All @@ -14,6 +15,65 @@ class MainMenuScreen extends StatefulWidget {
class _MainMenuScreenState extends State<MainMenuScreen> {
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) {
Expand All @@ -38,15 +98,12 @@ class _MainMenuScreenState extends State<MainMenuScreen> {
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'),
Expand All @@ -56,7 +113,19 @@ class _MainMenuScreenState extends State<MainMenuScreen> {
onPressed: () => GoRouter.of(context).push('/settings'),
child: const Text('Settings'),
),
_gap,
Center(
child: StreamBuilder<PlayerState>(
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),
)
],
),
),
Expand Down
6 changes: 6 additions & 0 deletions lib/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
)
],
),
],
Expand Down
5 changes: 5 additions & 0 deletions lib/scene/Scout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class _ScoutPageState extends State<ScoutPage> {
utils.generateEnemies(global.totalEnemyCount);
}

@override
void dispose() {
super.dispose();
}

int collectableCount = 0;

int randomNumGenerator(int max) {
Expand Down
36 changes: 33 additions & 3 deletions lib/settings/settings_screen.dart
Original file line number Diff line number Diff line change
@@ -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});
Expand All @@ -9,10 +11,38 @@ class SettingsScreen extends StatefulWidget {
}

class _SettingsScreenState extends State<SettingsScreen> {
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'))
],
),
),
),
);
}
}
6 changes: 6 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Loading