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