Compare commits
No commits in common. "a11e4545415b798c036af13f77db37e3459fccd4" and "3bc9ecacdc1d950bc29df75eddf7fd854923f75e" have entirely different histories.
a11e454541
...
3bc9ecacdc
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:minecraft_server_installer/main/adapter/presentation/installation_state.dart';
|
import 'package:minecraft_server_installer/main/adapter/presentation/installation_state.dart';
|
||||||
import 'package:minecraft_server_installer/main/adapter/presentation/progress_view_model.dart';
|
import 'package:minecraft_server_installer/main/adapter/presentation/progress_view_model.dart';
|
||||||
@ -32,9 +34,8 @@ class InstallationBloc extends Bloc<InstallationEvent, InstallationState> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final startScriptFilePath = path.join(savePath, Constants.startScriptFileName);
|
final startScriptFilePath = path.join(savePath, Constants.startScriptFileName);
|
||||||
final serverFilePath = path.join('.', Constants.serverFileName);
|
|
||||||
final startScriptContent =
|
final startScriptContent =
|
||||||
'java -Xmx${state.ramSize.max}M -Xms${state.ramSize.min}M -jar $serverFilePath ${state.isGuiEnabled ? '' : 'nogui'}';
|
'java -Xmx${state.ramSize.max}M -Xms${state.ramSize.min}M -jar ${Platform.isWindows ? '.${Constants.serverFileName}\r\n' : './${Constants.serverFileName}\n'}';
|
||||||
await writeFileUseCase(startScriptFilePath, startScriptContent);
|
await writeFileUseCase(startScriptFilePath, startScriptContent);
|
||||||
await grantFilePermissionUseCase(startScriptFilePath);
|
await grantFilePermissionUseCase(startScriptFilePath);
|
||||||
|
|
||||||
@ -66,7 +67,6 @@ class InstallationBloc extends Bloc<InstallationEvent, InstallationState> {
|
|||||||
gameVersion: event.gameVersion,
|
gameVersion: event.gameVersion,
|
||||||
savePath: event.savePath,
|
savePath: event.savePath,
|
||||||
isEulaAgreed: event.isEulaAgreed,
|
isEulaAgreed: event.isEulaAgreed,
|
||||||
isGuiEnabled: event.isGuiEnabled,
|
|
||||||
isCustomRamSizeEnabled: event.isCustomRamSizeEnabled,
|
isCustomRamSizeEnabled: event.isCustomRamSizeEnabled,
|
||||||
customRamSize: event.customRamSize,
|
customRamSize: event.customRamSize,
|
||||||
);
|
);
|
||||||
@ -89,7 +89,6 @@ class InstallationConfigurationUpdatedEvent extends InstallationEvent {
|
|||||||
final GameVersionViewModel? gameVersion;
|
final GameVersionViewModel? gameVersion;
|
||||||
final String? savePath;
|
final String? savePath;
|
||||||
final bool? isEulaAgreed;
|
final bool? isEulaAgreed;
|
||||||
final bool? isGuiEnabled;
|
|
||||||
final bool? isCustomRamSizeEnabled;
|
final bool? isCustomRamSizeEnabled;
|
||||||
final RangeViewModel? customRamSize;
|
final RangeViewModel? customRamSize;
|
||||||
|
|
||||||
@ -97,7 +96,6 @@ class InstallationConfigurationUpdatedEvent extends InstallationEvent {
|
|||||||
this.gameVersion,
|
this.gameVersion,
|
||||||
this.savePath,
|
this.savePath,
|
||||||
this.isEulaAgreed,
|
this.isEulaAgreed,
|
||||||
this.isGuiEnabled,
|
|
||||||
this.isCustomRamSizeEnabled,
|
this.isCustomRamSizeEnabled,
|
||||||
this.customRamSize,
|
this.customRamSize,
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,6 @@ class InstallationState with EquatableMixin {
|
|||||||
final GameVersionViewModel? gameVersion;
|
final GameVersionViewModel? gameVersion;
|
||||||
final String? savePath;
|
final String? savePath;
|
||||||
final bool isEulaAgreed;
|
final bool isEulaAgreed;
|
||||||
final bool isGuiEnabled;
|
|
||||||
final bool isCustomRamSizeEnabled;
|
final bool isCustomRamSizeEnabled;
|
||||||
final RangeViewModel? _customRamSize;
|
final RangeViewModel? _customRamSize;
|
||||||
final ProgressViewModel downloadProgress;
|
final ProgressViewModel downloadProgress;
|
||||||
@ -19,7 +18,6 @@ class InstallationState with EquatableMixin {
|
|||||||
required this.gameVersion,
|
required this.gameVersion,
|
||||||
required this.savePath,
|
required this.savePath,
|
||||||
required this.isEulaAgreed,
|
required this.isEulaAgreed,
|
||||||
required this.isGuiEnabled,
|
|
||||||
required this.isCustomRamSizeEnabled,
|
required this.isCustomRamSizeEnabled,
|
||||||
required RangeViewModel? customRamSize,
|
required RangeViewModel? customRamSize,
|
||||||
required this.downloadProgress,
|
required this.downloadProgress,
|
||||||
@ -31,7 +29,6 @@ class InstallationState with EquatableMixin {
|
|||||||
gameVersion: null,
|
gameVersion: null,
|
||||||
savePath: null,
|
savePath: null,
|
||||||
isEulaAgreed: false,
|
isEulaAgreed: false,
|
||||||
isGuiEnabled: false,
|
|
||||||
isCustomRamSizeEnabled: false,
|
isCustomRamSizeEnabled: false,
|
||||||
customRamSize: _defaultRamSize,
|
customRamSize: _defaultRamSize,
|
||||||
downloadProgress: const ProgressViewModel.zero(),
|
downloadProgress: const ProgressViewModel.zero(),
|
||||||
@ -43,7 +40,6 @@ class InstallationState with EquatableMixin {
|
|||||||
gameVersion,
|
gameVersion,
|
||||||
savePath,
|
savePath,
|
||||||
isEulaAgreed,
|
isEulaAgreed,
|
||||||
isGuiEnabled,
|
|
||||||
isCustomRamSizeEnabled,
|
isCustomRamSizeEnabled,
|
||||||
_customRamSize,
|
_customRamSize,
|
||||||
downloadProgress,
|
downloadProgress,
|
||||||
@ -54,7 +50,6 @@ class InstallationState with EquatableMixin {
|
|||||||
GameVersionViewModel? gameVersion,
|
GameVersionViewModel? gameVersion,
|
||||||
String? savePath,
|
String? savePath,
|
||||||
bool? isEulaAgreed,
|
bool? isEulaAgreed,
|
||||||
bool? isGuiEnabled,
|
|
||||||
bool? isCustomRamSizeEnabled,
|
bool? isCustomRamSizeEnabled,
|
||||||
RangeViewModel? customRamSize,
|
RangeViewModel? customRamSize,
|
||||||
ProgressViewModel? downloadProgress,
|
ProgressViewModel? downloadProgress,
|
||||||
@ -64,7 +59,6 @@ class InstallationState with EquatableMixin {
|
|||||||
gameVersion: gameVersion ?? this.gameVersion,
|
gameVersion: gameVersion ?? this.gameVersion,
|
||||||
savePath: savePath ?? this.savePath,
|
savePath: savePath ?? this.savePath,
|
||||||
isEulaAgreed: isEulaAgreed ?? this.isEulaAgreed,
|
isEulaAgreed: isEulaAgreed ?? this.isEulaAgreed,
|
||||||
isGuiEnabled: isGuiEnabled ?? this.isGuiEnabled,
|
|
||||||
isCustomRamSizeEnabled: isCustomRamSizeEnabled ?? this.isCustomRamSizeEnabled,
|
isCustomRamSizeEnabled: isCustomRamSizeEnabled ?? this.isCustomRamSizeEnabled,
|
||||||
customRamSize: customRamSize ?? _customRamSize,
|
customRamSize: customRamSize ?? _customRamSize,
|
||||||
downloadProgress: downloadProgress ?? this.downloadProgress,
|
downloadProgress: downloadProgress ?? this.downloadProgress,
|
||||||
|
@ -21,7 +21,6 @@ class BasicConfigurationTab extends StatelessWidget {
|
|||||||
_pathBrowsingField,
|
_pathBrowsingField,
|
||||||
const Gap(16),
|
const Gap(16),
|
||||||
_eulaCheckbox,
|
_eulaCheckbox,
|
||||||
_guiCheckBox,
|
|
||||||
_enableCustomRamSizeCheckbox,
|
_enableCustomRamSizeCheckbox,
|
||||||
_customRamSizeControl,
|
_customRamSizeControl,
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
@ -83,19 +82,6 @@ class BasicConfigurationTab extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget get _guiCheckBox => BlocConsumer<InstallationBloc, InstallationState>(
|
|
||||||
listener: (_, __) {},
|
|
||||||
builder: (context, state) => CheckboxListTile(
|
|
||||||
title: const Text(Strings.fieldGui),
|
|
||||||
value: state.isGuiEnabled,
|
|
||||||
onChanged: (value) =>
|
|
||||||
context.read<InstallationBloc>().add(InstallationConfigurationUpdatedEvent(isGuiEnabled: value)),
|
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget get _enableCustomRamSizeCheckbox => BlocConsumer<InstallationBloc, InstallationState>(
|
Widget get _enableCustomRamSizeCheckbox => BlocConsumer<InstallationBloc, InstallationState>(
|
||||||
listener: (_, __) {},
|
listener: (_, __) {},
|
||||||
builder: (context, state) => CheckboxListTile(
|
builder: (context, state) => CheckboxListTile(
|
||||||
@ -142,7 +128,7 @@ class BasicConfigurationTab extends StatelessWidget {
|
|||||||
canRequestFocus: false,
|
canRequestFocus: false,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
label: const Text('${Strings.fieldMinRamSize} (MB)'),
|
label: const Text('${Strings.labelMinRamSize} (MB)'),
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(4)),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(4)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -154,7 +140,7 @@ class BasicConfigurationTab extends StatelessWidget {
|
|||||||
canRequestFocus: false,
|
canRequestFocus: false,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
label: const Text('${Strings.fieldMaxRamSize} (MB)'),
|
label: const Text('${Strings.labelMaxRamSize} (MB)'),
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(4)),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(4)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -2,12 +2,11 @@ abstract class Strings {
|
|||||||
static const fieldGameVersion = '遊戲版本';
|
static const fieldGameVersion = '遊戲版本';
|
||||||
static const fieldPath = '安裝路徑';
|
static const fieldPath = '安裝路徑';
|
||||||
static const fieldEula = '我同意 EULA 條款';
|
static const fieldEula = '我同意 EULA 條款';
|
||||||
static const fieldGui = '啟用伺服器 GUI 介面';
|
|
||||||
static const fieldCustomRamSize = '啟用自定義 RAM 大小';
|
static const fieldCustomRamSize = '啟用自定義 RAM 大小';
|
||||||
static const fieldMinRamSize = '最小 RAM 大小';
|
|
||||||
static const fieldMaxRamSize = '最大 RAM 大小';
|
|
||||||
static const buttonStartToInstall = '開始安裝';
|
static const buttonStartToInstall = '開始安裝';
|
||||||
static const buttonBrowse = '瀏覽';
|
static const buttonBrowse = '瀏覽';
|
||||||
|
static const labelMinRamSize = '最小 RAM 大小';
|
||||||
|
static const labelMaxRamSize = '最大 RAM 大小';
|
||||||
static const tooltipEulaInfo = '點擊查看 EULA 條款';
|
static const tooltipEulaInfo = '點擊查看 EULA 條款';
|
||||||
static const dialogTitleSelectDirectory = '選擇安裝目錄';
|
static const dialogTitleSelectDirectory = '選擇安裝目錄';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user