重组qml文件,使用qmldir文件实现模块化
This commit is contained in:
notify 2023-05-19 10:08:36 +08:00 committed by GitHub
parent 0d709d6a73
commit 2acec5f20a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
85 changed files with 166 additions and 356 deletions

View File

@ -65,7 +65,7 @@ jobs:
run: | run: |
mkdir FreeKill-release mkdir FreeKill-release
cp build/FreeKill.exe FreeKill-release cp build/FreeKill.exe FreeKill-release
cp -r qml FreeKill-release cp -r qml Fk FreeKill-release
cd FreeKill-release cd FreeKill-release
windeployqt FreeKill.exe windeployqt FreeKill.exe
cp -r ../.git . cp -r ../.git .

View File

@ -3,7 +3,7 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import ".." import Fk.RoomElement
Item { Item {
id: root id: root

View File

@ -3,7 +3,7 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import ".." import Fk.RoomElement
Item { Item {
id: root id: root

6
Fk/Cheat/qmldir Normal file
View File

@ -0,0 +1,6 @@
module Fk.Cheat
CardDetail 1.0 CardDetail.qml
FreeAssign 1.0 FreeAssign.qml
GeneralDetail 1.0 GeneralDetail.qml
PlayerDetail 1.0 PlayerDetail.qml
SameConvert 1.0 SameConvert.qml

3
Fk/Common/qmldir Normal file
View File

@ -0,0 +1,3 @@
module Fk.Common
ChatBox 1.0 ChatBox.qml
LogEdit 1.0 LogEdit.qml

View File

@ -2,7 +2,7 @@
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import "../skin-bank.js" as SkinBank import Fk
Item { Item {
id: root id: root
@ -49,7 +49,7 @@ Item {
TapHandler { TapHandler {
onTapped: { onTapped: {
lobby_dialog.source = "LobbyElement/EditProfile.qml"; lobby_dialog.sourceComponent = Qt.createComponent("Fk.LobbyElement", "EditProfile");
lobby_drawer.open(); lobby_drawer.open();
} }
} }

9
Fk/LobbyElement/qmldir Normal file
View File

@ -0,0 +1,9 @@
module Fk.LobbyElement
AudioSetting 1.0 AudioSetting.qml
BGSetting 1.0 BGSetting.qml
CreateRoom 1.0 CreateRoom.qml
EditProfile 1.0 EditProfile.qml
PersonalSettings 1.0 PersonalSettings.qml
RoomGeneralSettings 1.0 RoomGeneralSettings.qml
RoomPackageSettings 1.0 RoomPackageSettings.qml
UserInfo 1.0 UserInfo.qml

View File

@ -3,7 +3,7 @@
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Controls import QtQuick.Controls
import "RoomElement" import Fk.RoomElement
Item { Item {
id: root id: root

View File

@ -3,7 +3,7 @@
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Controls import QtQuick.Controls
import "RoomElement" import Fk.RoomElement
Item { Item {
id: root id: root

View File

@ -4,8 +4,8 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Window import QtQuick.Window
import QtQuick.Layouts import QtQuick.Layouts
import "LobbyElement" import Fk.LobbyElement
import "Common" import Fk.Common
import "Logic.js" as Logic import "Logic.js" as Logic
Item { Item {
@ -154,7 +154,7 @@ Item {
icon.name: "media-playback-start" icon.name: "media-playback-start"
text: Backend.translate("Create Room") text: Backend.translate("Create Room")
onClicked: { onClicked: {
lobby_dialog.source = "LobbyElement/CreateRoom.qml"; lobby_dialog.sourceComponent = Qt.createComponent("Fk.LobbyElement", "CreateRoom");
lobby_drawer.open(); lobby_drawer.open();
config.observing = false; config.observing = false;
} }
@ -225,10 +225,11 @@ Item {
if (item === null) if (item === null)
return; return;
item.finished.connect(() => { item.finished.connect(() => {
source = ""; sourceComponent = undefined;
lobby_drawer.close(); lobby_drawer.close();
}); });
} }
onSourceComponentChanged: sourceChanged();
} }
} }
@ -289,4 +290,3 @@ Item {
toast.show(Backend.translate("$WelcomeToLobby")); toast.show(Backend.translate("$WelcomeToLobby"));
} }
} }

View File

@ -71,4 +71,3 @@ Item {
} }
} }
} }

View File

@ -4,10 +4,10 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import QtMultimedia import QtMultimedia
import "Common" import Fk
import "RoomElement" import Fk.Common
import Fk.RoomElement
import "RoomLogic.js" as Logic import "RoomLogic.js" as Logic
import "skin-bank.js" as SkinBank
Item { Item {
@ -100,7 +100,7 @@ Item {
from: "*"; to: "notactive" from: "*"; to: "notactive"
ScriptAction { ScriptAction {
script: { script: {
skillInteraction.source = ""; skillInteraction.sourceComponent = undefined;
promptText = ""; promptText = "";
progress.visible = false; progress.visible = false;
okCancel.visible = false; okCancel.visible = false;
@ -128,7 +128,7 @@ Item {
from: "*"; to: "playing" from: "*"; to: "playing"
ScriptAction { ScriptAction {
script: { script: {
skillInteraction.source = ""; skillInteraction.sourceComponent = undefined;
dashboard.enableCards(); dashboard.enableCards();
dashboard.enableSkills(); dashboard.enableSkills();
progress.visible = true; progress.visible = true;
@ -143,7 +143,7 @@ Item {
from: "*"; to: "responding" from: "*"; to: "responding"
ScriptAction { ScriptAction {
script: { script: {
skillInteraction.source = ""; skillInteraction.sourceComponent = undefined;
dashboard.enableCards(responding_card); dashboard.enableCards(responding_card);
dashboard.enableSkills(responding_card, respond_play); dashboard.enableSkills(responding_card, respond_play);
autoPending = false; autoPending = false;
@ -157,7 +157,7 @@ Item {
from: "*"; to: "replying" from: "*"; to: "replying"
ScriptAction { ScriptAction {
script: { script: {
skillInteraction.source = ""; skillInteraction.sourceComponent = undefined;
dashboard.disableAllCards(); dashboard.disableAllCards();
dashboard.disableSkills(); dashboard.disableSkills();
progress.visible = true; progress.visible = true;
@ -435,7 +435,7 @@ Item {
if (item === null) if (item === null)
return; return;
item.finished.connect(function(){ item.finished.connect(function(){
source = ""; sourceComponent = undefined;
}); });
item.widthChanged.connect(function(){ item.widthChanged.connect(function(){
popupBox.moveToCenter(); popupBox.moveToCenter();
@ -445,6 +445,7 @@ Item {
}); });
moveToCenter(); moveToCenter();
} }
onSourceComponentChanged: sourceChanged();
function moveToCenter() function moveToCenter()
{ {
@ -460,11 +461,12 @@ Item {
onSourceChanged: { onSourceChanged: {
if (item === null) if (item === null)
return; return;
item.finished.connect(() => source = ""); item.finished.connect(() => sourceComponent = undefined);
item.widthChanged.connect(() => manualBox.moveToCenter()); item.widthChanged.connect(() => manualBox.moveToCenter());
item.heightChanged.connect(() => manualBox.moveToCenter()); item.heightChanged.connect(() => manualBox.moveToCenter());
moveToCenter(); moveToCenter();
} }
onSourceComponentChanged: sourceChanged();
function moveToCenter() function moveToCenter()
{ {
@ -486,30 +488,30 @@ Item {
Backend.callLuaFunction("SetInteractionDataOfSkill", [skill_name, "null"]); Backend.callLuaFunction("SetInteractionDataOfSkill", [skill_name, "null"]);
switch (data.type) { switch (data.type) {
case "combo": case "combo":
skillInteraction.source = "RoomElement/SkillInteraction/SkillCombo.qml"; skillInteraction.sourceComponent = Qt.createComponent("Fk.SkillInteraction", "SkillCombo");
skillInteraction.item.skill = skill_name; skillInteraction.item.skill = skill_name;
skillInteraction.item.default_choice = data["default"]; skillInteraction.item.default_choice = data["default"];
skillInteraction.item.choices = data.choices; skillInteraction.item.choices = data.choices;
skillInteraction.item.clicked(); // skillInteraction.item.clicked();
break; break;
case "spin": case "spin":
skillInteraction.source = "RoomElement/SkillInteraction/SkillSpin.qml"; skillInteraction.sourceComponent = Qt.createComponent("Fk.SkillInteraction", "SkillSpin");
skillInteraction.item.skill = skill_name; skillInteraction.item.skill = skill_name;
skillInteraction.item.from = data.from; skillInteraction.item.from = data.from;
skillInteraction.item.to = data.to; skillInteraction.item.to = data.to;
break; break;
default: default:
skillInteraction.source = ""; skillInteraction.sourceComponent = undefined;
break; break;
} }
} else { } else {
skillInteraction.source = ""; skillInteraction.sourceComponent = undefined;
} }
dashboard.startPending(skill_name); dashboard.startPending(skill_name);
cancelButton.enabled = true; cancelButton.enabled = true;
} else { } else {
skillInteraction.source = ""; skillInteraction.sourceComponent = undefined;
Logic.doCancelButton(); Logic.doCancelButton();
} }
} }
@ -582,6 +584,7 @@ Item {
cheatDrawer.close(); cheatDrawer.close();
}); });
} }
onSourceComponentChanged: sourceChanged();
} }
} }
@ -798,8 +801,8 @@ Item {
} }
} }
function startCheat(source, data) { function startCheat(type, data) {
cheatLoader.source = source; cheatLoader.sourceComponent = Qt.createComponent("Fk.Cheat", type);
cheatLoader.item.extra_data = data; cheatLoader.item.extra_data = data;
cheatDrawer.open(); cheatDrawer.open();
} }
@ -834,4 +837,3 @@ Item {
Logic.arrangePhotos(); Logic.arrangePhotos();
} }
} }

View File

@ -227,7 +227,7 @@ function setEmotion(id, emotion, isCardId) {
// TODO: set picture emotion // TODO: set picture emotion
return; return;
} }
let component = Qt.createComponent("RoomElement/PixmapAnimation.qml"); let component = Qt.createComponent("Fk.RoomElement", "PixmapAnimation");
if (component.status !== Component.Ready) if (component.status !== Component.Ready)
return; return;
@ -276,7 +276,7 @@ function changeHp(id, delta, losthp) {
} }
function doIndicate(from, tos) { function doIndicate(from, tos) {
let component = Qt.createComponent("RoomElement/IndicatorLine.qml"); let component = Qt.createComponent("Fk.RoomElement", "IndicatorLine");
if (component.status !== Component.Ready) if (component.status !== Component.Ready)
return; return;
@ -593,7 +593,7 @@ callbacks["AskForGeneral"] = function(jsonData) {
let heg = data[2]; let heg = data[2];
roomScene.promptText = Backend.translate("#AskForGeneral"); roomScene.promptText = Backend.translate("#AskForGeneral");
roomScene.state = "replying"; roomScene.state = "replying";
roomScene.popupBox.source = "RoomElement/ChooseGeneralBox.qml"; roomScene.popupBox.sourceComponent = Qt.createComponent("Fk.RoomElement", "ChooseGeneralBox");
let box = roomScene.popupBox.item; let box = roomScene.popupBox.item;
box.accepted.connect(() => { box.accepted.connect(() => {
replyToServer(JSON.stringify(box.choices)); replyToServer(JSON.stringify(box.choices));
@ -626,7 +626,7 @@ callbacks["AskForGuanxing"] = function(jsonData) {
let min_bottom_cards = data.min_bottom_cards; let min_bottom_cards = data.min_bottom_cards;
let max_bottom_cards = data.max_bottom_cards; let max_bottom_cards = data.max_bottom_cards;
roomScene.state = "replying"; roomScene.state = "replying";
roomScene.popupBox.source = "RoomElement/GuanxingBox.qml"; roomScene.popupBox.sourceComponent = Qt.createComponent("Fk.RoomElement", "GuanxingBox");
data.cards.forEach(id => { data.cards.forEach(id => {
let d = Backend.callLuaFunction("GetCardData", [id]); let d = Backend.callLuaFunction("GetCardData", [id]);
cards.push(JSON.parse(d)); cards.push(JSON.parse(d));
@ -662,7 +662,7 @@ callbacks["AskForChoice"] = function(jsonData) {
roomScene.promptText = processPrompt(prompt); roomScene.promptText = processPrompt(prompt);
} }
roomScene.state = "replying"; roomScene.state = "replying";
roomScene.popupBox.source = "RoomElement/ChoiceBox.qml"; roomScene.popupBox.sourceComponent = Qt.createComponent("Fk.RoomElement", "ChoiceBox");
let box = roomScene.popupBox.item; let box = roomScene.popupBox.item;
box.options = choices; box.options = choices;
box.skill_name = skill_name; box.skill_name = skill_name;
@ -701,7 +701,7 @@ callbacks["AskForCardChosen"] = function(jsonData) {
roomScene.promptText = Backend.translate("#AskForChooseCard") roomScene.promptText = Backend.translate("#AskForChooseCard")
.arg(Backend.translate(reason)); .arg(Backend.translate(reason));
roomScene.state = "replying"; roomScene.state = "replying";
roomScene.popupBox.source = "RoomElement/PlayerCardBox.qml"; roomScene.popupBox.sourceComponent = Qt.createComponent("Fk.RoomElement", "PlayerCardBox");
let box = roomScene.popupBox.item; let box = roomScene.popupBox.item;
box.addHandcards(handcards); box.addHandcards(handcards);
box.addEquips(equips); box.addEquips(equips);
@ -744,7 +744,7 @@ callbacks["AskForCardsChosen"] = function(jsonData) {
roomScene.promptText = Backend.translate("#AskForChooseCard") roomScene.promptText = Backend.translate("#AskForChooseCard")
.arg(Backend.translate(reason)); .arg(Backend.translate(reason));
roomScene.state = "replying"; roomScene.state = "replying";
roomScene.popupBox.source = "RoomElement/PlayerCardBox.qml"; roomScene.popupBox.sourceComponent = Qt.createComponent("Fk.RoomElement", "PlayerCardBox");
let box = roomScene.popupBox.item; let box = roomScene.popupBox.item;
box.multiChoose = true; box.multiChoose = true;
box.min = min; box.min = min;
@ -933,7 +933,7 @@ callbacks["Animate"] = function(jsonData) {
} }
case "InvokeSkill": { case "InvokeSkill": {
let id = data.player; let id = data.player;
let component = Qt.createComponent("RoomElement/SkillInvokeAnimation.qml"); let component = Qt.createComponent("Fk.RoomElement", "SkillInvokeAnimation");
if (component.status !== Component.Ready) if (component.status !== Component.Ready)
return; return;
@ -997,7 +997,7 @@ callbacks["LogEvent"] = function(jsonData) {
callbacks["GameOver"] = function(jsonData) { callbacks["GameOver"] = function(jsonData) {
roomScene.state = "notactive"; roomScene.state = "notactive";
roomScene.popupBox.source = "RoomElement/GameOverBox.qml"; roomScene.popupBox.sourceComponent = Qt.createComponent("Fk.RoomElement", "GameOverBox");
let box = roomScene.popupBox.item; let box = roomScene.popupBox.item;
box.winner = jsonData; box.winner = jsonData;
roomScene.isStarted = false; roomScene.isStarted = false;
@ -1006,7 +1006,7 @@ callbacks["GameOver"] = function(jsonData) {
callbacks["FillAG"] = (j) => { callbacks["FillAG"] = (j) => {
let data = JSON.parse(j); let data = JSON.parse(j);
let ids = data[0]; let ids = data[0];
roomScene.manualBox.source = "RoomElement/AG.qml"; roomScene.manualBox.sourceComponent = Qt.createComponent("Fk.RoomElement", "AG");
roomScene.manualBox.item.addIds(ids); roomScene.manualBox.item.addIds(ids);
} }

View File

@ -2,7 +2,7 @@
import QtQuick import QtQuick
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import "skin-bank.js" as SkinBank import Fk
Item { Item {
property alias text: labelText.text property alias text: labelText.text

12
Fk/Pages/qmldir Normal file
View File

@ -0,0 +1,12 @@
module Fk.Pages
About 1.0 About.qml
CardsOverview 1.0 CardsOverview.qml
Danmaku 1.0 Danmaku.qml
GeneralsOverview 1.0 GeneralsOverview.qml
Init 1.0 Init.qml
Lobby 1.0 Lobby.qml
MetroButton 1.0 MetroButton.qml
ModesOverview 1.0 ModesOverview.qml
PackageManage 1.0 PackageManage.qml
Room 1.0 Room.qml
TileButton 1.0 TileButton.qml

View File

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import ".." import Fk
import "../../skin-bank.js" as SkinBank import Fk.RoomElement
Item { Item {
InvisibleCardArea { InvisibleCardArea {

View File

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import ".." import Fk
import "../../skin-bank.js" as SkinBank import Fk.RoomElement
/* Layout of EquipArea: /* Layout of EquipArea:
* | Treasure | * | Treasure |
@ -124,4 +124,3 @@ Column {
return area.cards; return area.cards;
} }
} }

View File

@ -1,9 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import ".." import Fk
import "../../../util.js" as Utility import Fk.RoomElement
import "../../skin-bank.js" as SkinBank
Item { Item {
property int cid: 0 property int cid: 0

View File

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import ".." import Fk
import "../../skin-bank.js" as SkinBank import Fk.RoomElement
Column { Column {
id: root id: root
@ -83,4 +83,3 @@ Column {
} }
} }
} }

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import "../../skin-bank.js" as SkinBank import Fk
Item { Item {
id: root id: root

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import "../../skin-bank.js" as SkinBank import Fk
Image { Image {
source: SkinBank.MAGATAMA_DIR + "0" source: SkinBank.MAGATAMA_DIR + "0"
@ -57,4 +57,3 @@ Image {
anchors.centerIn: parent anchors.centerIn: parent
} }
} }

View File

@ -59,7 +59,7 @@ Item {
return; return;
// Just for using room's right drawer // Just for using room's right drawer
roomScene.startCheat("RoomElement/ViewPile.qml", { roomScene.startCheat("ViewPile", {
name: mark_name, name: mark_name,
ids: data ids: data
}); });

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import "../../skin-bank.js" as SkinBank import Fk
Image { Image {
property string value: "unknown" property string value: "unknown"

View File

@ -1,5 +1,5 @@
import QtQuick import QtQuick
import "../../skin-bank.js" as SkinBank import Fk
Image { Image {
id: root id: root

12
Fk/PhotoElement/qmldir Normal file
View File

@ -0,0 +1,12 @@
module Fk.PhotoElement
DelayedTrickArea 1.0 DelayedTrickArea.qml
EquipArea 1.0 EquipArea.qml
EquipItem 1.0 EquipItem.qml
HpBar 1.0 HpBar.qml
LimitSkillArea 1.0 LimitSkillArea.qml
LimitSkillItem 1.0 LimitSkillItem.qml
Magatama 1.0 Magatama.qml
MarkArea 1.0 MarkArea.qml
RoleComboBox 1.0 RoleComboBox.qml
Shield 1.0 Shield.qml
SpecialMarkArea 1.0 SpecialMarkArea.qml

View File

@ -78,4 +78,3 @@ Item {
} }
} }
} }

View File

@ -2,7 +2,7 @@
import QtQuick import QtQuick
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import "../skin-bank.js" as SkinBank import Fk
/* Layout of card: /* Layout of card:
* +--------+ * +--------+
@ -70,7 +70,7 @@ Item {
onRightClicked: { onRightClicked: {
if (!showDetail) return; if (!showDetail) return;
roomScene.startCheat("RoomElement/Cheat/CardDetail.qml", { card: this }); roomScene.startCheat("CardDetail", { card: this });
} }
RectangularGlow { RectangularGlow {

View File

@ -2,7 +2,7 @@
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import ".." import Fk.Pages
GraphicsBox { GraphicsBox {
property var options: [] property var options: []

View File

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import ".." import Fk
import "../skin-bank.js" as SkinBank import Fk.Pages
GraphicsBox { GraphicsBox {
property alias generalList: generalList property alias generalList: generalList
@ -91,10 +91,7 @@ GraphicsBox {
MetroButton { MetroButton {
id: convertBtn id: convertBtn
text: Backend.translate("Same General Convert") text: Backend.translate("Same General Convert")
onClicked: roomScene.startCheat( onClicked: roomScene.startCheat("SameConvert", { cards: generalList });
"RoomElement/Cheat/SameConvert.qml",
{ cards: generalList }
);
} }
MetroButton { MetroButton {
@ -112,7 +109,7 @@ GraphicsBox {
enabled: choices.length > 0 enabled: choices.length > 0
text: Backend.translate("Show General Detail") text: Backend.translate("Show General Detail")
onClicked: roomScene.startCheat( onClicked: roomScene.startCheat(
"RoomElement/Cheat/GeneralDetail.qml", "GeneralDetail",
{ generals: choices } { generals: choices }
); );
} }
@ -146,7 +143,7 @@ GraphicsBox {
onRightClicked: { onRightClicked: {
if (selectedItem.indexOf(this) === -1 && config.enableFreeAssign) if (selectedItem.indexOf(this) === -1 && config.enableFreeAssign)
roomScene.startCheat("RoomElement/Cheat/FreeAssign.qml", { card: this }); roomScene.startCheat("FreeAssign", { card: this });
} }
onReleased: { onReleased: {

View File

@ -73,7 +73,7 @@ RowLayout {
if (expanded_pile_names.indexOf(pile) !== -1) if (expanded_pile_names.indexOf(pile) !== -1)
return; return;
let component = Qt.createComponent("CardItem.qml"); let component = Qt.createComponent("Fk.RoomElement", "CardItem");
let parentPos = roomScene.mapFromItem(self, 0, 0); let parentPos = roomScene.mapFromItem(self, 0, 0);
expanded_piles[pile] = []; expanded_piles[pile] = [];

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import ".." import Fk.Pages
GraphicsBox { GraphicsBox {
property string winner: "" property string winner: ""

View File

@ -2,8 +2,8 @@
import QtQuick import QtQuick
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import "PhotoElement" import Fk
import "../skin-bank.js" as SkinBank import Fk.PhotoElement
/* Layout of general card: /* Layout of general card:
* +--------+ * +--------+

View File

@ -2,7 +2,7 @@
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import ".." import Fk.Pages
GraphicsBox { GraphicsBox {
id: root id: root

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import "../../util.js" as Utility import Fk
Item { Item {
property alias cards: cardArea.cards property alias cards: cardArea.cards

View File

@ -50,7 +50,7 @@ Item {
function remove(outputs) function remove(outputs)
{ {
let component = Qt.createComponent("CardItem.qml"); let component = Qt.createComponent("Fk.RoomElement", "CardItem");
if (component.status !== Component.Ready) if (component.status !== Component.Ready)
return []; return [];

View File

@ -1,5 +1,5 @@
import QtQuick import QtQuick
import "../skin-bank.js" as SkinBank import Fk
Item { Item {
id: root id: root

View File

@ -3,8 +3,8 @@
import QtQuick import QtQuick
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import QtQuick.Controls import QtQuick.Controls
import "PhotoElement" import Fk
import "../skin-bank.js" as SkinBank import Fk.PhotoElement
Item { Item {
id: root id: root
@ -595,6 +595,6 @@ Item {
} }
function showDetail() { function showDetail() {
roomScene.startCheat("RoomElement/Cheat/PlayerDetail.qml", { photo: this }); roomScene.startCheat("PlayerDetail", { photo: this });
} }
} }

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import "../skin-bank.js" as SkinBank import Fk
Item { Item {
property string source: "" property string source: ""

View File

@ -2,7 +2,7 @@
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import ".." import Fk.Pages
GraphicsBox { GraphicsBox {
id: root id: root

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import "../skin-bank.js" as SkinBank import Fk
Item { Item {
id: root id: root

24
Fk/RoomElement/qmldir Normal file
View File

@ -0,0 +1,24 @@
module Fk.RoomElement
AG 1.0 AG.qml
CardArea 1.0 CardArea.qml
CardItem 1.0 CardItem.qml
ChoiceBox 1.0 ChoiceBox.qml
ChooseGeneralBox 1.0 ChooseGeneralBox.qml
Dashboard 1.0 Dashboard.qml
GameOverBox 1.0 GameOverBox.qml
GeneralCardItem 1.0 GeneralCardItem.qml
GlowText 1.0 GlowText.qml
GraphicsBox 1.0 GraphicsBox.qml
GuanxingBox 1.0 GuanxingBox.qml
HandcardArea 1.0 HandcardArea.qml
IndicatorLine 1.0 IndicatorLine.qml
InvisibleCardArea 1.0 InvisibleCardArea.qml
MiscStatus 1.0 MiscStatus.qml
Photo 1.0 Photo.qml
PixmapAnimation 1.0 PixmapAnimation.qml
PlayerCardBox 1.0 PlayerCardBox.qml
SkillArea 1.0 SkillArea.qml
SkillButton 1.0 SkillButton.qml
SkillInvokeAnimation 1.0 SkillInvokeAnimation.qml
TablePile 1.0 TablePile.qml
ViewPile 1.0 ViewPile.qml

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick import QtQuick
import "../.." import Fk.Pages
MetroButton { MetroButton {
id: root id: root
@ -21,7 +21,7 @@ MetroButton {
} }
onClicked: { onClicked: {
roomScene.popupBox.source = "RoomElement/ChoiceBox.qml"; roomScene.popupBox.sourceComponent = Qt.createComponent("Fk.RoomElement", "ChoiceBox");
let box = roomScene.popupBox.item; let box = roomScene.popupBox.item;
box.options = choices; box.options = choices;
box.accepted.connect(() => { box.accepted.connect(() => {

View File

@ -0,0 +1,3 @@
module Fk.SkillInteraction
SkillCombo 1.0 SkillCombo.qml
SkillSpin 1.0 SkillSpin.qml

View File

@ -4,7 +4,7 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Window import QtQuick.Window
import "Logic.js" as Logic import "Logic.js" as Logic
import "Pages" import Fk.Pages
Window { Window {
id: realMainWin id: realMainWin
@ -45,12 +45,11 @@ Item {
id: mainStack id: mainStack
visible: !mainWindow.busy visible: !mainWindow.busy
// If error occurs during loading initialItem, the program will fall into "polish()" loop // If error occurs during loading initialItem, the program will fall into "polish()" loop
// initialItem: OS !== "Web" ? init : webinit // initialItem: init
anchors.fill: parent anchors.fill: parent
} }
Component { id: init; Init {} } Component { id: init; Init {} }
Component { id: webinit; WebInit {} }
Component { id: packageManage; PackageManage {} } Component { id: packageManage; PackageManage {} }
Component { id: lobby; Lobby {} } Component { id: lobby; Lobby {} }
Component { id: generalsOverview; GeneralsOverview {} } Component { id: generalsOverview; GeneralsOverview {} }
@ -123,73 +122,6 @@ Item {
} }
} }
// global popup. it is modal and just lower than toast
Rectangle {
id: globalPopupDim
anchors.fill: parent
color: "black"
opacity: 0
visible: !mainWindow.busy
property bool stateVisible: false
states: [
State {
when: globalPopupDim.stateVisible
PropertyChanges { target: globalPopupDim; opacity: 0.5 }
},
State {
when: !globalPopupDim.stateVisible
PropertyChanges { target: globalPopupDim; opacity: 0.0 }
}
]
transitions: Transition {
NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad }
}
}
Popup {
id: globalPopup
property string source: ""
modal: true
dim: false // cannot animate the dim
focus: true
opacity: mainWindow.busy ? 0 : 1
closePolicy: Popup.CloseOnEscape
anchors.centerIn: parent
onAboutToShow: {
globalPopupDim.stateVisible = true
}
enter: Transition {
NumberAnimation { properties: "opacity"; from: 0; to: 1 }
NumberAnimation { properties: "scale"; from: 0.4; to: 1 }
}
onAboutToHide: {
globalPopupDim.stateVisible = false
}
exit: Transition {
NumberAnimation { properties: "opacity"; from: 1; to: 0 }
NumberAnimation { properties: "scale"; from: 1; to: 0.4 }
}
Loader {
visible: !mainWindow.busy
source: globalPopup.source === "" ? "" : "GlobalPopups/" + globalPopup.source
onSourceChanged: {
if (item === null)
return;
item.finished.connect(() => {
globalPopup.close();
globalPopup.source = "";
});
}
}
}
Popup { Popup {
id: errDialog id: errDialog
property string txt: "" property string txt: ""
@ -266,7 +198,6 @@ Item {
} }
Component.onCompleted: { Component.onCompleted: {
if (OS !== "Web") {
mainStack.push(init); mainStack.push(init);
if (!Debugging) { if (!Debugging) {
splashLoader.source = "Splash.qml"; splashLoader.source = "Splash.qml";
@ -274,9 +205,6 @@ Item {
splashLoader.source = ""; splashLoader.source = "";
}); });
} }
} else {
mainStack.push(webinit);
}
if (OS !== "Android" && OS !== "Web") { if (OS !== "Android" && OS !== "Web") {
x = config.winX; x = config.winX;
y = config.winY; y = config.winY;

3
Fk/qmldir Normal file
View File

@ -0,0 +1,3 @@
module Fk
SkinBank 1.0 skin-bank.js
Utility 1.0 util.js

View File

@ -27,6 +27,7 @@ cp -r ../packages/test assets/res/packages
rm assets/res/packages/test/test.lua rm assets/res/packages/test/test.lua
cp ../packages/init.sql assets/res/packages cp ../packages/init.sql assets/res/packages
cp -r ../qml assets/res cp -r ../qml assets/res
cp -r ../Fk assets/res
mkdir assets/res/server mkdir assets/res/server
cp ../server/init.sql assets/res/server cp ../server/init.sql assets/res/server
cp ../LICENSE assets/res cp ../LICENSE assets/res

View File

@ -1,187 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
Item {
id: root
Item {
width: 960 * 0.8
height: 540 * 0.8
anchors.centerIn: parent
Item {
id: left
width: 300
height: parent.height
Image {
id: lady
width: parent.width + 20
height: parent.height
fillMode: Image.PreserveAspectFit
}
Image {
anchors.bottom: parent.bottom
anchors.bottomMargin: 12
width: parent.width
source: AppPath + "/image/widelogo"
}
}
Rectangle {
id: right
anchors.left: left.right
width: parent.width - left.width
height: parent.height
color: "#88EEEEEE"
radius: 16
ColumnLayout {
width: parent.width * 0.8
height: parent.height * 0.8
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 40
//spacing
Text {
text: qsTr("Welcome back!")
font.pixelSize: 28
Layout.alignment: Qt.AlignHCenter
}
GridLayout {
columns: 2
rowSpacing: 20
Text {
text: qsTr("Server Addr")
}
ComboBox {
id: server_addr
Layout.fillWidth: true
model: []
editable: true
onEditTextChanged: {
if (model.indexOf(editText) === -1) {
passwordEdit.text = "";
} else {
let data = config.savedPassword[editText];
screenNameEdit.text = data.username;
passwordEdit.text = data.shorten_password;
}
}
}
Text {
text: qsTr("Username")
}
TextField {
id: screenNameEdit
Layout.fillWidth: true
placeholderText: qsTr("Username")
text: ""
onTextChanged: {
passwordEdit.text = "";
let data = config.savedPassword[server_addr.editText];
if (data) {
if (text === data.username) {
passwordEdit.text = data.shorten_password;
}
}
}
}
CheckBox {
id: showPasswordCheck
text: qsTr("Show Password")
}
TextField {
id: passwordEdit
Layout.fillWidth: true
placeholderText: qsTr("Password")
text: ""
echoMode: showPasswordCheck.checked ? TextInput.Normal : TextInput.Password
passwordCharacter: "*"
}
}
Button {
text: qsTr("Join Server")
Layout.fillWidth: true
display: AbstractButton.TextBesideIcon
icon.name: "go-next"
enabled: passwordEdit.text !== ""
onClicked: {
config.serverAddr = server_addr.editText;
config.screenName = screenNameEdit.text;
config.password = passwordEdit.text;
mainWindow.busy = true;
Backend.joinServer(server_addr.editText);
}
}
Button {
Layout.fillWidth: true
text: qsTr("PackageManage")
onClicked: {
mainStack.push(packageManage);
}
}
}
Text {
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.leftMargin: 12
anchors.bottomMargin: 12
text: "FreeKill " + FkVersion
font.pixelSize: 16
font.bold: true
}
Text {
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.rightMargin: 8
anchors.bottomMargin: 8
text: qsTr("FAQ")
color: "blue"
font.pixelSize: 24
font.underline: true
TapHandler {
onTapped: {
errDialog.txt = qsTr("$LoginFAQ");
errDialog.open();
}
}
}
}
}
function downloadComplete() {
toast.show(qsTr("updated packages for md5"));
}
Component.onCompleted: {
config.loadConf();
lady.source = config.ladyImg;
server_addr.model = Object.keys(config.savedPassword);
server_addr.onModelChanged();
server_addr.currentIndex = server_addr.model.indexOf(config.lastLoginServer);
let data = config.savedPassword[config.lastLoginServer];
if (data) {
screenNameEdit.text = data.username;
passwordEdit.text = data.shorten_password;
}
}
}

View File

@ -217,6 +217,8 @@ QString calcFileMD5() {
writeDirMD5(flist, "lua", "*.lua"); writeDirMD5(flist, "lua", "*.lua");
writeDirMD5(flist, "qml", "*.qml"); writeDirMD5(flist, "qml", "*.qml");
writeDirMD5(flist, "qml", "*.js"); writeDirMD5(flist, "qml", "*.js");
writeDirMD5(flist, "Fk", "*.qml");
writeDirMD5(flist, "Fk", "*.js");
// then, return flist.txt's md5 // then, return flist.txt's md5
flist.close(); flist.close();

View File

@ -288,8 +288,10 @@ int main(int argc, char *argv[]) {
engine->rootContext()->setContextProperty( engine->rootContext()->setContextProperty(
"AppPath", QUrl::fromLocalFile(QDir::currentPath())); "AppPath", QUrl::fromLocalFile(QDir::currentPath()));
engine->addImportPath(QDir::currentPath());
// 加载完全局变量后,就再去加载 main.qml此时UI界面正式显示 // 加载完全局变量后,就再去加载 main.qml此时UI界面正式显示
engine->load("qml/main.qml"); engine->load("Fk/main.qml");
// qml 报错了就直接退出吧 // qml 报错了就直接退出吧
if (engine->rootObjects().isEmpty()) if (engine->rootObjects().isEmpty())