mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-16 11:42:45 +08:00
Fixbug (#399)
* lua端的ob属性根本没同步,同步一下 * [需要C++] 让requestTimer的超时影响到Lua * 修复windows没图标 * qmllint; remove modmaker * 修理了选卡器 * 修理了确定取消消失 * 删除了已经不用的autoPending和respond_play * 修复异常烧条(或许吧) * 修复负数烧条时间,若为负数则无事发生
This commit is contained in:
parent
30df075db2
commit
196e92f5d3
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -16,6 +16,7 @@
|
|||
/.cache/
|
||||
/tags
|
||||
/.luarc.json
|
||||
/.qmllint.ini
|
||||
|
||||
# file produced by game
|
||||
/FreeKill
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# 2022-01-24 新建文件夹 2023-02-21 发布v0.0.1版本
|
||||
# ------------------------------------------------------------
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(FreeKill VERSION 0.4.20)
|
||||
add_definitions(-DFK_VERSION=\"${CMAKE_PROJECT_VERSION}\")
|
||||
|
|
|
@ -63,6 +63,9 @@ QtObject {
|
|||
property list<string> blockedUsers: []
|
||||
property int totalTime: 0 // FIXME: only for notifying
|
||||
|
||||
onObservingChanged: lcall("SetObserving", observing);
|
||||
//onReplayingChanged: lcall("SetReplaying", replaying);
|
||||
|
||||
// onDisabledGeneralsChanged: {
|
||||
// disableGeneralSchemes[disableSchemeIdx] = disabledGenerals;
|
||||
// }
|
||||
|
|
|
@ -390,7 +390,6 @@ Item {
|
|||
config.replaying = false;
|
||||
if (playerNum < capacity) {
|
||||
config.observing = false;
|
||||
lcall("SetObserving", false);
|
||||
mainWindow.busy = true;
|
||||
ClientInstance.notifyServer(
|
||||
"EnterRoom",
|
||||
|
@ -398,7 +397,6 @@ Item {
|
|||
);
|
||||
} else {
|
||||
config.observing = true;
|
||||
lcall("SetObserving", true);
|
||||
mainWindow.busy = true;
|
||||
ClientInstance.notifyServer(
|
||||
"ObserveRoom",
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
import Fk.ModMaker as Md
|
||||
|
||||
Md.ModMaker {}
|
|
@ -42,8 +42,6 @@ Item {
|
|||
|
||||
property var selected_targets: []
|
||||
property string responding_card
|
||||
property bool respond_play: false
|
||||
property bool autoPending: false
|
||||
property var extra_data: ({})
|
||||
property var skippedUseEventId: []
|
||||
|
||||
|
@ -353,6 +351,11 @@ Item {
|
|||
const total = dat["timeout"] * 1000;
|
||||
const now = Date.now(); // ms
|
||||
const elapsed = now - (dat["timestamp"] ?? now);
|
||||
|
||||
if (total <= elapsd) {
|
||||
roomScene.state = "notactive";
|
||||
}
|
||||
|
||||
progressAnim.from = (1 - elapsed / total) * 100.0;
|
||||
progressAnim.duration = total - elapsed;
|
||||
progress.visible = true;
|
||||
|
@ -449,11 +452,12 @@ Item {
|
|||
text: luatr("Choose one handcard")
|
||||
textFont.pixelSize: 28
|
||||
visible: {
|
||||
if (roomScene.state === "notactive") return false;
|
||||
if (dashboard.handcardArea.length <= 15) {
|
||||
return false;
|
||||
}
|
||||
const cards = dashboard.handcardArea.cards;
|
||||
for (const card in cards) {
|
||||
for (const card of cards) {
|
||||
if (card.selectable) return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1294,6 +1298,11 @@ Item {
|
|||
return Logic.getPhoto(id);
|
||||
}
|
||||
|
||||
function activate() {
|
||||
if (state === "active") state = "notactive";
|
||||
state = "active";
|
||||
}
|
||||
|
||||
function applyChange(uiUpdate) {
|
||||
uiUpdate["_delete"]?.forEach(data => {
|
||||
if (data.type == "Interaction") {
|
||||
|
|
|
@ -809,7 +809,7 @@ callbacks["AskForGeneral"] = (data) => {
|
|||
const convert = data[2];
|
||||
const heg = data[3];
|
||||
roomScene.setPrompt(luatr("#AskForGeneral"), true);
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.popupBox.sourceComponent =
|
||||
Qt.createComponent("../RoomElement/ChooseGeneralBox.qml");
|
||||
const box = roomScene.popupBox.item;
|
||||
|
@ -830,15 +830,15 @@ callbacks["AskForSkillInvoke"] = (data) => {
|
|||
const prompt = data[1];
|
||||
roomScene.promptText = prompt ? processPrompt(prompt)
|
||||
: luatr("#AskForSkillInvoke").arg(luatr(skill));
|
||||
// roomScene.state = "active";
|
||||
// roomScene.activate();
|
||||
// roomScene.okCancel.visible = true;
|
||||
// roomScene.okButton.enabled = true;
|
||||
// roomScene.cancelButton.enabled = true;
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
}
|
||||
|
||||
callbacks["AskForArrangeCards"] = (data) => {
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.popupBox.sourceComponent =
|
||||
Qt.createComponent("../RoomElement/ArrangeCardsBox.qml");
|
||||
const box = roomScene.popupBox.item;
|
||||
|
@ -869,7 +869,7 @@ callbacks["AskForGuanxing"] = (data) => {
|
|||
const top_area_name = data.top_area_name;
|
||||
const bottom_area_name = data.bottom_area_name;
|
||||
const prompt = data.prompt;
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.popupBox.sourceComponent =
|
||||
Qt.createComponent("../RoomElement/GuanxingBox.qml");
|
||||
const box = roomScene.popupBox.item;
|
||||
|
@ -905,7 +905,7 @@ callbacks["AskForExchange"] = (data) => {
|
|||
const cards_name = [];
|
||||
const capacities = [];
|
||||
const limits = [];
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.popupBox.sourceComponent =
|
||||
Qt.createComponent("../RoomElement/GuanxingBox.qml");
|
||||
let for_i = 0;
|
||||
|
@ -944,7 +944,7 @@ callbacks["AskForChoice"] = (data) => {
|
|||
} else {
|
||||
roomScene.setPrompt(processPrompt(prompt), true);
|
||||
}
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
let qmlSrc;
|
||||
if (!detailed) {
|
||||
qmlSrc = "../RoomElement/ChoiceBox.qml";
|
||||
|
@ -978,7 +978,7 @@ callbacks["AskForChoices"] = (data) => {
|
|||
} else {
|
||||
roomScene.setPrompt(processPrompt(prompt), true);
|
||||
}
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
let qmlSrc;
|
||||
if (!detailed) {
|
||||
qmlSrc = "../RoomElement/CheckBox.qml";
|
||||
|
@ -1013,7 +1013,7 @@ callbacks["AskForCardChosen"] = (data) => {
|
|||
} else {
|
||||
roomScene.setPrompt(processPrompt(prompt), true);
|
||||
}
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.popupBox.sourceComponent =
|
||||
Qt.createComponent("../RoomElement/PlayerCardBox.qml");
|
||||
|
||||
|
@ -1045,7 +1045,7 @@ callbacks["AskForCardsChosen"] = (data) => {
|
|||
roomScene.setPrompt(processPrompt(prompt), true);
|
||||
}
|
||||
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.popupBox.sourceComponent =
|
||||
Qt.createComponent("../RoomElement/PlayerCardBox.qml");
|
||||
const box = roomScene.popupBox.item;
|
||||
|
@ -1070,7 +1070,7 @@ callbacks["AskForCardsChosen"] = (data) => {
|
|||
callbacks["AskForPoxi"] = (dat) => {
|
||||
const { type, data, extra_data, cancelable } = dat;
|
||||
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.popupBox.sourceComponent =
|
||||
Qt.createComponent("../RoomElement/PoxiBox.qml");
|
||||
const box = roomScene.popupBox.item;
|
||||
|
@ -1096,7 +1096,7 @@ callbacks["AskForPoxi"] = (dat) => {
|
|||
callbacks["AskForMoveCardInBoard"] = (data) => {
|
||||
const { cards, cardsPosition, generalNames, playerIds } = data;
|
||||
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.popupBox.sourceComponent =
|
||||
Qt.createComponent("../RoomElement/MoveCardInBoardBox.qml");
|
||||
|
||||
|
@ -1133,7 +1133,8 @@ callbacks["MoveCards"] = (moves) => {
|
|||
// 切换状态 -> 向Lua询问UI情况
|
||||
// 所以Lua一开始就要设置好各种亮灭的值 而这个自然是通过update
|
||||
callbacks["PlayCard"] = () => {
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.okCancel.visible = true;
|
||||
}
|
||||
|
||||
callbacks["LoseSkill"] = (data) => {
|
||||
|
@ -1176,18 +1177,8 @@ callbacks["AskForUseActiveSkill"] = (data) => {
|
|||
roomScene.setPrompt(processPrompt(prompt), true);
|
||||
}
|
||||
|
||||
roomScene.respond_play = false;
|
||||
roomScene.state = "active";
|
||||
|
||||
// if (lcall('GetSkillData', skill_name).isViewAsSkill) {
|
||||
// roomScene.responding_card = ".";
|
||||
// }
|
||||
|
||||
// roomScene.autoPending = true;
|
||||
// roomScene.extra_data = extra_data;
|
||||
// // dashboard.startPending(skill_name);
|
||||
// // roomScene.activateSkill(skill_name, true);
|
||||
// cancelButton.enabled = cancelable;
|
||||
roomScene.activate();
|
||||
roomScene.okCancel.visible = true;
|
||||
}
|
||||
|
||||
callbacks["CancelRequest"] = () => {
|
||||
|
@ -1212,7 +1203,8 @@ callbacks["AskForUseCard"] = (data) => {
|
|||
} else {
|
||||
roomScene.setPrompt(processPrompt(prompt), true);
|
||||
}
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.okCancel.visible = true;
|
||||
if (extra_data != null) {
|
||||
if (extra_data.effectTo !== Self.id &&
|
||||
roomScene.skippedUseEventId.find(id => id === extra_data.useEventId)) {
|
||||
|
@ -1223,7 +1215,6 @@ callbacks["AskForUseCard"] = (data) => {
|
|||
}
|
||||
}
|
||||
// roomScene.responding_card = pattern;
|
||||
// roomScene.respond_play = false;
|
||||
// disabledSkillNames && (dashboard.disabledSkillNames = disabledSkillNames);
|
||||
// roomScene.state = "responding";
|
||||
// okButton.enabled = false;
|
||||
|
@ -1243,13 +1234,8 @@ callbacks["AskForResponseCard"] = (data) => {
|
|||
} else {
|
||||
roomScene.setPrompt(processPrompt(prompt), true);
|
||||
}
|
||||
roomScene.state = "active";
|
||||
// roomScene.responding_card = pattern;
|
||||
// roomScene.respond_play = true;
|
||||
// disabledSkillNames && (dashboard.disabledSkillNames = disabledSkillNames);
|
||||
// roomScene.state = "responding";
|
||||
// okButton.enabled = false;
|
||||
// cancelButton.enabled = true;
|
||||
roomScene.activate();
|
||||
roomScene.okCancel.visible = true;
|
||||
}
|
||||
|
||||
callbacks["WaitForNullification"] = () => {
|
||||
|
@ -1436,7 +1422,7 @@ callbacks["FillAG"] = (data) => {
|
|||
}
|
||||
|
||||
callbacks["AskForAG"] = (j) => {
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.manualBox.item.interactive = true;
|
||||
}
|
||||
|
||||
|
@ -1456,7 +1442,7 @@ callbacks["CloseAG"] = () => roomScene.manualBox.item.close();
|
|||
callbacks["CustomDialog"] = (data) => {
|
||||
const path = data.path;
|
||||
const dat = data.data;
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.popupBox.source = AppPath + "/" + path;
|
||||
if (dat) {
|
||||
roomScene.popupBox.item.loadData(dat);
|
||||
|
@ -1467,7 +1453,7 @@ callbacks["MiniGame"] = (data) => {
|
|||
const game = data.type;
|
||||
const dat = data.data;
|
||||
const gdata = lcall("GetMiniGame", game, Self.id, JSON.stringify(dat));
|
||||
roomScene.state = "active";
|
||||
roomScene.activate();
|
||||
roomScene.popupBox.source = AppPath + "/" + gdata.qml_path + ".qml";
|
||||
if (dat) {
|
||||
roomScene.popupBox.item.loadData(dat);
|
||||
|
@ -1536,21 +1522,10 @@ callbacks["UpdateRequestUI"] = (uiUpdate) => {
|
|||
roomScene.promptText = processPrompt(uiUpdate["_prompt"]);
|
||||
|
||||
if (uiUpdate._type == "Room") {
|
||||
// 需要判断是不是第一次收到这样的数据,可以通过state判断
|
||||
// 因为是先收到Lua的数据,再切换状态的
|
||||
// FIXME: 当然了 非常可能出现因为网络延迟过大导致在active状态收到新Request的情况!
|
||||
// if (roomScene.state === "notactive") {
|
||||
// okCancel.visible = true;
|
||||
// okButton.enabled = false;
|
||||
// cancelButton.enabled = false;
|
||||
// // endPhaseButton.visible = true;
|
||||
// }
|
||||
roomScene.applyChange(uiUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: 完全是因为ChangeSelf需要向服务器询问此人手牌信息导致不能直接暴力reply+设置notactive
|
||||
// FIXME: 后面需要杀掉所有客户端未知牌
|
||||
callbacks["ReplyToServer"] = (data) => {
|
||||
replyToServer(data);
|
||||
}
|
||||
|
|
|
@ -12,4 +12,3 @@ PackageManage 1.0 PackageManage.qml
|
|||
Room 1.0 Room.qml
|
||||
Replay 1.0 Replay.qml
|
||||
TileButton 1.0 TileButton.qml
|
||||
ModMaker 1.0 ModMaker.qml
|
||||
|
|
|
@ -40,7 +40,7 @@ ColumnLayout {
|
|||
for (let cd of clist) {
|
||||
if (cd.cid == cid) {
|
||||
cd.selected = !cd.selected;
|
||||
cd.clicked();
|
||||
cd.clicked(cd);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@ add_custom_command(
|
|||
${SWIG_SOURCE}
|
||||
)
|
||||
|
||||
set(freekill_EXESRCS
|
||||
"main.cpp"
|
||||
)
|
||||
|
||||
set(freekill_SRCS
|
||||
# "main.cpp"
|
||||
"freekill.cpp"
|
||||
|
@ -69,7 +73,7 @@ if (WIN32)
|
|||
set(CRYPTO_LIB OpenSSL::Crypto)
|
||||
set(GIT_LIB ${PROJECT_SOURCE_DIR}/lib/win/libgit2.dll)
|
||||
set(app_icon_resource_windows "${PROJECT_SOURCE_DIR}/image/icon.rc")
|
||||
list(APPEND freekill_SRCS ${app_icon_resource_windows})
|
||||
list(APPEND freekill_EXESRCS ${app_icon_resource_windows})
|
||||
elseif (ANDROID)
|
||||
set(LUA_LIB ${PROJECT_SOURCE_DIR}/lib/android/liblua54.so)
|
||||
set(SQLITE3_LIB ${PROJECT_SOURCE_DIR}/lib/android/libsqlite3.so)
|
||||
|
@ -127,7 +131,7 @@ target_link_libraries(libFreeKill PRIVATE
|
|||
${GIT_LIB}
|
||||
${IDBFS_LIB}
|
||||
)
|
||||
target_sources(FreeKill PRIVATE main.cpp)
|
||||
target_sources(FreeKill PRIVATE ${freekill_EXESRCS})
|
||||
target_link_libraries(FreeKill PRIVATE
|
||||
libFreeKill
|
||||
)
|
||||
|
|
|
@ -186,7 +186,7 @@ void Router::handlePacket(const QByteArray &rawPacket) {
|
|||
if (!_room->isLobby()) {
|
||||
auto room = qobject_cast<Room *>(_room);
|
||||
if (room->getThread()) {
|
||||
room->getThread()->wakeUp(room->getId());
|
||||
room->getThread()->wakeUp(room->getId(), "reply");
|
||||
// TODO: signal
|
||||
}
|
||||
}
|
||||
|
|
|
@ -608,7 +608,7 @@ void Room::setRequestTimer(int ms) {
|
|||
request_timer->setSingleShot(true);
|
||||
request_timer->setInterval(ms);
|
||||
connect(request_timer, &QTimer::timeout, this, [=](){
|
||||
m_thread->wakeUp(id);
|
||||
m_thread->wakeUp(id, "request_timer");
|
||||
});
|
||||
request_timer->start();
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class RoomThread : public QThread {
|
|||
signals:
|
||||
void pushRequest(const QString &req);
|
||||
void delay(int roomId, int ms);
|
||||
void wakeUp(int roomId);
|
||||
void wakeUp(int roomId, const char *);
|
||||
|
||||
protected:
|
||||
virtual void run();
|
||||
|
|
|
@ -36,16 +36,17 @@ void Scheduler::handleRequest(const QString &req) {
|
|||
}
|
||||
|
||||
void Scheduler::doDelay(int roomId, int ms) {
|
||||
QTimer::singleShot(ms, [=](){ resumeRoom(roomId); });
|
||||
QTimer::singleShot(ms, [=](){ resumeRoom(roomId, "delay_done"); });
|
||||
}
|
||||
|
||||
bool Scheduler::resumeRoom(int roomId) {
|
||||
bool Scheduler::resumeRoom(int roomId, const char *reason) {
|
||||
lua_getglobal(L, "ResumeRoom");
|
||||
lua_pushnumber(L, roomId);
|
||||
lua_pushstring(L, reason);
|
||||
|
||||
int err = lua_pcall(L, 1, 1, 0);
|
||||
const char *result = lua_tostring(L, -1);
|
||||
int err = lua_pcall(L, 2, 1, 0);
|
||||
if (err) {
|
||||
const char *result = lua_tostring(L, -1);
|
||||
qCritical() << result;
|
||||
lua_pop(L, 1);
|
||||
return true;
|
||||
|
|
|
@ -18,7 +18,7 @@ class Scheduler : public QObject {
|
|||
// 跨线程传递引用可能出问题!
|
||||
void handleRequest(const QString &req);
|
||||
void doDelay(int roomId, int ms);
|
||||
bool resumeRoom(int roomId);
|
||||
bool resumeRoom(int roomId, const char *reason);
|
||||
|
||||
private:
|
||||
RoomThread *m_thread;
|
||||
|
|
|
@ -366,7 +366,7 @@ void Server::onRoomAbandoned() {
|
|||
// FIXME: 但是这终归是内存泄漏!以后啥时候再改吧。
|
||||
// room->deleteLater();
|
||||
idle_rooms.push(room);
|
||||
room->getThread()->wakeUp(room->getId());
|
||||
room->getThread()->wakeUp(room->getId(), "abandon");
|
||||
room->getThread()->removeRoom(room);
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ void ServerPlayer::onDisconnected() {
|
|||
}
|
||||
if (room->getThread()) {
|
||||
// && thinking()) {
|
||||
room->getThread()->wakeUp(room->getId());
|
||||
room->getThread()->wakeUp(room->getId(), "player_disconnect");
|
||||
}
|
||||
setState(Player::Offline);
|
||||
setSocket(nullptr);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <QClipboard>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMessageBox>
|
||||
// #include "mod.h"
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
|
@ -481,10 +480,6 @@ void QmlBackend::installAESKey() {
|
|||
ClientInstance->installAESKey(aes_key.toLatin1());
|
||||
}
|
||||
|
||||
void QmlBackend::createModBackend() {
|
||||
//engine->rootContext()->setContextProperty("ModBackend", new ModMaker);
|
||||
}
|
||||
|
||||
|
||||
void QmlBackend::detectServer() {
|
||||
static const char *ask_str = "fkDetectServer";
|
||||
|
|
|
@ -60,8 +60,6 @@ public:
|
|||
Q_INVOKABLE QString getAESKey() const;
|
||||
Q_INVOKABLE void installAESKey();
|
||||
|
||||
Q_INVOKABLE void createModBackend();
|
||||
|
||||
Q_INVOKABLE void detectServer();
|
||||
Q_INVOKABLE void getServerInfo(const QString &addr, ushort port = 9527u);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user