diff --git a/Fk/Base/Config.qml b/Fk/Base/Config.qml index c10fc2a151683856055b265cecd0b21446213f17..63d489c7824d3131fca4e47af73c9ac642991c69 100644 --- a/Fk/Base/Config.qml +++ b/Fk/Base/Config.qml @@ -67,6 +67,7 @@ QtObject { property string serverMotd: "" property list serverHiddenPacks: [] property bool serverEnableBot: true + property string headerName: "" property int roomCapacity: 0 property int roomTimeout: 0 //property int roomChooseGeneralTimeout: 0 diff --git a/Fk/Components/LunarLTK/Dashboard.qml b/Fk/Components/LunarLTK/Dashboard.qml index 42ee2cc591c0de4909b00409e176cc2f992a2b95..8e13d1de3973eb7c6ab676e57605d10a775130f3 100644 --- a/Fk/Components/LunarLTK/Dashboard.qml +++ b/Fk/Components/LunarLTK/Dashboard.qml @@ -155,7 +155,6 @@ RowLayout { } }); uiUpdate["_new"]?.forEach(dat => { - const sortable = Lua.call("CanSortHandcards", Self.id); if (dat.type == "CardItem") { const data = Lua.call("GetCardData", dat.data.id); data.x = parentPos.x; @@ -168,7 +167,6 @@ RowLayout { if (vcard) { card.virt_name = vcard.name; } - card.draggable = sortable; handcardAreaItem.add(card); } }); diff --git a/Fk/Pages/Common/PackageDownload.qml b/Fk/Pages/Common/PackageDownload.qml index f54a1f027701eec42f25b27544e2d80fae1fd1d0..916be2044b51b83c3ff75f2c032a677ba6f716b1 100644 --- a/Fk/Pages/Common/PackageDownload.qml +++ b/Fk/Pages/Common/PackageDownload.qml @@ -8,10 +8,12 @@ W.PageBase { property bool needRestart: false + property var hasHandlerModel: [] function setPackages(summary) { const localSummary = JSON.parse(Pacman.getPackSummary()); packageModel.clear(); + hasHandlerModel = []; for (let data of summary) { data.oldHash = localSummary.find(d => d.name === data.name)?.hash ?? "(nil)"; packageModel.append(data); @@ -41,6 +43,9 @@ W.PageBase { } } + if (hasHandlerModel.length > 0) { + repairButton.visible = true; + } backButton.visible = true; } @@ -62,8 +67,14 @@ W.PageBase { function setDownloadError(sender, msg) { const item = packageRepeater.itemAt(root.currentPackageIndex); - item.subTitle = " " + msg; item.hasError = true; + item.subTitle = " " + msg; + if (item.myName !== "freekill-core") { + [item.errorMsg, item.errorHandler] = fastRepair(msg); + if (item.errorHandler !== null) { + root.hasHandlerModel.push(root.currentPackageIndex); + } + } } function showTransferProgress(sender, data) { @@ -104,6 +115,8 @@ W.PageBase { W.ActionRow { property string myName: name property bool hasError: false + property string errorMsg: "" + property var errorHandler: null title: { const old = oldHash === "(nil)" ? oldHash : oldHash.substring(0, 8); @@ -114,6 +127,9 @@ W.PageBase { } else { ret += `${old} -> ${now}`; } + if (errorMsg !== "") { + ret += ` (错误: ${errorMsg})`; + } return ret; } subTitle: "⏰ Please wait..." @@ -125,6 +141,17 @@ W.PageBase { border.width: 4 visible: root.currentPackageIndex === index } + + W.ButtonContent { + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + text: "修复" + visible: parent.errorHandler !== null + onClicked: {; + parent.errorHandler(parent.myName, index); + root.hasHandlerModel.remove(index); + } + } } } } @@ -169,6 +196,24 @@ W.PageBase { } } } + + W.ButtonContent { + id: repairButton + visible: false + text: "修复全部内容并退出" + anchors.bottom: backButton.top + anchors.bottomMargin: 8 + width: parent.width - 16 + x: 8 + + onClicked: { + for (let idx of root.hasHandlerModel) { + const it = packageRepeater.itemAt(idx); + it.errorHandler(it.myName, idx); + } + App.quitPage(); + } + } } Component.onCompleted: { @@ -177,4 +222,27 @@ W.PageBase { addCallback(Command.PackageDownloadError, setDownloadError); addCallback(Command.PackageTransferProgress, showTransferProgress); } + + function fastRepair(errorMsg) { + if (/Workspace is dirty/g.exec(errorMsg)) { + return ["工作区有未保存的人为修改", (packageName, index) => { + console.log("Uninstalling " + packageName); + Pacman.removePack(packageName); + // updatePackageList(); + packageModel.remove(index); + }]; + }else if (/exists and is not an empty directory/g.exec(errorMsg)) { + return ["目录已存在且非空", null]; + } else if (/no such file or directory/g.exec(errorMsg)) { + return ["文件或目录不存在", null]; + } else if (/authentiation required but no callback is set/g.exec(errorMsg)) { + return ["无法访问仓库URL", null]; + } else if (/no match for id/g.exec(errorMsg)) { + return ["服务器所需的版本不存在", null]; + } else if (/Http/g.exec(errorMsg)) { + return ["网络错误", null]; + } + + return [null, null]; + } } diff --git a/Fk/Pages/Common/RoomPage.qml b/Fk/Pages/Common/RoomPage.qml index 7b0df68cf9b45f429e81e91e1bfd1789352cab0f..903655ed5c462205379b14e97a49d576f4571672 100644 --- a/Fk/Pages/Common/RoomPage.qml +++ b/Fk/Pages/Common/RoomPage.qml @@ -62,7 +62,7 @@ Item { Text { anchors.centerIn: parent - text: Lua.tr("Click The Game Scene to back") + text: Config.headerName !== "" ? Config.headerName : Lua.tr("Click The Game Scene to back") font.pixelSize: 16 } } diff --git a/Fk/Pages/Lobby/Lobby.qml b/Fk/Pages/Lobby/Lobby.qml index 63ef806f4935cfd27c903f4bccece0091b8159f1..776b3d9a6502df7b1c5709de15054d5343356490 100644 --- a/Fk/Pages/Lobby/Lobby.qml +++ b/Fk/Pages/Lobby/Lobby.qml @@ -321,6 +321,11 @@ W.PageBase { const roomSettings = data[2]; // Config.enableFreeAssign = roomSettings.enableFreeAssign; Config.heg = roomSettings.gameMode.includes('heg_mode'); + let displayName = roomSettings.roomName; + if (roomSettings.roomId !== undefined) { + displayName += "[{id}]".replace("{id}", roomSettings.roomId); + } + Config.headerName = Lua.tr("Current room: %1").arg(displayName); App.enterNewPage("Fk.Pages.Common", "RoomPage", { gameComponent: Qt.createComponent("Fk.Pages.Common", "WaitingRoom"), }); diff --git a/Fk/Pages/Lobby/RoomGeneralSettings.qml b/Fk/Pages/Lobby/RoomGeneralSettings.qml index 958658222721789727c3ff23bb9da8526a38cdac..326b51b1da257dd4eb69ba3e083c0afbf21a433f 100644 --- a/Fk/Pages/Lobby/RoomGeneralSettings.qml +++ b/Fk/Pages/Lobby/RoomGeneralSettings.qml @@ -134,6 +134,7 @@ Item { roomName.text, playerNum.value, Config.preferredTimeout, { gameMode, + roomName: roomName.text, password: roomPassword.text, _game: boardgameConf, _mode: gameModeConf, diff --git a/Fk/Pages/LunarLTK/RoomLogic.js b/Fk/Pages/LunarLTK/RoomLogic.js index befafcc5c3e03dc61863b995b6e97ab0a7a55219..73c76cc158281174b433ed9a835dc45c4cb5b453 100644 --- a/Fk/Pages/LunarLTK/RoomLogic.js +++ b/Fk/Pages/LunarLTK/RoomLogic.js @@ -666,14 +666,12 @@ callbacks["PropertyUpdate"] = (sender, data) => { } callbacks["UpdateHandcard"] = (sender) => { - const sortable = Lua.call("CanSortHandcards", Self.id); - roomScene.dashboard.handcardArea.cards.forEach((v) => { const id = v.cid; if (Lua.evaluate(`ClientInstance:getCardArea(${id}) == Card.PlayerHand and ClientInstance:getCardOwner(${id}) == Self`)) { v.setData(Lua.call("GetCardData", id, true)); v.known = Lua.call("CardVisibility", id); - v.draggable = sortable; + v.draggable = true; } }); } diff --git a/lua/client/i18n/zh_CN.lua b/lua/client/i18n/zh_CN.lua index 60e07fb7be020217dce2209bd88d6066509295fa..c1c3fd036daf4b0f11f28f151d882a663a3b4713 100644 --- a/lua/client/i18n/zh_CN.lua +++ b/lua/client/i18n/zh_CN.lua @@ -305,6 +305,7 @@ FreeKill使用的是libgit2的C API,与此同时使用Git完成拓展包的下 ["Copy Audio Text"] = "复制语音文本", ["$WelcomeToLobby"] = "欢迎进入新月杀游戏大厅!", + ["Current room: %1"] = "当前房间:%1", ["GameMode"] = "游戏模式:", ["LuckCardNum"] = "手气卡次数:", ["ResponseTime"] = "出手时间:",