diff --git a/Fk/Cheat/GeneralDetail.qml b/Fk/Cheat/GeneralDetail.qml index 1fef8880..bd633c39 100644 --- a/Fk/Cheat/GeneralDetail.qml +++ b/Fk/Cheat/GeneralDetail.qml @@ -38,7 +38,7 @@ Flickable { skillDesc.text = ""; extra_data.generals.forEach((g) => { - let data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [g])); + const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [g])); skillDesc.append(Backend.translate(data.kingdom) + " " + Backend.translate(g) + " " + data.hp + "/" + data.maxHp); data.skill.forEach(t => { skillDesc.append("" + Backend.translate(t.name) + ": " + t.description) diff --git a/Fk/Common/ChatBox.qml b/Fk/Common/ChatBox.qml index bad08e44..9f72f9b6 100644 --- a/Fk/Common/ChatBox.qml +++ b/Fk/Common/ChatBox.qml @@ -12,6 +12,64 @@ Rectangle { chatLogBox.append(chatter) } + /* + function loadSkills(pid) { + if (isLobby) return; + let gender = 0; + // let g = false; + // if (g) { + // const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [g])); + // const extension = data.extension; + // gender = data.gender; + // data.skill.forEach(t => { + // for (let i = 0; i < 999; i++) { + // const fname = AppPath + "/packages/" + extension + "/audio/skill/" + + // t.name + (i !== 0 ? i.toString() : "") + ".mp3"; + + // if (Backend.exists(fname)) { + // skills.append({ name: t.name, idx: i }); + // } else { + // if (i > 0) break; + // } + // } + // }); + // data.related_skill.forEach(t => { + // for (let i = 0; i < 999; i++) { + // const fname = AppPath + "/packages/" + extension + "/audio/skill/" + + // t.name + (i !== 0 ? i.toString() : "") + ".mp3"; + + // if (Backend.exists(fname)) { + // skills.append({ name: t.name, idx: i }); + // } else { + // if (i > 0) break; + // } + // } + // }); + // } + for (let i = 0; i < 999; i++) { + const name = "fastchat_" + (gender == 1 ? "f" : "m") + const fname = AppPath + "/packages/standard/audio/skill/" + + name + (i !== 0 ? i.toString() : "") + ".mp3"; + + if (Backend.exists(fname)) { + skills.append({ name: name, idx: i }); + } else { + if (i > 0) break; + } + } + } + */ + function loadSkills() { + for (let i = 1; i <= 16; i++) { + skills.append({ name: "fastchat_m", idx: i }); + } + } + + Timer { + id: opTimer + interval: 1500 + } + ColumnLayout { anchors.fill: parent spacing: 0 @@ -47,6 +105,46 @@ Rectangle { } } + ListView { + id: soundSelector + Layout.fillWidth: true + Layout.preferredHeight: 180 + visible: false + clip: true + ScrollBar.vertical: ScrollBar {} + model: ListModel { + id: skills + } + // onVisibleChanged: {skills.clear(); loadSkills();} + + delegate: ItemDelegate { + width: soundSelector.width + height: 30 + text: Backend.translate("$" + name + (idx ? idx.toString() : "")) + + onClicked: { + opTimer.start(); + const general = roomScene.getPhoto(Self.id).general; + let skill = "fastchat_m"; + if (general !== "") { + const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [general])); + const gender = data.gender; + if (gender !== 1) { + skill = "fastchat_f"; + } + } + ClientInstance.notifyServer( + "Chat", + JSON.stringify({ + type: isLobby ? 1 : 2, + msg: "$" + skill + ":" + idx + }) + ); + soundSelector.visible = false; + } + } + } + RowLayout { Rectangle { Layout.fillWidth: true @@ -79,16 +177,38 @@ Rectangle { } } + MetroButton { + id: soundBtn + text: "🗨️" + visible: !isLobby + enabled: !opTimer.running; + onClicked: { + emojiSelector.visible = false; + soundSelector.visible = !soundSelector.visible; + } + } + MetroButton { id: emojiBtn text: "😃" - onClicked: emojiSelector.visible = !emojiSelector.visible; + onClicked: { + soundSelector.visible = false; + emojiSelector.visible = !emojiSelector.visible; + } } MetroButton { text: "✔️" - onClicked: chatEdit.accepted(); + enabled: !opTimer.running; + onClicked: { + opTimer.start(); + chatEdit.accepted(); + } } } } + + Component.onCompleted: { + loadSkills(); + } } diff --git a/Fk/Pages/Lobby.qml b/Fk/Pages/Lobby.qml index 7eb7cad4..32896d13 100644 --- a/Fk/Pages/Lobby.qml +++ b/Fk/Pages/Lobby.qml @@ -15,7 +15,7 @@ Item { property string password Rectangle { - width: parent.width / 2 - roomListLayout.width / 2 + width: parent.width / 2 - roomListLayout.width / 2 - 50 height: parent.height * 0.7 anchors.top: exitButton.bottom anchors.bottom: createRoomButton.top @@ -106,17 +106,32 @@ Item { PersonalSettings { } - RowLayout { + Timer { + id: opTimer + interval: 1000 + } + + ColumnLayout { id: roomListLayout - anchors.centerIn: parent - width: childrenRect.width - height: parent.height + anchors.top: parent.top + anchors.topMargin: 10 + anchors.horizontalCenter: parent.horizontalCenter + width: root.width * 0.48 + height: root.height - 80 + Button { + Layout.alignment: Qt.AlignRight + text: Backend.translate("Refresh Room List") + enabled: !opTimer.running + onClicked: { + opTimer.start(); + ClientInstance.notifyServer("RefreshRoomList", ""); + } + } Item { - Layout.preferredWidth: root.width * 0.6 + Layout.fillWidth: true Layout.fillHeight: true Rectangle { - width: parent.width * 0.8 - height: parent.height * 0.8 + anchors.fill: parent anchors.centerIn: parent color: "#88EEEEEE" radius: 16 diff --git a/Fk/Pages/Room.qml b/Fk/Pages/Room.qml index 49ba2451..cde31e6b 100644 --- a/Fk/Pages/Room.qml +++ b/Fk/Pages/Room.qml @@ -956,6 +956,10 @@ Item { }); } + function getPhoto(id) { + return Logic.getPhoto(id); + } + Component.onCompleted: { toast.show(Backend.translate("$EnterRoom")); playerNum = config.roomCapacity; diff --git a/lang/zh_CN.ts b/lang/zh_CN.ts index 777b88a6..8a70e9e1 100644 --- a/lang/zh_CN.ts +++ b/lang/zh_CN.ts @@ -322,6 +322,14 @@ you have been temporarily banned! 由于逃跑或者其他不正当行为,你已经被暂时封禁! + + Can only observe running room. + 只能旁观已开战的房间。 + + + Room is full or already started! + 房间已满! + diff --git a/lua/client/client_util.lua b/lua/client/client_util.lua index 2f15f2df..033018a2 100644 --- a/lua/client/client_util.lua +++ b/lua/client/client_util.lua @@ -31,6 +31,7 @@ function GetGeneralDetail(name) kingdom = general.kingdom, hp = general.hp, maxHp = general.maxHp, + gender = general.gender, skill = {}, related_skill = {} } diff --git a/lua/client/i18n/zh_CN.lua b/lua/client/i18n/zh_CN.lua index 19377f0b..a34d3575 100644 --- a/lua/client/i18n/zh_CN.lua +++ b/lua/client/i18n/zh_CN.lua @@ -26,6 +26,8 @@ Fk:loadTranslationTable{ ["Hide unselectable cards"] = "下移不可选卡牌", ["Back"] = "返回", + ["Refresh Room List"] = "刷新房间列表", + ["Create Room"] = "创建房间", ["Room Name"] = "房间名字", ["$RoomName"] = "%1的房间", diff --git a/packages/standard/audio/skill/fastchat_f1.mp3 b/packages/standard/audio/skill/fastchat_f1.mp3 new file mode 100644 index 00000000..f2f18490 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f1.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f10.mp3 b/packages/standard/audio/skill/fastchat_f10.mp3 new file mode 100644 index 00000000..f8195d61 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f10.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f11.mp3 b/packages/standard/audio/skill/fastchat_f11.mp3 new file mode 100644 index 00000000..7795af0f Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f11.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f12.mp3 b/packages/standard/audio/skill/fastchat_f12.mp3 new file mode 100644 index 00000000..7199f20a Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f12.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f13.mp3 b/packages/standard/audio/skill/fastchat_f13.mp3 new file mode 100644 index 00000000..69384557 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f13.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f14.mp3 b/packages/standard/audio/skill/fastchat_f14.mp3 new file mode 100644 index 00000000..3c27c4ab Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f14.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f15.mp3 b/packages/standard/audio/skill/fastchat_f15.mp3 new file mode 100644 index 00000000..046adfc2 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f15.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f16.mp3 b/packages/standard/audio/skill/fastchat_f16.mp3 new file mode 100644 index 00000000..7effb474 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f16.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f2.mp3 b/packages/standard/audio/skill/fastchat_f2.mp3 new file mode 100644 index 00000000..aad8bec6 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f2.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f3.mp3 b/packages/standard/audio/skill/fastchat_f3.mp3 new file mode 100644 index 00000000..20e4127f Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f3.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f4.mp3 b/packages/standard/audio/skill/fastchat_f4.mp3 new file mode 100644 index 00000000..30d81117 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f4.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f5.mp3 b/packages/standard/audio/skill/fastchat_f5.mp3 new file mode 100644 index 00000000..c9412f71 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f5.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f6.mp3 b/packages/standard/audio/skill/fastchat_f6.mp3 new file mode 100644 index 00000000..e5250340 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f6.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f7.mp3 b/packages/standard/audio/skill/fastchat_f7.mp3 new file mode 100644 index 00000000..28a8187d Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f7.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f8.mp3 b/packages/standard/audio/skill/fastchat_f8.mp3 new file mode 100644 index 00000000..945629d5 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f8.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_f9.mp3 b/packages/standard/audio/skill/fastchat_f9.mp3 new file mode 100644 index 00000000..19759acc Binary files /dev/null and b/packages/standard/audio/skill/fastchat_f9.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m1.mp3 b/packages/standard/audio/skill/fastchat_m1.mp3 new file mode 100644 index 00000000..69d41f9b Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m1.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m10.mp3 b/packages/standard/audio/skill/fastchat_m10.mp3 new file mode 100644 index 00000000..0772a8c5 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m10.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m11.mp3 b/packages/standard/audio/skill/fastchat_m11.mp3 new file mode 100644 index 00000000..4415f20f Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m11.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m12.mp3 b/packages/standard/audio/skill/fastchat_m12.mp3 new file mode 100644 index 00000000..8a8bca91 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m12.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m13.mp3 b/packages/standard/audio/skill/fastchat_m13.mp3 new file mode 100644 index 00000000..5606f616 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m13.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m14.mp3 b/packages/standard/audio/skill/fastchat_m14.mp3 new file mode 100644 index 00000000..a11bf66f Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m14.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m15.mp3 b/packages/standard/audio/skill/fastchat_m15.mp3 new file mode 100644 index 00000000..f401b08b Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m15.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m16.mp3 b/packages/standard/audio/skill/fastchat_m16.mp3 new file mode 100644 index 00000000..7bc8b16d Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m16.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m2.mp3 b/packages/standard/audio/skill/fastchat_m2.mp3 new file mode 100644 index 00000000..6599824a Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m2.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m3.mp3 b/packages/standard/audio/skill/fastchat_m3.mp3 new file mode 100644 index 00000000..3044851d Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m3.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m4.mp3 b/packages/standard/audio/skill/fastchat_m4.mp3 new file mode 100644 index 00000000..a72e357b Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m4.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m5.mp3 b/packages/standard/audio/skill/fastchat_m5.mp3 new file mode 100644 index 00000000..6577d553 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m5.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m6.mp3 b/packages/standard/audio/skill/fastchat_m6.mp3 new file mode 100644 index 00000000..59fe8355 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m6.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m7.mp3 b/packages/standard/audio/skill/fastchat_m7.mp3 new file mode 100644 index 00000000..9fe1820c Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m7.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m8.mp3 b/packages/standard/audio/skill/fastchat_m8.mp3 new file mode 100644 index 00000000..ba1e4f6d Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m8.mp3 differ diff --git a/packages/standard/audio/skill/fastchat_m9.mp3 b/packages/standard/audio/skill/fastchat_m9.mp3 new file mode 100644 index 00000000..abd2af54 Binary files /dev/null and b/packages/standard/audio/skill/fastchat_m9.mp3 differ diff --git a/packages/standard/game_rule.lua b/packages/standard/game_rule.lua index bf3af974..bca59a8f 100644 --- a/packages/standard/game_rule.lua +++ b/packages/standard/game_rule.lua @@ -130,3 +130,8 @@ GameRule = fk.CreateTriggerSkill{ end, } + +local fastchat_m = fk.CreateActiveSkill{ name = "fastchat_m" } +local fastchat_f = fk.CreateActiveSkill{ name = "fastchat_f" } +Fk:addSkill(fastchat_m) +Fk:addSkill(fastchat_f) diff --git a/packages/standard/i18n/zh_CN.lua b/packages/standard/i18n/zh_CN.lua index 8694d674..3dbcbca5 100644 --- a/packages/standard/i18n/zh_CN.lua +++ b/packages/standard/i18n/zh_CN.lua @@ -245,6 +245,42 @@ Fk:loadTranslationTable{ ["biyue"] = "闭月", [":biyue"] = "结束阶段开始时,你可以摸一张牌。", + ["fastchat_m"] = "快捷短语", + ["fastchat_f"] = "快捷短语", + + ["$fastchat_m1"] = "能不能快一点啊,兵贵神速啊。", + ["$fastchat_m2"] = "主公,别开枪,自己人!", + ["$fastchat_m3"] = "小内再不跳,后面还怎么玩啊?", + ["$fastchat_m4"] = "你们忍心,就这么让我酱油了?", + ["$fastchat_m5"] = "我……我惹你们了吗!?", + ["$fastchat_m6"] = "姑娘,你真是条汉子。", + ["$fastchat_m7"] = "三十六计走为上,容我去去便回。", + ["$fastchat_m8"] = "人心散了,队伍不好带啊。", + ["$fastchat_m9"] = "昏君,昏君呐!", + ["$fastchat_m10"] = "风吹鸡蛋壳,牌去人安乐。", + ["$fastchat_m11"] = "小内啊,你老悠着点。", + ["$fastchat_m12"] = "啊,不好意思,刚才卡了。", + ["$fastchat_m13"] = "你可以打的再烂一点吗?", + ["$fastchat_m14"] = "哥们,给力点行吗?", + ["$fastchat_m15"] = "哥哥,交个朋友吧。", + ["$fastchat_m16"] = "妹子,交个朋友吧。", + ["$fastchat_f1"] = "能不能快一点啊,兵贵神速啊。", + ["$fastchat_f2"] = "主公,别开枪,自己人!", + ["$fastchat_f3"] = "小内再不跳,后面还怎么玩啊?", + ["$fastchat_f4"] = "嗯嘛~你们忍心,就这么让我酱油了?", + ["$fastchat_f5"] = "我……我惹你们了吗?", + ["$fastchat_f6"] = "姑娘,你真是条汉子。", + ["$fastchat_f7"] = "三十六计走为上,容我去去便回。", + ["$fastchat_f8"] = "人心散了,队伍不好带啊。", + ["$fastchat_f9"] = "昏君,昏君呐!", + ["$fastchat_f10"] = "风吹鸡蛋壳,牌去人安乐。", + ["$fastchat_f11"] = "小内啊,你老悠着点儿。", + ["$fastchat_f12"] = "不好意思,刚才卡了。", + ["$fastchat_f13"] = "你可以打的再烂一点吗?", + ["$fastchat_f14"] = "哥们,给力点行吗?", + ["$fastchat_f15"] = "哥,交个朋友吧。", + ["$fastchat_f16"] = "妹子,交个朋友吧。", + ["aaa_role_mode"] = "身份模式", [":aaa_role_mode"] = [========================================[ # 身份模式简介 diff --git a/src/network/router.cpp b/src/network/router.cpp index 89bdabee..6ea1745d 100644 --- a/src/network/router.cpp +++ b/src/network/router.cpp @@ -243,6 +243,10 @@ void Router::handlePacket(const QByteArray &rawPacket) { lobby_actions["Chat"] = [](ServerPlayer *sender, const QString &jsonData) { sender->getRoom()->chat(sender, jsonData); }; + lobby_actions["RefreshRoomList"] = [](ServerPlayer *sender, + const QString &jsonData) { + ServerInstance->updateRoomList(sender); + }; } #endif diff --git a/src/server/room.cpp b/src/server/room.cpp index 4e94606c..1ed0bcd8 100644 --- a/src/server/room.cpp +++ b/src/server/room.cpp @@ -177,11 +177,13 @@ void Room::addPlayer(ServerPlayer *player) { player->doNotify("UpdateGameData", JsonArray2Bytes(jsonData)); } + /* if (this->owner != nullptr) { jsonData = QJsonArray(); jsonData << this->owner->getId(); player->doNotify("RoomOwner", JsonArray2Bytes(jsonData)); } + */ if (player->getLastGameMode() != mode) { player->setLastGameMode(mode); diff --git a/src/server/server.cpp b/src/server/server.cpp index 29b97ec1..404eff8b 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -46,8 +46,8 @@ Server::Server(QObject *parent) : QObject(parent) { nextRoomId = 0; createRoom(nullptr, "Lobby", INT32_MAX); // 大厅只要发生人员变动,就向所有人广播一下房间列表 - connect(lobby(), &Room::playerAdded, this, &Server::updateRoomList); - connect(lobby(), &Room::playerRemoved, this, &Server::updateRoomList); + connect(lobby(), &Room::playerAdded, this, &Server::updateOnlineInfo); + connect(lobby(), &Room::playerRemoved, this, &Server::updateOnlineInfo); // 启动心跳包线程 auto heartbeatThread = QThread::create([=]() { @@ -166,7 +166,7 @@ void Server::removePlayer(int id) { } } -void Server::updateRoomList() { +void Server::updateRoomList(ServerPlayer *teller) { QJsonArray arr; QJsonArray avail_arr; foreach (Room *room, rooms) { @@ -192,9 +192,10 @@ void Server::updateRoomList() { arr.prepend(v); } auto jsonData = JsonArray2Bytes(arr); - lobby()->doBroadcastNotify(lobby()->getPlayers(), "UpdateRoomList", - QString(jsonData)); + teller->doNotify("UpdateRoomList", QString(jsonData)); +} +void Server::updateOnlineInfo() { lobby()->doBroadcastNotify(lobby()->getPlayers(), "UpdatePlayerNum", QString(JsonArray2Bytes(QJsonArray({ lobby()->getPlayers().length(), @@ -499,7 +500,7 @@ void Server::onRoomAbandoned() { Room *room = qobject_cast(sender()); room->gameOver(); rooms.remove(room->getId()); - updateRoomList(); + updateOnlineInfo(); // 按理说这时候就可以删除了,但是这里肯定比Lua先检测到。 // 倘若在Lua的Room:gameOver时C++的Room被删除了问题就大了。 // FIXME: 但是这终归是内存泄漏!以后啥时候再改吧。 diff --git a/src/server/server.h b/src/server/server.h index 02e23f30..02196c64 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -35,7 +35,8 @@ public: void addPlayer(ServerPlayer *player); void removePlayer(int id); - void updateRoomList(); + void updateRoomList(ServerPlayer *teller); + void updateOnlineInfo(); sqlite3 *getDatabase();