Changelog: v0.4.14

This commit is contained in:
notify 2024-04-19 22:38:00 +08:00
parent f419bd555d
commit 955be51226
7 changed files with 106 additions and 100 deletions

View File

@ -1,5 +1,12 @@
# ChangeLog # ChangeLog
## v0.4.13 & v0.4.14
- 优化重连逻辑
- 客户端代码大量删除JSON。可能影响部分拓展
___
## v0.4.12 ## v0.4.12
- 修前个版本poxi框bug - 修前个版本poxi框bug

View File

@ -6,7 +6,7 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(FreeKill VERSION 0.4.13) project(FreeKill VERSION 0.4.14)
add_definitions(-DFK_VERSION=\"${CMAKE_PROJECT_VERSION}\") add_definitions(-DFK_VERSION=\"${CMAKE_PROJECT_VERSION}\")
find_package(Qt6 REQUIRED COMPONENTS find_package(Qt6 REQUIRED COMPONENTS

View File

@ -76,7 +76,7 @@ callbacks["ErrorMsg"] = (jsonData) => {
mainWindow.busy = false; mainWindow.busy = false;
if (sheduled_download !== "") { if (sheduled_download !== "") {
mainWindow.busy = true; mainWindow.busy = true;
Pacman.loadSummary(sheduled_download, true); Pacman.loadSummary(JSON.stringify(sheduled_download), true);
sheduled_download = ""; sheduled_download = "";
} }
} }

View File

@ -98,7 +98,6 @@ Item {
delete s.normalPkg[name]; delete s.normalPkg[name];
s.banPkg[name] = []; s.banPkg[name] = [];
} }
console.log(JSON.stringify(config.curScheme))
config.curSchemeChanged(); config.curSchemeChanged();
} else { } else {
pkgList.currentIndex = index; pkgList.currentIndex = index;
@ -394,12 +393,12 @@ Item {
} }
onClicked: { onClicked: {
callbacks["LogEvent"](JSON.stringify({ callbacks["LogEvent"]({
type: "PlaySkillSound", type: "PlaySkillSound",
name: name, name: name,
general: detailGeneralCard.name, general: detailGeneralCard.name,
i: idx, i: idx,
})); });
} }
} }
} }

View File

@ -1176,12 +1176,12 @@ Item {
if (!config.disableMsgAudio) if (!config.disableMsgAudio)
try { try {
callbacks["LogEvent"](JSON.stringify({ callbacks["LogEvent"]({
type: "PlaySkillSound", type: "PlaySkillSound",
name: skill, name: skill,
general: gene, general: gene,
i: idx, i: idx,
})); });
} catch (e) {} } catch (e) {}
const m = luatr("$" + skill + (gene ? "_" + gene : "") const m = luatr("$" + skill + (gene ? "_" + gene : "")
+ (idx ? idx.toString() : "")); + (idx ? idx.toString() : ""));
@ -1278,7 +1278,7 @@ Item {
roomScene.isOwner = d.isOwner; roomScene.isOwner = d.isOwner;
} else { } else {
lcall("ResetAddPlayer", lcall("ResetAddPlayer",
JSON.stringify([d.id, d.name, d.avatar, d.ready, d.gameData[3]])); [d.id, d.name, d.avatar, d.ready, d.gameData[3]]);
} }
lcall("SetPlayerGameData", d.id, d.gameData); lcall("SetPlayerGameData", d.id, d.gameData);
Logic.getPhotoModel(d.id).isOwner = d.isOwner; Logic.getPhotoModel(d.id).isOwner = d.isOwner;

View File

@ -3,8 +3,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.notify.FreeKill" package="org.notify.FreeKill"
android:installLocation="preferExternal" android:installLocation="preferExternal"
android:versionCode="413" android:versionCode="414"
android:versionName="0.4.13"> android:versionName="0.4.14">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

View File

