mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-16 11:42:45 +08:00
cc271bcdf8
* support fkp * get default setting in qml * correct zixing * mark * TODO: parse fkp in c++ * scale the drawer * free assign * fix free assign bug * add submodule for official generals * generate fkp in cpp code * use UTF-8 in windows conhost * use onUse for regular skill * active skill for fkp * add fkp function; change data for DMG and Heal * add cancelable to askForDiscard * don't let generals naked * config bg and bgm * fix exists for win * bugfix: rewardandpunish * fkp: vs skill * room config * observe * god_salavation * fkp: judge * add read storage permission for android build * remove submodule fk_official * remove include/ * use a submodule as include directory * libgit2 * remove debugging 'downloadNewPack' * libgit2.dll for Windows * rewrite system_enum, disable dangerous function * fix bug in trigger() * filter skill * filter judgement card * add about page for git2 * very basic general detail * FKP: status skill * libgit: android test * libgit: build for android * 1 * libgit2.dll * android: load qm file after copy asset * filter skill: if no filter skill then remove filtered card * allow warning and critical to show a popup, and fix warnings from QML * resource: move general audio/image to packages/ * move assets of cards * FKP: modify * use sqlite db to manage packages * packman cli * packman gui * use Popup for error dialog * android full screen note * fix android ssl problem
113 lines
3.3 KiB
JavaScript
113 lines
3.3 KiB
JavaScript
var generalsOverviewPage, cardsOverviewPage;
|
|
var clientPageCreated = false;
|
|
function createClientPages() {
|
|
if (!clientPageCreated) {
|
|
clientPageCreated = true;
|
|
|
|
generalsOverviewPage = generalsOverview.createObject(mainWindow);
|
|
cardsOverviewPage = cardsOverview.createObject(mainWindow);
|
|
|
|
mainWindow.generalsOverviewPage = generalsOverviewPage;
|
|
mainWindow.cardsOverviewPage = cardsOverviewPage;
|
|
}
|
|
}
|
|
|
|
var callbacks = {};
|
|
|
|
callbacks["NetworkDelayTest"] = function(jsonData) {
|
|
// jsonData: RSA pub key
|
|
let cipherText
|
|
if (config.savedPassword[config.serverAddr] !== undefined
|
|
&& config.savedPassword[config.serverAddr].shorten_password === config.password) {
|
|
cipherText = config.savedPassword[config.serverAddr].password;
|
|
if (Debugging)
|
|
console.log("use remembered password", config.password);
|
|
} else {
|
|
cipherText = Backend.pubEncrypt(jsonData, config.password);
|
|
}
|
|
config.cipherText = cipherText;
|
|
let md5sum = Backend.calcFileMD5();
|
|
ClientInstance.notifyServer("Setup", JSON.stringify([
|
|
config.screenName, cipherText, md5sum
|
|
]));
|
|
}
|
|
|
|
callbacks["ErrorMsg"] = function(jsonData) {
|
|
console.log("ERROR: " + jsonData);
|
|
toast.show(qsTr(jsonData), 5000);
|
|
mainWindow.busy = false;
|
|
}
|
|
|
|
callbacks["UpdateBusyText"] = function(jsonData) {
|
|
mainWindow.busyText = jsonData;
|
|
}
|
|
|
|
callbacks["DownloadComplete"] = function() {
|
|
mainWindow.busy = false;
|
|
mainStack.currentItem.downloadComplete(); // should be pacman page
|
|
}
|
|
|
|
callbacks["BackToStart"] = function(jsonData) {
|
|
while (mainStack.depth > 1) {
|
|
mainStack.pop();
|
|
}
|
|
}
|
|
|
|
callbacks["EnterLobby"] = function(jsonData) {
|
|
// depth == 1 means the lobby page is not present in mainStack
|
|
createClientPages();
|
|
if (mainStack.depth === 1) {
|
|
// we enter the lobby successfully, so save password now.
|
|
config.lastLoginServer = config.serverAddr;
|
|
config.savedPassword[config.serverAddr] = {
|
|
username: config.screenName,
|
|
password: config.cipherText,
|
|
shorten_password: config.cipherText.slice(0, 8)
|
|
}
|
|
mainStack.push(lobby);
|
|
} else {
|
|
mainStack.pop();
|
|
}
|
|
mainWindow.busy = false;
|
|
}
|
|
|
|
callbacks["EnterRoom"] = function(jsonData) {
|
|
// jsonData: int capacity, int timeout
|
|
let data = JSON.parse(jsonData);
|
|
config.roomCapacity = data[0];
|
|
config.roomTimeout = data[1] - 1;
|
|
let roomSettings = data[2];
|
|
config.enableFreeAssign = roomSettings.enableFreeAssign;
|
|
mainStack.push(room);
|
|
mainWindow.busy = false;
|
|
}
|
|
|
|
callbacks["UpdateRoomList"] = function(jsonData) {
|
|
let current = mainStack.currentItem; // should be lobby
|
|
current.roomModel.clear();
|
|
JSON.parse(jsonData).forEach(function(room) {
|
|
current.roomModel.append({
|
|
roomId: room[0],
|
|
roomName: room[1],
|
|
gameMode: room[2],
|
|
playerNum: room[3],
|
|
capacity: room[4],
|
|
});
|
|
});
|
|
}
|
|
|
|
callbacks["Chat"] = function(jsonData) {
|
|
// jsonData: { string userName, string general, string time, string msg }
|
|
let current = mainStack.currentItem; // lobby(TODO) or room
|
|
let data = JSON.parse(jsonData);
|
|
let pid = data.type;
|
|
let userName = data.userName;
|
|
let general = Backend.translate(data.general);
|
|
let time = data.time;
|
|
let msg = data.msg;
|
|
if (general === "")
|
|
current.addToChat(pid, data, `[${time}] ${userName}: ${msg}`);
|
|
else
|
|
current.addToChat(pid, data, `[${time}] ${userName}(${general}): ${msg}`);
|
|
}
|