2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-09-14 13:01:10 +08:00
|
|
|
import QtQuick
|
2022-03-24 21:23:42 +08:00
|
|
|
|
|
|
|
QtObject {
|
2022-04-30 15:27:56 +08:00
|
|
|
// Client configuration
|
2023-02-27 10:23:48 +08:00
|
|
|
property real winX
|
|
|
|
property real winY
|
2022-12-18 12:52:52 +08:00
|
|
|
property real winWidth
|
|
|
|
property real winHeight
|
|
|
|
property var conf: ({})
|
|
|
|
property string lastLoginServer
|
|
|
|
property var savedPassword: ({})
|
2023-02-15 19:54:35 +08:00
|
|
|
property string lobbyBg
|
|
|
|
property string roomBg
|
|
|
|
property string bgmFile
|
2023-02-27 10:23:48 +08:00
|
|
|
property string language
|
2023-08-13 02:25:04 +08:00
|
|
|
property list<string> disabledPack: []
|
2023-03-14 14:12:13 +08:00
|
|
|
property string preferedMode
|
|
|
|
property int preferedPlayerNum
|
2023-03-20 14:53:56 +08:00
|
|
|
property int preferredGeneralNum
|
|
|
|
property string ladyImg
|
2023-04-28 18:24:31 +08:00
|
|
|
property real bgmVolume
|
|
|
|
property bool disableMsgAudio
|
2023-06-24 14:48:49 +08:00
|
|
|
property bool hideUseless
|
2023-08-13 02:25:04 +08:00
|
|
|
property list<string> disabledGenerals: []
|
|
|
|
property list<var> disableGeneralSchemes: []
|
2023-08-02 21:40:00 +08:00
|
|
|
property int disableSchemeIdx: 0
|
2022-03-24 21:23:42 +08:00
|
|
|
|
2023-04-30 18:54:23 +08:00
|
|
|
property int preferredTimeout
|
2023-05-19 07:45:21 +08:00
|
|
|
property int preferredLuckTime
|
2023-04-30 18:54:23 +08:00
|
|
|
|
2023-09-29 21:16:53 +08:00
|
|
|
property bool firstRun: true
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
// Player property of client
|
2022-12-18 12:52:52 +08:00
|
|
|
property string serverAddr
|
2022-04-30 15:27:56 +08:00
|
|
|
property string screenName: ""
|
|
|
|
property string password: ""
|
2022-12-18 12:52:52 +08:00
|
|
|
property string cipherText
|
2023-04-15 12:06:39 +08:00
|
|
|
property string aeskey
|
2022-03-24 21:23:42 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
// Client data
|
2023-08-03 15:24:17 +08:00
|
|
|
property string serverMotd: ""
|
2023-08-13 02:25:04 +08:00
|
|
|
property list<string> serverHiddenPacks: []
|
2023-08-27 20:21:37 +08:00
|
|
|
property bool serverEnableBot: true
|
2022-04-30 15:27:56 +08:00
|
|
|
property int roomCapacity: 0
|
|
|
|
property int roomTimeout: 0
|
2023-09-06 22:16:09 +08:00
|
|
|
property bool heg: false
|
2023-02-15 19:54:35 +08:00
|
|
|
property bool enableFreeAssign: false
|
|
|
|
property bool observing: false
|
2023-08-01 21:01:01 +08:00
|
|
|
property bool replaying: false
|
2023-08-13 02:25:04 +08:00
|
|
|
property list<string> blockedUsers: []
|
2022-12-18 12:52:52 +08:00
|
|
|
|
2023-08-02 21:40:00 +08:00
|
|
|
onDisabledGeneralsChanged: {
|
|
|
|
disableGeneralSchemes[disableSchemeIdx] = disabledGenerals;
|
|
|
|
}
|
|
|
|
|
2022-12-18 12:52:52 +08:00
|
|
|
function loadConf() {
|
|
|
|
conf = JSON.parse(Backend.loadConf());
|
2023-04-27 14:15:08 +08:00
|
|
|
winX = conf.winX ?? 100;
|
|
|
|
winY = conf.winY ?? 100;
|
|
|
|
winWidth = conf.winWidth ?? 960;
|
|
|
|
winHeight = conf.winHeight ?? 540;
|
|
|
|
lastLoginServer = conf.lastLoginServer ?? "127.0.0.1";
|
|
|
|
savedPassword = conf.savedPassword ?? {};
|
|
|
|
lobbyBg = conf.lobbyBg ?? AppPath + "/image/background";
|
|
|
|
roomBg = conf.roomBg ?? AppPath + "/image/gamebg";
|
|
|
|
bgmFile = conf.bgmFile ?? AppPath + "/audio/system/bgm.mp3";
|
2023-08-13 01:39:45 +08:00
|
|
|
language = conf.language ?? (() => {
|
|
|
|
let ret = SysLocale;
|
2023-11-07 12:49:31 +08:00
|
|
|
if (ret.startsWith('zh_')) {
|
|
|
|
return 'zh_CN';
|
|
|
|
} else {
|
|
|
|
return 'en_US';
|
2023-08-13 01:39:45 +08:00
|
|
|
}
|
|
|
|
})();
|
2023-04-27 14:15:08 +08:00
|
|
|
disabledPack = conf.disabledPack ?? [ "test_p_0" ];
|
|
|
|
preferedMode = conf.preferedMode ?? "aaa_role_mode";
|
|
|
|
preferedPlayerNum = conf.preferedPlayerNum ?? 2;
|
|
|
|
preferredGeneralNum = conf.preferredGeneralNum ?? 3;
|
|
|
|
ladyImg = conf.ladyImg ?? AppPath + "/image/lady";
|
2023-04-28 18:24:31 +08:00
|
|
|
Backend.volume = conf.effectVolume ?? 50.;
|
|
|
|
bgmVolume = conf.bgmVolume ?? 50.;
|
|
|
|
disableMsgAudio = conf.disableMsgAudio ?? false;
|
2023-06-24 14:48:49 +08:00
|
|
|
hideUseless = conf.hideUseless ?? false;
|
2023-04-30 18:54:23 +08:00
|
|
|
preferredTimeout = conf.preferredTimeout ?? 15;
|
2023-05-19 07:45:21 +08:00
|
|
|
preferredLuckTime = conf.preferredLuckTime ?? 0;
|
2023-09-29 21:16:53 +08:00
|
|
|
firstRun = conf.firstRun ?? true;
|
2023-05-13 14:20:48 +08:00
|
|
|
disabledGenerals = conf.disabledGenerals ?? [];
|
2023-08-02 21:40:00 +08:00
|
|
|
disableGeneralSchemes = conf.disableGeneralSchemes ?? [ disabledGenerals ];
|
|
|
|
disableSchemeIdx = conf.disableSchemeIdx ?? 0;
|
2022-12-18 12:52:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function saveConf() {
|
2023-02-27 10:23:48 +08:00
|
|
|
conf.winX = realMainWin.x;
|
|
|
|
conf.winY = realMainWin.y;
|
2022-12-18 12:52:52 +08:00
|
|
|
conf.winWidth = realMainWin.width;
|
|
|
|
conf.winHeight = realMainWin.height;
|
|
|
|
conf.lastLoginServer = lastLoginServer;
|
|
|
|
conf.savedPassword = savedPassword;
|
2023-02-15 19:54:35 +08:00
|
|
|
conf.lobbyBg = lobbyBg;
|
|
|
|
conf.roomBg = roomBg;
|
|
|
|
conf.bgmFile = bgmFile;
|
2023-02-27 10:23:48 +08:00
|
|
|
conf.language = language;
|
2023-03-14 14:12:13 +08:00
|
|
|
conf.disabledPack = disabledPack;
|
|
|
|
conf.preferedMode = preferedMode;
|
|
|
|
conf.preferedPlayerNum = preferedPlayerNum;
|
2023-03-20 14:53:56 +08:00
|
|
|
conf.ladyImg = ladyImg;
|
|
|
|
conf.preferredGeneralNum = preferredGeneralNum;
|
2023-04-28 18:24:31 +08:00
|
|
|
conf.effectVolume = Backend.volume;
|
|
|
|
conf.bgmVolume = bgmVolume;
|
|
|
|
conf.disableMsgAudio = disableMsgAudio;
|
2023-06-24 14:48:49 +08:00
|
|
|
conf.hideUseless = hideUseless;
|
2023-04-30 18:54:23 +08:00
|
|
|
conf.preferredTimeout = preferredTimeout;
|
2023-05-19 07:45:21 +08:00
|
|
|
conf.preferredLuckTime = preferredLuckTime;
|
2023-09-29 21:16:53 +08:00
|
|
|
conf.firstRun = firstRun;
|
2023-05-13 14:20:48 +08:00
|
|
|
conf.disabledGenerals = disabledGenerals;
|
2023-08-02 21:40:00 +08:00
|
|
|
conf.disableGeneralSchemes = disableGeneralSchemes;
|
|
|
|
conf.disableSchemeIdx = disableSchemeIdx;
|
2022-12-18 12:52:52 +08:00
|
|
|
|
|
|
|
Backend.saveConf(JSON.stringify(conf, undefined, 2));
|
|
|
|
}
|
2022-03-24 21:23:42 +08:00
|
|
|
}
|