mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 11:12:23 +01:00
<feat: New project structure>
<feat: New release>
This commit is contained in:
131
gui/lib/src/page/authenticator_page.dart
Normal file
131
gui/lib/src/page/authenticator_page.dart
Normal file
@@ -0,0 +1,131 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide showDialog;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/authenticator_controller.dart';
|
||||
import 'package:reboot_launcher/src/widget/server/start_button.dart';
|
||||
import 'package:reboot_launcher/src/widget/server/type_selector.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
|
||||
|
||||
import 'package:reboot_launcher/src/dialog/dialog.dart';
|
||||
import 'package:reboot_launcher/src/dialog/dialog_button.dart';
|
||||
|
||||
class AuthenticatorPage extends StatefulWidget {
|
||||
const AuthenticatorPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AuthenticatorPage> createState() => _AuthenticatorPageState();
|
||||
}
|
||||
|
||||
class _AuthenticatorPageState extends State<AuthenticatorPage> with AutomaticKeepAliveClientMixin {
|
||||
final AuthenticatorController _authenticatorController = Get.find<AuthenticatorController>();
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Obx(() => Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
SettingTile(
|
||||
title: "Authenticator configuration",
|
||||
subtitle: "This section contains the authenticator's configuration",
|
||||
content: const ServerTypeSelector(
|
||||
authenticator: true
|
||||
),
|
||||
expandedContent: [
|
||||
if(_authenticatorController.type.value == ServerType.remote)
|
||||
SettingTile(
|
||||
title: "Host",
|
||||
subtitle: "The hostname of the authenticator",
|
||||
isChild: true,
|
||||
content: TextFormBox(
|
||||
placeholder: "Host",
|
||||
controller: _authenticatorController.host,
|
||||
readOnly: !_isRemote
|
||||
)
|
||||
),
|
||||
if(_authenticatorController.type.value != ServerType.embedded)
|
||||
SettingTile(
|
||||
title: "Port",
|
||||
subtitle: "The port of the authenticator",
|
||||
isChild: true,
|
||||
content: TextFormBox(
|
||||
placeholder: "Port",
|
||||
controller: _authenticatorController.port,
|
||||
readOnly: !_isRemote
|
||||
)
|
||||
),
|
||||
if(_authenticatorController.type.value == ServerType.embedded)
|
||||
SettingTile(
|
||||
title: "Detached",
|
||||
subtitle: "Whether the embedded authenticator should be started as a separate process, useful for debugging",
|
||||
contentWidth: null,
|
||||
isChild: true,
|
||||
content: Obx(() => ToggleSwitch(
|
||||
checked: _authenticatorController.detached(),
|
||||
onChanged: (value) => _authenticatorController.detached.value = value
|
||||
))
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: "Installation directory",
|
||||
subtitle: "Opens the folder where the embedded authenticator is located",
|
||||
content: Button(
|
||||
onPressed: () => launchUrl(authenticatorDirectory.uri),
|
||||
child: const Text("Show Files")
|
||||
)
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: "Reset authenticator",
|
||||
subtitle: "Resets the authenticator's settings to their default values",
|
||||
content: Button(
|
||||
onPressed: () => showDialog(
|
||||
builder: (context) => InfoDialog(
|
||||
text: "Do you want to reset all the setting in this tab to their default values? This action is irreversible",
|
||||
buttons: [
|
||||
DialogButton(
|
||||
type: ButtonType.secondary,
|
||||
text: "Close",
|
||||
),
|
||||
DialogButton(
|
||||
type: ButtonType.primary,
|
||||
text: "Reset",
|
||||
onTap: () {
|
||||
_authenticatorController.reset();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
child: const Text("Reset"),
|
||||
)
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
const ServerButton(
|
||||
authenticator: true
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
bool get _isRemote => _authenticatorController.type.value == ServerType.remote;
|
||||
}
|
||||
265
gui/lib/src/page/browse_page.dart
Normal file
265
gui/lib/src/page/browse_page.dart
Normal file
@@ -0,0 +1,265 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
|
||||
import 'package:reboot_launcher/src/controller/game_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
|
||||
import 'package:reboot_launcher/src/interactive/server.dart';
|
||||
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
|
||||
import 'package:skeletons/skeletons.dart';
|
||||
|
||||
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
|
||||
|
||||
class BrowsePage extends StatefulWidget {
|
||||
const BrowsePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<BrowsePage> createState() => _BrowsePageState();
|
||||
}
|
||||
|
||||
class _BrowsePageState extends State<BrowsePage> with AutomaticKeepAliveClientMixin {
|
||||
final GameController _gameController = Get.find<GameController>();
|
||||
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
|
||||
final TextEditingController _filterController = TextEditingController();
|
||||
final StreamController<String> _filterControllerStream = StreamController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return FutureBuilder(
|
||||
future: Future.delayed(const Duration(seconds: 1)), // Fake delay to show loading
|
||||
builder: (context, futureSnapshot) => Obx(() {
|
||||
var ready = futureSnapshot.connectionState == ConnectionState.done;
|
||||
var data = _gameController.servers.value;
|
||||
if(ready && data?.isEmpty == true) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"No servers are available right now",
|
||||
style: FluentTheme.of(context).typography.titleLarge,
|
||||
),
|
||||
Text(
|
||||
"Host a server yourself or come back later",
|
||||
style: FluentTheme.of(context).typography.body
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
_buildSearchBar(ready),
|
||||
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: StreamBuilder<String?>(
|
||||
stream: _filterControllerStream.stream,
|
||||
builder: (context, filterSnapshot) {
|
||||
var items = _getItems(data, filterSnapshot.data, ready);
|
||||
var itemsCount = items != null ? items.length * 2 : null;
|
||||
if(itemsCount == 0) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"No results found",
|
||||
style: FluentTheme.of(context).typography.titleLarge,
|
||||
),
|
||||
Text(
|
||||
"No server matches your query",
|
||||
style: FluentTheme.of(context).typography.body
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: itemsCount,
|
||||
itemBuilder: (context, index) {
|
||||
if(index % 2 != 0) {
|
||||
return const SizedBox(
|
||||
height: 8.0
|
||||
);
|
||||
}
|
||||
|
||||
var entry = _getItem(index ~/ 2, items);
|
||||
if(!ready || entry == null) {
|
||||
return const SettingTile(
|
||||
content: SkeletonAvatar(
|
||||
style: SkeletonAvatarStyle(
|
||||
height: 32,
|
||||
width: 64
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
var hasPassword = entry["password"] != null;
|
||||
return SettingTile(
|
||||
title: "${_formatName(entry)} • ${entry["author"]}",
|
||||
subtitle: "${_formatDescription(entry)} • ${_formatVersion(entry)}",
|
||||
content: Button(
|
||||
onPressed: () => _matchmakerController.joinServer(entry),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if(hasPassword)
|
||||
const Icon(FluentIcons.lock),
|
||||
if(hasPassword)
|
||||
const SizedBox(width: 8.0),
|
||||
Text(_matchmakerController.type.value == ServerType.embedded ? "Join Server" : "Copy IP"),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Set<Map<String, dynamic>>? _getItems(Set<Map<String, dynamic>>? data, String? filter, bool ready) {
|
||||
if (!ready) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return data.where((entry) => _isValidItem(entry, filter)).toSet();
|
||||
}
|
||||
|
||||
bool _isValidItem(Map<String, dynamic> entry, String? filter) =>
|
||||
(entry["discoverable"] ?? false) && (filter == null || _filterServer(entry, filter));
|
||||
|
||||
bool _filterServer(Map<String, dynamic> element, String filter) {
|
||||
String? id = element["id"];
|
||||
if(id?.toLowerCase().contains(filter) == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var uri = Uri.tryParse(filter);
|
||||
if(uri != null && id?.toLowerCase().contains(uri.host.toLowerCase()) == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String? name = element["name"];
|
||||
if(name?.toLowerCase().contains(filter) == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String? author = element["author"];
|
||||
if(author?.toLowerCase().contains(filter) == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String? description = element["description"];
|
||||
if(description?.toLowerCase().contains(filter) == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Widget _buildSearchBar(bool ready) {
|
||||
if(ready) {
|
||||
return TextBox(
|
||||
placeholder: 'Find a server',
|
||||
controller: _filterController,
|
||||
onChanged: (value) => _filterControllerStream.add(value),
|
||||
suffix: _searchBarIcon,
|
||||
);
|
||||
}
|
||||
|
||||
return const SkeletonLine(
|
||||
style: SkeletonLineStyle(
|
||||
height: 32
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Widget get _searchBarIcon => Button(
|
||||
onPressed: _filterController.text.isEmpty ? null : () {
|
||||
_filterController.clear();
|
||||
_filterControllerStream.add("");
|
||||
},
|
||||
style: ButtonStyle(
|
||||
backgroundColor: _filterController.text.isNotEmpty ? null : ButtonState.all(Colors.transparent),
|
||||
border: _filterController.text.isNotEmpty ? null : ButtonState.all(const BorderSide(color: Colors.transparent))
|
||||
),
|
||||
child: _searchBarIconData
|
||||
);
|
||||
|
||||
Widget get _searchBarIconData {
|
||||
var color = FluentTheme.of(context).resources.textFillColorPrimary;
|
||||
if (_filterController.text.isNotEmpty) {
|
||||
return Icon(
|
||||
FluentIcons.clear,
|
||||
size: 8.0,
|
||||
color: color
|
||||
);
|
||||
}
|
||||
|
||||
return Transform.flip(
|
||||
flipX: true,
|
||||
child: Icon(
|
||||
FluentIcons.search,
|
||||
size: 12.0,
|
||||
color: color
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic>? _getItem(int index, Set? data) {
|
||||
if(data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (index >= data.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return data.elementAt(index);
|
||||
}
|
||||
|
||||
String _formatName(Map<String, dynamic> entry) {
|
||||
String result = entry['name'];
|
||||
return result.isEmpty ? kDefaultServerName : result;
|
||||
}
|
||||
|
||||
String _formatDescription(Map<String, dynamic> entry) {
|
||||
String result = entry['description'];
|
||||
return result.isEmpty ? kDefaultDescription : result;
|
||||
}
|
||||
|
||||
String _formatVersion(Map<String, dynamic> entry) {
|
||||
var version = entry['version'];
|
||||
var versionSplit = version.indexOf("-");
|
||||
var minimalVersion = version = versionSplit != -1 ? version.substring(0, versionSplit) : version;
|
||||
String result = minimalVersion.endsWith(".0") ? minimalVersion.substring(0, minimalVersion.length - 2) : minimalVersion;
|
||||
if(result.toLowerCase().startsWith("fortnite ")) {
|
||||
result = result.substring(0, 10);
|
||||
}
|
||||
|
||||
return "Fortnite $result";
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
253
gui/lib/src/page/home_page.dart
Normal file
253
gui/lib/src/page/home_page.dart
Normal file
@@ -0,0 +1,253 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide showDialog;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_launcher/src/page/browse_page.dart';
|
||||
import 'package:reboot_launcher/src/page/authenticator_page.dart';
|
||||
import 'package:reboot_launcher/src/page/matchmaker_page.dart';
|
||||
import 'package:reboot_launcher/src/page/play_page.dart';
|
||||
import 'package:reboot_launcher/src/page/settings_page.dart';
|
||||
import 'package:reboot_launcher/src/util/os.dart';
|
||||
import 'package:reboot_launcher/src/widget/home/pane.dart';
|
||||
import 'package:reboot_launcher/src/widget/home/profile.dart';
|
||||
|
||||
import 'package:reboot_launcher/src/controller/settings_controller.dart';
|
||||
import 'package:reboot_launcher/src/widget/os/border.dart';
|
||||
import 'package:reboot_launcher/src/widget/os/title_bar.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'hosting_page.dart';
|
||||
import 'info_page.dart';
|
||||
|
||||
const int pagesLength = 7;
|
||||
final RxInt pageIndex = RxInt(0);
|
||||
final Queue<int> _pagesStack = Queue();
|
||||
final List<GlobalKey> _pageKeys = List.generate(pagesLength, (index) => GlobalKey());
|
||||
GlobalKey get pageKey => _pageKeys[pageIndex.value];
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepAliveClientMixin {
|
||||
static const double _kDefaultPadding = 12.0;
|
||||
|
||||
final SettingsController _settingsController = Get.find<SettingsController>();
|
||||
final GlobalKey _searchKey = GlobalKey();
|
||||
final FocusNode _searchFocusNode = FocusNode();
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
final RxBool _focused = RxBool(true);
|
||||
final RxBool _fullScreen = RxBool(false);
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
windowManager.show();
|
||||
windowManager.addListener(this);
|
||||
_searchController.addListener(_onSearch);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void _onSearch() {
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
windowManager.removeListener(this);
|
||||
_searchFocusNode.dispose();
|
||||
_searchController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowEnterFullScreen() {
|
||||
_fullScreen.value = true;
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowLeaveFullScreen() {
|
||||
_fullScreen.value = false;
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowFocus() {
|
||||
_focused.value = true;
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowBlur() {
|
||||
_focused.value = false;
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowResized() {
|
||||
_settingsController.saveWindowSize();
|
||||
super.onWindowResized();
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowMoved() {
|
||||
windowManager.getPosition()
|
||||
.then((value) => _settingsController.saveWindowOffset(value));
|
||||
super.onWindowMoved();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Stack(
|
||||
children: [
|
||||
Obx(() => NavigationPaneTheme(
|
||||
data: NavigationPaneThemeData(
|
||||
backgroundColor: FluentTheme.of(context).micaBackgroundColor.withOpacity(0.9),
|
||||
),
|
||||
child: NavigationView(
|
||||
paneBodyBuilder: (pane, body) => Padding(
|
||||
padding: const EdgeInsets.all(_kDefaultPadding),
|
||||
child: SizedBox(
|
||||
key: pageKey,
|
||||
child: body
|
||||
)
|
||||
),
|
||||
appBar: NavigationAppBar(
|
||||
height: 32,
|
||||
title: _draggableArea,
|
||||
actions: WindowTitleBar(focused: _focused()),
|
||||
leading: _backButton,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
pane: NavigationPane(
|
||||
selected: pageIndex.value,
|
||||
onChanged: (index) {
|
||||
_pagesStack.add(pageIndex.value);
|
||||
pageIndex.value = index;
|
||||
},
|
||||
menuButton: const SizedBox(),
|
||||
displayMode: PaneDisplayMode.open,
|
||||
items: _items,
|
||||
header: const ProfileWidget(),
|
||||
autoSuggestBox: _autoSuggestBox,
|
||||
autoSuggestBoxReplacement: const Icon(FluentIcons.search),
|
||||
),
|
||||
contentShape: const RoundedRectangleBorder(),
|
||||
onOpenSearch: () => _searchFocusNode.requestFocus(),
|
||||
transitionBuilder: (child, animation) => child
|
||||
)
|
||||
)),
|
||||
if (isWin11)
|
||||
Obx(() => !_fullScreen.value && _focused.value ? const WindowBorder() : const SizedBox())
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Widget get _backButton => Obx(() {
|
||||
pageIndex.value;
|
||||
return Button(
|
||||
style: ButtonStyle(
|
||||
padding: ButtonState.all(const EdgeInsets.only(top: 6.0)),
|
||||
backgroundColor: ButtonState.all(Colors.transparent),
|
||||
border: ButtonState.all(const BorderSide(color: Colors.transparent))
|
||||
),
|
||||
onPressed: _pagesStack.isEmpty ? null : () => pageIndex.value = _pagesStack.removeLast(),
|
||||
child: const Icon(FluentIcons.back, size: 12.0),
|
||||
);
|
||||
});
|
||||
|
||||
GestureDetector get _draggableArea => GestureDetector(
|
||||
onDoubleTap: () async => await windowManager.isMaximized() ? await windowManager.restore() : await windowManager.maximize(),
|
||||
onHorizontalDragStart: (event) => windowManager.startDragging(),
|
||||
onVerticalDragStart: (event) => windowManager.startDragging()
|
||||
);
|
||||
|
||||
Widget get _autoSuggestBox => Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: TextBox(
|
||||
key: _searchKey,
|
||||
controller: _searchController,
|
||||
placeholder: 'Find a setting',
|
||||
focusNode: _searchFocusNode,
|
||||
autofocus: true,
|
||||
suffix: Button(
|
||||
onPressed: null,
|
||||
style: ButtonStyle(
|
||||
backgroundColor: ButtonState.all(Colors.transparent),
|
||||
border: ButtonState.all(const BorderSide(color: Colors.transparent))
|
||||
),
|
||||
child: Transform.flip(
|
||||
flipX: true,
|
||||
child: Icon(
|
||||
FluentIcons.search,
|
||||
size: 12.0,
|
||||
color: FluentTheme.of(context).resources.textFillColorPrimary
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
List<NavigationPaneItem> get _items => [
|
||||
RebootPaneItem(
|
||||
title: const Text("Play"),
|
||||
icon: SizedBox.square(
|
||||
dimension: 24,
|
||||
child: Image.asset("assets/images/play.png")
|
||||
),
|
||||
body: const PlayPage()
|
||||
),
|
||||
RebootPaneItem(
|
||||
title: const Text("Host"),
|
||||
icon: SizedBox.square(
|
||||
dimension: 24,
|
||||
child: Image.asset("assets/images/host.png")
|
||||
),
|
||||
body: const HostingPage()
|
||||
),
|
||||
RebootPaneItem(
|
||||
title: const Text("Server Browser"),
|
||||
icon: SizedBox.square(
|
||||
dimension: 24,
|
||||
child: Image.asset("assets/images/browse.png")
|
||||
),
|
||||
body: const BrowsePage()
|
||||
),
|
||||
RebootPaneItem(
|
||||
title: const Text("Authenticator"),
|
||||
icon: SizedBox.square(
|
||||
dimension: 24,
|
||||
child: Image.asset("assets/images/auth.png")
|
||||
),
|
||||
body: const AuthenticatorPage()
|
||||
),
|
||||
RebootPaneItem(
|
||||
title: const Text("Matchmaker"),
|
||||
icon: SizedBox.square(
|
||||
dimension: 24,
|
||||
child: Image.asset("assets/images/matchmaker.png")
|
||||
),
|
||||
body: const MatchmakerPage()
|
||||
),
|
||||
RebootPaneItem(
|
||||
title: const Text("Info"),
|
||||
icon: SizedBox.square(
|
||||
dimension: 24,
|
||||
child: Image.asset("assets/images/info.png")
|
||||
),
|
||||
body: const InfoPage()
|
||||
),
|
||||
RebootPaneItem(
|
||||
title: const Text("Settings"),
|
||||
icon: SizedBox.square(
|
||||
dimension: 24,
|
||||
child: Image.asset("assets/images/settings.png")
|
||||
),
|
||||
body: const SettingsPage()
|
||||
),
|
||||
];
|
||||
|
||||
String get searchValue => _searchController.text;
|
||||
}
|
||||
215
gui/lib/src/page/hosting_page.dart
Normal file
215
gui/lib/src/page/hosting_page.dart
Normal file
@@ -0,0 +1,215 @@
|
||||
import 'package:clipboard/clipboard.dart';
|
||||
import 'package:dart_ipify/dart_ipify.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide showDialog;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_launcher/main.dart';
|
||||
import 'package:reboot_launcher/src/controller/game_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/update_controller.dart';
|
||||
import 'package:reboot_launcher/src/dialog/message.dart';
|
||||
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
|
||||
import 'package:flutter/material.dart' show Icons;
|
||||
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/widget/game/start_button.dart';
|
||||
import 'package:reboot_launcher/src/widget/version/version_selector.dart';
|
||||
|
||||
class HostingPage extends StatefulWidget {
|
||||
const HostingPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<HostingPage> createState() => _HostingPageState();
|
||||
}
|
||||
|
||||
class _HostingPageState extends State<HostingPage> with AutomaticKeepAliveClientMixin {
|
||||
final GameController _gameController = Get.find<GameController>();
|
||||
final HostingController _hostingController = Get.find<HostingController>();
|
||||
final UpdateController _updateController = Get.find<UpdateController>();
|
||||
late final RxBool _showPasswordTrailing = RxBool(_hostingController.password.text.isNotEmpty);
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
Obx(() => Column(
|
||||
children: _updateController.status.value != UpdateStatus.error ? [] : [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: _updateError
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0
|
||||
),
|
||||
],
|
||||
)),
|
||||
SettingTile(
|
||||
title: "Game Server",
|
||||
subtitle: "Provide basic information about your server",
|
||||
expandedContent: [
|
||||
SettingTile(
|
||||
title: "Name",
|
||||
subtitle: "The name of your game server",
|
||||
isChild: true,
|
||||
content: TextFormBox(
|
||||
placeholder: "Name",
|
||||
controller: _hostingController.name
|
||||
)
|
||||
),
|
||||
SettingTile(
|
||||
title: "Description",
|
||||
subtitle: "The description of your game server",
|
||||
isChild: true,
|
||||
content: TextFormBox(
|
||||
placeholder: "Description",
|
||||
controller: _hostingController.description
|
||||
)
|
||||
),
|
||||
SettingTile(
|
||||
title: "Password",
|
||||
subtitle: "The password of your game server for the server browser",
|
||||
isChild: true,
|
||||
content: Obx(() => TextFormBox(
|
||||
placeholder: "Password",
|
||||
controller: _hostingController.password,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
obscureText: !_hostingController.showPassword.value,
|
||||
enableSuggestions: false,
|
||||
autocorrect: false,
|
||||
onChanged: (text) => _showPasswordTrailing.value = text.isNotEmpty,
|
||||
suffix: Button(
|
||||
onPressed: () => _hostingController.showPassword.value = !_hostingController.showPassword.value,
|
||||
style: ButtonStyle(
|
||||
shape: ButtonState.all(const CircleBorder()),
|
||||
backgroundColor: ButtonState.all(Colors.transparent)
|
||||
),
|
||||
child: Icon(
|
||||
_hostingController.showPassword.value ? Icons.visibility_off : Icons.visibility,
|
||||
color: _showPasswordTrailing.value ? null : Colors.transparent
|
||||
),
|
||||
)
|
||||
))
|
||||
),
|
||||
SettingTile(
|
||||
title: "Discoverable",
|
||||
subtitle: "Make your server available to other players on the server browser",
|
||||
isChild: true,
|
||||
contentWidth: null,
|
||||
content: Obx(() => ToggleSwitch(
|
||||
checked: _hostingController.discoverable(),
|
||||
onChanged: (value) => _hostingController.discoverable.value = value
|
||||
))
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
const SettingTile(
|
||||
title: "Version",
|
||||
subtitle: "Select the version of Fortnite you want to host",
|
||||
content: VersionSelector(),
|
||||
expandedContent: [
|
||||
SettingTile(
|
||||
title: "Add a version from this PC's local storage",
|
||||
subtitle: "Versions coming from your local disk are not guaranteed to work",
|
||||
content: Button(
|
||||
onPressed: VersionSelector.openAddDialog,
|
||||
child: Text("Add build"),
|
||||
),
|
||||
isChild: true
|
||||
),
|
||||
SettingTile(
|
||||
title: "Download any version from the cloud",
|
||||
subtitle: "Download any Fortnite build easily from the cloud",
|
||||
content: Button(
|
||||
onPressed: VersionSelector.openDownloadDialog,
|
||||
child: Text("Download"),
|
||||
),
|
||||
isChild: true
|
||||
)
|
||||
]
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0
|
||||
),
|
||||
SettingTile(
|
||||
title: "Share",
|
||||
subtitle: "Make it easy for other people to join your server with the options in this section",
|
||||
expandedContent: [
|
||||
SettingTile(
|
||||
title: "Link",
|
||||
subtitle: "Copies a link for your server to the clipboard (requires the Reboot Launcher)",
|
||||
isChild: true,
|
||||
content: Button(
|
||||
onPressed: () async {
|
||||
FlutterClipboard.controlC("$kCustomUrlSchema://${_gameController.uuid}");
|
||||
showMessage(
|
||||
"Copied your link to the clipboard",
|
||||
severity: InfoBarSeverity.success
|
||||
);
|
||||
},
|
||||
child: const Text("Copy Link"),
|
||||
)
|
||||
),
|
||||
SettingTile(
|
||||
title: "Public IP",
|
||||
subtitle: "Copies your current public IP to the clipboard (doesn't require the Reboot Launcher)",
|
||||
isChild: true,
|
||||
content: Button(
|
||||
onPressed: () async {
|
||||
try {
|
||||
showMessage(
|
||||
"Obtaining your public IP...",
|
||||
loading: true,
|
||||
duration: null
|
||||
);
|
||||
var ip = await Ipify.ipv4();
|
||||
FlutterClipboard.controlC(ip);
|
||||
showMessage(
|
||||
"Copied your IP to the clipboard",
|
||||
severity: InfoBarSeverity.success
|
||||
);
|
||||
}catch(error) {
|
||||
showMessage(
|
||||
"An error occurred while obtaining your public IP: $error",
|
||||
severity: InfoBarSeverity.error,
|
||||
duration: snackbarLongDuration
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text("Copy IP"),
|
||||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
const LaunchButton(
|
||||
host: true
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget get _updateError => MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
onTap: _updateController.update,
|
||||
child: const InfoBar(
|
||||
title: Text("The reboot dll couldn't be downloaded: click here to try again"),
|
||||
severity: InfoBarSeverity.info
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
133
gui/lib/src/page/info_page.dart
Normal file
133
gui/lib/src/page/info_page.dart
Normal file
@@ -0,0 +1,133 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide showDialog;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
|
||||
|
||||
import 'package:reboot_launcher/src/controller/settings_controller.dart';
|
||||
|
||||
class InfoPage extends StatefulWidget {
|
||||
const InfoPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<InfoPage> createState() => _InfoPageState();
|
||||
}
|
||||
|
||||
class _InfoPageState extends State<InfoPage> with AutomaticKeepAliveClientMixin {
|
||||
final SettingsController _settingsController = Get.find<SettingsController>();
|
||||
late final ScrollController _controller;
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = ScrollController(initialScrollOffset: _settingsController.scrollingDistance);
|
||||
_controller.addListener(() {
|
||||
_settingsController.scrollingDistance = _controller.offset;
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
SettingTile(
|
||||
title: 'What is Project Reboot?',
|
||||
subtitle: 'Project Reboot allows anyone to easily host a game server for most of Fortnite\'s seasons. '
|
||||
'The project was started on Discord by Milxnor. '
|
||||
'The project is no longer being actively maintained.',
|
||||
titleStyle: FluentTheme
|
||||
.of(context)
|
||||
.typography
|
||||
.title,
|
||||
contentWidth: null,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: 'What is a game server?',
|
||||
subtitle: 'When you join a Fortnite Game, your client connects to a game server that allows you to play with others. '
|
||||
'You can join someone else\'s game server, or host one on your PC by going to the "Host" tab. ',
|
||||
titleStyle: FluentTheme
|
||||
.of(context)
|
||||
.typography
|
||||
.title,
|
||||
contentWidth: null,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: 'What is a client?',
|
||||
subtitle: 'A client is the actual Fortnite game. '
|
||||
'You can download any version of Fortnite from the launcher in the "Play" tab. '
|
||||
'You can also import versions from your local PC, but remember that these may be corrupted. '
|
||||
'If a local version doesn\'t work, try installing it from the launcher before reporting a bug.',
|
||||
titleStyle: FluentTheme
|
||||
.of(context)
|
||||
.typography
|
||||
.title,
|
||||
contentWidth: null,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: 'What is an authenticator?',
|
||||
subtitle: 'An authenticator is a program that handles authentication, parties and voice chats. '
|
||||
'By default, a LawinV1 server will be started for you to play. '
|
||||
'You can use also use an authenticator running locally(on your PC) or remotely(on another PC). '
|
||||
'Changing the authenticator settings can break the client and game server: unless you are an advanced user, do not edit, for any reason, these settings! '
|
||||
'If you need to restore these settings, go to the "Settings" tab and click on "Restore Defaults". ',
|
||||
titleStyle: FluentTheme
|
||||
.of(context)
|
||||
.typography
|
||||
.title,
|
||||
contentWidth: null,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: 'Do I need to update DLLs?',
|
||||
subtitle: 'No, all the files that the launcher uses are automatically updated. '
|
||||
'You can use your own DLLs by going to the "Settings" tab, but make sure that they don\'t create a console that reads IO or the launcher will stop working correctly. '
|
||||
'Unless you are an advanced user, changing these options is not recommended',
|
||||
titleStyle: FluentTheme
|
||||
.of(context)
|
||||
.typography
|
||||
.title,
|
||||
contentWidth: null,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: 'Where can I report bugs or ask for new features?',
|
||||
subtitle: 'Go to the "Settings" tab and click on report bug. '
|
||||
'Please make sure to be as specific as possible when filing a report as it\'s crucial to make it as easy to fix/implement',
|
||||
titleStyle: FluentTheme
|
||||
.of(context)
|
||||
.typography
|
||||
.title,
|
||||
contentWidth: null,
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
139
gui/lib/src/page/matchmaker_page.dart
Normal file
139
gui/lib/src/page/matchmaker_page.dart
Normal file
@@ -0,0 +1,139 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide showDialog;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
|
||||
import 'package:reboot_launcher/src/widget/server/type_selector.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
|
||||
|
||||
import 'package:reboot_launcher/src/dialog/dialog.dart';
|
||||
import 'package:reboot_launcher/src/dialog/dialog_button.dart';
|
||||
import 'package:reboot_launcher/src/widget/server/start_button.dart';
|
||||
|
||||
class MatchmakerPage extends StatefulWidget {
|
||||
const MatchmakerPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MatchmakerPage> createState() => _MatchmakerPageState();
|
||||
}
|
||||
|
||||
class _MatchmakerPageState extends State<MatchmakerPage> with AutomaticKeepAliveClientMixin {
|
||||
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
Obx(() => SettingTile(
|
||||
title: "Matchmaker configuration",
|
||||
subtitle: "This section contains the matchmaker's configuration",
|
||||
content: const ServerTypeSelector(
|
||||
authenticator: false
|
||||
),
|
||||
expandedContent: [
|
||||
if(_matchmakerController.type.value == ServerType.remote)
|
||||
SettingTile(
|
||||
title: "Host",
|
||||
subtitle: "The hostname of the matchmaker",
|
||||
isChild: true,
|
||||
content: TextFormBox(
|
||||
placeholder: "Host",
|
||||
controller: _matchmakerController.host,
|
||||
readOnly: _matchmakerController.type.value != ServerType.remote
|
||||
)
|
||||
),
|
||||
if(_matchmakerController.type.value != ServerType.embedded)
|
||||
SettingTile(
|
||||
title: "Port",
|
||||
subtitle: "The port of the matchmaker",
|
||||
isChild: true,
|
||||
content: TextFormBox(
|
||||
placeholder: "Port",
|
||||
controller: _matchmakerController.port,
|
||||
readOnly: _matchmakerController.type.value != ServerType.remote
|
||||
)
|
||||
),
|
||||
if(_matchmakerController.type.value == ServerType.embedded)
|
||||
SettingTile(
|
||||
title: "Game server address",
|
||||
subtitle: "The address of the game server used by the matchmaker",
|
||||
isChild: true,
|
||||
content: TextFormBox(
|
||||
placeholder: "Address",
|
||||
controller: _matchmakerController.gameServerAddress
|
||||
)
|
||||
),
|
||||
if(_matchmakerController.type.value == ServerType.embedded)
|
||||
SettingTile(
|
||||
title: "Detached",
|
||||
subtitle: "Whether the embedded matchmaker should be started as a separate process, useful for debugging",
|
||||
contentWidth: null,
|
||||
isChild: true,
|
||||
content: Obx(() => ToggleSwitch(
|
||||
checked: _matchmakerController.detached.value,
|
||||
onChanged: (value) => _matchmakerController.detached.value = value
|
||||
)),
|
||||
)
|
||||
]
|
||||
)),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: "Installation directory",
|
||||
subtitle: "Opens the folder where the embedded matchmaker is located",
|
||||
content: Button(
|
||||
onPressed: () => launchUrl(authenticatorDirectory.uri),
|
||||
child: const Text("Show Files")
|
||||
)
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: "Reset matchmaker",
|
||||
subtitle: "Resets the authenticator's settings to their default values",
|
||||
content: Button(
|
||||
onPressed: () => showDialog(
|
||||
builder: (context) => InfoDialog(
|
||||
text: "Do you want to reset all the setting in this tab to their default values? This action is irreversible",
|
||||
buttons: [
|
||||
DialogButton(
|
||||
type: ButtonType.secondary,
|
||||
text: "Close",
|
||||
),
|
||||
DialogButton(
|
||||
type: ButtonType.primary,
|
||||
text: "Reset",
|
||||
onTap: () {
|
||||
_matchmakerController.reset();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
child: const Text("Reset"),
|
||||
)
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
const ServerButton(
|
||||
authenticator: false
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
109
gui/lib/src/page/play_page.dart
Normal file
109
gui/lib/src/page/play_page.dart
Normal file
@@ -0,0 +1,109 @@
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide showDialog;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
|
||||
import 'package:reboot_launcher/src/page/home_page.dart';
|
||||
import 'package:reboot_launcher/src/widget/game/start_button.dart';
|
||||
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
|
||||
import 'package:reboot_launcher/src/widget/version/version_selector.dart';
|
||||
|
||||
|
||||
class PlayPage extends StatefulWidget {
|
||||
const PlayPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<PlayPage> createState() => _PlayPageState();
|
||||
}
|
||||
|
||||
class _PlayPageState extends State<PlayPage> {
|
||||
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
|
||||
final HostingController _hostingController = Get.find<HostingController>();
|
||||
late final RxBool _selfServer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_selfServer = RxBool(_isLocalPlay);
|
||||
_matchmakerController.gameServerAddress.addListener(() => _selfServer.value = _isLocalPlay);
|
||||
_hostingController.started.listen((_) => _selfServer.value = _isLocalPlay);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
bool get _isLocalPlay => isLocalHost(_matchmakerController.gameServerAddress.text)
|
||||
&& !_hostingController.started.value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
const SettingTile(
|
||||
title: "Version",
|
||||
subtitle: "Select the version of Fortnite you want to host",
|
||||
content: VersionSelector(),
|
||||
expandedContent: [
|
||||
SettingTile(
|
||||
title: "Add a version from this PC's local storage",
|
||||
subtitle: "Versions coming from your local disk are not guaranteed to work",
|
||||
content: Button(
|
||||
onPressed: VersionSelector.openAddDialog,
|
||||
child: Text("Add build"),
|
||||
),
|
||||
isChild: true
|
||||
),
|
||||
SettingTile(
|
||||
title: "Download any version from the cloud",
|
||||
subtitle: "Download any Fortnite build easily from the cloud",
|
||||
content: Button(
|
||||
onPressed: VersionSelector.openDownloadDialog,
|
||||
child: Text("Download"),
|
||||
),
|
||||
isChild: true
|
||||
)
|
||||
]
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: "Game Server",
|
||||
subtitle: "Helpful shortcuts to find the server where you want to play",
|
||||
expandedContent: [
|
||||
SettingTile(
|
||||
title: "Host a server",
|
||||
subtitle: "Do you want to play with your friends? Host a server for them!",
|
||||
content: Button(
|
||||
onPressed: () => pageIndex.value = 1,
|
||||
child: const Text("Host")
|
||||
),
|
||||
isChild: true
|
||||
),
|
||||
SettingTile(
|
||||
title: "Join a server",
|
||||
subtitle: "Find a server where you can play on the launcher's server browser",
|
||||
content: Button(
|
||||
onPressed: () => pageIndex.value = 2,
|
||||
child: const Text("Browse")
|
||||
),
|
||||
isChild: true
|
||||
)
|
||||
]
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
const LaunchButton(
|
||||
startLabel: 'Launch Fortnite',
|
||||
stopLabel: 'Close Fortnite',
|
||||
host: false
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
182
gui/lib/src/page/settings_page.dart
Normal file
182
gui/lib/src/page/settings_page.dart
Normal file
@@ -0,0 +1,182 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide showDialog;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/build_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/game_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/authenticator_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/settings_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/update_controller.dart';
|
||||
import 'package:reboot_launcher/src/dialog/dialog_button.dart';
|
||||
import 'package:reboot_launcher/src/widget/common/file_selector.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:reboot_launcher/src/util/checks.dart';
|
||||
import 'package:reboot_launcher/src/dialog/dialog.dart';
|
||||
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
|
||||
|
||||
class SettingsPage extends StatefulWidget {
|
||||
const SettingsPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SettingsPage> createState() => _SettingsPageState();
|
||||
}
|
||||
|
||||
class _SettingsPageState extends State<SettingsPage> with AutomaticKeepAliveClientMixin {
|
||||
final BuildController _buildController = Get.find<BuildController>();
|
||||
final GameController _gameController = Get.find<GameController>();
|
||||
final HostingController _hostingController = Get.find<HostingController>();
|
||||
final AuthenticatorController _authenticatorController = Get.find<AuthenticatorController>();
|
||||
final SettingsController _settingsController = Get.find<SettingsController>();
|
||||
final UpdateController _updateController = Get.find<UpdateController>();
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return ListView(
|
||||
children: [
|
||||
SettingTile(
|
||||
title: "Client settings",
|
||||
subtitle: "This section contains the dlls used to make the Fortnite client work",
|
||||
expandedContent: [
|
||||
_createFileSetting(
|
||||
title: "Unreal engine console",
|
||||
description: "This file is injected to unlock the Unreal Engine Console",
|
||||
controller: _settingsController.consoleDll
|
||||
),
|
||||
_createFileSetting(
|
||||
title: "Authentication patcher",
|
||||
description: "This file is injected to redirect all HTTP requests to the launcher's authenticator",
|
||||
controller: _settingsController.authDll
|
||||
),
|
||||
SettingTile(
|
||||
title: "Custom launch arguments",
|
||||
subtitle: "Additional arguments to use when launching the game",
|
||||
isChild: true,
|
||||
content: TextFormBox(
|
||||
placeholder: "Arguments...",
|
||||
controller: _gameController.customLaunchArgs,
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: "Server settings",
|
||||
subtitle: "This section contains settings related to the game server implementation",
|
||||
expandedContent: [
|
||||
_createFileSetting(
|
||||
title: "Game server",
|
||||
description: "This file is injected to create a game server & host matches",
|
||||
controller: _settingsController.rebootDll
|
||||
),
|
||||
SettingTile(
|
||||
title: "Update mirror",
|
||||
subtitle: "The URL used to update the game server dll",
|
||||
content: TextFormBox(
|
||||
placeholder: "URL",
|
||||
controller: _updateController.url,
|
||||
validator: checkUpdateUrl
|
||||
),
|
||||
isChild: true
|
||||
),
|
||||
SettingTile(
|
||||
title: "Update timer",
|
||||
subtitle: "Determines when the game server dll should be updated",
|
||||
content: Obx(() => DropDownButton(
|
||||
leading: Text(_updateController.timer.value.text),
|
||||
items: UpdateTimer.values.map((entry) => MenuFlyoutItem(
|
||||
text: Text(entry.text),
|
||||
onPressed: () => _updateController.timer.value = entry
|
||||
)).toList()
|
||||
)),
|
||||
isChild: true
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
SettingTile(
|
||||
title: "Launcher utilities",
|
||||
subtitle: "This section contains handy settings for the launcher",
|
||||
expandedContent: [
|
||||
SettingTile(
|
||||
title: "Installation directory",
|
||||
subtitle: "Opens the installation directory",
|
||||
isChild: true,
|
||||
content: Button(
|
||||
onPressed: () => launchUrl(installationDirectory.uri),
|
||||
child: const Text("Show Files"),
|
||||
)
|
||||
),
|
||||
SettingTile(
|
||||
title: "Create a bug report",
|
||||
subtitle: "Help me fix bugs by reporting them",
|
||||
isChild: true,
|
||||
content: Button(
|
||||
onPressed: () => launchUrl(Uri.parse("https://github.com/Auties00/reboot_launcher/issues")),
|
||||
child: const Text("Report a bug"),
|
||||
)
|
||||
),
|
||||
SettingTile(
|
||||
title: "Reset settings",
|
||||
subtitle: "Resets the launcher's settings to their default values",
|
||||
isChild: true,
|
||||
content: Button(
|
||||
onPressed: () => showDialog(
|
||||
builder: (context) => InfoDialog(
|
||||
text: "Do you want to reset all the launcher's settings to their default values? This action is irreversible",
|
||||
buttons: [
|
||||
DialogButton(
|
||||
type: ButtonType.secondary,
|
||||
text: "Close",
|
||||
),
|
||||
DialogButton(
|
||||
type: ButtonType.primary,
|
||||
text: "Reset",
|
||||
onTap: () {
|
||||
_buildController.reset();
|
||||
_gameController.reset();
|
||||
_hostingController.reset();
|
||||
_authenticatorController.reset();
|
||||
_settingsController.reset();
|
||||
_updateController.reset();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
child: const Text("Reset"),
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Widget _createFileSetting({required String title, required String description, required TextEditingController controller}) => SettingTile(
|
||||
title: title,
|
||||
subtitle: description,
|
||||
content: FileSelector(
|
||||
placeholder: "Path",
|
||||
windowTitle: "Select a file",
|
||||
controller: controller,
|
||||
validator: checkDll,
|
||||
extension: "dll",
|
||||
folder: false
|
||||
),
|
||||
isChild: true
|
||||
);
|
||||
}
|
||||
|
||||
extension _UpdateTimerExtension on UpdateTimer {
|
||||
String get text => this == UpdateTimer.never ? "Never" : "Every $name";
|
||||
}
|
||||
Reference in New Issue
Block a user