快速短句 (#213)

- 添加了快速短句及其对应的i18n,可以疯狂“兵贵神速啊”(

---------

Co-authored-by: notify <notify-ctrl@qq.com>
This commit is contained in:
YoumuKon 2023-07-02 13:21:13 +08:00 committed by GitHub
parent f24ea5dead
commit 2e8adf1918
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 217 additions and 18 deletions

View File

@ -38,7 +38,7 @@ Flickable {
skillDesc.text = ""; skillDesc.text = "";
extra_data.generals.forEach((g) => { 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); skillDesc.append(Backend.translate(data.kingdom) + " " + Backend.translate(g) + " " + data.hp + "/" + data.maxHp);
data.skill.forEach(t => { data.skill.forEach(t => {
skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description) skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description)

View File

@ -12,6 +12,64 @@ Rectangle {
chatLogBox.append(chatter) 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 { ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: 0 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 { RowLayout {
Rectangle { Rectangle {
Layout.fillWidth: true 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 { MetroButton {
id: emojiBtn id: emojiBtn
text: "😃" text: "😃"
onClicked: emojiSelector.visible = !emojiSelector.visible; onClicked: {
soundSelector.visible = false;
emojiSelector.visible = !emojiSelector.visible;
}
} }
MetroButton { MetroButton {
text: "✔️" text: "✔️"
onClicked: chatEdit.accepted(); enabled: !opTimer.running;
onClicked: {
opTimer.start();
chatEdit.accepted();
} }
} }
} }
} }
Component.onCompleted: {
loadSkills();
}
}

View File

@ -15,7 +15,7 @@ Item {
property string password property string password
Rectangle { Rectangle {
width: parent.width / 2 - roomListLayout.width / 2 width: parent.width / 2 - roomListLayout.width / 2 - 50
height: parent.height * 0.7 height: parent.height * 0.7
anchors.top: exitButton.bottom anchors.top: exitButton.bottom
anchors.bottom: createRoomButton.top anchors.bottom: createRoomButton.top
@ -106,17 +106,32 @@ Item {
PersonalSettings { PersonalSettings {
} }
RowLayout { Timer {
id: opTimer
interval: 1000
}
ColumnLayout {
id: roomListLayout id: roomListLayout
anchors.centerIn: parent anchors.top: parent.top
width: childrenRect.width anchors.topMargin: 10
height: parent.height 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 { Item {
Layout.preferredWidth: root.width * 0.6 Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Rectangle { Rectangle {
width: parent.width * 0.8 anchors.fill: parent
height: parent.height * 0.8
anchors.centerIn: parent anchors.centerIn: parent
color: "#88EEEEEE" color: "#88EEEEEE"
radius: 16 radius: 16

View File

@ -956,6 +956,10 @@ Item {
}); });
} }
function getPhoto(id) {
return Logic.getPhoto(id);
}
Component.onCompleted: { Component.onCompleted: {
toast.show(Backend.translate("$EnterRoom")); toast.show(Backend.translate("$EnterRoom"));
playerNum = config.roomCapacity; playerNum = config.roomCapacity;

View File

@ -322,6 +322,14 @@
<source>you have been temporarily banned!</source> <source>you have been temporarily banned!</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Can only observe running room.</source>
<translation></translation>
</message>
<message>
<source>Room is full or already started!</source>
<translation></translation>
</message>
</context> </context>
<context> <context>

View File

@ -31,6 +31,7 @@ function GetGeneralDetail(name)
kingdom = general.kingdom, kingdom = general.kingdom,
hp = general.hp, hp = general.hp,
maxHp = general.maxHp, maxHp = general.maxHp,
gender = general.gender,
skill = {}, skill = {},
related_skill = {} related_skill = {}
} }

View File

@ -26,6 +26,8 @@ Fk:loadTranslationTable{
["Hide unselectable cards"] = "下移不可选卡牌", ["Hide unselectable cards"] = "下移不可选卡牌",
["Back"] = "返回", ["Back"] = "返回",
["Refresh Room List"] = "刷新房间列表",
["Create Room"] = "创建房间", ["Create Room"] = "创建房间",
["Room Name"] = "房间名字", ["Room Name"] = "房间名字",
["$RoomName"] = "%1的房间", ["$RoomName"] = "%1的房间",

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -130,3 +130,8 @@ GameRule = fk.CreateTriggerSkill{
end, 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)

View File

@ -245,6 +245,42 @@ Fk:loadTranslationTable{
["biyue"] = "闭月", ["biyue"] = "闭月",
[":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"] = "身份模式",
[":aaa_role_mode"] = [========================================[ [":aaa_role_mode"] = [========================================[
# #

View File

@ -243,6 +243,10 @@ void Router::handlePacket(const QByteArray &rawPacket) {
lobby_actions["Chat"] = [](ServerPlayer *sender, const QString &jsonData) { lobby_actions["Chat"] = [](ServerPlayer *sender, const QString &jsonData) {
sender->getRoom()->chat(sender, jsonData); sender->getRoom()->chat(sender, jsonData);
}; };
lobby_actions["RefreshRoomList"] = [](ServerPlayer *sender,
const QString &jsonData) {
ServerInstance->updateRoomList(sender);
};
} }
#endif #endif

View File

@ -177,11 +177,13 @@ void Room::addPlayer(ServerPlayer *player) {
player->doNotify("UpdateGameData", JsonArray2Bytes(jsonData)); player->doNotify("UpdateGameData", JsonArray2Bytes(jsonData));
} }
/*
if (this->owner != nullptr) { if (this->owner != nullptr) {
jsonData = QJsonArray(); jsonData = QJsonArray();
jsonData << this->owner->getId(); jsonData << this->owner->getId();
player->doNotify("RoomOwner", JsonArray2Bytes(jsonData)); player->doNotify("RoomOwner", JsonArray2Bytes(jsonData));
} }
*/
if (player->getLastGameMode() != mode) { if (player->getLastGameMode() != mode) {
player->setLastGameMode(mode); player->setLastGameMode(mode);

View File

@ -46,8 +46,8 @@ Server::Server(QObject *parent) : QObject(parent) {
nextRoomId = 0; nextRoomId = 0;
createRoom(nullptr, "Lobby", INT32_MAX); createRoom(nullptr, "Lobby", INT32_MAX);
// 大厅只要发生人员变动,就向所有人广播一下房间列表 // 大厅只要发生人员变动,就向所有人广播一下房间列表
connect(lobby(), &Room::playerAdded, this, &Server::updateRoomList); connect(lobby(), &Room::playerAdded, this, &Server::updateOnlineInfo);
connect(lobby(), &Room::playerRemoved, this, &Server::updateRoomList); connect(lobby(), &Room::playerRemoved, this, &Server::updateOnlineInfo);
// 启动心跳包线程 // 启动心跳包线程
auto heartbeatThread = QThread::create([=]() { auto heartbeatThread = QThread::create([=]() {
@ -166,7 +166,7 @@ void Server::removePlayer(int id) {
} }
} }
void Server::updateRoomList() { void Server::updateRoomList(ServerPlayer *teller) {
QJsonArray arr; QJsonArray arr;
QJsonArray avail_arr; QJsonArray avail_arr;
foreach (Room *room, rooms) { foreach (Room *room, rooms) {
@ -192,9 +192,10 @@ void Server::updateRoomList() {
arr.prepend(v); arr.prepend(v);
} }
auto jsonData = JsonArray2Bytes(arr); auto jsonData = JsonArray2Bytes(arr);
lobby()->doBroadcastNotify(lobby()->getPlayers(), "UpdateRoomList", teller->doNotify("UpdateRoomList", QString(jsonData));
QString(jsonData)); }
void Server::updateOnlineInfo() {
lobby()->doBroadcastNotify(lobby()->getPlayers(), "UpdatePlayerNum", lobby()->doBroadcastNotify(lobby()->getPlayers(), "UpdatePlayerNum",
QString(JsonArray2Bytes(QJsonArray({ QString(JsonArray2Bytes(QJsonArray({
lobby()->getPlayers().length(), lobby()->getPlayers().length(),
@ -499,7 +500,7 @@ void Server::onRoomAbandoned() {
Room *room = qobject_cast<Room *>(sender()); Room *room = qobject_cast<Room *>(sender());
room->gameOver(); room->gameOver();
rooms.remove(room->getId()); rooms.remove(room->getId());
updateRoomList(); updateOnlineInfo();
// 按理说这时候就可以删除了但是这里肯定比Lua先检测到。 // 按理说这时候就可以删除了但是这里肯定比Lua先检测到。
// 倘若在Lua的Room:gameOver时C++的Room被删除了问题就大了。 // 倘若在Lua的Room:gameOver时C++的Room被删除了问题就大了。
// FIXME: 但是这终归是内存泄漏!以后啥时候再改吧。 // FIXME: 但是这终归是内存泄漏!以后啥时候再改吧。

View File

@ -35,7 +35,8 @@ public:
void addPlayer(ServerPlayer *player); void addPlayer(ServerPlayer *player);
void removePlayer(int id); void removePlayer(int id);
void updateRoomList(); void updateRoomList(ServerPlayer *teller);
void updateOnlineInfo();
sqlite3 *getDatabase(); sqlite3 *getDatabase();