武将搜索+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
Item { height: 6 }
GridView {
clip: true
Layout.preferredWidth: stack.width - stack.width % 100 + 10
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter

View File

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

View File

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

View File

@ -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

View File

@ -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 {

View File

@ -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
}
}

View File

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

View File

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

View File

@ -128,7 +128,8 @@ Item {
Component.onCompleted: {
const data = JSON.parse(Backend.callLuaFunction("GetRoomConfig", []));
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,10 +444,12 @@ function enableTargets(card) { // card: int | { skill: string, subcards: int[] }
all_photos.forEach(photo => {
photo.state = "candidate";
const id = photo.playerid;
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",
[card, id, selected_targets]

View File

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

View File

@ -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)