forked from rustdesk/rustdesk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
300 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:flutter_hbb/common.dart'; | ||
import 'package:flutter_hbb/models/platform_model.dart'; | ||
|
||
// 游戏模式状态管理类 | ||
class GameModeState { | ||
// 单例模式 | ||
static final GameModeState instance = GameModeState._internal(); | ||
GameModeState._internal(); | ||
|
||
// 游戏模式是否启用的状态 | ||
final RxBool gameModeEnabled = false.obs; | ||
|
||
// 注册事件处理器,监听游戏模式状态变化 | ||
void registerEventListener() { | ||
// 注册游戏模式状态变化事件 | ||
platformFFI.registerEventHandler('on_game_mode_changed', 'game_mode', (evt) async { | ||
bool enabled = evt['enabled'] ?? false; | ||
gameModeEnabled.value = enabled; | ||
debugPrint('Game mode changed: $enabled'); | ||
|
||
// 显示游戏模式状态提示 | ||
if (enabled) { | ||
showToast('游戏模式已启用'); | ||
} else { | ||
showToast('游戏模式已禁用'); | ||
} | ||
}); | ||
} | ||
|
||
// 初始化游戏模式状态 | ||
void init() { | ||
// 读取当前游戏模式状态 | ||
gameModeEnabled.value = bind.sessionGetOption(id: ''.obs, arg: kOptionGameMode) == 'Y'; | ||
registerEventListener(); | ||
} | ||
} | ||
|
||
// 全局访问点 | ||
final gameModeState = GameModeState.instance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.