From fe93722fd358f7a14a65acd0c650824c94dab605 Mon Sep 17 00:00:00 2001 From: amit <125254014+aruhant@users.noreply.github.com> Date: Wed, 7 Feb 2024 12:38:16 -0800 Subject: [PATCH] fixed credits navigation --- app/assets/translations/en-US.json | 1 + app/lib/level_picker/level_slector.dart | 7 ++++++- app/lib/title_screen/level_intro.dart | 9 ++++----- app/lib/title_screen/title_screen.dart | 20 ++++++++++++++++---- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/assets/translations/en-US.json b/app/assets/translations/en-US.json index 6e54fb6..0ab03b8 100644 --- a/app/assets/translations/en-US.json +++ b/app/assets/translations/en-US.json @@ -8,6 +8,7 @@ "coming_soon": "Coming Soon!", "close": "Close", "credits": "Credits", + "credits_intro": "Credits~Title Music:\nBSBARU Music\nhttps://www.youtube.com/watch?v=sFSnHaWRuvQ~Ramayana Translations:\nValmiki Ramayana\nhttps://www.valmiki.iitk.ac.in~Game Design & Development:\nAruhant Mehta\nhttps://aruhant.github.io/", "lanka_dahan_intro": "As the sun dipped below the horizon, casting an amber glow over the ancient city of Lanka, you, Fearless Hanuman, found yourself ensnared. Ravana, the ten-headed demon king, had captured you—the mighty ape warrior.~His eyes gleamed with malice as he spoke:\n\n“कपीनां किल लाङ्गूलमिष्टं भवति भूषणम्।\nतदस्य दीप्यतां शीघ्रं तेन दग्धेन गच्छतु।।5.53.3।।”\n\nTranslation: “The tail of a monkey is dear to them. It is like an ornament to them. Set it blaze swiftly with fire, and let him go.”~But you are Hanuman—the wind-swift, the leaper of oceans, the loyal servant of Lord Rama. You have the blessings of Maa Sita.~The flames dance upon your fur, but it is as cold as ice.\nAs your heart beats with courage, a mischief twinkled in your eyes. \nYou would turn Lanka into an inferno, a beacon of defiance.~Cross the sprawling city, avoid detection, and unleash the flames of retribution. \n\nRemember, Fearless Hanuman, you have but one chance. If captured, the level resets. The city awaits your wrath, and Lanka trembles in anticipation.\n\nNote: Inspired by the epic Ramayana, this game level is a fictional adaptation.", "win_message": "You have successfully destroyed Lanka!" } \ No newline at end of file diff --git a/app/lib/level_picker/level_slector.dart b/app/lib/level_picker/level_slector.dart index f7d553a..2d1d02c 100644 --- a/app/lib/level_picker/level_slector.dart +++ b/app/lib/level_picker/level_slector.dart @@ -38,7 +38,12 @@ class LevelTile extends StatelessWidget { onPressed: () { if (level.isAvailable) { Navigator.of(context).pushReplacement(MaterialPageRoute( - builder: (context) => LevelIntro(level: level.map!), + builder: (context) => LevelIntro( + level: level.map!, + onFinished: (context) => Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => GameEngine(level: level.map!)))), )); } }, diff --git a/app/lib/title_screen/level_intro.dart b/app/lib/title_screen/level_intro.dart index 974b73e..3f12681 100644 --- a/app/lib/title_screen/level_intro.dart +++ b/app/lib/title_screen/level_intro.dart @@ -5,7 +5,9 @@ import 'package:ramayana/game/game_engine.dart'; import 'package:ramayana/utils/logging.dart'; class LevelIntro extends StatefulWidget { - const LevelIntro({Key? key, required this.level}) : super(key: key); + const LevelIntro({Key? key, required this.onFinished, required this.level}) + : super(key: key); + final Function (BuildContext c ) onFinished; final String level; @override @@ -86,10 +88,7 @@ class _LevelIntroState extends State { _animationStopped = false; }); } else { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => GameEngine(level: widget.level))); + widget.onFinished(context); } } } diff --git a/app/lib/title_screen/title_screen.dart b/app/lib/title_screen/title_screen.dart index 93a2bdf..928cdb4 100644 --- a/app/lib/title_screen/title_screen.dart +++ b/app/lib/title_screen/title_screen.dart @@ -59,8 +59,14 @@ class _TitleScreenState extends State { onPressed: () => Navigator.push( context, MaterialPageRoute( - builder: (context) => - LevelIntro(level: 'credits'))), + builder: (context) => LevelIntro( + level: 'credits', + onFinished: (context) => + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => + TitleScreen()))))), child: Text( 'credits'.tr(), style: TextStyle(color: Colors.black87), @@ -98,8 +104,14 @@ class _TitleScreenState extends State { onPressed: () => Navigator.push( context, MaterialPageRoute( - builder: (context) => - LevelIntro(level: 'lanka_dahan'))), + builder: (context) => LevelIntro( + level: 'lanka_dahan', + onFinished: (context) => + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => GameEngine( + level: 'lanka_dahan')))))), // const GameEngine(level: 'lanka_dahan'))), child: Text('start_game'.tr())), ],