Minor fixes

This commit is contained in:
Alessandro Autiero
2023-06-04 01:46:12 +02:00
parent 62611c29a4
commit 1d745f5187
3 changed files with 84 additions and 47 deletions

View File

@@ -23,6 +23,7 @@ class GameController extends GetxController {
late final Rx<List<FortniteVersion>> versions;
late final Rxn<FortniteVersion> _selectedVersion;
late final RxBool started;
late final RxBool autoStartGameServer;
GameInstance? instance;
GameController() {
@@ -47,6 +48,8 @@ class GameController extends GetxController {
customLaunchArgs = TextEditingController(text: _storage.read("custom_launch_args" ?? ""));
customLaunchArgs.addListener(() => _storage.write("custom_launch_args", customLaunchArgs.text));
started = RxBool(false);
autoStartGameServer = RxBool(_storage.read("auto_game_server") ?? true);
autoStartGameServer.listen((value) => _storage.write("auto_game_server", value));
}
FortniteVersion? getVersionByName(String name) {

View File

@@ -1,5 +1,7 @@
import 'dart:async';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart' show Icons;
import 'package:get/get.dart';
@@ -11,6 +13,7 @@ import 'package:reboot_launcher/src/ui/widget/home/version_selector.dart';
import 'package:reboot_launcher/src/ui/widget/shared/setting_tile.dart';
import '../../util/checks.dart';
import '../../util/os.dart';
class LauncherPage extends StatefulWidget {
final GlobalKey<NavigatorState> navigatorKey;
@@ -66,6 +69,13 @@ class _GamePageState extends State<_GamePage> {
final GameController _gameController = Get.find<GameController>();
final SettingsController _settingsController = Get.find<SettingsController>();
late final RxBool _showPasswordTrailing = RxBool(_gameController.password.text.isNotEmpty);
final StreamController _matchmakingStream = StreamController();
@override
void initState() {
_settingsController.matchmakingIp.addListener(() => _matchmakingStream.add(null));
super.initState();
}
@override
Widget build(BuildContext context) => Column(
@@ -118,6 +128,9 @@ class _GamePageState extends State<_GamePage> {
const SizedBox(
height: 16.0,
),
StreamBuilder(
stream: _matchmakingStream.stream,
builder: (context, value) =>
SettingTile(
title: "Matchmaking host",
subtitle: "Enter the IP address of the game server hosting the match",
@@ -127,7 +140,18 @@ class _GamePageState extends State<_GamePage> {
validator: checkMatchmaking,
autovalidateMode: AutovalidateMode.always
),
expandedContentSpacing: isLocalHost(_settingsController.matchmakingIp.text) ? SettingTile.kDefaultSpacing : 0,
expandedContent: [
!isLocalHost(_settingsController.matchmakingIp.text) ? const SizedBox() : SettingTile(
title: "Automatically start game server",
subtitle: "This option is available when the matchmaker is set to localhost",
contentWidth: null,
content: Obx(() => ToggleSwitch(
checked: _gameController.autoStartGameServer(),
onChanged: (value) => _gameController.autoStartGameServer.value = value
)),
isChild: true
),
SettingTile(
title: "Browse available servers",
subtitle: "Discover new game servers that fit your play-style",
@@ -141,6 +165,7 @@ class _GamePageState extends State<_GamePage> {
isChild: true
)
]
)
),
const SizedBox(
height: 16.0,

View File

@@ -178,6 +178,10 @@ class _LaunchButtonState extends State<LaunchButton> {
return false;
}
if(!_gameController.autoStartGameServer()){
return false;
}
var version = _gameController.selectedVersion!;
await _startGameProcesses(version, true, false);
return true;
@@ -198,7 +202,12 @@ class _LaunchButtonState extends State<LaunchButton> {
return kDefaultPlayerName;
}
var username = _gameController.username.text.replaceAll(RegExp("[^A-Za-z0-9]"), "").trim();
var username = _gameController.username.text;
if(_gameController.password.text.isNotEmpty){
return username;
}
username = _gameController.username.text.replaceAll(RegExp("[^A-Za-z0-9]"), "").trim();
if(username.isEmpty){
return kDefaultPlayerName;
}