Skip to content

Commit

Permalink
qol improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja committed Dec 2, 2023
1 parent d444f83 commit ccd47dd
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 70 deletions.
5 changes: 3 additions & 2 deletions tarok/lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bool AVTOLP = false;
bool PREMOVE = false;
bool DEVELOPER_MODE = false;
bool SKISFANG = false;
bool DISCORD_RPC = true;
String THEME = "";
Locale LOCALE = Get.deviceLocale ?? const Locale("sl", "SI");

Expand Down Expand Up @@ -86,10 +87,10 @@ const GAME_DESC = [
];

final List<LocalCard> KINGS = [
LocalCard(asset: "/kara/kralj", worth: 5, worthOver: 8, alt: "Kara kralj"),
LocalCard(asset: "/kriz/kralj", worth: 5, worthOver: 8, alt: "Križ kralj"),
LocalCard(asset: "/pik/kralj", worth: 5, worthOver: 8, alt: "Pik kralj"),
LocalCard(asset: "/kara/kralj", worth: 5, worthOver: 8, alt: "Kara kralj"),
LocalCard(asset: "/src/kralj", worth: 5, worthOver: 8, alt: "Src kralj"),
LocalCard(asset: "/kriz/kralj", worth: 5, worthOver: 8, alt: "Križ kralj"),
];

