Changelog: v0.4.14
This commit is contained in:
parent
f419bd555d
commit
955be51226
|
@ -1,5 +1,12 @@
|
|||
# ChangeLog
|
||||
|
||||
## v0.4.13 & v0.4.14
|
||||
|
||||
- 优化重连逻辑
|
||||
- 客户端代码大量删除JSON。可能影响部分拓展
|
||||
|
||||
___
|
||||
|
||||
## v0.4.12
|
||||
|
||||
- 修前个版本poxi框bug
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
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}\")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS
|
||||
|
|
|
@ -76,7 +76,7 @@ callbacks["ErrorMsg"] = (jsonData) => {
|
|||
mainWindow.busy = false;
|
||||
if (sheduled_download !== "") {
|
||||
mainWindow.busy = true;
|
||||
Pacman.loadSummary(sheduled_download, true);
|
||||
Pacman.loadSummary(JSON.stringify(sheduled_download), true);
|
||||
sheduled_download = "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,6 @@ Item {
|
|||
delete s.normalPkg[name];
|
||||
s.banPkg[name] = [];
|
||||
}
|
||||
console.log(JSON.stringify(config.curScheme))
|
||||
config.curSchemeChanged();
|
||||
} else {
|
||||
pkgList.currentIndex = index;
|
||||
|
@ -394,12 +393,12 @@ Item {
|
|||
}
|
||||
|
||||
onClicked: {
|
||||
callbacks["LogEvent"](JSON.stringify({
|
||||
callbacks["LogEvent"]({
|
||||
type: "PlaySkillSound",
|
||||
name: name,
|
||||
general: detailGeneralCard.name,
|
||||
i: idx,
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1176,12 +1176,12 @@ Item {
|
|||
|
||||
if (!config.disableMsgAudio)
|
||||
try {
|
||||
callbacks["LogEvent"](JSON.stringify({
|
||||
callbacks["LogEvent"]({
|
||||
type: "PlaySkillSound",
|
||||
name: skill,
|
||||
general: gene,
|
||||
i: idx,
|
||||
}));
|
||||
});
|
||||
} catch (e) {}
|
||||
const m = luatr("$" + skill + (gene ? "_" + gene : "")
|
||||
+ (idx ? idx.toString() : ""));
|
||||
|
@ -1278,7 +1278,7 @@ Item {
|
|||
roomScene.isOwner = d.isOwner;
|
||||
} else {
|
||||
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);
|
||||
Logic.getPhotoModel(d.id).isOwner = d.isOwner;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.notify.FreeKill"
|
||||
android:installLocation="preferExternal"
|
||||
android:versionCode="413"
|
||||
android:versionName="0.4.13">
|
||||
android:versionCode="414"
|
||||
android:versionName="0.4.14">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
|
|
@ -72,96 +72,6 @@ bool QmlBackend::isDir(const QString &file) {
|
|||
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) {
|
||||
QVariantList list;
|
||||
QVariantMap map;
|
||||
|
@ -284,6 +194,96 @@ QVariant QmlBackend::readLuaValue(lua_State *L, int index,
|
|||
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,
|
||||
QVariantList params) {
|
||||
if (!ClientInstance) return QVariantMap();
|
||||
|
|
Loading…
Reference in New Issue