武将搜索+bug fix (#197)

- 武将一览新增简单的武将搜索
- bug fix
This commit is contained in:
YoumuKon 2023-06-16 23:53:44 +08:00 committed by GitHub
parent f422039b71
commit c6c51a7e2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 76 additions and 8 deletions

View File

@ -87,6 +87,7 @@ Item {
height: stack.height height: stack.height
Item { height: 6 } Item { height: 6 }
GridView { GridView {
clip: true
Layout.preferredWidth: stack.width - stack.width % 100 + 10 Layout.preferredWidth: stack.width - stack.width % 100 + 10
Layout.fillHeight: true Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter

View File

@ -36,6 +36,7 @@ Rectangle {
cellWidth: 48 cellWidth: 48
model: 50 model: 50
visible: false visible: false
clip: true
delegate: ItemDelegate { delegate: ItemDelegate {
Image { Image {
height: 32; width: 32 height: 32; width: 32

View File

@ -45,6 +45,7 @@ Item {
ListView { ListView {
anchors.fill: parent anchors.fill: parent
model: modConfig.modList model: modConfig.modList
clip: true
delegate: SwipeDelegate { delegate: SwipeDelegate {
width: root.width width: root.width
text: modelData text: modelData

View File

@ -18,6 +18,7 @@ Item {
ListView { ListView {
id: listView id: listView
clip: true
width: 130 width: 130
height: parent.height - 20 height: parent.height - 20
y: 10 y: 10
@ -50,6 +51,7 @@ Item {
GridView { GridView {
id: gridView id: gridView
clip: true
width: root.width - listView.width - cardDetail.width - 16 width: root.width - listView.width - cardDetail.width - 16
height: parent.height - 20 height: parent.height - 20
y: 10 y: 10

View File

@ -18,6 +18,7 @@ Item {
ListView { ListView {
id: listView id: listView
clip: true
width: 130 width: 130
height: parent.height - 20 height: parent.height - 20
y: 10 y: 10
@ -50,6 +51,7 @@ Item {
GridView { GridView {
id: gridView id: gridView
clip: true
width: root.width - listView.width - generalDetail.width - 16 width: root.width - listView.width - generalDetail.width - 16
height: parent.height - 20 height: parent.height - 20
y: 10 y: 10
@ -109,8 +111,14 @@ Item {
easing.type: Easing.InOutQuad easing.type: Easing.InOutQuad
} }
onFinished: { onFinished: {
gridView.model = JSON.parse(Backend.callLuaFunction("GetGenerals", if (word.text !== "") {
[listView.model.get(listView.currentIndex).name])); 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(); appearAnim.start();
} }
} }
@ -140,7 +148,7 @@ Item {
Rectangle { Rectangle {
id: generalDetail id: generalDetail
width: 310 width: 310
height: parent.height - 20 height: parent.height - searcher.height - 20
y: 10 y: 10
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 10 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 { ColumnLayout {

View File

@ -64,7 +64,7 @@ Item {
Text { Text {
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
Layout.fillWidth: true Layout.fillWidth: true
text: roomName + (hasPassword ? "(🔒)" : "") text: roomName + (hasPassword ? "(有密码)" : "")
font.pixelSize: 20 font.pixelSize: 20
} }
@ -133,6 +133,7 @@ Item {
ScrollBar.vertical: ScrollBar {} ScrollBar.vertical: ScrollBar {}
anchors.centerIn: parent anchors.centerIn: parent
delegate: roomDelegate delegate: roomDelegate
clip: true
model: roomModel model: roomModel
} }
} }

View File

@ -11,6 +11,7 @@ Item {
ListView { ListView {
id: listView id: listView
clip: true
width: parent.width * 0.2 width: parent.width * 0.2
height: parent.height height: parent.height
model: ListModel { model: ListModel {

View File

@ -74,6 +74,7 @@ Item {
ListView { ListView {
id: packageList id: packageList
clip: true
anchors.fill: parent anchors.fill: parent
model: ListModel { model: ListModel {
id: packageModel id: packageModel

View File

@ -128,7 +128,8 @@ Item {
Component.onCompleted: { Component.onCompleted: {
const data = JSON.parse(Backend.callLuaFunction("GetRoomConfig", [])); const data = JSON.parse(Backend.callLuaFunction("GetRoomConfig", []));
text = "手气卡次数:" + data.luckTime + "<br />出手时间:" + config.roomTimeout text = "手气卡次数:" + data.luckTime + "<br />出手时间:" + config.roomTimeout
+ "<br />选将框数:" + data.generalNum + "<br />选将框数:" + data.generalNum + (data.enableFreeAssign ? "<br /><font color=\"red\">可自由点将</font>" : "")
+ (data.enableDeputy ? "<br /><font color=\"red\">启用副将机制</font>" : "")
} }
} }
} }

View File

@ -444,9 +444,11 @@ function enableTargets(card) { // card: int | { skill: string, subcards: int[] }
all_photos.forEach(photo => { all_photos.forEach(photo => {
photo.state = "candidate"; photo.state = "candidate";
const id = photo.playerid; const id = photo.playerid;
const exclusived = roomScene.extra_data.exclusive_targets; if (roomScene.extra_data instanceof Object) {
if (exclusived instanceof Array) { const exclusived = roomScene.extra_data.exclusive_targets;
if (exclusived.indexOf(id) === -1) return; if (exclusived instanceof Array) {
if (exclusived.indexOf(id) === -1) return;
}
} }
const ret = JSON.parse(Backend.callLuaFunction( const ret = JSON.parse(Backend.callLuaFunction(
"CanUseCardToTarget", "CanUseCardToTarget",

View File

@ -13,6 +13,7 @@ ListView {
} }
id: root id: root
clip: true
z: Infinity z: Infinity
spacing: 5 spacing: 5

View File

@ -126,6 +126,27 @@ function GetGenerals(pack_name)
return json.encode(ret) return json.encode(ret)
end 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) function UpdatePackageEnable(pkg, enabled)
if enabled then if enabled then
table.removeOne(ClientInstance.disabled_packs, pkg) table.removeOne(ClientInstance.disabled_packs, pkg)