@ -0,0 +1,21 @@
|
||||
name: spell_check
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Spell Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check spelling
|
||||
uses: zwaldowski/cspell-action@v1
|
||||
with:
|
||||
paths: '**/*.{dart,arb,md}'
|
||||
config: .vscode/cspell.json
|
@ -1,7 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="development" type="FlutterRunConfigurationType" factoryName="Flutter">
|
||||
<option name="buildFlavor" value="development" />
|
||||
<option name="filePath" value="$PROJECT_DIR$/lib/main_development.dart" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
@ -0,0 +1,6 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="main" type="FlutterRunConfigurationType" factoryName="Flutter">
|
||||
<option name="filePath" value="$PROJECT_DIR$/lib/main.dart" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
@ -1,7 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="production" type="FlutterRunConfigurationType" factoryName="Flutter">
|
||||
<option name="buildFlavor" value="production" />
|
||||
<option name="filePath" value="$PROJECT_DIR$/lib/main_production.dart" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
@ -1,7 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="staging" type="FlutterRunConfigurationType" factoryName="Flutter">
|
||||
<option name="buildFlavor" value="staging" />
|
||||
<option name="filePath" value="$PROJECT_DIR$/lib/main_staging.dart" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
@ -0,0 +1,50 @@
|
||||
{
|
||||
"version": "0.2",
|
||||
"enabled": true,
|
||||
"language": "en",
|
||||
"words": [
|
||||
"animatronic",
|
||||
"argb",
|
||||
"audioplayers",
|
||||
"backbox",
|
||||
"bezier",
|
||||
"contador",
|
||||
"cupertino",
|
||||
"dashbook",
|
||||
"deserialization",
|
||||
"dpad",
|
||||
"endtemplate",
|
||||
"firestore",
|
||||
"gapless",
|
||||
"genhtml",
|
||||
"goldens",
|
||||
"lcov",
|
||||
"leaderboard",
|
||||
"loadables",
|
||||
"localizable",
|
||||
"mixins",
|
||||
"mocktail",
|
||||
"mostrado",
|
||||
"multiball",
|
||||
"multiballs",
|
||||
"occluder",
|
||||
"página",
|
||||
"pixelated",
|
||||
"pixeloid",
|
||||
"rects",
|
||||
"rrect",
|
||||
"serializable",
|
||||
"sparky's",
|
||||
"tappable",
|
||||
"tappables",
|
||||
"texto",
|
||||
"theming",
|
||||
"unawaited",
|
||||
"unfocus",
|
||||
"unlayered",
|
||||
"vsync"
|
||||
],
|
||||
"ignorePaths": [
|
||||
".github/workflows/**"
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 306 KiB After Width: | Height: | Size: 207 KiB |
Before Width: | Height: | Size: 422 KiB After Width: | Height: | Size: 209 KiB |
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 124 KiB |
Before Width: | Height: | Size: 200 KiB After Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 298 KiB After Width: | Height: | Size: 169 KiB |
Before Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 7.8 KiB |
@ -1,27 +1,39 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:pinball/game/game.dart';
|
||||
import 'package:pinball/select_character/select_character.dart';
|
||||
import 'package:pinball_audio/pinball_audio.dart';
|
||||
|
||||
part 'assets_manager_state.dart';
|
||||
|
||||
/// {@template assets_manager_cubit}
|
||||
/// Cubit responsable for pre loading any game assets
|
||||
/// {@endtemplate}
|
||||
class AssetsManagerCubit extends Cubit<AssetsManagerState> {
|
||||
/// {@macro assets_manager_cubit}
|
||||
AssetsManagerCubit(List<Future> loadables)
|
||||
: super(
|
||||
AssetsManagerState.initial(
|
||||
loadables: loadables,
|
||||
),
|
||||
);
|
||||
AssetsManagerCubit(this._game, this._audioPlayer)
|
||||
: super(const AssetsManagerState.initial());
|
||||
|
||||
final PinballGame _game;
|
||||
final PinballAudioPlayer _audioPlayer;
|
||||
|
||||
/// Loads the assets
|
||||
Future<void> load() async {
|
||||
/// Assigning loadables is a very expensive operation. With this purposeful
|
||||
/// delay here, which is a bit random in duration but enough to let the UI
|
||||
/// do its job without adding too much delay for the user, we are letting
|
||||
/// the UI paint first, and then we start loading the assets.
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
emit(
|
||||
state.copyWith(
|
||||
loadables: [
|
||||
_game.preFetchLeaderboard(),
|
||||
..._game.preLoadAssets(),
|
||||
..._audioPlayer.load(),
|
||||
...BonusAnimation.loadAssets(),
|
||||
...SelectedCharacter.loadAssets(),
|
||||
],
|
||||
),
|
||||
);
|
||||
final all = state.loadables.map((loadable) async {
|
||||
await loadable;
|
||||
emit(state.copyWith(loaded: [...state.loaded, loadable]));
|
||||
}).toList();
|
||||
|
||||
await Future.wait(all);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
export 'ball_spawning_behavior.dart';
|
||||
export 'bonus_ball_spawning_behavior.dart';
|
||||
export 'bonus_noise_behavior.dart';
|
||||
export 'bumper_noise_behavior.dart';
|
||||
export 'camera_focusing_behavior.dart';
|
||||
export 'character_selection_behavior.dart';
|
||||
export 'cow_bumper_noise_behavior.dart';
|
||||
export 'kicker_noise_behavior.dart';
|
||||
export 'scoring_behavior.dart';
|
||||
|
@ -0,0 +1,30 @@
|
||||
import 'package:flame/components.dart';
|
||||
import 'package:pinball/select_character/select_character.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
|
||||
/// {@template bonus_ball_spawning_behavior}
|
||||
/// After a duration, spawns a bonus ball from the [DinoWalls] and boosts it
|
||||
/// into the middle of the board.
|
||||
/// {@endtemplate}
|
||||
class BonusBallSpawningBehavior extends TimerComponent with HasGameRef {
|
||||
/// {@macro bonus_ball_spawning_behavior}
|
||||
BonusBallSpawningBehavior()
|
||||
: super(
|
||||
period: 5,
|
||||
removeOnFinish: true,
|
||||
);
|
||||
|
||||
@override
|
||||
void onTick() {
|
||||
final characterTheme = readBloc<CharacterThemeCubit, CharacterThemeState>()
|
||||
.state
|
||||
.characterTheme;
|
||||
gameRef.descendants().whereType<ZCanvasComponent>().single.add(
|
||||
Ball(assetPath: characterTheme.ball.keyName)
|
||||
..add(BallImpulsingBehavior(impulse: Vector2(-40, 0)))
|
||||
..initialPosition = Vector2(29.2, -24.5)
|
||||
..zIndex = ZIndexes.ballOnBoard,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
import 'package:flame/components.dart';
|
||||
import 'package:flame_bloc/flame_bloc.dart';
|
||||
import 'package:pinball/select_character/select_character.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
|
||||
/// Updates the [ArcadeBackground] and launch [Ball] to reflect character
|
||||
/// selections.
|
||||
class CharacterSelectionBehavior extends Component
|
||||
with
|
||||
FlameBlocListenable<CharacterThemeCubit, CharacterThemeState>,
|
||||
HasGameRef {
|
||||
@override
|
||||
void onNewState(CharacterThemeState state) {
|
||||
gameRef
|
||||
.descendants()
|
||||
.whereType<ArcadeBackground>()
|
||||
.single
|
||||
.bloc
|
||||
.onCharacterSelected(state.characterTheme);
|
||||
gameRef
|
||||
.descendants()
|
||||
.whereType<Ball>()
|
||||
.single
|
||||
.bloc
|
||||
.onCharacterSelected(state.characterTheme);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
// ignore_for_file: public_member_api_docs
|
||||
|
||||
import 'package:flame_forge2d/flame_forge2d.dart';
|
||||
import 'package:pinball_audio/pinball_audio.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
|
||||
class CowBumperNoiseBehavior extends ContactBehavior {
|
||||
@override
|
||||
void beginContact(Object other, Contact contact) {
|
||||
super.beginContact(other, contact);
|
||||
readProvider<PinballAudioPlayer>().play(PinballAudio.cowMoo);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import 'package:flame_forge2d/flame_forge2d.dart';
|
||||
import 'package:pinball_audio/pinball_audio.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
|
||||
class KickerNoiseBehavior extends ContactBehavior {
|
||||
@override
|
||||
void beginContact(Object other, Contact contact) {
|
||||
super.beginContact(other, contact);
|
||||
readProvider<PinballAudioPlayer>().play(PinballAudio.kicker);
|
||||
}
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
export 'game_over_info_display.dart';
|
||||
export 'initials_input_display.dart';
|
||||
export 'initials_submission_failure_display.dart';
|
||||
export 'initials_submission_success_display.dart';
|
||||
export 'leaderboard_display.dart';
|
||||
export 'leaderboard_failure_display.dart';
|
||||
export 'loading_display.dart';
|
||||
export 'share_display.dart';
|
||||
|
@ -0,0 +1,311 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flame/components.dart';
|
||||
import 'package:flame/input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball/game/game.dart';
|
||||
import 'package:pinball/l10n/l10n.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
import 'package:pinball_ui/pinball_ui.dart';
|
||||
import 'package:share_repository/share_repository.dart';
|
||||
|
||||
/// Signature for the callback called when the user tries to share their score
|
||||
/// from the [GameOverInfoDisplay].
|
||||
typedef OnShareTap = void Function();
|
||||
|
||||
final _titleTextPaint = TextPaint(
|
||||
style: const TextStyle(
|
||||
fontSize: 1.6,
|
||||
color: PinballColors.white,
|
||||
fontFamily: PinballFonts.pixeloidSans,
|
||||
),
|
||||
);
|
||||
|
||||
final _titleBoldTextPaint = TextPaint(
|
||||
style: const TextStyle(
|
||||
fontSize: 1.4,
|
||||
color: PinballColors.white,
|
||||
fontFamily: PinballFonts.pixeloidSans,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
);
|
||||
|
||||
final _linkTextPaint = TextPaint(
|
||||
style: const TextStyle(
|
||||
fontSize: 1.7,
|
||||
color: PinballColors.orange,
|
||||
fontFamily: PinballFonts.pixeloidSans,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
);
|
||||
|
||||
final _descriptionTextPaint = TextPaint(
|
||||
style: const TextStyle(
|
||||
fontSize: 1.6,
|
||||
color: PinballColors.white,
|
||||
fontFamily: PinballFonts.pixeloidSans,
|
||||
),
|
||||
);
|
||||
|
||||
/// {@template game_over_info_display}
|
||||
/// Display with links to share your score or go to the IO webpage.
|
||||
/// {@endtemplate}
|
||||
class GameOverInfoDisplay extends Component with HasGameRef {
|
||||
/// {@macro game_over_info_display}
|
||||
GameOverInfoDisplay({
|
||||
OnShareTap? onShare,
|
||||
}) : super(
|
||||
children: [
|
||||
_InstructionsComponent(
|
||||
onShare: onShare,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
gameRef.overlays.add(PinballGame.playButtonOverlay);
|
||||
}
|
||||
}
|
||||
|
||||
class _InstructionsComponent extends PositionComponent with HasGameRef {
|
||||
_InstructionsComponent({
|
||||
OnShareTap? onShare,
|
||||
}) : super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, -25),
|
||||
children: [
|
||||
_TitleComponent(),
|
||||
_LinksComponent(
|
||||
onShare: onShare,
|
||||
),
|
||||
_DescriptionComponent(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class _TitleComponent extends PositionComponent with HasGameRef {
|
||||
_TitleComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, 3),
|
||||
children: [
|
||||
_TitleBackgroundSpriteComponent(),
|
||||
_ShareScoreTextComponent(),
|
||||
_ChallengeFriendsTextComponent(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class _ShareScoreTextComponent extends TextComponent with HasGameRef {
|
||||
_ShareScoreTextComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, -1.5),
|
||||
textRenderer: _titleTextPaint,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
text = readProvider<AppLocalizations>().shareYourScore;
|
||||
}
|
||||
}
|
||||
|
||||
class _ChallengeFriendsTextComponent extends TextComponent with HasGameRef {
|
||||
_ChallengeFriendsTextComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, 1.5),
|
||||
textRenderer: _titleBoldTextPaint,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
text = readProvider<AppLocalizations>().andChallengeYourFriends;
|
||||
}
|
||||
}
|
||||
|
||||
class _TitleBackgroundSpriteComponent extends SpriteComponent with HasGameRef {
|
||||
_TitleBackgroundSpriteComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2.zero(),
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
final sprite = Sprite(
|
||||
gameRef.images
|
||||
.fromCache(Assets.images.backbox.displayTitleDecoration.keyName),
|
||||
);
|
||||
this.sprite = sprite;
|
||||
size = sprite.originalSize / 22;
|
||||
}
|
||||
}
|
||||
|
||||
class _LinksComponent extends PositionComponent with HasGameRef {
|
||||
_LinksComponent({
|
||||
OnShareTap? onShare,
|
||||
}) : super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, 9.2),
|
||||
children: [
|
||||
ShareLinkComponent(onTap: onShare),
|
||||
GoogleIOLinkComponent(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// {@template share_link_component}
|
||||
/// Link button to navigate to sharing score display.
|
||||
/// {@endtemplate}
|
||||
class ShareLinkComponent extends TextComponent with HasGameRef, Tappable {
|
||||
/// {@macro share_link_component}
|
||||
ShareLinkComponent({
|
||||
OnShareTap? onTap,
|
||||
}) : _onTap = onTap,
|
||||
super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(-7, 0),
|
||||
textRenderer: _linkTextPaint,
|
||||
);
|
||||
|
||||
final OnShareTap? _onTap;
|
||||
|
||||
@override
|
||||
bool onTapDown(TapDownInfo info) {
|
||||
_onTap?.call();
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
await add(
|
||||
RectangleComponent(
|
||||
size: Vector2(6.4, 0.2),
|
||||
paint: Paint()..color = PinballColors.orange,
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(3.2, 2.3),
|
||||
),
|
||||
);
|
||||
|
||||
text = readProvider<AppLocalizations>().share;
|
||||
}
|
||||
}
|
||||
|
||||
/// {@template google_io_link_component}
|
||||
/// Link button to navigate to Google I/O site.
|
||||
/// {@endtemplate}
|
||||
class GoogleIOLinkComponent extends TextComponent with HasGameRef, Tappable {
|
||||
/// {@macro google_io_link_component}
|
||||
GoogleIOLinkComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(6, 0),
|
||||
textRenderer: _linkTextPaint,
|
||||
);
|
||||
|
||||
@override
|
||||
bool onTapDown(TapDownInfo info) {
|
||||
openLink(ShareRepository.googleIOEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
await add(
|
||||
RectangleComponent(
|
||||
size: Vector2(10.2, 0.2),
|
||||
paint: Paint()..color = PinballColors.orange,
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(5.1, 2.3),
|
||||
),
|
||||
);
|
||||
|
||||
text = readProvider<AppLocalizations>().gotoIO;
|
||||
}
|
||||
}
|
||||
|
||||
class _DescriptionComponent extends PositionComponent with HasGameRef {
|
||||
_DescriptionComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, 13),
|
||||
children: [
|
||||
_LearnMoreTextComponent(),
|
||||
_FirebaseTextComponent(),
|
||||
OpenSourceTextComponent(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class _LearnMoreTextComponent extends TextComponent with HasGameRef {
|
||||
_LearnMoreTextComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2.zero(),
|
||||
textRenderer: _descriptionTextPaint,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
text = readProvider<AppLocalizations>().learnMore;
|
||||
}
|
||||
}
|
||||
|
||||
class _FirebaseTextComponent extends TextComponent with HasGameRef {
|
||||
_FirebaseTextComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(-8.5, 2.5),
|
||||
textRenderer: _descriptionTextPaint,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
text = readProvider<AppLocalizations>().firebaseOr;
|
||||
}
|
||||
}
|
||||
|
||||
/// {@template open_source_link_component}
|
||||
/// Link text to navigate to Open Source site.
|
||||
/// {@endtemplate}
|
||||
@visibleForTesting
|
||||
class OpenSourceTextComponent extends TextComponent with HasGameRef, Tappable {
|
||||
/// {@macro open_source_link_component}
|
||||
OpenSourceTextComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(13.5, 2.5),
|
||||
textRenderer: _descriptionTextPaint,
|
||||
);
|
||||
|
||||
@override
|
||||
bool onTapDown(TapDownInfo info) {
|
||||
openLink(ShareRepository.openSourceCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
await add(
|
||||
RectangleComponent(
|
||||
size: Vector2(16, 0.2),
|
||||
paint: Paint()..color = PinballColors.white,
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(8, 2.3),
|
||||
),
|
||||
);
|
||||
text = readProvider<AppLocalizations>().openSourceCode;
|
||||
}
|
||||
}
|
@ -1,27 +1,47 @@
|
||||
import 'package:flame/components.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball/game/game.dart';
|
||||
import 'package:pinball/l10n/l10n.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
import 'package:pinball_ui/pinball_ui.dart';
|
||||
|
||||
final _bodyTextPaint = TextPaint(
|
||||
style: const TextStyle(
|
||||
fontSize: 3,
|
||||
fontSize: 1.8,
|
||||
color: PinballColors.white,
|
||||
fontFamily: PinballFonts.pixeloidSans,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
);
|
||||
|
||||
/// {@template initials_submission_failure_display}
|
||||
/// [Backbox] display for when a failure occurs during initials submission.
|
||||
/// {@endtemplate}
|
||||
class InitialsSubmissionFailureDisplay extends TextComponent {
|
||||
class InitialsSubmissionFailureDisplay extends Component {
|
||||
/// {@macro initials_submission_failure_display}
|
||||
InitialsSubmissionFailureDisplay({
|
||||
required this.onDismissed,
|
||||
});
|
||||
|
||||
final VoidCallback onDismissed;
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
position = Vector2(0, -10);
|
||||
anchor = Anchor.center;
|
||||
text = 'Failure!';
|
||||
textRenderer = _bodyTextPaint;
|
||||
final l10n = readProvider<AppLocalizations>();
|
||||
|
||||
await addAll([
|
||||
ErrorComponent.bold(
|
||||
label: l10n.initialsErrorTitle,
|
||||
position: Vector2(0, -20),
|
||||
),
|
||||
TextComponent(
|
||||
text: l10n.initialsErrorMessage,
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, -12),
|
||||
textRenderer: _bodyTextPaint,
|
||||
),
|
||||
TimerComponent(period: 4, onTick: onDismissed),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
import 'package:flame/components.dart';
|
||||
import 'package:pinball/l10n/l10n.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
|
||||
/// {@template leaderboard_failure_display}
|
||||
/// Display showing an error message when the leaderboard couldn't be loaded
|
||||
/// {@endtemplate}
|
||||
class LeaderboardFailureDisplay extends Component {
|
||||
/// {@macro leaderboard_failure_display}
|
||||
LeaderboardFailureDisplay();
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
final l10n = readProvider<AppLocalizations>();
|
||||
await add(
|
||||
ErrorComponent(
|
||||
label: l10n.leaderboardErrorMessage,
|
||||
position: Vector2(0, -18),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,189 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flame/components.dart';
|
||||
import 'package:flame/input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball/l10n/l10n.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
import 'package:pinball_ui/pinball_ui.dart';
|
||||
import 'package:share_repository/share_repository.dart';
|
||||
|
||||
/// Signature for the callback called when the user tries to share their score
|
||||
/// on the [ShareDisplay].
|
||||
typedef OnSocialShareTap = void Function(SharePlatform);
|
||||
|
||||
final _descriptionTextPaint = TextPaint(
|
||||
style: const TextStyle(
|
||||
fontSize: 1.6,
|
||||
color: PinballColors.white,
|
||||
fontFamily: PinballFonts.pixeloidSans,
|
||||
),
|
||||
);
|
||||
|
||||
/// {@template share_display}
|
||||
/// Display that allows users to share their score to social networks.
|
||||
/// {@endtemplate}
|
||||
class ShareDisplay extends Component with HasGameRef {
|
||||
/// {@macro share_display}
|
||||
ShareDisplay({
|
||||
OnSocialShareTap? onShare,
|
||||
}) : super(
|
||||
children: [
|
||||
_ShareInstructionsComponent(
|
||||
onShare: onShare,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class _ShareInstructionsComponent extends PositionComponent with HasGameRef {
|
||||
_ShareInstructionsComponent({
|
||||
OnSocialShareTap? onShare,
|
||||
}) : super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, -25),
|
||||
children: [
|
||||
_DescriptionComponent(),
|
||||
_SocialNetworksComponent(
|
||||
onShare: onShare,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class _DescriptionComponent extends PositionComponent with HasGameRef {
|
||||
_DescriptionComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2.zero(),
|
||||
children: [
|
||||
_LetEveryoneTextComponent(),
|
||||
_SharingYourScoreTextComponent(),
|
||||
_SocialMediaTextComponent(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class _LetEveryoneTextComponent extends TextComponent with HasGameRef {
|
||||
_LetEveryoneTextComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2.zero(),
|
||||
textRenderer: _descriptionTextPaint,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
text = readProvider<AppLocalizations>().letEveryone;
|
||||
}
|
||||
}
|
||||
|
||||
class _SharingYourScoreTextComponent extends TextComponent with HasGameRef {
|
||||
_SharingYourScoreTextComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, 2.5),
|
||||
textRenderer: _descriptionTextPaint,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
text = readProvider<AppLocalizations>().bySharingYourScore;
|
||||
}
|
||||
}
|
||||
|
||||
class _SocialMediaTextComponent extends TextComponent with HasGameRef {
|
||||
_SocialMediaTextComponent()
|
||||
: super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, 5),
|
||||
textRenderer: _descriptionTextPaint,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
text = readProvider<AppLocalizations>().socialMediaAccount;
|
||||
}
|
||||
}
|
||||
|
||||
class _SocialNetworksComponent extends PositionComponent with HasGameRef {
|
||||
_SocialNetworksComponent({
|
||||
OnSocialShareTap? onShare,
|
||||
}) : super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(0, 12),
|
||||
children: [
|
||||
FacebookButtonComponent(onTap: onShare),
|
||||
TwitterButtonComponent(onTap: onShare),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// {@template facebook_button_component}
|
||||
/// Button for sharing on Facebook.
|
||||
/// {@endtemplate}
|
||||
class FacebookButtonComponent extends SpriteComponent
|
||||
with HasGameRef, Tappable {
|
||||
/// {@macro facebook_button_component}
|
||||
FacebookButtonComponent({
|
||||
OnSocialShareTap? onTap,
|
||||
}) : _onTap = onTap,
|
||||
super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(-5, 0),
|
||||
);
|
||||
|
||||
final OnSocialShareTap? _onTap;
|
||||
|
||||
@override
|
||||
bool onTapDown(TapDownInfo info) {
|
||||
_onTap?.call(SharePlatform.facebook);
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
final sprite = Sprite(
|
||||
gameRef.images.fromCache(Assets.images.backbox.button.facebook.keyName),
|
||||
);
|
||||
this.sprite = sprite;
|
||||
size = sprite.originalSize / 25;
|
||||
}
|
||||
}
|
||||
|
||||
/// {@template twitter_button_component}
|
||||
/// Button for sharing on Twitter.
|
||||
/// {@endtemplate}
|
||||
class TwitterButtonComponent extends SpriteComponent with HasGameRef, Tappable {
|
||||
/// {@macro twitter_button_component}
|
||||
TwitterButtonComponent({
|
||||
OnSocialShareTap? onTap,
|
||||
}) : _onTap = onTap,
|
||||
super(
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(5, 0),
|
||||
);
|
||||
|
||||
final OnSocialShareTap? _onTap;
|
||||
|
||||
@override
|
||||
bool onTapDown(TapDownInfo info) {
|
||||
_onTap?.call(SharePlatform.twitter);
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
await super.onLoad();
|
||||
final sprite = Sprite(
|
||||
gameRef.images.fromCache(Assets.images.backbox.button.twitter.keyName),
|
||||
);
|
||||
this.sprite = sprite;
|
||||
size = sprite.originalSize / 25;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pinball/game/game.dart';
|
||||
import 'package:pinball/l10n/l10n.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
import 'package:pinball_ui/pinball_ui.dart';
|
||||
|
||||
/// {@template mobile_controls}
|
||||
/// Widget with the controls used to enable the user initials input on mobile.
|
||||
/// {@endtemplate}
|
||||
class MobileControls extends StatelessWidget {
|
||||
/// {@macro mobile_controls}
|
||||
const MobileControls({
|
||||
Key? key,
|
||||
required this.game,
|
||||
}) : super(key: key);
|
||||
|
||||
/// Game instance
|
||||
final PinballGame game;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
MobileDpad(
|
||||
onTapUp: () => game.triggerVirtualKeyUp(LogicalKeyboardKey.arrowUp),
|
||||
onTapDown: () => game.triggerVirtualKeyUp(
|
||||
LogicalKeyboardKey.arrowDown,
|
||||
),
|
||||
onTapLeft: () => game.triggerVirtualKeyUp(
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
),
|
||||
onTapRight: () => game.triggerVirtualKeyUp(
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
),
|
||||
),
|
||||
PinballButton(
|
||||
text: l10n.enter,
|
||||
onTap: () => game.triggerVirtualKeyUp(LogicalKeyboardKey.enter),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball_ui/pinball_ui.dart';
|
||||
|
||||
/// {@template mobile_dpad}
|
||||
/// Widget rendering 4 directional input arrows.
|
||||
/// {@endtemplate}
|
||||
class MobileDpad extends StatelessWidget {
|
||||
/// {@template mobile_dpad}
|
||||
const MobileDpad({
|
||||
Key? key,
|
||||
required this.onTapUp,
|
||||
required this.onTapDown,
|
||||
required this.onTapLeft,
|
||||
required this.onTapRight,
|
||||
}) : super(key: key);
|
||||
|
||||
static const _size = 180.0;
|
||||
|
||||
/// Called when dpad up is pressed
|
||||
final VoidCallback onTapUp;
|
||||
|
||||
/// Called when dpad down is pressed
|
||||
final VoidCallback onTapDown;
|
||||
|
||||
/// Called when dpad left is pressed
|
||||
final VoidCallback onTapLeft;
|
||||
|
||||
/// Called when dpad right is pressed
|
||||
final VoidCallback onTapRight;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: _size,
|
||||
height: _size,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
PinballDpadButton(
|
||||
direction: PinballDpadDirection.up,
|
||||
onTap: onTapUp,
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
PinballDpadButton(
|
||||
direction: PinballDpadDirection.left,
|
||||
onTap: onTapLeft,
|
||||
),
|
||||
const Spacer(),
|
||||
PinballDpadButton(
|
||||
direction: PinballDpadDirection.right,
|
||||
onTap: onTapRight,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
PinballDpadButton(
|
||||
direction: PinballDpadDirection.down,
|
||||
onTap: onTapDown,
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:pinball/l10n/l10n.dart';
|
||||
import 'package:pinball/start_game/start_game.dart';
|
||||
import 'package:pinball_ui/pinball_ui.dart';
|
||||
|
||||
/// {@template replay_button_overlay}
|
||||
/// [Widget] that renders the button responsible for restarting the game.
|
||||
/// {@endtemplate}
|
||||
class ReplayButtonOverlay extends StatelessWidget {
|
||||
/// {@macro replay_button_overlay}
|
||||
const ReplayButtonOverlay({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
|
||||
return PinballButton(
|
||||
text: l10n.replay,
|
||||
onTap: () {
|
||||
context.read<StartGameBloc>().add(const ReplayTapped());
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
export 'bonus_animation.dart';
|
||||
export 'game_hud.dart';
|
||||
export 'mobile_controls.dart';
|
||||
export 'mobile_dpad.dart';
|
||||
export 'play_button_overlay.dart';
|
||||
export 'replay_button_overlay.dart';
|
||||
export 'round_count_display.dart';
|
||||
export 'score_view.dart';
|
||||
|
@ -1,26 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:authentication_repository/authentication_repository.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:leaderboard_repository/leaderboard_repository.dart';
|
||||
import 'package:pinball/app/app.dart';
|
||||
import 'package:pinball/bootstrap.dart';
|
||||
import 'package:pinball_audio/pinball_audio.dart';
|
||||
|
||||
void main() {
|
||||
bootstrap((firestore, firebaseAuth) async {
|
||||
final leaderboardRepository = LeaderboardRepository(firestore);
|
||||
final authenticationRepository = AuthenticationRepository(firebaseAuth);
|
||||
final pinballPlayer = PinballPlayer();
|
||||
unawaited(
|
||||
Firebase.initializeApp().then(
|
||||
(_) => authenticationRepository.authenticateAnonymously(),
|
||||
),
|
||||
);
|
||||
return App(
|
||||
authenticationRepository: authenticationRepository,
|
||||
leaderboardRepository: leaderboardRepository,
|
||||
pinballPlayer: pinballPlayer,
|
||||
);
|
||||
});
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:authentication_repository/authentication_repository.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:leaderboard_repository/leaderboard_repository.dart';
|
||||
import 'package:pinball/app/app.dart';
|
||||
import 'package:pinball/bootstrap.dart';
|
||||
import 'package:pinball_audio/pinball_audio.dart';
|
||||
|
||||
void main() {
|
||||
bootstrap((firestore, firebaseAuth) async {
|
||||
final leaderboardRepository = LeaderboardRepository(firestore);
|
||||
final authenticationRepository = AuthenticationRepository(firebaseAuth);
|
||||
final pinballPlayer = PinballPlayer();
|
||||
unawaited(
|
||||
Firebase.initializeApp().then(
|
||||
(_) => authenticationRepository.authenticateAnonymously(),
|
||||
),
|
||||
);
|
||||
return App(
|
||||
authenticationRepository: authenticationRepository,
|
||||
leaderboardRepository: leaderboardRepository,
|
||||
pinballPlayer: pinballPlayer,
|
||||
);
|
||||
});
|
||||
}
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 637 KiB After Width: | Height: | Size: 544 KiB |
Before Width: | Height: | Size: 390 KiB After Width: | Height: | Size: 334 KiB |
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 7.5 KiB |