From c6c51a7e2de84c5ada1d5ea12df7d16ace762292 Mon Sep 17 00:00:00 2001 From: YoumuKon <38815081+YoumuKon@users.noreply.github.com> Date: Fri, 16 Jun 2023 23:53:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A6=E5=B0=86=E6=90=9C=E7=B4=A2+bug=20fix?= =?UTF-8?q?=20(#197)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 武将一览新增简单的武将搜索 - bug fix --- Fk/Cheat/FreeAssign.qml | 1 + Fk/Common/ChatBox.qml | 1 + Fk/ModMaker/ModInit.qml | 1 + Fk/Pages/CardsOverview.qml | 2 ++ Fk/Pages/GeneralsOverview.qml | 41 ++++++++++++++++++++++++++++++++--- Fk/Pages/Lobby.qml | 3 ++- Fk/Pages/ModesOverview.qml | 1 + Fk/Pages/PackageManage.qml | 1 + Fk/Pages/Room.qml | 3 ++- Fk/Pages/RoomLogic.js | 8 ++++--- Fk/ToastManager.qml | 1 + lua/client/client_util.lua | 21 ++++++++++++++++++ 12 files changed, 76 insertions(+), 8 deletions(-) diff --git a/Fk/Cheat/FreeAssign.qml b/Fk/Cheat/FreeAssign.qml index 4b41e9e6..12fd18e3 100644 --- a/Fk/Cheat/FreeAssign.qml +++ b/Fk/Cheat/FreeAssign.qml @@ -87,6 +87,7 @@ Item { height: stack.height Item { height: 6 } GridView { + clip: true Layout.preferredWidth: stack.width - stack.width % 100 + 10 Layout.fillHeight: true Layout.alignment: Qt.AlignHCenter diff --git a/Fk/Common/ChatBox.qml b/Fk/Common/ChatBox.qml index 2ddce5d7..bad08e44 100644 --- a/Fk/Common/ChatBox.qml +++ b/Fk/Common/ChatBox.qml @@ -36,6 +36,7 @@ Rectangle { cellWidth: 48 model: 50 visible: false + clip: true delegate: ItemDelegate { Image { height: 32; width: 32 diff --git a/Fk/ModMaker/ModInit.qml b/Fk/ModMaker/ModInit.qml index 7d369a61..df3f98bb 100644 --- a/Fk/ModMaker/ModInit.qml +++ b/Fk/ModMaker/ModInit.qml @@ -45,6 +45,7 @@ Item { ListView { anchors.fill: parent model: modConfig.modList + clip: true delegate: SwipeDelegate { width: root.width text: modelData diff --git a/Fk/Pages/CardsOverview.qml b/Fk/Pages/CardsOverview.qml index 6ca24b63..68ef35b9 100644 --- a/Fk/Pages/CardsOverview.qml +++ b/Fk/Pages/CardsOverview.qml @@ -18,6 +18,7 @@ Item { ListView { id: listView + clip: true width: 130 height: parent.height - 20 y: 10 @@ -50,6 +51,7 @@ Item { GridView { id: gridView + clip: true width: root.width - listView.width - cardDetail.width - 16 height: parent.height - 20 y: 10 diff --git a/Fk/Pages/GeneralsOverview.qml b/Fk/Pages/GeneralsOverview.qml index c41f05f0..98e30390 100644 --- a/Fk/Pages/GeneralsOverview.qml +++ b/Fk/Pages/GeneralsOverview.qml @@ -18,6 +18,7 @@ Item { ListView { id: listView + clip: true width: 130 height: parent.height - 20 y: 10 @@ -50,6 +51,7 @@ Item { GridView { id: gridView + clip: true width: root.width - listView.width - generalDetail.width - 16 height: parent.height - 20 y: 10 @@ -109,8 +111,14 @@ Item { easing.type: Easing.InOutQuad } onFinished: { - gridView.model = JSON.parse(Backend.callLuaFunction("GetGenerals", - [listView.model.get(listView.currentIndex).name])); + if (word.text !== "") { + gridView.model = JSON.parse(Backend.callLuaFunction("SearchAllGenerals", + [word.text])); + } else { + gridView.model = JSON.parse(Backend.callLuaFunction("SearchGenerals", + [listView.model.get(listView.currentIndex).name, word.text])); + } + word.text = ""; appearAnim.start(); } } @@ -140,7 +148,7 @@ Item { Rectangle { id: generalDetail width: 310 - height: parent.height - 20 + height: parent.height - searcher.height - 20 y: 10 anchors.right: parent.right anchors.rightMargin: 10 @@ -282,6 +290,33 @@ Item { } } } + Rectangle { + id: searcher + width: parent.width + height: childrenRect.height + color: "snow" + opacity: 0.75 + anchors.top: parent.bottom + radius: 8 + + RowLayout { + width: parent.width + TextField { + id: word + Layout.fillWidth: true + clip: true + } + + Button { + text: qsTr("Search") + enabled: word.text !== "" + onClicked: { + listView.currentIndex = 0; + vanishAnim.start(); + } + } + } + } } ColumnLayout { diff --git a/Fk/Pages/Lobby.qml b/Fk/Pages/Lobby.qml index 810576a0..a0afee2d 100644 --- a/Fk/Pages/Lobby.qml +++ b/Fk/Pages/Lobby.qml @@ -64,7 +64,7 @@ Item { Text { horizontalAlignment: Text.AlignLeft Layout.fillWidth: true - text: roomName + (hasPassword ? "(🔒)" : "") + text: roomName + (hasPassword ? "(有密码)" : "") font.pixelSize: 20 } @@ -133,6 +133,7 @@ Item { ScrollBar.vertical: ScrollBar {} anchors.centerIn: parent delegate: roomDelegate + clip: true model: roomModel } } diff --git a/Fk/Pages/ModesOverview.qml b/Fk/Pages/ModesOverview.qml index 74ec3728..bd8813fd 100644 --- a/Fk/Pages/ModesOverview.qml +++ b/Fk/Pages/ModesOverview.qml @@ -11,6 +11,7 @@ Item { ListView { id: listView + clip: true width: parent.width * 0.2 height: parent.height model: ListModel { diff --git a/Fk/Pages/PackageManage.qml b/Fk/Pages/PackageManage.qml index c093c88e..39b53abc 100644 --- a/Fk/Pages/PackageManage.qml +++ b/Fk/Pages/PackageManage.qml @@ -74,6 +74,7 @@ Item { ListView { id: packageList + clip: true anchors.fill: parent model: ListModel { id: packageModel diff --git a/Fk/Pages/Room.qml b/Fk/Pages/Room.qml index 51f46825..91562eca 100644 --- a/Fk/Pages/Room.qml +++ b/Fk/Pages/Room.qml @@ -128,7 +128,8 @@ Item { Component.onCompleted: { const data = JSON.parse(Backend.callLuaFunction("GetRoomConfig", [])); text = "手气卡次数:" + data.luckTime + "
出手时间:" + config.roomTimeout - + "
选将框数:" + data.generalNum + + "
选将框数:" + data.generalNum + (data.enableFreeAssign ? "
可自由点将" : "") + + (data.enableDeputy ? "
启用副将机制" : "") } } } diff --git a/Fk/Pages/RoomLogic.js b/Fk/Pages/RoomLogic.js index d155ec54..544524db 100644 --- a/Fk/Pages/RoomLogic.js +++ b/Fk/Pages/RoomLogic.js @@ -444,9 +444,11 @@ function enableTargets(card) { // card: int | { skill: string, subcards: int[] } all_photos.forEach(photo => { photo.state = "candidate"; const id = photo.playerid; - const exclusived = roomScene.extra_data.exclusive_targets; - if (exclusived instanceof Array) { - if (exclusived.indexOf(id) === -1) return; + if (roomScene.extra_data instanceof Object) { + const exclusived = roomScene.extra_data.exclusive_targets; + if (exclusived instanceof Array) { + if (exclusived.indexOf(id) === -1) return; + } } const ret = JSON.parse(Backend.callLuaFunction( "CanUseCardToTarget", diff --git a/Fk/ToastManager.qml b/Fk/ToastManager.qml index 7c59cd0f..3649c42a 100644 --- a/Fk/ToastManager.qml +++ b/Fk/ToastManager.qml @@ -13,6 +13,7 @@ ListView { } id: root + clip: true z: Infinity spacing: 5 diff --git a/lua/client/client_util.lua b/lua/client/client_util.lua index 99d4ffca..d1fe0383 100644 --- a/lua/client/client_util.lua +++ b/lua/client/client_util.lua @@ -126,6 +126,27 @@ function GetGenerals(pack_name) return json.encode(ret) end +function SearchAllGenerals(word) + local ret = {} + for _, name in ipairs(Fk.package_names) do + if Fk.packages[name].type == Package.GeneralPack then + table.insertTable(ret, json.decode(SearchGenerals(name, word))) + end + end + return json.encode(ret) +end + +function SearchGenerals(pack_name, word) + local ret = {} + if word == "" then return GetGenerals(pack_name) end + for _, g in ipairs(Fk.packages[pack_name].generals) do + if not g.total_hidden and string.find(Fk:translate(g.name), word) then + table.insert(ret, g.name) + end + end + return json.encode(ret) +end + function UpdatePackageEnable(pkg, enabled) if enabled then table.removeOne(ClientInstance.disabled_packs, pkg)