From 68f088e07612fcb965f8f3b2a67d9cdc8d327198 Mon Sep 17 00:00:00 2001 From: notify Date: Fri, 27 Oct 2023 22:53:25 +0800 Subject: [PATCH] Enhancement2 (#281) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 各种小改 --- Fk/LobbyElement/AudioSetting.qml | 4 ++++ Fk/LobbyElement/BGSetting.qml | 4 ++++ Fk/LobbyElement/RoomGeneralSettings.qml | 5 +++++ Fk/LobbyElement/UserInfo.qml | 4 ++++ Fk/Logic.js | 2 +- lua/core/debug.lua | 3 +-- lua/server/events/usecard.lua | 4 ++-- lua/server/gameevent.lua | 6 ++---- lua/server/room.lua | 5 ++--- lua/server/scheduler.lua | 3 +-- src/server/shell.cpp | 6 +++++- 11 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Fk/LobbyElement/AudioSetting.qml b/Fk/LobbyElement/AudioSetting.qml index 235bdd9d..15ef8489 100644 --- a/Fk/LobbyElement/AudioSetting.qml +++ b/Fk/LobbyElement/AudioSetting.qml @@ -12,6 +12,8 @@ ColumnLayout { text: Backend.translate("BGM Volume") } Slider { + Layout.rightMargin: 16 + Layout.fillWidth: true from: 0 to: 100 value: config.bgmVolume @@ -26,6 +28,8 @@ ColumnLayout { text: Backend.translate("Effect Volume") } Slider { + Layout.rightMargin: 16 + Layout.fillWidth: true from: 0 to: 100 value: Backend.volume diff --git a/Fk/LobbyElement/BGSetting.qml b/Fk/LobbyElement/BGSetting.qml index eeb1b58b..f6b279fb 100644 --- a/Fk/LobbyElement/BGSetting.qml +++ b/Fk/LobbyElement/BGSetting.qml @@ -13,6 +13,7 @@ ColumnLayout { text: Backend.translate("Lobby BG") } TextField { + Layout.fillWidth: true text: config.lobbyBg } Button { @@ -32,6 +33,7 @@ ColumnLayout { text: Backend.translate("Room BG") } TextField { + Layout.fillWidth: true text: config.roomBg } Button { @@ -51,6 +53,7 @@ ColumnLayout { text: Backend.translate("Game BGM") } TextField { + Layout.fillWidth: true text: config.bgmFile } Button { @@ -70,6 +73,7 @@ ColumnLayout { text: Backend.translate("Poster Girl") } TextField { + Layout.fillWidth: true text: config.ladyImg } Button { diff --git a/Fk/LobbyElement/RoomGeneralSettings.qml b/Fk/LobbyElement/RoomGeneralSettings.qml index b6e61668..839a3376 100644 --- a/Fk/LobbyElement/RoomGeneralSettings.qml +++ b/Fk/LobbyElement/RoomGeneralSettings.qml @@ -11,6 +11,7 @@ Flickable { ColumnLayout { id: layout + width: parent.width RowLayout { anchors.rightMargin: 8 spacing: 16 @@ -21,6 +22,8 @@ Flickable { id: roomName maximumLength: 64 font.pixelSize: 18 + Layout.rightMargin: 16 + Layout.fillWidth: true text: Backend.translate("$RoomName").arg(Self.screenName) } } @@ -142,6 +145,8 @@ Flickable { id: roomPassword maximumLength: 16 font.pixelSize: 18 + Layout.rightMargin: 16 + Layout.fillWidth: true } } diff --git a/Fk/LobbyElement/UserInfo.qml b/Fk/LobbyElement/UserInfo.qml index d8ac7dce..68549203 100644 --- a/Fk/LobbyElement/UserInfo.qml +++ b/Fk/LobbyElement/UserInfo.qml @@ -30,6 +30,7 @@ ColumnLayout { maximumLength: 64 font.pixelSize: 18 text: Self.avatar + Layout.fillWidth: true } Button { text: Backend.translate("Update Avatar") @@ -54,6 +55,8 @@ ColumnLayout { id: oldPassword echoMode: TextInput.Password passwordCharacter: "*" + Layout.rightMargin: 16 + Layout.fillWidth: true } } @@ -67,6 +70,7 @@ ColumnLayout { id: newPassword echoMode: TextInput.Password passwordCharacter: "*" + Layout.fillWidth: true } Button { text: Backend.translate("Update Password") diff --git a/Fk/Logic.js b/Fk/Logic.js index aa7d1835..15a011ea 100644 --- a/Fk/Logic.js +++ b/Fk/Logic.js @@ -189,7 +189,7 @@ callbacks["Chat"] = (jsonData) => { callbacks["ServerMessage"] = (jsonData) => { const current = mainStack.currentItem; // lobby or room - current.sendDanmaku('[Server] ' + jsonData); + current.sendDanmaku('[Server] ' + jsonData); } callbacks["ShowToast"] = (j) => toast.show(j); diff --git a/lua/core/debug.lua b/lua/core/debug.lua index daa70fa9..be097798 100644 --- a/lua/core/debug.lua +++ b/lua/core/debug.lua @@ -23,8 +23,7 @@ function Traceback() end local msgh = function(err) - fk.qCritical(err) - print(debug.traceback(nil, 2)) + fk.qCritical(err .. "\n" .. debug.traceback(nil, 2)) end function Pcall(f, ...) diff --git a/lua/server/events/usecard.lua b/lua/server/events/usecard.lua index 29caf8d7..df258768 100644 --- a/lua/server/events/usecard.lua +++ b/lua/server/events/usecard.lua @@ -185,14 +185,14 @@ GameEvent.functions[GameEvent.UseCard] = function(self) local room = self.room local logic = room.logic - sendCardEmotionAndLog(room, cardUseEvent) - room:moveCardTo(cardUseEvent.card, Card.Processing, nil, fk.ReasonUse) if cardUseEvent.card.skill then cardUseEvent.card.skill:onUse(room, cardUseEvent) end + sendCardEmotionAndLog(room, cardUseEvent) + if logic:trigger(fk.PreCardUse, room:getPlayerById(cardUseEvent.from), cardUseEvent) then logic:breakEvent() end diff --git a/lua/server/gameevent.lua b/lua/server/gameevent.lua index 40a24388..23304f8f 100644 --- a/lua/server/gameevent.lua +++ b/lua/server/gameevent.lua @@ -179,8 +179,7 @@ function GameEvent:clear() if err == false then -- handle error, then break if not string.find(yield_result, "__manuallyBreak") then - fk.qCritical(yield_result) - print(debug.traceback(clear_co)) + fk.qCritical(yield_result .. "\n" .. debug.traceback(clear_co)) end coroutine.close(clear_co) break @@ -294,8 +293,7 @@ function GameEvent:exec() if err == false then -- handle error, then break if not string.find(yield_result, "__manuallyBreak") then - fk.qCritical(yield_result) - print(debug.traceback(co)) + fk.qCritical(yield_result .. "\n" .. debug.traceback(co)) end self.interrupted = true self:clear() diff --git a/lua/server/room.lua b/lua/server/room.lua index cb3d4055..8fa2fffe 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -127,8 +127,7 @@ function Room:resume() -- handle error if ret == false then - fk.qCritical(err_msg) - print(debug.traceback(main_co)) + fk.qCritical(err_msg .. "\n" .. debug.traceback(main_co)) goto GAME_OVER end @@ -968,7 +967,7 @@ end ---@param skill_name nil @ 技能名 ---@param index integer | nil @ 语音编号,默认为-1(也就是随机播放) function Room:broadcastSkillInvoke(skill_name, index) - print 'Room:broadcastSkillInvoke deprecated; use SPlayer:broadcastSkillInvoke' + fk.qCritical 'Room:broadcastSkillInvoke deprecated; use SPlayer:broadcastSkillInvoke' index = index or -1 self:sendLogEvent("PlaySkillSound", { name = skill_name, diff --git a/lua/server/scheduler.lua b/lua/server/scheduler.lua index b8014ff6..d2c04e77 100644 --- a/lua/server/scheduler.lua +++ b/lua/server/scheduler.lua @@ -34,8 +34,7 @@ local requestRoom = setmetatable({ resume = function(self) local err, msg = coroutine.resume(requestCo, self) if err == false then - fk.qCritical(msg) - print(debug.traceback(requestCo)) + fk.qCritical(msg .. "\n" .. debug.traceback(requestCo)) end return nil, 0 end, diff --git a/src/server/shell.cpp b/src/server/shell.cpp index b6f5c552..9b2ee0ca 100644 --- a/src/server/shell.cpp +++ b/src/server/shell.cpp @@ -9,6 +9,7 @@ #include #include #include +#include static void sigintHandler(int) { fprintf(stderr, "\n"); @@ -81,7 +82,10 @@ void Shell::lsrCommand(QStringList &) { } qInfo("Current %lld running rooms are:", ServerInstance->rooms.size()); foreach (auto room, ServerInstance->rooms) { - qInfo() << room->getId() << "," << room->getName(); + auto config = QJsonDocument::fromJson(room->getSettings()); + auto pw = config["password"].toString(); + qInfo() << room->getId() << "," << (pw.isEmpty() ? QString("%1").arg(room->getName()) : + QString("%1 [pw=%2]").arg(room->getName()).arg(pw)); } }