parent
0d1d3a079b
commit
c9e6892322
|
@ -50,7 +50,8 @@ class Preferences {
|
|||
this.algorithm = 2,
|
||||
this.drawOnHumanExperience = true,
|
||||
this.considerMobility = true,
|
||||
this.developerMode = false,
|
||||
@Deprecated("we won't export the developer settings anymore. People should use the EnvironmentConfig.devMode")
|
||||
this.developerMode = false,
|
||||
this.experimentsEnabled = false,
|
||||
});
|
||||
|
||||
|
@ -92,6 +93,9 @@ class Preferences {
|
|||
@HiveField(17)
|
||||
final bool considerMobility;
|
||||
@HiveField(18)
|
||||
@Deprecated(
|
||||
"we won't export the developer settings anymore. People should use the EnvironmentConfig.devMode",
|
||||
)
|
||||
final bool developerMode;
|
||||
@HiveField(19)
|
||||
final bool experimentsEnabled;
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
This file is part of Sanmill.
|
||||
Copyright (C) 2019-2021 The Sanmill developers (see AUTHORS file)
|
||||
|
||||
Sanmill is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Sanmill is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:sanmill/services/environment_config.dart';
|
||||
|
||||
/// Temporary data model
|
||||
///
|
||||
/// holds temporary runtime data that isn't yet or shouldn't be saved to the LocalDatabase
|
||||
class Temp {
|
||||
const Temp._();
|
||||
|
||||
/// represents a temporary value for Preferences.developerMode
|
||||
static bool developerMode = EnvironmentConfig.devMode;
|
||||
}
|
|
@ -50,9 +50,9 @@ class Board extends StatelessWidget {
|
|||
(index) => Center(
|
||||
child: Text(
|
||||
squareDesc[index],
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
// TODO: [Leptopoda] instead of making it transparent when not needed we should not show it in the first place
|
||||
color: LocalDatabaseService.preferences.developerMode
|
||||
color: EnvironmentConfig.devMode
|
||||
? Colors.red
|
||||
: Colors.transparent,
|
||||
),
|
||||
|
|
|
@ -33,6 +33,7 @@ import 'package:sanmill/screens/game_settings/game_settings_page.dart';
|
|||
import 'package:sanmill/services/audios.dart';
|
||||
import 'package:sanmill/services/engine/engine.dart';
|
||||
import 'package:sanmill/services/engine/native_engine.dart';
|
||||
import 'package:sanmill/services/environment_config.dart';
|
||||
import 'package:sanmill/services/storage/storage.dart';
|
||||
import 'package:sanmill/shared/constants.dart';
|
||||
import 'package:sanmill/shared/custom_drawer/custom_drawer.dart';
|
||||
|
@ -1041,7 +1042,7 @@ class _GamePageState extends State<GamePage>
|
|||
if (loseReasonStr == null) {
|
||||
loseReasonStr = S.of(context).gameOverUnknownReason;
|
||||
debugPrint("$_tag Game over reason string: $loseReasonStr");
|
||||
if (LocalDatabaseService.preferences.developerMode) {
|
||||
if (EnvironmentConfig.devMode) {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:hive_flutter/hive_flutter.dart' show Box;
|
||||
import 'package:sanmill/generated/intl/l10n.dart';
|
||||
import 'package:sanmill/models/preferences.dart';
|
||||
import 'package:sanmill/models/temporary.dart';
|
||||
import 'package:sanmill/screens/env_page.dart';
|
||||
import 'package:sanmill/services/environment_config.dart';
|
||||
import 'package:sanmill/services/storage/storage.dart';
|
||||
|
@ -142,13 +141,6 @@ class GameSettingsPage extends StatelessWidget {
|
|||
debugPrint("$_tag screenReaderSupport: $value");
|
||||
}
|
||||
|
||||
void _setDeveloperMode(Preferences _preferences, bool value) {
|
||||
LocalDatabaseService.preferences =
|
||||
_preferences.copyWith(developerMode: value);
|
||||
|
||||
debugPrint("$_tag developerMode: $value");
|
||||
}
|
||||
|
||||
void _setExperimentsEnabled(Preferences _preferences, bool value) {
|
||||
LocalDatabaseService.preferences =
|
||||
_preferences.copyWith(experimentsEnabled: value);
|
||||
|
@ -187,8 +179,8 @@ class GameSettingsPage extends StatelessWidget {
|
|||
SettingsCard(
|
||||
children: <Widget>[
|
||||
SettingsSwitchListTile(
|
||||
value: _preferences.developerMode,
|
||||
onChanged: (val) => _setDeveloperMode(_preferences, val),
|
||||
value: EnvironmentConfig.devMode,
|
||||
onChanged: (_) {},
|
||||
titleString: S.of(context).developerMode,
|
||||
),
|
||||
SettingsSwitchListTile(
|
||||
|
@ -297,7 +289,7 @@ class GameSettingsPage extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
if (Temp.developerMode) ..._developerSettings,
|
||||
if (EnvironmentConfig.devMode) ..._developerSettings,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import 'package:sanmill/screens/help_screen.dart';
|
|||
import 'package:sanmill/screens/personalization_settings/personalization_settings_page.dart';
|
||||
import 'package:sanmill/screens/rule_settings/rule_settings_page.dart';
|
||||
import 'package:sanmill/services/engine/engine.dart';
|
||||
import 'package:sanmill/services/storage/storage.dart';
|
||||
import 'package:sanmill/services/environment_config.dart';
|
||||
import 'package:sanmill/shared/constants.dart';
|
||||
import 'package:sanmill/shared/custom_drawer/custom_drawer.dart';
|
||||
|
||||
|
@ -105,7 +105,7 @@ class _HomeState extends State<Home> with TickerProviderStateMixin {
|
|||
_screenView = const PersonalizationSettingsPage();
|
||||
break;
|
||||
case _DrawerIndex.feedback:
|
||||
if (!LocalDatabaseService.preferences.developerMode) {
|
||||
if (!EnvironmentConfig.devMode) {
|
||||
if (Platform.isWindows) {
|
||||
debugPrint("flutter_email_sender does not support Windows.");
|
||||
} else {
|
||||
|
@ -114,13 +114,13 @@ class _HomeState extends State<Home> with TickerProviderStateMixin {
|
|||
}
|
||||
break;
|
||||
case _DrawerIndex.Help:
|
||||
if (!LocalDatabaseService.preferences.developerMode) {
|
||||
if (!EnvironmentConfig.devMode) {
|
||||
_screenView = const HelpScreen();
|
||||
}
|
||||
break;
|
||||
|
||||
case _DrawerIndex.About:
|
||||
if (!LocalDatabaseService.preferences.developerMode) {
|
||||
if (!EnvironmentConfig.devMode) {
|
||||
_screenView = const AboutPage();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -23,6 +23,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:sanmill/mill/position.dart';
|
||||
import 'package:sanmill/mill/types.dart';
|
||||
import 'package:sanmill/services/engine/engine.dart';
|
||||
import 'package:sanmill/services/environment_config.dart';
|
||||
import 'package:sanmill/services/storage/storage.dart';
|
||||
|
||||
class NativeEngine extends Engine {
|
||||
|
@ -104,7 +105,7 @@ class NativeEngine extends Engine {
|
|||
}) async {
|
||||
final _pref = LocalDatabaseService.preferences;
|
||||
|
||||
var timeLimit = _pref.developerMode ? 100 : 6000;
|
||||
var timeLimit = EnvironmentConfig.devMode ? 100 : 6000;
|
||||
|
||||
if (_pref.moveTime > 0) {
|
||||
// TODO: Accurate timeLimit
|
||||
|
@ -113,7 +114,7 @@ class NativeEngine extends Engine {
|
|||
|
||||
if (times > timeLimit) {
|
||||
debugPrint("[engine] Timeout. sleep = $sleep, times = $times");
|
||||
if (_pref.developerMode && isActive) {
|
||||
if (EnvironmentConfig.devMode && isActive) {
|
||||
throw "Exception: waitResponse timeout.";
|
||||
}
|
||||
return '';
|
||||
|
@ -149,7 +150,7 @@ class NativeEngine extends Engine {
|
|||
final _rules = LocalDatabaseService.rules;
|
||||
|
||||
await send(
|
||||
'setoption name DeveloperMode value ${_pref.developerMode}',
|
||||
'setoption name DeveloperMode value ${EnvironmentConfig.devMode}',
|
||||
);
|
||||
await send(
|
||||
'setoption name Algorithm value ${_pref.algorithm}',
|
||||
|
|
|
@ -24,7 +24,6 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:sanmill/models/temporary.dart';
|
||||
import 'package:sanmill/services/storage/storage.dart';
|
||||
import 'package:sanmill/shared/constants.dart';
|
||||
import 'package:sanmill/shared/theme/app_theme.dart';
|
||||
|
|
|
@ -29,12 +29,6 @@ class CustomDrawerHeader extends StatelessWidget {
|
|||
|
||||
static const String _tag = "[home_drawer]";
|
||||
|
||||
void _enableDeveloperMode() {
|
||||
Temp.developerMode = true;
|
||||
|
||||
debugPrint("$_tag Developer mode enabled.");
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Color> _animatedTextsColors = [
|
||||
|
@ -48,22 +42,19 @@ class CustomDrawerHeader extends StatelessWidget {
|
|||
LocalDatabaseService.colorSettings.drawerHighlightItemColor,
|
||||
];
|
||||
|
||||
final animation = GestureDetector(
|
||||
onDoubleTap: _enableDeveloperMode,
|
||||
child: AnimatedTextKit(
|
||||
animatedTexts: [
|
||||
ColorizeAnimatedText(
|
||||
title,
|
||||
textStyle: AppTheme.drawerHeaderTextStyle,
|
||||
colors: _animatedTextsColors,
|
||||
speed: const Duration(seconds: 3),
|
||||
),
|
||||
],
|
||||
pause: const Duration(seconds: 3),
|
||||
repeatForever: true,
|
||||
stopPauseOnTap: true,
|
||||
onTap: () => debugPrint("$_tag DoubleTap to enable developer mode."),
|
||||
),
|
||||
final animation = AnimatedTextKit(
|
||||
animatedTexts: [
|
||||
ColorizeAnimatedText(
|
||||
title,
|
||||
textStyle: AppTheme.drawerHeaderTextStyle,
|
||||
colors: _animatedTextsColors,
|
||||
speed: const Duration(seconds: 3),
|
||||
),
|
||||
],
|
||||
pause: const Duration(seconds: 3),
|
||||
repeatForever: true,
|
||||
stopPauseOnTap: true,
|
||||
onTap: () => debugPrint("$_tag DoubleTap to enable developer mode."),
|
||||
);
|
||||
|
||||
final _padding = EdgeInsets.only(
|
||||
|
|
|
@ -23,6 +23,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:sanmill/mill/game.dart';
|
||||
import 'package:sanmill/mill/position.dart';
|
||||
import 'package:sanmill/mill/types.dart';
|
||||
import 'package:sanmill/services/environment_config.dart';
|
||||
import 'package:sanmill/services/storage/storage.dart';
|
||||
import 'package:sanmill/shared/theme/app_theme.dart';
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class BoardPainter extends PiecesBasePainter {
|
|||
final offset = (width - _squareWidth * 6) / 4;
|
||||
|
||||
// Show notations "a b c d e f" on board
|
||||
if (LocalDatabaseService.preferences.developerMode) {
|
||||
if (EnvironmentConfig.devMode) {
|
||||
notationPainterV.paint(
|
||||
canvas,
|
||||
_offset.translate(
|
||||
|
@ -131,7 +131,7 @@ class BoardPainter extends PiecesBasePainter {
|
|||
),
|
||||
);
|
||||
|
||||
if (LocalDatabaseService.preferences.developerMode) {
|
||||
if (EnvironmentConfig.devMode) {
|
||||
notationPainterH.paint(
|
||||
canvas,
|
||||
_offset.translate(
|
||||
|
|
Loading…
Reference in New Issue