diff --git a/lua/client/client.lua b/lua/client/client.lua index 710fd98d..f5d431e7 100644 --- a/lua/client/client.lua +++ b/lua/client/client.lua @@ -205,6 +205,7 @@ fk.client_callback["EnterRoom"] = function(jsonData) local data = json.decode(jsonData)[3] Fk.disabled_packs = data.disabledPack + Fk.disabled_generals = data.disabledGenerals ClientInstance:notifyUI("EnterRoom", jsonData) end diff --git a/lua/client/i18n/zh_CN.lua b/lua/client/i18n/zh_CN.lua index b92b61a3..f6100f03 100644 --- a/lua/client/i18n/zh_CN.lua +++ b/lua/client/i18n/zh_CN.lua @@ -116,6 +116,8 @@ FreeKill使用的是libgit2的C API,与此同时使用Git完成拓展包的下 ["Cancel"] = "取消", ["End"] = "结束", ["Quit"] = "退出", + ["BanGeneral"] = "禁将", + ["ResumeGeneral"] = "解禁", ["$WelcomeToLobby"] = "欢迎进入FreeKill游戏大厅!", diff --git a/lua/core/engine.lua b/lua/core/engine.lua index 006b474d..e8d3c927 100644 --- a/lua/core/engine.lua +++ b/lua/core/engine.lua @@ -50,6 +50,7 @@ function Engine:initialize() self.translations = {} -- srcText --> translated self.game_modes = {} self.disabled_packs = {} + self.disabled_generals = {} self.kingdoms = {} self:loadPackages() @@ -213,8 +214,9 @@ function Engine:getSameGenerals(name) local tName = tmp[#tmp] local ret = self.same_generals[tName] or {} return table.filter(ret, function(g) - return g ~= name and self.generals[g] ~= nil and not - table.contains(self.disabled_packs, self.generals[g].package.name) + return g ~= name and self.generals[g] ~= nil and + not table.contains(self.disabled_packs, self.generals[g].package.name) and + not table.contains(self.disabled_generals, g) end) end @@ -334,7 +336,7 @@ function Engine:getAllGenerals(except) local result = {} for _, general in pairs(self.generals) do if not (except and table.contains(except, general)) then - if not table.contains(self.disabled_packs, general.package.name) then + if not table.contains(self.disabled_packs, general.package.name) and not table.contains(self.disabled_generals, general.name) then table.insert(result, general) end end diff --git a/lua/server/room.lua b/lua/server/room.lua index c81dedc2..cd021851 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -67,6 +67,7 @@ function Room:initialize(_room) Room.initialize(self, _room) -- clear old data self.settings = json.decode(_room:settings()) Fk.disabled_packs = self.settings.disabledPack + Fk.disabled_generals = self.settings.disabledGenerals local main_co = coroutine.create(function() self:run() end) diff --git a/qml/Config.qml b/qml/Config.qml index edb5f6f1..e51b21e0 100644 --- a/qml/Config.qml +++ b/qml/Config.qml @@ -22,6 +22,7 @@ QtObject { property string ladyImg property real bgmVolume property bool disableMsgAudio + property var disabledGenerals: [] property int preferredTimeout @@ -59,6 +60,7 @@ QtObject { bgmVolume = conf.bgmVolume ?? 50.; disableMsgAudio = conf.disableMsgAudio ?? false; preferredTimeout = conf.preferredTimeout ?? 15; + disabledGenerals = conf.disabledGenerals ?? []; } function saveConf() { @@ -81,6 +83,7 @@ QtObject { conf.bgmVolume = bgmVolume; conf.disableMsgAudio = disableMsgAudio; conf.preferredTimeout = preferredTimeout; + conf.disabledGenerals = disabledGenerals; Backend.saveConf(JSON.stringify(conf, undefined, 2)); } diff --git a/qml/Pages/GeneralsOverview.qml b/qml/Pages/GeneralsOverview.qml index 3b69b0a1..6e5d27dc 100644 --- a/qml/Pages/GeneralsOverview.qml +++ b/qml/Pages/GeneralsOverview.qml @@ -65,7 +65,29 @@ Item { generalText.clear(); generalDetail.general = modelData; generalDetail.updateGeneral(); - // generalDetail.open(); + // generalDetail.open(); + } + + Rectangle { + anchors.fill: parent + color: "black" + opacity: config.disabledGenerals.includes(modelData) ? 0.7 : 0 + Behavior on opacity { + NumberAnimation {} + } + } + + GlowText { + visible: config.disabledGenerals.includes(modelData) + text: '禁' + anchors.centerIn: parent + font.family: fontLi2.name + color: "#E4D5A0" + font.pixelSize: 36 + font.weight: Font.Medium + glow.color: "black" + glow.spread: 0.3 + glow.radius: 5 } } } @@ -172,11 +194,40 @@ Item { } } - Button { - text: Backend.translate("Quit") + ColumnLayout { anchors.right: parent.right - onClicked: { - mainStack.pop(); + Button { + text: Backend.translate("Quit") + onClicked: { + mainStack.pop(); + config.saveConf(); + } + } + + Button { + id: banButton + text: Backend.translate(config.disabledGenerals.includes(detailGeneralCard.name) ? 'ResumeGeneral' : 'BanGeneral') + visible: detailGeneralCard.name + onClicked: { + const { disabledGenerals } = config; + const { name } = detailGeneralCard; + + if (banButton.text === Backend.translate('ResumeGeneral')) { + const deleteIndex = disabledGenerals.findIndex((general) => general === name); + if (deleteIndex === -1) { + return; + } + + disabledGenerals.splice(deleteIndex, 1); + } else { + if (disabledGenerals.includes(name)) { + return; + } + + disabledGenerals.push(name); + } + config.disabledGeneralsChanged(); + } } } diff --git a/qml/Pages/Lobby.qml b/qml/Pages/Lobby.qml index a35d8a19..5ceccd46 100644 --- a/qml/Pages/Lobby.qml +++ b/qml/Pages/Lobby.qml @@ -11,6 +11,38 @@ import "Logic.js" as Logic Item { id: root property alias roomModel: roomModel + + Rectangle { + width: parent.width / 2 - roomListLayout.width / 2 + height: parent.height * 0.7 + anchors.top: exitButton.bottom + anchors.bottom: createRoomButton.top + anchors.right: parent.right + anchors.rightMargin: 20 + color: "#88EEEEEE" + radius: 6 + + Flickable { + id: flickableContainer + ScrollBar.vertical: ScrollBar {} + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: 10 + flickableDirection: Flickable.VerticalFlick + width: parent.width - 10 + height: parent.height - 10 + contentWidth: flickableContainer.width + contentHeight: flickableContainer.height + clip: true + + Text { + anchors.fill: parent + wrapMode: TextEdit.WrapAnywhere + text: '