List<String> KONTRE = [
Expand Down
179 changes: 126 additions & 53 deletions tarok/lib/game/game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -793,62 +793,106 @@ class Game extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
...KINGS.map(
(king) => GestureDetector(
onTap: () async {
await controller.selectKing(king.asset);
},
child: Stack(
children: [
Row(
children: [
ClipRRect(
borderRadius:
BorderRadius.circular(
10 * border),
child: SizedBox(
height: popupCardSize,
child: Stack(
SizedBox(
width: (popupCardSize * 0.8 * 1.1 * 3 +
popupCardSize * 1.1) *
0.57,
height: popupCardSize * 1.1,
child: Stack(
children: [
...KINGS.asMap().entries.map(
(king) => Positioned(
left: popupCardSize *
1.1 *
king.key *
0.8 *
0.57,
child: GestureDetector(
onTap: () async {
await controller
.selectKing(king.value.asset);
},
child: Stack(
children: [
Row(
children: [
Container(
color: Colors.white,
height: popupCardSize,
width:
popupCardSize * 0.57,
ClipRRect(
borderRadius:
BorderRadius.circular(
10 * border),
child: SizedBox(
height:
popupCardSize * 1.1,
child: Stack(
children: [
Container(
color:
Colors.white,
height:
popupCardSize *
1.1,
width:
popupCardSize *
0.57 *
1.1,
),
Image.asset(
"assets/tarok${king.value.asset}.webp"),
],
),
),
),
const SizedBox(
width: 10,
),
Image.asset(
"assets/tarok${king.asset}.webp"),
],
),
),
),
const SizedBox(
width: 10,
),
],
),
if (controller.selectedKing.value !=
king.asset &&
!controller.kingSelect.value)
ClipRRect(
borderRadius: BorderRadius.circular(
10 * border),
child: Container(
color:
Colors.black.withAlpha(100),
height: popupCardSize,
width: popupCardSize * 0.57,
if (controller.selectedKing
.value !=
king.value.asset &&
!controller
.kingSelect.value)
ClipRRect(
borderRadius:
BorderRadius.circular(
10 * border),
child: Container(
color: Colors.black
.withAlpha(100),
height:
popupCardSize * 1.1,
width: popupCardSize *
0.57 *
1.1,
),
),
if (controller
.hasCard(king.value.asset))
Container(
decoration: BoxDecoration(
border: Border.all(
width: 10.0,
color: Colors.red,
),
color: Colors.black
.withAlpha(30),
borderRadius: BorderRadius
.all(Radius
.circular(10 *
(fullWidth /
1000)))),
width: popupCardSize *
0.57 *
1.1,
height: popupCardSize * 1.1,
),
],
),
),
],
),
),
),
],
),
),
],
),
),
],
),
Expand Down Expand Up @@ -1534,11 +1578,40 @@ class Game extends StatelessWidget {
SizedBox(
height:
popupCardSize,
child:
Image.asset(
"assets/tarok${entry.value.asset}.webp",
width:
popupCardSize *
0.57,
child: Center(
child:
Image.asset(
"assets/tarok${entry.value.asset}.webp",
),
),
),
if (controller
.selectedKing
.value ==
entry.value
.asset)
Container(
decoration:
BoxDecoration(
border: Border
.all(
width:
10.0,
color:
Colors.red,
),
borderRadius:
BorderRadius.all(Radius.circular(10 *
(fullWidth / 1000)))),
width:
popupCardSize *
0.57,
height:
popupCardSize,
),
if (controller
.talonSelected
.value !=
Expand Down
11 changes: 9 additions & 2 deletions tarok/lib/game/game_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import 'dart:convert';
import 'dart:developer';
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';

import 'package:dart_discord_rpc/dart_discord_rpc.dart';
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -240,6 +239,14 @@ class GameController extends GetxController {
return gameListAssembly;
}

bool hasCard(String asset) {
for (int i = 0; i < cards.length; i++) {
if (cards[i].asset != asset) continue;
return true;
}
return false;
}

void resetPredictions() {
kontraIgra.value = false;
kontraPagat.value = false;
Expand Down Expand Up @@ -884,7 +891,7 @@ class GameController extends GetxController {
}
}
debugPrint("končujem igro predčasno");
await Future.delayed(const Duration(milliseconds: 1000), () async {
await Future.delayed(const Duration(milliseconds: 500), () async {
await bResults();
});
return true;
Expand Down
10 changes: 10 additions & 0 deletions tarok/lib/internationalization/languages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ class Messages extends Translations {
"This procedure will sign you out of all your devices",
"password_reset_change": "Change your password",
"tos": "Terms of service",
"other": "Other settings",
"discord_rpc": "Enable Discord RPC",
"enable_discord_rpc":
"Enables Discord Rich Presence. Your in-game status will be shown on your profile.",
"talon_picked": "Picked talon: @talon",
},
'sl_SI': {
"login": "Prijava",
Expand Down Expand Up @@ -514,6 +519,11 @@ class Messages extends Translations {
"password_reset_procedure": "Postopek vas bo izpisal iz vseh naprav",
"password_reset_change": "Spremenite svoje geslo",
"tos": "Pogoji uporabe",
"other": "Ostale nastavitve",
"discord_rpc": "Vključite Discord RPC",
"enable_discord_rpc":
"Vključi Discordovo bogato prisotnost (Rich Presence). Vaš status znotraj igre bo prikazan na vašem Discord profilu.",
"talon_picked": "Izbran talon: @talon",
}
};
}
27 changes: 14 additions & 13 deletions tarok/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,7 @@ import 'package:url_strategy/url_strategy.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();

if (!kIsWeb && (Platform.isLinux || Platform.isWindows)) {
DiscordRPC.initialize();
rpc.start(autoRegister: true);
rpc.updatePresence(
DiscordPresence(
details: 'Gleda na začetni zaslon',
startTimeStamp: DateTime.now().millisecondsSinceEpoch,
largeImageKey: 'palcka_logo',
largeImageText: 'Tarok Palčka',
),
);
}
DiscordRPC.initialize();

setPathUrlStrategy();

Expand Down Expand Up @@ -87,6 +75,19 @@ void main() async {
THEME = prefs.getString("theme") ?? "dark";
SOUNDS_ENABLED = prefs.getBool("sounds") ?? true;
DEVELOPER_MODE = prefs.getBool("developer_mode") ?? false;
DISCORD_RPC = prefs.getBool("discordRpc") ?? true;

if (!kIsWeb && (Platform.isLinux || Platform.isWindows) && DISCORD_RPC) {
rpc.start(autoRegister: true);
rpc.updatePresence(
DiscordPresence(
details: 'Gleda na začetni zaslon',
startTimeStamp: DateTime.now().millisecondsSinceEpoch,
largeImageKey: 'palcka_logo',
largeImageText: 'Tarok Palčka',
),
);
}

String? locale = prefs.getString("locale");
parseLocale(locale);
Expand Down
36 changes: 36 additions & 0 deletions tarok/lib/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import 'dart:io';

import 'package:dart_discord_rpc/dart_discord_rpc.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:settings_ui/settings_ui.dart';
Expand Down Expand Up @@ -123,6 +127,38 @@ class _SettingsState extends State<Settings> {
),
],
),
if (!kIsWeb && (Platform.isLinux || Platform.isWindows))
SettingsSection(
title: Text("other".tr),
tiles: [
SettingsTile.switchTile(
onToggle: (value) async {
final SharedPreferences prefs =
await SharedPreferences.getInstance();
await prefs.setBool("discordRpc", value);
DISCORD_RPC = prefs.getBool("discordRpc") ?? true;
if (DISCORD_RPC) {
rpc.start(autoRegister: true);
rpc.updatePresence(
DiscordPresence(
details: 'Spreminja nastavitve',
startTimeStamp: DateTime.now().millisecondsSinceEpoch,
largeImageKey: 'palcka_logo',
largeImageText: 'Tarok Palčka',
),
);
} else {
rpc.shutDown();
}
setState(() {});
},
initialValue: DISCORD_RPC,
leading: const Icon(Icons.discord),
title: Text("discord_rpc".tr),
description: Text("enable_discord_rpc".tr),
),
],
),
SettingsSection(
title: Text("modifications".tr),
tiles: [
Expand Down

0 comments on commit ccd47dd

Please sign in to comment.