From 782422f265723b519a82cd4fdcfcec999d34ed1d Mon Sep 17 00:00:00 2001 From: mytja Date: Sun, 28 Apr 2024 22:59:32 +0200 Subject: [PATCH] app: togglable evaluation bar --- tarok/lib/constants.dart | 1 + tarok/lib/game/game.dart | 4 ++-- tarok/lib/internationalization/languages.dart | 11 ++++++++++- tarok/lib/main.dart | 1 + tarok/lib/settings.dart | 13 +++++++++++++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/tarok/lib/constants.dart b/tarok/lib/constants.dart index 09cb6b0..c08b797 100644 --- a/tarok/lib/constants.dart +++ b/tarok/lib/constants.dart @@ -51,6 +51,7 @@ bool DISCORD_RPC = true; bool RED_FILTER = true; bool COUNTERCLOCKWISE_GAME = false; bool POINTS_TOOLTIP = false; +bool SHOW_EVALUATION = true; String THEME = ""; Locale LOCALE = Get.deviceLocale ?? const Locale("sl", "SI"); diff --git a/tarok/lib/game/game.dart b/tarok/lib/game/game.dart index 5abe7ba..9bb760b 100644 --- a/tarok/lib/game/game.dart +++ b/tarok/lib/game/game.dart @@ -661,7 +661,7 @@ class Game extends StatelessWidget { ), // EVAL BAR - if (controller.bots) + if (controller.bots && SHOW_EVALUATION) Positioned( top: 0, right: fullWidth / 5.5, @@ -689,7 +689,7 @@ class Game extends StatelessWidget { ), ), - if (controller.bots) + if (controller.bots && SHOW_EVALUATION) Positioned( top: fullHeight / 3 + 25, right: fullWidth / 5.5 + 20, diff --git a/tarok/lib/internationalization/languages.dart b/tarok/lib/internationalization/languages.dart index f3c97bf..369695f 100644 --- a/tarok/lib/internationalization/languages.dart +++ b/tarok/lib/internationalization/languages.dart @@ -474,6 +474,9 @@ class Messages extends Translations { "player_plays": "Players 👤 are playing \"@game\" @times times", "other_players_are_playing": "Other players are currently playing following games", + "show_evaluation": "Show evaluation", + "show_evaluation_desc": + "Shows current StockŠkis evaluation in an evaluation bar in offline (bot) games.", }, "fr_FR": { "login": "Connexion", @@ -938,7 +941,10 @@ class Messages extends Translations { "bot_plays": "Les robots 🤖 jouent \"@game\" @times fois", "player_plays": "Les joueurs 👤 jouent \"@game\" @times fois", "other_players_are_playing": - "Les autres joueurs sont actuellement en train de jouer aux jeux suivants" + "Les autres joueurs sont actuellement en train de jouer aux jeux suivants", + "show_evaluation": "Show evaluation", + "show_evaluation_desc": + "Shows current StockŠkis evaluation in an evaluation bar in offline (bot) games.", }, "sl_SI": { "login": "Prijava", @@ -1392,6 +1398,9 @@ class Messages extends Translations { "bot_plays": "Boti 🤖 igrajo \"@game\" @times-krat", "player_plays": "Igralci 👤 igrajo \"@game\" @times-krat", "other_players_are_playing": "Drugi igralci igrajo naslednje igre", + "show_evaluation": "Prikaži evaluacijo", + "show_evaluation_desc": + "Prikaže trenutno StockŠkis evaluacijo v igrah brez internetne povezave (offline/z boti).", } }; } diff --git a/tarok/lib/main.dart b/tarok/lib/main.dart index 2b2a8aa..b90a313 100644 --- a/tarok/lib/main.dart +++ b/tarok/lib/main.dart @@ -86,6 +86,7 @@ void main() async { CARD_CLEANUP_DELAY = prefs.getInt("card_cleanup_delay") ?? 1000; COUNTERCLOCKWISE_GAME = prefs.getBool("counterclockwise_game") ?? false; POINTS_TOOLTIP = prefs.getBool("points_tooltip") ?? false; + SHOW_EVALUATION = prefs.getBool("show_evaluation") ?? true; if (kReleaseMode) { BACKEND_URL = prefs.getString("api_url") ?? "https://palcka.si/api"; diff --git a/tarok/lib/settings.dart b/tarok/lib/settings.dart index 97413ab..c74a1c1 100644 --- a/tarok/lib/settings.dart +++ b/tarok/lib/settings.dart @@ -324,6 +324,19 @@ class _SettingsState extends State { title: Text("premove".tr), description: Text("premove_desc".tr), ), + SettingsTile.switchTile( + onToggle: (value) async { + final SharedPreferences prefs = + await SharedPreferences.getInstance(); + await prefs.setBool("show_evaluation", value); + SHOW_EVALUATION = prefs.getBool("show_evaluation") ?? true; + setState(() {}); + }, + initialValue: SHOW_EVALUATION, + leading: const Icon(Icons.help), + title: Text("show_evaluation".tr), + description: Text("show_evaluation_desc".tr), + ), ], ), SettingsSection(