From e11f0979b2273631152d58a4f77dc845ddb17261 Mon Sep 17 00:00:00 2001 From: mytja Date: Thu, 8 Feb 2024 01:13:30 +0100 Subject: [PATCH] improve tournament organization add more tournament statistics improve UX at some parts add counterclockwise option - resolves a ticket in a Discord server Potential points for winning a round - resolves #68 --- messages/messages.proto | 11 + tarok/lib/constants.dart | 1 + tarok/lib/game/game.dart | 197 +++++++++++++++++- tarok/lib/game/game_controller.dart | 90 ++++++-- tarok/lib/internationalization/languages.dart | 26 +++ tarok/lib/main.dart | 1 + tarok/lib/messages/messages.pb.dart | 142 ++++++++++++- tarok/lib/messages/messages.pbjson.dart | 33 ++- tarok/lib/settings.dart | 22 +- tarok/lib/tms/tms_controller.dart | 14 -- tarok/lib/tms/tournaments.dart | 8 +- 11 files changed, 495 insertions(+), 50 deletions(-) diff --git a/messages/messages.proto b/messages/messages.proto index 6f20ca4..20108ca 100644 --- a/messages/messages.proto +++ b/messages/messages.proto @@ -223,6 +223,16 @@ message TournamentStatistics { int32 top_player_points = 3; } +message TournamentGameStatisticInner { + int32 game = 1; + bool bots = 2; + int32 amount = 3; +} + +message TournamentGameStatistics { + repeated TournamentGameStatisticInner statistics = 1; +} + message ChatMessage { string user_id = 1; string message = 2; @@ -279,5 +289,6 @@ message Message { StartEarly start_early = 41; PrepareGameMode prepare_game_mode = 42; TournamentStatistics tournament_statistics = 43; + TournamentGameStatistics tournament_game_statistics = 44; } } diff --git a/tarok/lib/constants.dart b/tarok/lib/constants.dart index 71e77e8..0f66abd 100644 --- a/tarok/lib/constants.dart +++ b/tarok/lib/constants.dart @@ -50,6 +50,7 @@ bool SKISFANG = false; bool DISCORD_RPC = true; bool RED_FILTER = true; bool COUNTERCLOCKWISE_GAME = false; +bool POINTS_TOOLTIP = false; 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 b5880a2..c565fa3 100644 --- a/tarok/lib/game/game.dart +++ b/tarok/lib/game/game.dart @@ -318,6 +318,16 @@ class Game extends StatelessWidget { ]), const SizedBox(width: 5), const Divider(), + if (controller + .tournamentGameStatistics.isNotEmpty) + Text( + "other_players_are_playing".tr, + style: const TextStyle(fontSize: 18), + ), + ...controller.tournamentGameStatistics, + if (controller + .tournamentGameStatistics.isNotEmpty) + const Divider(), const SizedBox(height: 5), Row( children: [ @@ -553,7 +563,7 @@ class Game extends StatelessWidget { ElevatedButton( onPressed: () { controller.socket.close(); - controller.connect(controller.gameId); + controller.connect(controller.gameId!); controller.listen(); }, child: Text("reset_websocket".tr), @@ -570,7 +580,7 @@ class Game extends StatelessWidget { content: SizedBox( width: double.maxFinite, child: Friends( - gameId: controller.gameId, + gameId: controller.gameId!, ), ), ), @@ -721,7 +731,10 @@ class Game extends StatelessWidget { Row( mainAxisSize: MainAxisSize.min, children: [ - ...controller.users.map( + ...(COUNTERCLOCKWISE_GAME && !controller.bots + ? controller.users.reversed + : controller.users) + .map( (stockskis.SimpleUser user) => Row( children: [ Column( @@ -1024,6 +1037,30 @@ class Game extends StatelessWidget { ), ), ), + DataColumn( + label: Expanded( + child: Text( + "points_prediction".trParams( + { + "points": (stockskis + .GAMES[controller + .currentPredictions + .value! + .gamemode + + 1] + .worth * + pow( + 2, + controller + .currentPredictions + .value! + .igraKontra)) + .toString(), + }, + ), + ), + ), + ), ], rows: [ if (!(controller.valat.value || @@ -1078,6 +1115,25 @@ class Game extends StatelessWidget { ], ), ), + DataCell( + Row( + children: [ + Text( + "points_prediction".trParams({ + "points": controller + .trula.value || + controller + .currentPredictions + .value! + .trula + .id != + "" + ? "20" + : "0" + })), + ], + ), + ), ], ), if (!(controller.valat.value || @@ -1132,6 +1188,25 @@ class Game extends StatelessWidget { ], ), ), + DataCell( + Row( + children: [ + Text( + "points_prediction".trParams({ + "points": controller + .kralji.value || + controller + .currentPredictions + .value! + .kralji + .id != + "" + ? "20" + : "0" + })), + ], + ), + ), ], ), if (!(controller.valat.value || @@ -1213,6 +1288,32 @@ class Game extends StatelessWidget { ], ), ), + DataCell( + Row( + children: [ + Text( + "points_prediction".trParams({ + "points": controller.pagatUltimo + .value || + controller + .currentPredictions + .value! + .pagatUltimo + .id != + "" + ? (50 * + pow( + 2, + controller + .currentPredictions + .value! + .pagatUltimoKontra)) + .toString() + : "0", + })), + ], + ), + ), ], ), if (!(controller.valat.value || @@ -1294,6 +1395,32 @@ class Game extends StatelessWidget { ], ), ), + DataCell( + Row( + children: [ + Text( + "points_prediction".trParams({ + "points": controller.kraljUltimo + .value || + controller + .currentPredictions + .value! + .kraljUltimo + .id != + "" + ? (20 * + pow( + 2, + controller + .currentPredictions + .value! + .kraljUltimoKontra)) + .toString() + : "0", + })), + ], + ), + ), ], ), if (!controller.valat.value && @@ -1380,6 +1507,32 @@ class Game extends StatelessWidget { ], ), ), + DataCell( + Row( + children: [ + Text( + "points_prediction".trParams({ + "points": controller + .mondfang.value || + controller + .currentPredictions + .value! + .mondfang + .id != + "" + ? (21 * + pow( + 2, + controller + .currentPredictions + .value! + .mondfangKontra)) + .toString() + : "0", + })), + ], + ), + ), ], ), if (!(controller.valat.value || @@ -1419,6 +1572,25 @@ class Game extends StatelessWidget { return ""; }).join(""))), const DataCell(SizedBox()), + DataCell( + Row( + children: [ + Text( + "points_prediction".trParams({ + "points": controller + .barvic.value || + controller + .currentPredictions + .value! + .barvniValat + .id != + "" + ? "125" + : "0", + })), + ], + ), + ), ], ), if (!(controller.barvic.value || @@ -1455,6 +1627,25 @@ class Game extends StatelessWidget { return ""; }).join(""))), const DataCell(SizedBox()), + DataCell( + Row( + children: [ + Text( + "points_prediction".trParams({ + "points": controller + .valat.value || + controller + .currentPredictions + .value! + .valat + .id != + "" + ? "500" + : "0", + })), + ], + ), + ), ], ), ], diff --git a/tarok/lib/game/game_controller.dart b/tarok/lib/game/game_controller.dart index 1b23400..f99ab85 100644 --- a/tarok/lib/game/game_controller.dart +++ b/tarok/lib/game/game_controller.dart @@ -100,6 +100,7 @@ class GameController extends GetxController { var gamesPlayed = 0.obs; var gamesRequired = (-1).obs; var canExtendGame = true.obs; + var tournamentGameStatistics = [].obs; var unreadMessages = 0.obs; @@ -110,7 +111,7 @@ class GameController extends GetxController { Timer? currentTimer; final bool bbots = Get.parameters["bots"] == "true"; - final String gameId = Get.parameters["gameId"]!; + final String? gameId = Get.parameters["gameId"]; final int playing = int.parse(Get.parameters["playing"]!); final bool replay = Get.parameters["replay"] == "true"; @@ -156,8 +157,13 @@ class GameController extends GetxController { return; } + if (gameId == null) { + super.onInit(); + return; + } + // ONLINE - connect(gameId); + connect(gameId!); listen(); super.onInit(); @@ -220,26 +226,34 @@ class GameController extends GetxController { if (users.length == 3 && !e.playsThree) { continue; } + + Widget button = ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: + suggestions.contains(e.id) ? Colors.purpleAccent.shade400 : null, + ), + onPressed: () async { + await licitiranjeSend(e); + }, + child: Text( + e.name.tr, + maxLines: 1, + ), + ); + gameListAssembly.add( SizedBox( width: fullHeight / 25, height: fullHeight / 25, child: FittedBox( fit: BoxFit.contain, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: suggestions.contains(e.id) - ? Colors.purpleAccent.shade400 - : null, - ), - onPressed: () async { - await licitiranjeSend(e); - }, - child: Text( - e.name.tr, - maxLines: 1, - ), - ), + child: POINTS_TOOLTIP + ? Tooltip( + message: "points_prediction" + .trParams({"points": e.worth.toString()}), + child: button, + ) + : button, ), ), ); @@ -1081,9 +1095,9 @@ class GameController extends GetxController { break; } - if (userId != playerId.value) { - break; - } + //if (userId != playerId.value) { + // break; + //} turn.value = false; @@ -1274,9 +1288,20 @@ class GameController extends GetxController { } if (COUNTERCLOCKWISE_GAME) { + debugPrint("Obračam igro."); + userWidgets.value = [ - ...userWidgets.sublist(0, userWidgets.length - 1).reversed + ...userWidgets.sublist(0, userWidgets.length - 1).reversed, + userWidgets.last, ]; + users.value = [...users.reversed]; + for (int i = 0; i < users.length; i++) { + final newUser = users[i]; + if (newUser.id == playerId.value) { + myPosition.value = i; + break; + } + } } debugPrint("anotacije so bile dodane"); @@ -1346,6 +1371,8 @@ class GameController extends GetxController { } else if (msg.hasResults()) { final r = msg.results; + tournamentGameStatistics.value = []; + if (!msg.silent) { results.value = r; } @@ -1566,6 +1593,23 @@ class GameController extends GetxController { } } else if (msg.hasTournamentStatistics()) { tournamentStatistics.value = msg.tournamentStatistics; + } else if (msg.hasTournamentGameStatistics()) { + var a = msg.tournamentGameStatistics.statistics; + a.sort((a, b) => b.amount.compareTo(a.amount)); + for (int i = 0; i < a.length; i++) { + if (a[i].bots) { + tournamentGameStatistics.add(Text("bot_plays".trParams({ + "game": stockskis.GAMES[a[i].game + 1].name.tr, + "times": a[i].amount.toString(), + }))); + continue; + } + tournamentGameStatistics.add(Text("player_plays".trParams({ + "game": stockskis.GAMES[a[i].game + 1].name.tr, + "times": a[i].amount.toString(), + }))); + } + tournamentGameStatistics.refresh(); } }, onDone: () { @@ -1687,9 +1731,9 @@ class GameController extends GetxController { userWidgets.removeAt(0); userWidgets.add(w); if (COUNTERCLOCKWISE_GAME) { - userWidgets.value = [ - ...userWidgets.sublist(0, userWidgets.length - 1).reversed - ]; + //userWidgets.value = [ + // ...userWidgets.sublist(0, userWidgets.length - 1).reversed + //]; stockskisContext!.userPositions = [ ...stockskisContext!.userPositions.reversed ]; diff --git a/tarok/lib/internationalization/languages.dart b/tarok/lib/internationalization/languages.dart index 76ecd48..981ef1e 100644 --- a/tarok/lib/internationalization/languages.dart +++ b/tarok/lib/internationalization/languages.dart @@ -465,6 +465,15 @@ class Messages extends Translations { "counterclockwise_gameplay_desc": "The game will be running counterclockwise. You have to restart the game or leave it to apply this change.", "reset_websocket": "Reset the WebSocket connection", + "points_prediction": "@points points", + "enable_points_tooltip": "Enable point tooltips", + "enable_points_tooltip_desc": + "Values of all games will be shown during the licitation process. You will have to restart the game to apply the change.", + "accessibility": "Accessibility", + "bot_plays": "Bots 🤖 are playing \"@game\" @times times", + "player_plays": "Players 👤 are playing \"@game\" @times times", + "other_players_are_playing": + "Other players are currently playing following games", }, "fr_FR": { "login": "Connexion", @@ -920,6 +929,15 @@ class Messages extends Translations { "counterclockwise_gameplay_desc": "The game will be running counterclockwise. You have to restart the game or leave it to apply this change.", "reset_websocket": "Reset the WebSocket connection", + "points_prediction": "@points points", + "enable_points_tooltip": "Enable point tooltips", + "enable_points_tooltip_desc": + "Values of all games will be shown during the licitation process. You will have to restart the game to apply the change.", + "accessibility": "Accessibility", + "bot_plays": "Bots 🤖 are playing \"@game\" @times times", + "player_plays": "Players 👤 are playing \"@game\" @times times", + "other_players_are_playing": + "Other players are currently playing following games", }, "sl_SI": { "login": "Prijava", @@ -1365,6 +1383,14 @@ class Messages extends Translations { "counterclockwise_gameplay_desc": "Igra bo potekala v nasprotni smeri urinega kazalca. Ko to vključite, morate zapustiti igro.", "reset_websocket": "Resetiraj WebSocket povezavo", + "points_prediction": "@points točk", + "enable_points_tooltip": "Vključi prikaze točk za igre", + "enable_points_tooltip_desc": + "Vrednost vseh iger se bo prikazala na zaslonu med igro. Igro boste morali znova zagnati, da se spremembe uveljavijo.", + "accessibility": "Dostopnost", + "bot_plays": "Boti 🤖 igrajo \"@game\" @times-krat", + "player_plays": "Igralci 👤 igrajo \"@game\" @times-krat", + "other_players_are_playing": "Drugi igralci igrajo naslednje igre", } }; } diff --git a/tarok/lib/main.dart b/tarok/lib/main.dart index 3b4e676..2b2a8aa 100644 --- a/tarok/lib/main.dart +++ b/tarok/lib/main.dart @@ -85,6 +85,7 @@ void main() async { BOT_DELAY = prefs.getInt("bot_delay") ?? 500; CARD_CLEANUP_DELAY = prefs.getInt("card_cleanup_delay") ?? 1000; COUNTERCLOCKWISE_GAME = prefs.getBool("counterclockwise_game") ?? false; + POINTS_TOOLTIP = prefs.getBool("points_tooltip") ?? false; if (kReleaseMode) { BACKEND_URL = prefs.getString("api_url") ?? "https://palcka.si/api"; diff --git a/tarok/lib/messages/messages.pb.dart b/tarok/lib/messages/messages.pb.dart index 17ba34b..7f9e7c0 100644 --- a/tarok/lib/messages/messages.pb.dart +++ b/tarok/lib/messages/messages.pb.dart @@ -3256,6 +3256,128 @@ class TournamentStatistics extends $pb.GeneratedMessage { void clearTopPlayerPoints() => clearField(3); } +class TournamentGameStatisticInner extends $pb.GeneratedMessage { + factory TournamentGameStatisticInner({ + $core.int? game, + $core.bool? bots, + $core.int? amount, + }) { + final $result = create(); + if (game != null) { + $result.game = game; + } + if (bots != null) { + $result.bots = bots; + } + if (amount != null) { + $result.amount = amount; + } + return $result; + } + TournamentGameStatisticInner._() : super(); + factory TournamentGameStatisticInner.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory TournamentGameStatisticInner.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'TournamentGameStatisticInner', package: const $pb.PackageName(_omitMessageNames ? '' : 'game_messages'), createEmptyInstance: create) + ..a<$core.int>(1, _omitFieldNames ? '' : 'game', $pb.PbFieldType.O3) + ..aOB(2, _omitFieldNames ? '' : 'bots') + ..a<$core.int>(3, _omitFieldNames ? '' : 'amount', $pb.PbFieldType.O3) + ..hasRequiredFields = false + ; + + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + TournamentGameStatisticInner clone() => TournamentGameStatisticInner()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + TournamentGameStatisticInner copyWith(void Function(TournamentGameStatisticInner) updates) => super.copyWith((message) => updates(message as TournamentGameStatisticInner)) as TournamentGameStatisticInner; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static TournamentGameStatisticInner create() => TournamentGameStatisticInner._(); + TournamentGameStatisticInner createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static TournamentGameStatisticInner getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static TournamentGameStatisticInner? _defaultInstance; + + @$pb.TagNumber(1) + $core.int get game => $_getIZ(0); + @$pb.TagNumber(1) + set game($core.int v) { $_setSignedInt32(0, v); } + @$pb.TagNumber(1) + $core.bool hasGame() => $_has(0); + @$pb.TagNumber(1) + void clearGame() => clearField(1); + + @$pb.TagNumber(2) + $core.bool get bots => $_getBF(1); + @$pb.TagNumber(2) + set bots($core.bool v) { $_setBool(1, v); } + @$pb.TagNumber(2) + $core.bool hasBots() => $_has(1); + @$pb.TagNumber(2) + void clearBots() => clearField(2); + + @$pb.TagNumber(3) + $core.int get amount => $_getIZ(2); + @$pb.TagNumber(3) + set amount($core.int v) { $_setSignedInt32(2, v); } + @$pb.TagNumber(3) + $core.bool hasAmount() => $_has(2); + @$pb.TagNumber(3) + void clearAmount() => clearField(3); +} + +class TournamentGameStatistics extends $pb.GeneratedMessage { + factory TournamentGameStatistics({ + $core.Iterable? statistics, + }) { + final $result = create(); + if (statistics != null) { + $result.statistics.addAll(statistics); + } + return $result; + } + TournamentGameStatistics._() : super(); + factory TournamentGameStatistics.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory TournamentGameStatistics.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'TournamentGameStatistics', package: const $pb.PackageName(_omitMessageNames ? '' : 'game_messages'), createEmptyInstance: create) + ..pc(1, _omitFieldNames ? '' : 'statistics', $pb.PbFieldType.PM, subBuilder: TournamentGameStatisticInner.create) + ..hasRequiredFields = false + ; + + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + TournamentGameStatistics clone() => TournamentGameStatistics()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + TournamentGameStatistics copyWith(void Function(TournamentGameStatistics) updates) => super.copyWith((message) => updates(message as TournamentGameStatistics)) as TournamentGameStatistics; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static TournamentGameStatistics create() => TournamentGameStatistics._(); + TournamentGameStatistics createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static TournamentGameStatistics getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static TournamentGameStatistics? _defaultInstance; + + @$pb.TagNumber(1) + $core.List get statistics => $_getList(0); +} + class ChatMessage extends $pb.GeneratedMessage { factory ChatMessage({ $core.String? userId, @@ -3516,6 +3638,7 @@ enum Message_Data { startEarly, prepareGameMode, tournamentStatistics, + tournamentGameStatistics, notSet } @@ -3558,6 +3681,7 @@ class Message extends $pb.GeneratedMessage { StartEarly? startEarly, PrepareGameMode? prepareGameMode, TournamentStatistics? tournamentStatistics, + TournamentGameStatistics? tournamentGameStatistics, }) { final $result = create(); if (username != null) { @@ -3671,6 +3795,9 @@ class Message extends $pb.GeneratedMessage { if (tournamentStatistics != null) { $result.tournamentStatistics = tournamentStatistics; } + if (tournamentGameStatistics != null) { + $result.tournamentGameStatistics = tournamentGameStatistics; + } return $result; } Message._() : super(); @@ -3712,10 +3839,11 @@ class Message extends $pb.GeneratedMessage { 41 : Message_Data.startEarly, 42 : Message_Data.prepareGameMode, 43 : Message_Data.tournamentStatistics, + 44 : Message_Data.tournamentGameStatistics, 0 : Message_Data.notSet }; static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Message', package: const $pb.PackageName(_omitMessageNames ? '' : 'game_messages'), createEmptyInstance: create) - ..oo(0, [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]) + ..oo(0, [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44]) ..aOS(1, _omitFieldNames ? '' : 'username') ..aOS(2, _omitFieldNames ? '' : 'playerId') ..aOB(4, _omitFieldNames ? '' : 'silent') @@ -3753,6 +3881,7 @@ class Message extends $pb.GeneratedMessage { ..aOM(41, _omitFieldNames ? '' : 'startEarly', subBuilder: StartEarly.create) ..aOM(42, _omitFieldNames ? '' : 'prepareGameMode', subBuilder: PrepareGameMode.create) ..aOM(43, _omitFieldNames ? '' : 'tournamentStatistics', subBuilder: TournamentStatistics.create) + ..aOM(44, _omitFieldNames ? '' : 'tournamentGameStatistics', subBuilder: TournamentGameStatistics.create) ..hasRequiredFields = false ; @@ -4180,6 +4309,17 @@ class Message extends $pb.GeneratedMessage { void clearTournamentStatistics() => clearField(43); @$pb.TagNumber(43) TournamentStatistics ensureTournamentStatistics() => $_ensure(36); + + @$pb.TagNumber(44) + TournamentGameStatistics get tournamentGameStatistics => $_getN(37); + @$pb.TagNumber(44) + set tournamentGameStatistics(TournamentGameStatistics v) { setField(44, v); } + @$pb.TagNumber(44) + $core.bool hasTournamentGameStatistics() => $_has(37); + @$pb.TagNumber(44) + void clearTournamentGameStatistics() => clearField(44); + @$pb.TagNumber(44) + TournamentGameStatistics ensureTournamentGameStatistics() => $_ensure(37); } diff --git a/tarok/lib/messages/messages.pbjson.dart b/tarok/lib/messages/messages.pbjson.dart index d96b107..3152344 100644 --- a/tarok/lib/messages/messages.pbjson.dart +++ b/tarok/lib/messages/messages.pbjson.dart @@ -663,6 +663,34 @@ final $typed_data.Uint8List tournamentStatisticsDescriptor = $convert.base64Deco 'gCIAEoBVIHcGxheWVycxIqChF0b3BfcGxheWVyX3BvaW50cxgDIAEoBVIPdG9wUGxheWVyUG9p' 'bnRz'); +@$core.Deprecated('Use tournamentGameStatisticInnerDescriptor instead') +const TournamentGameStatisticInner$json = { + '1': 'TournamentGameStatisticInner', + '2': [ + {'1': 'game', '3': 1, '4': 1, '5': 5, '10': 'game'}, + {'1': 'bots', '3': 2, '4': 1, '5': 8, '10': 'bots'}, + {'1': 'amount', '3': 3, '4': 1, '5': 5, '10': 'amount'}, + ], +}; + +/// Descriptor for `TournamentGameStatisticInner`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List tournamentGameStatisticInnerDescriptor = $convert.base64Decode( + 'ChxUb3VybmFtZW50R2FtZVN0YXRpc3RpY0lubmVyEhIKBGdhbWUYASABKAVSBGdhbWUSEgoEYm' + '90cxgCIAEoCFIEYm90cxIWCgZhbW91bnQYAyABKAVSBmFtb3VudA=='); + +@$core.Deprecated('Use tournamentGameStatisticsDescriptor instead') +const TournamentGameStatistics$json = { + '1': 'TournamentGameStatistics', + '2': [ + {'1': 'statistics', '3': 1, '4': 3, '5': 11, '6': '.game_messages.TournamentGameStatisticInner', '10': 'statistics'}, + ], +}; + +/// Descriptor for `TournamentGameStatistics`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List tournamentGameStatisticsDescriptor = $convert.base64Decode( + 'ChhUb3VybmFtZW50R2FtZVN0YXRpc3RpY3MSSwoKc3RhdGlzdGljcxgBIAMoCzIrLmdhbWVfbW' + 'Vzc2FnZXMuVG91cm5hbWVudEdhbWVTdGF0aXN0aWNJbm5lclIKc3RhdGlzdGljcw=='); + @$core.Deprecated('Use chatMessageDescriptor instead') const ChatMessage$json = { '1': 'ChatMessage', @@ -756,6 +784,7 @@ const Message$json = { {'1': 'start_early', '3': 41, '4': 1, '5': 11, '6': '.game_messages.StartEarly', '9': 0, '10': 'startEarly'}, {'1': 'prepare_game_mode', '3': 42, '4': 1, '5': 11, '6': '.game_messages.PrepareGameMode', '9': 0, '10': 'prepareGameMode'}, {'1': 'tournament_statistics', '3': 43, '4': 1, '5': 11, '6': '.game_messages.TournamentStatistics', '9': 0, '10': 'tournamentStatistics'}, + {'1': 'tournament_game_statistics', '3': 44, '4': 1, '5': 11, '6': '.game_messages.TournamentGameStatistics', '9': 0, '10': 'tournamentGameStatistics'}, ], '8': [ {'1': 'data'}, @@ -805,5 +834,7 @@ final $typed_data.Uint8List messageDescriptor = $convert.base64Decode( 'YXJ0RWFybHlIAFIKc3RhcnRFYXJseRJMChFwcmVwYXJlX2dhbWVfbW9kZRgqIAEoCzIeLmdhbW' 'VfbWVzc2FnZXMuUHJlcGFyZUdhbWVNb2RlSABSD3ByZXBhcmVHYW1lTW9kZRJaChV0b3VybmFt' 'ZW50X3N0YXRpc3RpY3MYKyABKAsyIy5nYW1lX21lc3NhZ2VzLlRvdXJuYW1lbnRTdGF0aXN0aW' - 'NzSABSFHRvdXJuYW1lbnRTdGF0aXN0aWNzQgYKBGRhdGE='); + 'NzSABSFHRvdXJuYW1lbnRTdGF0aXN0aWNzEmcKGnRvdXJuYW1lbnRfZ2FtZV9zdGF0aXN0aWNz' + 'GCwgASgLMicuZ2FtZV9tZXNzYWdlcy5Ub3VybmFtZW50R2FtZVN0YXRpc3RpY3NIAFIYdG91cm' + '5hbWVudEdhbWVTdGF0aXN0aWNzQgYKBGRhdGE='); diff --git a/tarok/lib/settings.dart b/tarok/lib/settings.dart index 6a041a7..97413ab 100644 --- a/tarok/lib/settings.dart +++ b/tarok/lib/settings.dart @@ -85,7 +85,7 @@ class _SettingsState extends State { title: Text("toggle_red_filter".tr), description: Text("toggle_red_filter_desc".tr), ), - /*SettingsTile.switchTile( + SettingsTile.switchTile( onToggle: (value) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -98,7 +98,7 @@ class _SettingsState extends State { leading: const Icon(Icons.replay), title: Text("counterclockwise_gameplay".tr), description: Text("counterclockwise_gameplay_desc".tr), - ),*/ + ), ], ), SettingsSection( @@ -175,6 +175,24 @@ class _SettingsState extends State { ), ], ), + SettingsSection( + title: Text("accessibility".tr), + tiles: [ + SettingsTile.switchTile( + onToggle: (value) async { + final SharedPreferences prefs = + await SharedPreferences.getInstance(); + await prefs.setBool("points_tooltip", value); + POINTS_TOOLTIP = prefs.getBool("points_tooltip") ?? false; + setState(() {}); + }, + initialValue: POINTS_TOOLTIP, + leading: const Icon(Icons.help), + title: Text("enable_points_tooltip".tr), + description: Text("enable_points_tooltip_desc".tr), + ), + ], + ), if (!kIsWeb && (Platform.isLinux || Platform.isWindows)) SettingsSection( title: Text("other".tr), diff --git a/tarok/lib/tms/tms_controller.dart b/tarok/lib/tms/tms_controller.dart index d9b6189..9678538 100644 --- a/tarok/lib/tms/tms_controller.dart +++ b/tarok/lib/tms/tms_controller.dart @@ -17,7 +17,6 @@ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:get/get.dart' hide FormData; import 'package:omni_datetime_picker/omni_datetime_picker.dart'; import 'package:tarok/constants.dart'; @@ -35,10 +34,6 @@ class TMSController extends GetxController { @override void onInit() async { - SystemChrome.setPreferredOrientations([ - DeviceOrientation.landscapeLeft, - DeviceOrientation.landscapeRight, - ]); String? token = await storage.read(key: "token"); if (token == "" || token == "a" || token == null) { guest.value = true; @@ -53,15 +48,6 @@ class TMSController extends GetxController { super.onInit(); } - @override - void onClose() { - SystemChrome.setPreferredOrientations([ - DeviceOrientation.portraitUp, - DeviceOrientation.portraitDown, - ]); - super.onClose(); - } - void newTournamentDialog( {String editId = "", bool private = true, diff --git a/tarok/lib/tms/tournaments.dart b/tarok/lib/tms/tournaments.dart index f5d684c..5d21d5e 100644 --- a/tarok/lib/tms/tournaments.dart +++ b/tarok/lib/tms/tournaments.dart @@ -44,9 +44,7 @@ class Tournaments extends StatelessWidget { style: const TextStyle(fontSize: 30), ), ...controller.tournaments.map( - (e) => e["start_time"] < DateTime.now().millisecondsSinceEpoch - ? const SizedBox() - : TournamentCard(e: e), + (e) => e["ended"] ? const SizedBox() : TournamentCard(e: e), ), const SizedBox( height: 20, @@ -56,9 +54,7 @@ class Tournaments extends StatelessWidget { style: const TextStyle(fontSize: 30), ), ...controller.tournaments.map( - (e) => e["start_time"] > DateTime.now().millisecondsSinceEpoch - ? const SizedBox() - : TournamentCard(e: e), + (e) => !e["ended"] ? const SizedBox() : TournamentCard(e: e), ), ], ),