flutter: Keep mute when taking back (configurable)
This commit is contained in:
parent
194b461788
commit
0b48028810
|
@ -28,6 +28,7 @@ class Config {
|
|||
|
||||
// Preferences
|
||||
static bool toneEnabled = true;
|
||||
static bool keepMuteWhenTakingBack = true;
|
||||
static bool aiMovesFirst = false;
|
||||
static bool aiIsLazy = false;
|
||||
static int skillLevel = 1;
|
||||
|
@ -85,6 +86,7 @@ class Config {
|
|||
|
||||
// Preferences
|
||||
Config.toneEnabled = settings['ToneEnabled'] ?? true;
|
||||
Config.keepMuteWhenTakingBack = settings['KeepMuteWhenTakingBack'] ?? true;
|
||||
Config.aiMovesFirst = settings['AiMovesFirst'] ?? false;
|
||||
Config.aiIsLazy = settings['AiIsLazy'] ?? false;
|
||||
Config.skillLevel = settings['SkillLevel'] ?? 1;
|
||||
|
@ -162,6 +164,7 @@ class Config {
|
|||
|
||||
// Preferences
|
||||
settings['ToneEnabled'] = Config.toneEnabled;
|
||||
settings['KeepMuteWhenTakingBack'] = Config.keepMuteWhenTakingBack;
|
||||
settings['AiMovesFirst'] = Config.aiMovesFirst;
|
||||
settings['AiIsLazy'] = Config.aiIsLazy;
|
||||
settings['SkillLevel'] = Config.skillLevel;
|
||||
|
|
|
@ -384,6 +384,10 @@
|
|||
"@playSoundsInTheGame": {
|
||||
"description": "Play sounds in the game"
|
||||
},
|
||||
"keepMuteWhenTakingBack": "Beim Zurücknehmen stumm bleiben",
|
||||
"@keepMuteWhenTakingBack": {
|
||||
"description": "Keep mute when taking back"
|
||||
},
|
||||
"tone": "Tone",
|
||||
"@tone": {
|
||||
"description": "Tone"
|
||||
|
|
|
@ -384,6 +384,10 @@
|
|||
"@playSoundsInTheGame": {
|
||||
"description": "Play sounds in the game"
|
||||
},
|
||||
"keepMuteWhenTakingBack": "Keep mute when taking back",
|
||||
"@keepMuteWhenTakingBack": {
|
||||
"description": "Keep mute when taking back"
|
||||
},
|
||||
"tone": "Tone",
|
||||
"@tone": {
|
||||
"description": "Tone"
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
"moveTime": "机器思考时间",
|
||||
"playSounds": "声音",
|
||||
"playSoundsInTheGame": "行棋时播放声音",
|
||||
"keepMuteWhenTakingBack": "悔棋时保持静音",
|
||||
"tone": "提示音效",
|
||||
"leaderBoard": "排行榜",
|
||||
"whoMovesFirst": "先手",
|
||||
|
|
|
@ -37,6 +37,7 @@ class Audios {
|
|||
static var removeSoundId;
|
||||
static var selectSoundId;
|
||||
static var winSoundId;
|
||||
static var isTemporaryMute = false;
|
||||
|
||||
static Future<void> loadSounds() async {
|
||||
if (Platform.isWindows) {
|
||||
|
@ -190,7 +191,7 @@ class Audios {
|
|||
|
||||
static playTone(var soundId) async {
|
||||
Chain.capture(() async {
|
||||
if (!Config.toneEnabled) {
|
||||
if (!Config.toneEnabled || isTemporaryMute) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -784,10 +784,14 @@ class _GamePageState extends State<GamePage>
|
|||
|
||||
isGoingToHistory = true;
|
||||
|
||||
Audios.isTemporaryMute = Config.keepMuteWhenTakingBack;
|
||||
|
||||
if (await func == false) {
|
||||
showSnackBar(S.of(context).atEnd);
|
||||
}
|
||||
|
||||
Audios.isTemporaryMute = false;
|
||||
|
||||
isGoingToHistory = false;
|
||||
|
||||
if (mounted) {
|
||||
|
|
|
@ -236,6 +236,13 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
|
|||
onChanged: setTone,
|
||||
titleString: S.of(context).playSoundsInTheGame,
|
||||
),
|
||||
ListItemDivider(),
|
||||
SettingsSwitchListTile(
|
||||
context: context,
|
||||
value: Config.keepMuteWhenTakingBack,
|
||||
onChanged: setKeepMuteWhenTakingBack,
|
||||
titleString: S.of(context).keepMuteWhenTakingBack,
|
||||
),
|
||||
],
|
||||
)
|
||||
: Container(height: 0.0, width: 0.0),
|
||||
|
@ -452,6 +459,16 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
|
|||
Config.save();
|
||||
}
|
||||
|
||||
setKeepMuteWhenTakingBack(bool value) async {
|
||||
setState(() {
|
||||
Config.keepMuteWhenTakingBack = value;
|
||||
});
|
||||
|
||||
print("[config] keepMuteWhenTakingBack: $value");
|
||||
|
||||
Config.save();
|
||||
}
|
||||
|
||||
setDeveloperMode(bool value) async {
|
||||
if (Config.developerMode && value == false) {
|
||||
print("$tag You must uninstall me to disable developer mode!");
|
||||
|
|
Loading…
Reference in New Issue