@ -72,96 +72,6 @@ bool QmlBackend::isDir(const QString &file) {
return QFileInfo(QUrl(file).path()).isDir(); return QFileInfo(QUrl(file).path()).isDir();
} }
#ifndef FK_SERVER_ONLY
QQmlApplicationEngine *QmlBackend::getEngine() const { return engine; }
void QmlBackend::setEngine(QQmlApplicationEngine *engine) {
this->engine = engine;
}
void QmlBackend::startServer(ushort port) {
if (!ServerInstance) {
Server *server = new Server(this);
if (!server->listen(QHostAddress::Any, port)) {
server->deleteLater();
emit notifyUI("ErrorMsg", tr("Cannot start server!"));
}
}
}
void QmlBackend::joinServer(QString address) {
if (ClientInstance != nullptr)
return;
Client *client = new Client(this);
connect(client, &Client::error_message, this, [=](const QString &msg) {
if (replayer) {
emit replayerShutdown();
}
client->deleteLater();
emit notifyUI("ErrorMsg", msg);
emit notifyUI("BackToStart", "[]");
});
QString addr = "127.0.0.1";
ushort port = 9527u;
if (address.contains(QChar(':'))) {
QStringList texts = address.split(QChar(':'));
addr = texts.value(0);
port = texts.value(1).toUShort();
} else {
addr = address;
// SRV解析查询
QDnsLookup* dns = new QDnsLookup(QDnsLookup::SRV, "_freekill._tcp." + addr);
QEventLoop eventLoop;
// 阻塞的SRV解析查询回调
connect(dns, &QDnsLookup::finished,[&eventLoop](void){
eventLoop.quit();
});
dns->lookup();
eventLoop.exec();
if (dns->error() == QDnsLookup::NoError) { // SRV解析成功
const auto records = dns->serviceRecords();
const QDnsServiceRecord &record = records.first();
QHostInfo host = QHostInfo::fromName(record.target());
if (host.error() == QHostInfo::NoError) { // 主机解析成功
addr = host.addresses().first().toString();
port = record.port();
}
}
}
client->connectToHost(addr, port);
}
void QmlBackend::quitLobby(bool close) {
if (ClientInstance)
delete ClientInstance;
// if (ServerInstance && close)
// ServerInstance->deleteLater();
}
QString QmlBackend::translate(const QString &src) {
if (!ClientInstance)
return src;
lua_State *L = ClientInstance->getLuaState();
lua_getglobal(L, "Translate");
auto bytes = src.toUtf8();
lua_pushstring(L, bytes.data());
int err = lua_pcall(L, 1, 1, 0);
const char *result = lua_tostring(L, -1);
if (err) {
qCritical() << result;
lua_pop(L, 1);
return "";
}
lua_pop(L, 1);
return QString(result);
}
void QmlBackend::pushLuaValue(lua_State *L, QVariant v) { void QmlBackend::pushLuaValue(lua_State *L, QVariant v) {
QVariantList list; QVariantList list;
QVariantMap map; QVariantMap map;
@ -284,6 +194,96 @@ QVariant QmlBackend::readLuaValue(lua_State *L, int index,
return QVariant(); // won't return return QVariant(); // won't return
} }
#ifndef FK_SERVER_ONLY
QQmlApplicationEngine *QmlBackend::getEngine() const { return engine; }
void QmlBackend::setEngine(QQmlApplicationEngine *engine) {
this->engine = engine;
}
void QmlBackend::startServer(ushort port) {
if (!ServerInstance) {
Server *server = new Server(this);
if (!server->listen(QHostAddress::Any, port)) {
server->deleteLater();
emit notifyUI("ErrorMsg", tr("Cannot start server!"));
}
}
}
void QmlBackend::joinServer(QString address) {
if (ClientInstance != nullptr)
return;
Client *client = new Client(this);
connect(client, &Client::error_message, this, [=](const QString &msg) {
if (replayer) {
emit replayerShutdown();
}
client->deleteLater();
emit notifyUI("ErrorMsg", msg);
emit notifyUI("BackToStart", "[]");
});
QString addr = "127.0.0.1";
ushort port = 9527u;
if (address.contains(QChar(':'))) {
QStringList texts = address.split(QChar(':'));
addr = texts.value(0);
port = texts.value(1).toUShort();
} else {
addr = address;
// SRV解析查询
QDnsLookup* dns = new QDnsLookup(QDnsLookup::SRV, "_freekill._tcp." + addr);
QEventLoop eventLoop;
// 阻塞的SRV解析查询回调
connect(dns, &QDnsLookup::finished,[&eventLoop](void){
eventLoop.quit();
});
dns->lookup();
eventLoop.exec();
if (dns->error() == QDnsLookup::NoError) { // SRV解析成功
const auto records = dns->serviceRecords();
const QDnsServiceRecord &record = records.first();
QHostInfo host = QHostInfo::fromName(record.target());
if (host.error() == QHostInfo::NoError) { // 主机解析成功
addr = host.addresses().first().toString();
port = record.port();
}
}
}
client->connectToHost(addr, port);
}
void QmlBackend::quitLobby(bool close) {
if (ClientInstance)
delete ClientInstance;
// if (ServerInstance && close)
// ServerInstance->deleteLater();
}
QString QmlBackend::translate(const QString &src) {
if (!ClientInstance)
return src;
lua_State *L = ClientInstance->getLuaState();
lua_getglobal(L, "Translate");
auto bytes = src.toUtf8();
lua_pushstring(L, bytes.data());
int err = lua_pcall(L, 1, 1, 0);
const char *result = lua_tostring(L, -1);
if (err) {
qCritical() << result;
lua_pop(L, 1);
return "";
}
lua_pop(L, 1);
return QString(result);
}
QVariant QmlBackend::callLuaFunction(const QString &func_name, QVariant QmlBackend::callLuaFunction(const QString &func_name,
QVariantList params) { QVariantList params) {
if (!ClientInstance) return QVariantMap(); if (!ClientInstance) return QVariantMap();