小修复&Qml美化 (#308)

- 修复了虚拟牌点数相加的bug
- 修复cleaner出错直接爆炸
- QML的代码将宽度控制到80以内
This commit is contained in:
notify 2024-01-25 03:23:29 +08:00 committed by GitHub
parent 21e4c65204
commit be03b04ef0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
83 changed files with 914 additions and 808 deletions

View File

@ -46,7 +46,8 @@ Item {
}
ScriptAction {
script: Backend.playSound("./audio/system/fly" + (Math.floor(Math.random() * 2) + 1));
script: Backend.playSound("./audio/system/fly" +
(Math.floor(Math.random() * 2) + 1));
}
ParallelAnimation {
@ -91,7 +92,8 @@ Item {
}
ScriptAction {
script: Backend.playSound("./audio/system/egg" + (Math.floor(Math.random() * 2) + 1));
script: Backend.playSound("./audio/system/egg" +
(Math.floor(Math.random() * 2) + 1));
}
ParallelAnimation {

View File

@ -43,7 +43,8 @@ Item {
id: pointToAnimation
running: false
ScriptAction {
script: Backend.playSound("./audio/system/fly" + (Math.floor(Math.random() * 2) + 1));
script: Backend.playSound("./audio/system/fly" +
(Math.floor(Math.random() * 2) + 1));
}
ParallelAnimation {
@ -80,7 +81,8 @@ Item {
}
ScriptAction {
script: Backend.playSound("./audio/system/flower" + (Math.floor(Math.random() * 2) + 1));
script: Backend.playSound("./audio/system/flower" +
(Math.floor(Math.random() * 2) + 1));
}
ParallelAnimation {

View File

@ -46,7 +46,8 @@ Item {
}
ScriptAction {
script: Backend.playSound("./audio/system/fly" + (Math.floor(Math.random() * 2) + 1));
script: Backend.playSound("./audio/system/fly" +
(Math.floor(Math.random() * 2) + 1));
}
ParallelAnimation {
@ -91,7 +92,8 @@ Item {
}
ScriptAction {
script: Backend.playSound("./audio/system/egg" + (Math.floor(Math.random() * 2) + 1));
script: Backend.playSound("./audio/system/egg" +
(Math.floor(Math.random() * 2) + 1));
}
ParallelAnimation {

View File

@ -64,7 +64,8 @@ Item {
script: {
egg.opacity = 0;
whip.opacity = 1;
Backend.playSound("./audio/system/egg" + (Math.floor(Math.random() * 2) + 1));
Backend.playSound("./audio/system/egg" +
(Math.floor(Math.random() * 2) + 1));
}
}
PropertyAnimation {

View File

@ -27,7 +27,8 @@ Item {
y: start.y - height / 2 + yOffset
scale: 0.7
opacity: 0
rotation: (Math.atan(Math.abs(end.y - start.y) / Math.abs(end.x - start.x))
rotation: (Math.atan(Math.abs(end.y - start.y)
/ Math.abs(end.x - start.x))
/ Math.PI * 180 - 90) * (end.x > start.x ? -1 : 1)
}

View File

@ -57,7 +57,7 @@ Flickable {
if (!card) return;
cardPic.setData(card.toData());
const name = card.virt_name ? card.virt_name : card.name;
screenName.text = Backend.translate(name);
skillDesc.text = Backend.translate(":" + name);
screenName.text = luatr(name);
skillDesc.text = luatr(":" + name);
}
}

View File

@ -21,12 +21,12 @@ Item {
ToolButton {
opacity: stack.depth > 1 ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 100 } }
text: Backend.translate("Back")
text: luatr("Back")
onClicked: stack.pop()
}
Label {
text: Backend.translate("Enable free assign")
text: luatr("Enable free assign")
elide: Label.ElideRight
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
@ -46,12 +46,11 @@ Item {
}
ToolButton {
text: Backend.translate("Search")
text: luatr("Search")
enabled: word.text !== ""
onClicked: {
if (stack.depth > 1) stack.pop();
generalModel = JSON.parse(Backend.callLuaFunction("SearchAllGenerals",
[word.text]));
generalModel = lcall("SearchAllGenerals", word.text);
stack.push(generalList);
word.text = "";
}
@ -88,14 +87,13 @@ Item {
height: 40
Text {
text: Backend.translate(name)
text: luatr(name)
color: "#E4D5A0"
anchors.centerIn: parent
}
onClicked: {
generalModel = JSON.parse(Backend.callLuaFunction("GetGenerals",
[packages.get(index).name]));
generalModel = lcall("GetGenerals", packages.get(index).name);
stack.push(generalList);
}
}
@ -134,7 +132,7 @@ Item {
}
function load() {
const packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
const packs = lcall("GetAllGeneralPack");
packs.forEach((name) => packages.append({ name: name }));
}

View File

@ -39,21 +39,23 @@ Flickable {
skillDesc.text = "";
extra_data.generals.forEach((g) => {
const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [g]));
skillDesc.append(Backend.translate(data.kingdom) + " " + Backend.translate(g) + " " + data.hp + "/" + data.maxHp);
const data = lcall("GetGeneralDetail", g);
skillDesc.append(luatr(data.kingdom) + " " + luatr(g) + " " + data.hp +
"/" + data.maxHp);
if (data.companions.length > 0){
let ret = '';
ret += "<font color=\"slategrey\"><b>" + Backend.translate("Companions") + "</b>: ";
ret +="<font color=\"slategrey\"><b>" + luatr("Companions") + "</b>: ";
data.companions.forEach(t => {
ret += Backend.translate(t) + ' '
ret += luatr(t) + ' '
});
skillDesc.append(ret)
}
data.skill.forEach(t => {
skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description)
skillDesc.append("<b>" + luatr(t.name) + "</b>: " + t.description)
});
data.related_skill.forEach(t => {
skillDesc.append("<font color=\"purple\"><b>" + Backend.translate(t.name) + "</b>: " + t.description + "</font>")
skillDesc.append("<font color=\"purple\"><b>" + luatr(t.name) +
"</b>: " + t.description + "</font>")
});
skillDesc.append("\n");
});

View File

@ -38,7 +38,7 @@ Flickable {
RowLayout {
MetroButton {
text: Backend.translate("Give Flower")
text: luatr("Give Flower")
onClicked: {
enabled = false;
root.givePresent("Flower");
@ -47,7 +47,7 @@ Flickable {
}
MetroButton {
text: Backend.translate("Give Egg")
text: luatr("Give Egg")
onClicked: {
enabled = false;
if (Math.random() < 0.03) {
@ -60,7 +60,7 @@ Flickable {
}
MetroButton {
text: Backend.translate("Give Wine")
text: luatr("Give Wine")
enabled: Math.random() < 0.3
onClicked: {
enabled = false;
@ -70,7 +70,7 @@ Flickable {
}
MetroButton {
text: Backend.translate("Give Shoe")
text: luatr("Give Shoe")
enabled: Math.random() < 0.3
onClicked: {
enabled = false;
@ -80,7 +80,10 @@ Flickable {
}
MetroButton {
text: config.blockedUsers.indexOf(screenName.text) === -1 ? Backend.translate("Block Chatter") : Backend.translate("Unblock Chatter")
text: {
const blocked = !config.blockedUsers.includes(screenName.text);
return blocked ? luatr("Block Chatter") : luatr("Unblock Chatter");
}
enabled: pid !== Self.id && pid > 0
onClicked: {
const idx = config.blockedUsers.indexOf(screenName.text);
@ -94,7 +97,7 @@ Flickable {
}
MetroButton {
text: Backend.translate("Kick From Room")
text: luatr("Kick From Room")
visible: !roomScene.isStarted && roomScene.isOwner
enabled: pid !== Self.id
onClicked: {
@ -157,7 +160,7 @@ Flickable {
skillDesc.text = "";
const id = extra_data.photo.playerid;
if (id == 0) return;
if (id === 0) return;
root.pid = id;
screenName.text = extra_data.photo.screenName;
@ -165,36 +168,34 @@ Flickable {
deputyChara.name = extra_data.photo.deputyGeneral;
if (!config.observing) {
const gamedata = JSON.parse(Backend.callLuaFunction("GetPlayerGameData", [id]));
const gamedata = lcall("GetPlayerGameData", id);
const total = gamedata[0];
const win = gamedata[1];
const run = gamedata[2];
const totalTime = gamedata[3];
const winRate = (win / total) * 100;
const runRate = (run / total) * 100;
playerGameData.text = total === 0 ? Backend.translate("Newbie") :
Backend.translate("Win=%1 Run=%2 Total=%3").arg(winRate.toFixed(2))
playerGameData.text = total === 0 ? luatr("Newbie") :
luatr("Win=%1 Run=%2 Total=%3").arg(winRate.toFixed(2))
.arg(runRate.toFixed(2)).arg(total);
const h = (totalTime / 3600).toFixed(2);
const m = Math.floor(totalTime / 60);
if (m < 100) {
playerGameData.text += " " + Backend.translate("TotalGameTime: %1 min").arg(m);
playerGameData.text += " " + luatr("TotalGameTime: %1 min").arg(m);
} else {
playerGameData.text += " " + Backend.translate("TotalGameTime: %1 h").arg(h);
playerGameData.text += " " + luatr("TotalGameTime: %1 h").arg(h);
}
}
const data = JSON.parse(Backend.callLuaFunction("GetPlayerSkills", [id]));
data.forEach(t => {
skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description)
lcall("GetPlayerSkills", id).forEach(t => {
skillDesc.append("<b>" + luatr(t.name) + "</b>: " + t.description)
});
const equips = JSON.parse(Backend.callLuaFunction("GetPlayerEquips", [id]));
equips.forEach(cid => {
const t = JSON.parse(Backend.callLuaFunction("GetCardData", [cid]));
lcall("GetPlayerEquips", id).forEach(cid => {
const t = lcall("GetCardData", cid);
skillDesc.append("--------------------");
skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + Backend.translate(":" + t.name));
skillDesc.append("<b>" + luatr(t.name) + "</b>: " + luatr(":" + t.name));
});
}
}

View File

@ -28,13 +28,13 @@ Item {
ColumnLayout {
Text {
color: "#E4D5A0"
text: Backend.translate(gname)
text: luatr(gname)
}
GridLayout {
columns: 6
Repeater {
model: JSON.parse(Backend.callLuaFunction("GetSameGenerals", [gname]))
model: lcall("GetSameGenerals", gname)
GeneralCardItem {
name: modelData

View File

@ -6,7 +6,8 @@ Image {
width: 64
height: 64
source: SkinBank.getGeneralExtraPic(general, "avatar/") ?? SkinBank.getGeneralPicture(general)
source: SkinBank.getGeneralExtraPic(general, "avatar/")
?? SkinBank.getGeneralPicture(general)
// sourceSize.width: 250
// sourceSize.height: 292
property bool useSmallPic: !!SkinBank.getGeneralExtraPic(general, "avatar/")

View File

@ -18,7 +18,8 @@ Rectangle {
avatar = "__observer";
}
chatLogBox.append({
avatar: data.general || roomScene.getPhoto(data.sender)?.general || avatar || "unknown",
avatar: data.general || roomScene.getPhoto(data.sender)?.general ||
avatar || "unknown",
general: general,
msg: data.msg,
userName: data.userName,
@ -60,7 +61,7 @@ Rectangle {
anchors.right: !isSelf ? undefined : avatarPic.left
anchors.margins: 6
font.pixelSize: 14
text: userName + (general ? (" (" + Backend.translate(general) + ")") : "")
text: userName + (general ? (" (" + luatr(general) + ")") : "")
+ ' <font color="grey">[' + time + "]</font>"
}
@ -123,7 +124,8 @@ Rectangle {
anchors.centerIn: parent
source: "../../image/emoji/" + index
}
onClicked: chatEdit.insert(chatEdit.cursorPosition, "{emoji" + index + "}");
onClicked: chatEdit.insert(chatEdit.cursorPosition,
"{emoji" + index + "}");
}
}
@ -142,14 +144,14 @@ Rectangle {
delegate: ItemDelegate {
width: soundSelector.width
height: 30
text: Backend.translate("$" + name + (idx ? idx.toString() : ""))
text: luatr("$" + name + (idx ? idx.toString() : ""))
onClicked: {
opTimer.start();
const general = roomScene.getPhoto(Self.id).general;
let skill = "fastchat_m";
if (general !== "") {
const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [general]));
const data = lcall("GetGeneralDetail", general);
const gender = data.gender;
if (gender !== 1) {
skill = "fastchat_f";

View File

@ -54,7 +54,8 @@ Rectangle {
anchors.centerIn: parent
source: "../../image/emoji/" + index
}
onClicked: chatEdit.insert(chatEdit.cursorPosition, "{emoji" + index + "}");
onClicked: chatEdit.insert(chatEdit.cursorPosition,
"{emoji" + index + "}");
}
}
@ -73,14 +74,14 @@ Rectangle {
delegate: ItemDelegate {
width: soundSelector.width
height: 30
text: Backend.translate("$" + name + (idx ? idx.toString() : ""))
text: luatr("$" + name + (idx ? idx.toString() : ""))
onClicked: {
opTimer.start();
const general = roomScene.getPhoto(Self.id).general;
let skill = "fastchat_m";
if (general !== "") {
const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [general]));
const data = lcall("GetGeneralDetail", general);
const gender = data.gender;
if (gender !== 1) {
skill = "fastchat_f";

View File

@ -9,7 +9,7 @@ ColumnLayout {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("BGM Volume")
text: luatr("BGM Volume")
}
Slider {
Layout.rightMargin: 16
@ -25,7 +25,7 @@ ColumnLayout {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Effect Volume")
text: luatr("Effect Volume")
}
Slider {
Layout.rightMargin: 16
@ -38,13 +38,13 @@ ColumnLayout {
}
Switch {
text: Backend.translate("Disable message audio")
text: luatr("Disable message audio")
checked: config.disableMsgAudio
onCheckedChanged: config.disableMsgAudio = checked;
}
Switch {
text: Backend.translate("Hide unselectable cards")
text: luatr("Hide unselectable cards")
checked: config.hideUseless
onCheckedChanged: {
config.hideUseless = checked;

View File

@ -10,7 +10,7 @@ ColumnLayout {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Lobby BG")
text: luatr("Lobby BG")
}
TextField {
Layout.fillWidth: true
@ -30,7 +30,7 @@ ColumnLayout {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Room BG")
text: luatr("Room BG")
}
TextField {
Layout.fillWidth: true
@ -50,7 +50,7 @@ ColumnLayout {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Game BGM")
text: luatr("Game BGM")
}
TextField {
Layout.fillWidth: true
@ -70,7 +70,7 @@ ColumnLayout {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Poster Girl")
text: luatr("Poster Girl")
}
TextField {
Layout.fillWidth: true

View File

@ -14,7 +14,7 @@ Item {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Ban List")
text: luatr("Ban List")
}
ComboBox {
id: banCombo
@ -30,54 +30,54 @@ Item {
}
Button {
text: Backend.translate("New")
text: luatr("New")
onClicked: {
const i = config.disableGeneralSchemes.length;
banComboList.append({
name: Backend.translate("List") + (i + 1),
name: luatr("List") + (i + 1),
});
config.disableGeneralSchemes.push([]);
}
}
Button {
text: Backend.translate("Clear")
text: luatr("Clear")
onClicked: {
config.disabledGenerals = [];
}
}
Button {
text: Backend.translate("Export")
text: luatr("Export")
onClicked: {
Backend.copyToClipboard(JSON.stringify(config.disabledGenerals));
toast.show(Backend.translate("Export Success"));
toast.show(luatr("Export Success"));
}
}
Button {
text: Backend.translate("Import")
text: luatr("Import")
onClicked: {
const str = Backend.readClipboard();
let data;
try {
data = JSON.parse(str);
} catch (e) {
toast.show(Backend.translate("Not Legal"));
toast.show(luatr("Not Legal"));
return;
}
if (!data instanceof Array) {
toast.show(Backend.translate("Not JSON"));
toast.show(luatr("Not JSON"));
return;
}
let d = [];
for (let e of data) {
if (typeof e === "string" && Backend.translate(e) !== e) {
if (typeof e === "string" && luatr(e) !== e) {
d.push(e);
}
}
config.disabledGenerals = d;
toast.show(Backend.translate("Import Success"));
toast.show(luatr("Import Success"));
}
}
}
@ -86,7 +86,7 @@ Item {
Layout.fillWidth: true
Layout.margins: 8
wrapMode: Text.WrapAnywhere
text: Backend.translate("Help_Ban_List")
text: luatr("Help_Ban_List")
}
GridView {
@ -101,9 +101,9 @@ Item {
width: listView.width
text: {
const prefix = modelData.split("__")[0];
let name = Backend.translate(modelData);
let name = luatr(modelData);
if (prefix !== modelData) {
name += (" (" + Backend.translate(prefix) + ")");
name += (" (" + luatr(prefix) + ")");
}
return name;
}
@ -115,7 +115,7 @@ Item {
Component.onCompleted: {
for (let i = 0; i < config.disableGeneralSchemes.length; i++) {
banComboList.append({
name: Backend.translate("List") + (i + 1),
name: luatr("List") + (i + 1),
});
}
banCombo.currentIndex = config.disableSchemeIdx;

View File

@ -18,13 +18,13 @@ Item {
width: root.height
background: Rectangle { color: "#EEEEEEEE" }
TabButton {
text: Backend.translate("General Settings")
text: luatr("General Settings")
}
TabButton {
text: Backend.translate("Package Settings")
text: luatr("Package Settings")
}
TabButton {
text: Backend.translate("Ban General Settings")
text: luatr("Ban General Settings")
}
}

View File

@ -17,13 +17,13 @@ Item {
width: root.height
background: Rectangle { color: "#EEEEEEEE" }
TabButton {
text: Backend.translate("Userinfo Settings")
text: luatr("Userinfo Settings")
}
TabButton {
text: Backend.translate("BG Settings")
text: luatr("BG Settings")
}
TabButton {
text: Backend.translate("Audio Settings")
text: luatr("Audio Settings")
}
}

View File

@ -23,14 +23,14 @@ Item {
Text {
text: {
config.totalTime;
const gamedata = JSON.parse(Backend.callLuaFunction("GetPlayerGameData", [Self.id]));
const gamedata = lcall("GetPlayerGameData", Self.id);
const totalTime = gamedata[3];
const h = (totalTime / 3600).toFixed(2);
const m = Math.floor(totalTime / 60);
if (m < 100) {
return Backend.translate("TotalGameTime: %1 min").arg(m);
return luatr("TotalGameTime: %1 min").arg(m);
} else {
return Backend.translate("TotalGameTime: %1 h").arg(h);
return luatr("TotalGameTime: %1 h").arg(h);
}
}
x: 12; y: 1

View File

@ -16,7 +16,7 @@ Flickable {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Room Name")
text: luatr("Room Name")
}
TextField {
id: roomName
@ -24,7 +24,7 @@ Flickable {
font.pixelSize: 18
Layout.rightMargin: 16
Layout.fillWidth: true
text: Backend.translate("$RoomName").arg(Self.screenName)
text: luatr("$RoomName").arg(Self.screenName)
}
}
@ -32,7 +32,7 @@ Flickable {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Game Mode")
text: luatr("Game Mode")
}
ComboBox {
id: gameModeCombo
@ -57,16 +57,16 @@ Flickable {
columnSpacing: 20
columns: 4
Text {
text: Backend.translate("Player num")
text: luatr("Player num")
}
Text {
text: Backend.translate("Select generals num")
text: luatr("Select generals num")
}
Text {
text: Backend.translate("Operation timeout")
text: luatr("Operation timeout")
}
Text {
text: Backend.translate("Luck Card Times")
text: luatr("Luck Card Times")
}
SpinBox {
id: playerNum
@ -114,11 +114,12 @@ Flickable {
anchors.rightMargin: 8
visible: {
//config.disabledPack; // visible
const avail = JSON.parse(Backend.callLuaFunction("GetAvailableGeneralsNum", []));
const ret = avail < config.preferredGeneralNum * config.preferedPlayerNum;
const avail = lcall("GetAvailableGeneralsNum");
const ret = avail <
config.preferredGeneralNum * config.preferedPlayerNum;
return ret;
}
text: Backend.translate("No enough generals")
text: luatr("No enough generals")
color: "red"
}
@ -126,7 +127,7 @@ Flickable {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Room Password")
text: luatr("Room Password")
}
TextField {
id: roomPassword
@ -143,13 +144,13 @@ Flickable {
Switch {
id: freeAssignCheck
checked: Debugging ? true : false
text: Backend.translate("Enable free assign")
text: luatr("Enable free assign")
}
Switch {
id: deputyCheck
checked: Debugging ? true : false
text: Backend.translate("Enable deputy general")
text: luatr("Enable deputy general")
}
}
@ -157,7 +158,7 @@ Flickable {
anchors.rightMargin: 8
spacing: 16
Button {
text: Backend.translate("OK")
text: luatr("OK")
enabled: !(warning.visible)
onClicked: {
config.saveConf();
@ -166,10 +167,11 @@ Flickable {
let disabledGenerals = config.disabledGenerals.slice();
if (disabledGenerals.length) {
const availablePack = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", [])).
const availablePack = lcall("GetAllGeneralPack").
filter((pack) => !config.disabledPack.includes(pack));
disabledGenerals = disabledGenerals.filter((general) => {
return availablePack.find((pack) => JSON.parse(Backend.callLuaFunction("GetGenerals", [pack])).includes(general));
return availablePack.find(pack =>
lcall("GetGenerals", pack).includes(general));
});
disabledGenerals = Array.from(new Set(disabledGenerals));
@ -181,20 +183,22 @@ Flickable {
disabledPack.push(p);
}
});
const generalPacks = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
const generalPacks = lcall("GetAllGeneralPack");
for (let pk of generalPacks) {
if (disabledPack.includes(pk)) continue;
let generals = JSON.parse(Backend.callLuaFunction("GetGenerals", [pk]));
let generals = lcall("GetGenerals", pk);
let t = generals.filter(g => !disabledGenerals.includes(g));
if (t.length === 0) {
disabledPack.push(pk);
disabledGenerals = disabledGenerals.filter(g1 => !generals.includes(g1));
disabledGenerals = disabledGenerals
.filter(g1 => !generals.includes(g1));
}
}
ClientInstance.notifyServer(
"CreateRoom",
JSON.stringify([roomName.text, playerNum.value, config.preferredTimeout, {
JSON.stringify([roomName.text, playerNum.value,
config.preferredTimeout, {
enableFreeAssign: freeAssignCheck.checked,
enableDeputy: deputyCheck.checked,
gameMode: config.preferedMode,
@ -208,7 +212,7 @@ Flickable {
}
}
Button {
text: Backend.translate("Cancel")
text: luatr("Cancel")
onClicked: {
root.finished();
}
@ -216,11 +220,11 @@ Flickable {
}
Component.onCompleted: {
const mode_data = JSON.parse(Backend.callLuaFunction("GetGameModes", []));
const mode_data = lcall("GetGameModes");
let i = 0;
for (let d of mode_data) {
gameModeList.append(d);
if (d.orig_name == config.preferedMode) {
if (d.orig_name === config.preferedMode) {
gameModeCombo.currentIndex = i;
}
i += 1;
@ -228,9 +232,7 @@ Flickable {
playerNum.value = config.preferedPlayerNum;
config.disabledPack.forEach(p => {
Backend.callLuaFunction("UpdatePackageEnable", [p, false]);
});
config.disabledPack.forEach(p => lcall("UpdatePackageEnable", p, false));
config.disabledPackChanged();
}
}

View File

@ -23,16 +23,16 @@ Flickable {
anchors.topMargin: 8
Switch {
text: Backend.translate("Disable Extension")
text: luatr("Disable Extension")
}
RowLayout {
Text {
text: Backend.translate("General Packages")
text: luatr("General Packages")
font.bold: true
}
Button {
text: Backend.translate("Select All")
text: luatr("Select All")
onClicked: {
for (let i = 0; i < gpacks.count; i++) {
const item = gpacks.itemAt(i);
@ -41,7 +41,7 @@ Flickable {
}
}
Button {
text: Backend.translate("Revert Selection")
text: luatr("Revert Selection")
onClicked: {
for (let i = 0; i < gpacks.count; i++) {
const item = gpacks.itemAt(i);
@ -76,11 +76,11 @@ Flickable {
RowLayout {
Text {
text: Backend.translate("Card Packages")
text: luatr("Card Packages")
font.bold: true
}
Button {
text: Backend.translate("Select All")
text: luatr("Select All")
onClicked: {
for (let i = 0; i < cpacks.count; i++) {
const item = cpacks.itemAt(i);
@ -89,7 +89,7 @@ Flickable {
}
}
Button {
text: Backend.translate("Revert Selection")
text: luatr("Revert Selection")
onClicked: {
for (let i = 0; i < cpacks.count; i++) {
const item = cpacks.itemAt(i);
@ -128,31 +128,32 @@ Flickable {
} else {
packs.push(orig_name);
}
Backend.callLuaFunction("UpdatePackageEnable", [orig_name, checked]);
lcall("UpdatePackageEnable", orig_name, checked);
config.disabledPackChanged();
}
Component.onCompleted: {
loading = true;
const g = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
for (let orig of g) {
const g = lcall("GetAllGeneralPack");
let orig;
for (orig of g) {
if (config.serverHiddenPacks.includes(orig)) {
continue;
}
gpacklist.append({
name: Backend.translate(orig),
name: luatr(orig),
orig_name: orig,
pkg_enabled: !config.disabledPack.includes(orig),
});
}
const c = JSON.parse(Backend.callLuaFunction("GetAllCardPack", []));
for (let orig of c) {
const c = lcall("GetAllCardPack");
for (orig of c) {
if (config.serverHiddenPacks.includes(orig)) {
continue;
}
cpacklist.append({
name: Backend.translate(orig),
name: luatr(orig),
orig_name: orig,
pkg_enabled: !config.disabledPack.includes(orig),
});

View File

@ -11,7 +11,7 @@ ColumnLayout {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Username")
text: luatr("Username")
}
Text {
text: Self.screenName
@ -28,7 +28,7 @@ ColumnLayout {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Avatar")
text: luatr("Avatar")
}
TextField {
id: avatarName
@ -38,7 +38,7 @@ ColumnLayout {
Layout.fillWidth: true
}
Button {
text: Backend.translate("Update Avatar")
text: luatr("Update Avatar")
enabled: avatarName.text !== "" && !opTimer.running
onClicked: {
mainWindow.busy = true;
@ -55,7 +55,7 @@ ColumnLayout {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("Old Password")
text: luatr("Old Password")
}
TextField {
id: oldPassword
@ -70,7 +70,7 @@ ColumnLayout {
anchors.rightMargin: 8
spacing: 16
Text {
text: Backend.translate("New Password")
text: luatr("New Password")
}
TextField {
id: newPassword
@ -79,8 +79,9 @@ ColumnLayout {
Layout.fillWidth: true
}
Button {
text: Backend.translate("Update Password")
enabled: oldPassword.text !== "" && newPassword.text !== "" && !opTimer.running
text: luatr("Update Password")
enabled: oldPassword.text !== "" && newPassword.text !== ""
&& !opTimer.running
onClicked: {
mainWindow.busy = true;
opTimer.start();

View File

@ -46,8 +46,8 @@ callbacks["NetworkDelayTest"] = (jsonData) => {
// jsonData: RSA pub key
let cipherText;
let aeskey;
if (config.savedPassword[config.serverAddr] !== undefined
&& config.savedPassword[config.serverAddr].shorten_password === config.password) {
const savedPw = config.savedPassword[config.serverAddr];
if (savedPw?.shorten_password === config.password) {
cipherText = config.savedPassword[config.serverAddr].password;
aeskey = config.savedPassword[config.serverAddr].key;
config.aeskey = aeskey ?? "";
@ -173,7 +173,7 @@ callbacks["Chat"] = (jsonData) => {
const data = JSON.parse(jsonData);
const pid = data.sender;
const userName = data.userName;
const general = Backend.translate(data.general);
const general = luatr(data.general);
const time = data.time;
const msg = data.msg;
@ -181,10 +181,13 @@ callbacks["Chat"] = (jsonData) => {
return;
}
let text;
if (general === "")
current.addToChat(pid, data, `<font color="#3598E8">[${time}] ${userName}:</font> ${msg}`);
text = `<font color="#3598E8">[${time}] ${userName}:</font> ${msg}`;
else
current.addToChat(pid, data, `<font color="#3598E8">[${time}] ${userName}(${general}):</font> ${msg}`);
text = `<font color="#3598E8">[${time}] ${userName}` +
`(${general}):</font> ${msg}`;
current.addToChat(pid, data, text);
}
callbacks["ServerMessage"] = (jsonData) => {

View File

@ -36,7 +36,9 @@ ColumnLayout {
id: edit
font.pixelSize: 18
Layout.fillWidth: true
validator: RegularExpressionValidator { regularExpression: /[0-9A-Za-z_]+/ }
validator: RegularExpressionValidator {
regularExpression: /[0-9A-Za-z_]+/
}
}
Button {

View File

@ -19,7 +19,8 @@ QtObject {
conf.email = email;
conf.modList = modList;
ModBackend.saveToFile("mymod/config.json", JSON.stringify(conf, undefined, 2));
ModBackend.saveToFile("mymod/config.json",
JSON.stringify(conf, undefined, 2));
}
function addMod(mod) {

View File

@ -62,7 +62,8 @@ Item {
SwipeDelegate.onClicked: deletePackage(modelData);
background: Rectangle {
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1)
: "tomato"
}
}
}
@ -118,14 +119,19 @@ Item {
toast.show(qsTr("cannot use this package name"));
return;
}
const path = modPath + new_name + "/";
ModBackend.mkdir(path);
mod.packages.push(new_name);
ModBackend.saveToFile(modPath + "mod.json", JSON.stringify(mod, undefined, 2));
ModBackend.saveToFile(modPath + "mod.json",
JSON.stringify(mod, undefined, 2));
const pkgInfo = {
name: new_name,
};
ModBackend.saveToFile(path + "pkg.json", JSON.stringify(pkgInfo, undefined, 2));
ModBackend.saveToFile(path + "pkg.json",
JSON.stringify(pkgInfo, undefined, 2));
root.modChanged();
}
@ -133,7 +139,9 @@ Item {
const path = modPath + name + "/";
ModBackend.rmrf(path);
mod.packages.splice(mod.packages.indexOf(name), 1);
ModBackend.saveToFile(modPath + "mod.json", JSON.stringify(mod, undefined, 2));
ModBackend.saveToFile(modPath + "mod.json",
JSON.stringify(mod, undefined, 2));
root.modChanged();
}
}

View File

@ -84,7 +84,8 @@ Item {
SwipeDelegate.onClicked: deleteMod(modelData);
background: Rectangle {
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1)
: "tomato"
}
}
}
@ -136,7 +137,8 @@ Item {
function createNewMod(name) {
const banned = [ "test", "standard", "standard_cards", "maneuvering" ];
if (banned.indexOf(name) !== -1 || modConfig.modList.indexOf(name) !== -1) {
if (banned.indexOf(name) !== -1 ||
modConfig.modList.indexOf(name) !== -1) {
toast.show(qsTr("cannot use this mod name"));
return;
}
@ -146,10 +148,12 @@ Item {
descrption: "",
author: modConfig.userName,
};
ModBackend.saveToFile(`mymod/${name}/mod.json`, JSON.stringify(modInfo, undefined, 2));
ModBackend.saveToFile(`mymod/${name}/mod.json`,
JSON.stringify(modInfo, undefined, 2));
ModBackend.saveToFile(`mymod/${name}/.gitignore`, "init.lua");
ModBackend.stageFiles(name);
ModBackend.commitChanges(name, "Initial commit", modConfig.userName, modConfig.email);
ModBackend.commitChanges(name, "Initial commit", modConfig.userName,
modConfig.email);
modConfig.addMod(name);
}

View File

@ -50,7 +50,7 @@ Item {
anchors.left: logo.right
anchors.leftMargin: 16
width: parent.width * 0.65
text: Backend.translate("about_" + dest + "_description")
text: luatr("about_" + dest + "_description")
wrapMode: Text.WordWrap
textFormat: Text.MarkdownText
font.pixelSize: 18
@ -73,7 +73,7 @@ Item {
}
Button {
text: Backend.translate("Quit")
text: luatr("Quit")
anchors.right: parent.right
onClicked: {
swipe.opacity = 0;

View File

@ -3,6 +3,7 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Fk
import Fk.RoomElement
Item {
@ -35,7 +36,7 @@ Item {
height: 40
Text {
text: Backend.translate(name)
text: luatr(name)
anchors.centerIn: parent
}
@ -115,10 +116,9 @@ Item {
easing.type: Easing.InOutQuad
}
onFinished: {
const pkg = [listView.model.get(listView.currentIndex).name];
const idList = JSON.parse(Backend.callLuaFunction("GetCards", pkg));
const cardList = idList.map(id => JSON.parse(Backend.callLuaFunction
("GetCardData",[id])));
const pkg = listView.model.get(listView.currentIndex).name;
const idList = lcall("GetCards", pkg);
const cardList = idList.map(id => lcall("GetCardData", id));
const groupedCardList = [];
let groupedCards = {};
@ -194,25 +194,11 @@ Item {
property int cid: 1
property var cards
function updateCard() {
const data = JSON.parse(Backend.callLuaFunction("GetCardData", [cid]));
const data = lcall("GetCardData", cid);
const suitTable = {
spade: "♠", heart: '<font color="red">♥</font>',
club: "♣", diamond: '<font color="red">♦</font>',
}
const getNumString = n => {
switch (n) {
case 1:
return "A";
case 11:
return "J";
case 12:
return "Q";
case 13:
return "K";
default:
return n.toString();
}
}
if (!cards) {
detailCard.setData(data);
@ -227,22 +213,21 @@ Item {
detailCard.known = true;
cardText.clear();
audioRow.clear();
cardText.append(Backend.translate(":" + data.name));
cardText.append(luatr(":" + data.name));
addCardAudio(data)
const skills = JSON.parse(Backend.callLuaFunction
("GetCardSpecialSkills", [cid]));
const skills = lcall("GetCardSpecialSkills", cid);
if (skills.length > 0) {
cardText.append("<br/>" + Backend.translate("Special card skills:"));
cardText.append("<br/>" + luatr("Special card skills:"));
skills.forEach(t => {
cardText.append("<b>" + Backend.translate(t) + "</b>: "
+ Backend.translate(":" + t));
cardText.append("<b>" + luatr(t) + "</b>: "
+ luatr(":" + t));
});
}
if (cards) {
cardText.append("<br/>" + Backend.translate("Every suit & number:"));
cardText.append("<br/>" + luatr("Every suit & number:"));
cardText.append(cards.map(c => {
return (suitTable[c.suit] + getNumString(c.number))
return (suitTable[c.suit] + Util.convertNumber(c.number))
}).join(", "));
}
}
@ -303,16 +288,17 @@ Item {
verticalAlignment: Text.AlignVCenter
text: {
if (gender === "male") {
return Backend.translate("Male Audio");
return luatr("Male Audio");
} else {
return Backend.translate("Female Audio");
return luatr("Female Audio");
}
}
font.pixelSize: 14
}
onClicked: {
const data = JSON.parse(Backend.callLuaFunction("GetCardData", [cardDetail.cid]));
Backend.playSound("./packages/" + extension + "/audio/card/" + gender + "/" + data.name);
const data = lcall("GetCardData", cardDetail.cid);
Backend.playSound("./packages/" + extension + "/audio/card/"
+ gender + "/" + data.name);
}
}
}
@ -322,7 +308,7 @@ Item {
}
Button {
text: Backend.translate("Quit")
text: luatr("Quit")
anchors.right: parent.right
onClicked: {
mainStack.pop();
@ -331,30 +317,32 @@ Item {
function addCardAudio(card) {
const extension = card.extension;
const orig_extension = Backend.callLuaFunction("GetCardExtensionByName", [card.name]);
let fname = AppPath + "/packages/" + extension + "/audio/card/male/" + card.name + ".mp3";
const orig_extension = lcall("GetCardExtensionByName", card.name);
const prefix = AppPath + "/packages/";
const suffix = card.name + ".mp3";
let fname = prefix + extension + "/audio/card/male/" + suffix;
if (Backend.exists(fname)) {
audioRow.append( {gender: "male", extension: extension} );
audioRow.append( { gender: "male", extension: extension } );
} else {
fname = AppPath + "/packages/" + orig_extension + "/audio/card/male/" + card.name + ".mp3";
fname = prefix + orig_extension + "/audio/card/male/" + suffix;
if (Backend.exists(fname)) {
audioRow.append( {gender: "male", extension: orig_extension} );
}
}
fname = AppPath + "/packages/" + extension + "/audio/card/female/" + card.name + ".mp3";
fname = prefix + extension + "/audio/card/female/" + suffix;
if (Backend.exists(fname)) {
audioRow.append( {gender: "female", extension: extension} );
audioRow.append( { gender: "female", extension: extension } );
}else {
fname = AppPath + "/packages/" + orig_extension + "/audio/card/female/" + card.name + ".mp3";
fname = prefix + orig_extension + "/audio/card/female/" + suffix;
if (Backend.exists(fname)) {
audioRow.append( {gender: "female", extension: orig_extension} );
audioRow.append( { gender: "female", extension: orig_extension } );
}
}
}
function loadPackages() {
if (loaded) return;
const packs = JSON.parse(Backend.callLuaFunction("GetAllCardPack", []));
const packs = lcall("GetAllCardPack");
packs.forEach(name => {
if (!config.serverHiddenPacks.includes(name)) {
packages.append({ name: name });

View File

@ -3,6 +3,7 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Fk
import Fk.RoomElement
import "RoomLogic.js" as RoomLogic
@ -36,7 +37,7 @@ Item {
height: 40
Text {
text: Backend.translate(name)
text: luatr(name)
anchors.centerIn: parent
}
@ -113,11 +114,10 @@ Item {
}
onFinished: {
if (word.text !== "") {
gridView.model = JSON.parse(Backend.callLuaFunction("SearchAllGenerals",
[word.text]));
gridView.model = lcall("SearchAllGenerals", word.text);
} else {
gridView.model = JSON.parse(Backend.callLuaFunction("SearchGenerals",
[listView.model.get(listView.currentIndex).name, word.text]));
gridView.model = lcall("SearchGenerals",
listView.model.get(listView.currentIndex).name, word.text);
}
word.text = "";
appearAnim.start();
@ -159,7 +159,7 @@ Item {
property string general: "caocao"
function addSpecialSkillAudio(skill) {
const gdata = JSON.parse(Backend.callLuaFunction("GetGeneralData", [general]));
const gdata = lcall("GetGeneralData", general);
const extension = gdata.extension;
let ret = false;
for (let i = 0; i < 999; i++) {
@ -178,7 +178,7 @@ Item {
function addSkillAudio(skill) {
if (addSpecialSkillAudio(skill)) return;
const skilldata = JSON.parse(Backend.callLuaFunction("GetSkillData", [skill]));
const skilldata = lcall("GetSkillData", skill);
if (!skilldata) return;
const extension = skilldata.extension;
for (let i = 0; i < 999; i++) {
@ -194,8 +194,9 @@ Item {
}
function findDeathAudio(general) {
const extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [general])).extension;
const fname = AppPath + "/packages/" + extension + "/audio/death/" + general + ".mp3";
const extension = lcall("GetGeneralData", general).extension;
const fname = AppPath + "/packages/" + extension + "/audio/death/"
+ general + ".mp3";
if (Backend.exists(fname)) {
audioDeath.visible = true;
} else {
@ -205,27 +206,27 @@ Item {
function updateGeneral() {
detailGeneralCard.name = general;
const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [general]));
const data = lcall("GetGeneralDetail", general);
generalText.clear();
audioModel.clear();
if (data.companions.length > 0){
let ret = '';
ret += "<font color=\"slategrey\"><b>" + Backend.translate("Companions") + "</b>: ";
let ret = "<font color=\"slategrey\"><b>" + luatr("Companions")
+ "</b>: ";
data.companions.forEach(t => {
ret += Backend.translate(t) + ' '
ret += luatr(t) + ' '
});
generalText.append(ret)
}
data.skill.forEach(t => {
generalText.append("<b>" + Backend.translate(t.name) +
generalText.append("<b>" + luatr(t.name) +
"</b>: " + t.description);
addSkillAudio(t.name);
});
data.related_skill.forEach(t => {
generalText.append("<font color=\"purple\"><b>" + Backend.translate(t.name) +
generalText.append("<font color=\"purple\"><b>" + luatr(t.name) +
"</b>: " + t.description + "</font>");
addSkillAudio(t.name);
@ -279,7 +280,8 @@ Item {
if (name.endsWith("_win_audio")) {
return "胜利语音";
}
return Backend.translate(name) + (idx ? " (" + idx.toString() + ")" : "");
return luatr(name) + (idx ? " (" + idx.toString() + ")"
: "");
}
font.bold: true
font.pixelSize: 14
@ -288,11 +290,12 @@ Item {
Layout.fillWidth: true
text: {
const orig = '$' + name + (idx ? idx.toString() : "");
const orig_trans = Backend.translate(orig);
const orig_trans = luatr(orig);
// try general specific
const orig_g = '$' + name + '_' + detailGeneralCard.name + (idx ? idx.toString() : "");
const orig_g_trans = Backend.translate(orig_g);
const orig_g = '$' + name + '_' + detailGeneralCard.name
+ (idx ? idx.toString() : "");
const orig_g_trans = luatr(orig_g);
if (orig_g_trans !== orig_g) {
return orig_g_trans;
@ -325,21 +328,29 @@ Item {
contentItem: ColumnLayout {
Text {
Layout.fillWidth: true
text: Backend.translate("Death audio")
text: luatr("Death audio")
font.bold: true
font.pixelSize: 14
}
Text {
Layout.fillWidth: true
text: Backend.translate("~" + generalDetail.general) == "~" + generalDetail.general ? "" : Backend.translate("~" + generalDetail.general)
text: {
const orig = "~" + generalDetail.general;
const tr = luatr(orig);
if (tr === orig) {
return "";
}
return tr;
}
wrapMode: Text.WordWrap
}
}
onClicked: {
const general = generalDetail.general
const extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [general])).extension;
Backend.playSound("./packages/" + extension + "/audio/death/" + general);
const extension = lcall("GetGeneralData", general).extension;
Backend.playSound("./packages/" + extension + "/audio/death/"
+ general);
}
}
}
@ -364,7 +375,7 @@ Item {
}
Button {
text: Backend.translate("Search")
text: luatr("Search")
enabled: word.text !== ""
onClicked: {
listView.currentIndex = 0;
@ -378,7 +389,7 @@ Item {
ColumnLayout {
anchors.right: parent.right
Button {
text: Backend.translate("Quit")
text: luatr("Quit")
onClicked: {
mainStack.pop();
config.saveConf();
@ -387,14 +398,16 @@ Item {
Button {
id: banButton
text: Backend.translate(config.disabledGenerals.includes(detailGeneralCard.name) ? 'ResumeGeneral' : 'BanGeneral')
text: luatr(config.disabledGenerals.includes(detailGeneralCard.name) ?
'ResumeGeneral' : 'BanGeneral')
visible: detailGeneralCard.name
onClicked: {
const { disabledGenerals } = config;
const { name } = detailGeneralCard;
if (banButton.text === Backend.translate('ResumeGeneral')) {
const deleteIndex = disabledGenerals.findIndex((general) => general === name);
if (banButton.text === luatr('ResumeGeneral')) {
const deleteIndex = disabledGenerals.findIndex(
(general) => general === name);
if (deleteIndex === -1) {
return;
}
@ -417,8 +430,9 @@ Item {
}
Button {
text: Backend.translate("Set as Avatar")
enabled: detailGeneralCard.name !== "" && !opTimer.running && Self.avatar !== detailGeneralCard.name
text: luatr("Set as Avatar")
enabled: detailGeneralCard.name !== "" && !opTimer.running
&& Self.avatar !== detailGeneralCard.name
onClicked: {
mainWindow.busy = true;
opTimer.start();
@ -432,7 +446,7 @@ Item {
function loadPackages() {
if (loaded) return;
const packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
const packs = lcall("GetAllGeneralPack");
packs.forEach(name => {
if (!config.serverHiddenPacks.includes(name)) {
packages.append({ name: name });

View File

@ -118,7 +118,8 @@ Item {
TapHandler {
onTapped: {
mainStack.push(Qt.createComponent("../Tutorial.qml").createObject());
mainStack.push(Qt.createComponent("../Tutorial.qml")
.createObject());
}
}
}

View File

@ -204,7 +204,8 @@ Item {
Layout.fillWidth: true
placeholderText: qsTr("Password")
text: ""
echoMode: showPasswordCheck.checked ? TextInput.Normal : TextInput.Password
echoMode: showPasswordCheck.checked ? TextInput.Normal
: TextInput.Password
passwordCharacter: "*"
}
@ -215,10 +216,12 @@ Item {
Button {
Layout.fillWidth: true
enabled: serverAddrEdit.text !== "" && screenNameEdit.text !== "" && passwordEdit.text !== ""
enabled: serverAddrEdit.text !== "" && screenNameEdit.text !== ""
&& passwordEdit.text !== ""
text: "OK"
onClicked: {
root.addNewServer(serverAddrEdit.text, screenNameEdit.text, passwordEdit.text);
root.addNewServer(serverAddrEdit.text, screenNameEdit.text,
passwordEdit.text);
finished();
}
}
@ -259,7 +262,8 @@ Item {
Layout.fillWidth: true
placeholderText: qsTr("Password")
text: ""
echoMode: showPasswordCheck.checked ? TextInput.Normal : TextInput.Password
echoMode: showPasswordCheck.checked ? TextInput.Normal
: TextInput.Password
passwordCharacter: "*"
}
@ -371,7 +375,11 @@ Item {
const item = serverModel.get(i);
const ip = item.serverIP;
if (addr.endsWith(ip)) { // endsWithIPv6ip
item.misMatchMsg = FkVersion === ver ? "" : qsTr("@VersionMismatch").arg(ver);
item.misMatchMsg = "";
if (FkVersion !== ver) {
item.misMatchMsg = qsTr("@VersionMismatch").arg(ver);
}
item.description = desc;
item.favicon = icon;
item.online = count.toString();

View File

@ -41,7 +41,7 @@ Item {
width: parent.width
wrapMode: TextEdit.WordWrap
textFormat: Text.MarkdownText
text: config.serverMotd + "\n___\n" + Backend.translate('Bulletin Info')
text: config.serverMotd + "\n___\n" + luatr('Bulletin Info')
}
}
}
@ -64,13 +64,13 @@ Item {
Text {
horizontalAlignment: Text.AlignLeft
Layout.fillWidth: true
text: (hasPassword ? Backend.translate("Has Password") : "") + roomName
text: (hasPassword ? luatr("Has Password") : "") + roomName
font.pixelSize: 20
elide: Label.ElideRight
}
Text {
text: Backend.translate(gameMode)
text: luatr(gameMode)
}
Text {
@ -81,8 +81,8 @@ Item {
}
Button {
text: (playerNum < capacity) ? Backend.translate("Enter") :
Backend.translate("Observe")
text: (playerNum < capacity) ? luatr("Enter") :
luatr("Observe")
enabled: !opTimer.running
@ -124,7 +124,7 @@ Item {
height: root.height - 80
Button {
Layout.alignment: Qt.AlignRight
text: Backend.translate("Refresh Room List")
text: luatr("Refresh Room List")
enabled: !opTimer.running
onClicked: {
opTimer.start();
@ -142,7 +142,7 @@ Item {
Text {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: Backend.translate("Room List").arg(roomModel.count)
text: luatr("Room List").arg(roomModel.count)
}
ListView {
id: roomList
@ -166,9 +166,10 @@ Item {
width: 120
display: AbstractButton.TextUnderIcon
icon.name: "media-playback-start"
text: Backend.translate("Create Room")
text: luatr("Create Room")
onClicked: {
lobby_dialog.sourceComponent = Qt.createComponent("../LobbyElement/CreateRoom.qml");
lobby_dialog.sourceComponent =
Qt.createComponent("../LobbyElement/CreateRoom.qml");
lobby_drawer.open();
config.observing = false;
config.replaying = false;
@ -180,33 +181,33 @@ Item {
anchors.right: parent.right
anchors.bottom: parent.bottom
Button {
text: Backend.translate("Generals Overview")
text: luatr("Generals Overview")
onClicked: {
mainStack.push(mainWindow.generalsOverviewPage);
mainStack.currentItem.loadPackages();
}
}
Button {
text: Backend.translate("Cards Overview")
text: luatr("Cards Overview")
onClicked: {
mainStack.push(mainWindow.cardsOverviewPage);
mainStack.currentItem.loadPackages();
}
}
Button {
text: Backend.translate("Scenarios Overview")
text: luatr("Scenarios Overview")
onClicked: {
mainStack.push(mainWindow.modesOverviewPage);
}
}
Button {
text: Backend.translate("Replay")
text: luatr("Replay")
onClicked: {
mainStack.push(mainWindow.replayPage);
}
}
Button {
text: Backend.translate("About")
text: luatr("About")
onClicked: {
mainStack.push(mainWindow.aboutPage);
}
@ -216,7 +217,7 @@ Item {
Button {
id: exitButton
anchors.right: parent.right
text: Backend.translate("Exit Lobby")
text: luatr("Exit Lobby")
display: AbstractButton.TextBesideIcon
icon.name: "application-exit"
onClicked: {
@ -269,7 +270,7 @@ Item {
anchors.margins: 16
Text {
text: Backend.translate("Please input room's password")
text: luatr("Please input room's password")
}
TextField {
@ -295,7 +296,7 @@ Item {
config.replaying = false;
if (playerNum < capacity) {
config.observing = false;
Backend.callLuaFunction("SetObserving", [false]);
lcall("SetObserving", false);
mainWindow.busy = true;
ClientInstance.notifyServer(
"EnterRoom",
@ -303,7 +304,7 @@ Item {
);
} else {
config.observing = true;
Backend.callLuaFunction("SetObserving", [true]);
lcall("SetObserving", true);
mainWindow.busy = true;
ClientInstance.notifyServer(
"ObserveRoom",
@ -334,7 +335,7 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
x: 4; y: 2
font.pixelSize: 16
text: Backend.translate("$OnlineInfo")
text: luatr("$OnlineInfo")
.arg(lobbyPlayerNum).arg(serverPlayerNum) + "\n"
+ "Powered by FreeKill " + FkVersion
}
@ -357,8 +358,10 @@ Item {
function addToChat(pid, raw, msg) {
if (raw.type !== 1) return;
msg = msg.replace(/\{emoji([0-9]+)\}/g, '<img src="../../image/emoji/$1.png" height="24" width="24" />');
raw.msg = raw.msg.replace(/\{emoji([0-9]+)\}/g, '<img src="../../image/emoji/$1.png" height="24" width="24" />');
msg = msg.replace(/\{emoji([0-9]+)\}/g,
'<img src="../../image/emoji/$1.png" height="24" width="24" />');
raw.msg = raw.msg.replace(/\{emoji([0-9]+)\}/g,
'<img src="../../image/emoji/$1.png" height="24" width="24" />');
lobbyChat.append(msg);
danmaku.sendLog("<b>" + raw.userName + "</b>: " + raw.msg);
}
@ -369,6 +372,6 @@ Item {
}
Component.onCompleted: {
toast.show(Backend.translate("$WelcomeToLobby"));
toast.show(luatr("$WelcomeToLobby"));
}
}

View File

@ -51,7 +51,7 @@ Item {
id: modeDesc
width: parent.width - 16
wrapMode: Text.WordWrap
text: Backend.translate(":" + modeList.get(listView.currentIndex).orig_name)
text: luatr(":" + modeList.get(listView.currentIndex).orig_name)
textFormat: Text.MarkdownText
font.pixelSize: 16
}
@ -60,7 +60,7 @@ Item {
}
Button {
text: Backend.translate("Quit")
text: luatr("Quit")
anchors.bottom: parent.bottom
onClicked: {
mainStack.pop();
@ -68,7 +68,7 @@ Item {
}
Component.onCompleted: {
const mode_data = JSON.parse(Backend.callLuaFunction("GetGameModes", []));
const mode_data = lcall("GetGameModes");
for (let d of mode_data) {
modeList.append(d);
}

View File

@ -20,7 +20,7 @@ Item {
onClicked: mainStack.pop();
}
Label {
text: Backend.translate("Replay Manager")
text: luatr("Replay Manager")
horizontalAlignment: Qt.AlignHCenter
Layout.fillWidth: true
}
@ -75,8 +75,9 @@ Item {
Text {
text: {
const win = winner.split("+").indexOf(role) !== -1;
const winStr = win ? Backend.translate("Game Win") : Backend.translate("Game Lose");
return "<b>" + Backend.translate(_general) + "</b> " + Backend.translate(role) + " " + winStr;
const winStr = win ? luatr("Game Win") : luatr("Game Lose");
return "<b>" + luatr(_general) + "</b> " + luatr(role)
+ " " + winStr;
}
font.pixelSize: 20
textFormat: Text.RichText
@ -89,16 +90,16 @@ Item {
const h = repDate.slice(8,10);
const m = repDate.slice(10,12);
const s = repDate.slice(12,14);
const dateStr = y + "-" + month + "-" + d + " " + h + ":" + m + ":" + s;
const dateStr = `${y}-${month}-${d} ${h}:${m}:${s}`;
return playerName + " " + Backend.translate(gameMode) + " " + dateStr
return playerName + " " + luatr(gameMode) + " " + dateStr
}
}
}
Button {
id: replayBtn
text: Backend.translate("Play the Replay")
text: luatr("Play the Replay")
anchors.right: delBtn.left
anchors.rightMargin: 8
onClicked: {
@ -110,7 +111,7 @@ Item {
Button {
id: delBtn
text: Backend.translate("Delete Replay")
text: luatr("Delete Replay")
anchors.right: parent.right
anchors.rightMargin: 8
onClicked: {

View File

@ -87,7 +87,7 @@ Item {
anchors.topMargin: 12
anchors.right: parent.right
anchors.rightMargin: 12
text: Backend.translate("Menu")
text: luatr("Menu")
onClicked: {
if (menuContainer.visible){
menuContainer.close();
@ -103,7 +103,7 @@ Item {
MenuItem {
id: quitButton
text: Backend.translate("Quit")
text: luatr("Quit")
onClicked: {
if (config.replaying) {
Backend.controlReplayer("shutdown");
@ -119,14 +119,18 @@ Item {
MenuItem {
id: surrenderButton
enabled: !config.observing && !config.replaying
text: Backend.translate("Surrender")
text: luatr("Surrender")
onClicked: {
if (isStarted && !getPhoto(Self.id).dead) {
const surrenderCheck = JSON.parse(Backend.callLuaFunction('CheckSurrenderAvailable', [miscStatus.playedTime]));
const surrenderCheck =
lcall('CheckSurrenderAvailable', miscStatus.playedTime);
if (!surrenderCheck.length) {
surrenderDialog.informativeText = Backend.translate('Surrender is disabled in this mode');
surrenderDialog.informativeText =
luatr('Surrender is disabled in this mode');
} else {
surrenderDialog.informativeText = surrenderCheck.map(str => `${Backend.translate(str.text)}${str.passed ? '√' : '×'}`).join('<br>');
surrenderDialog.informativeText = surrenderCheck
.map(str => `${luatr(str.text)}${str.passed ? '√' : '×'}`)
.join('<br>');
}
surrenderDialog.open();
}
@ -135,7 +139,7 @@ Item {
MenuItem {
id: volumeButton
text: Backend.translate("Audio Settings")
text: luatr("Audio Settings")
onClicked: {
volumeDialog.open();
}
@ -144,7 +148,7 @@ Item {
}
Button {
text: Backend.translate("Add Robot")
text: luatr("Add Robot")
visible: isOwner && !isStarted && !isFull
anchors.centerIn: parent
enabled: config.serverEnableBot
@ -153,7 +157,7 @@ Item {
}
}
Button {
text: Backend.translate("Start Game")
text: luatr("Start Game")
visible: isOwner && !isStarted && isFull
enabled: isAllReady
anchors.centerIn: parent
@ -166,7 +170,7 @@ Item {
interval: 1000
}
Button {
text: isReady ? Backend.translate("Cancel Ready") : Backend.translate("Ready")
text: isReady ? luatr("Cancel Ready") : luatr("Ready")
visible: !isOwner && !isStarted
enabled: !opTimer.running
anchors.centerIn: parent
@ -237,25 +241,25 @@ Item {
width: parent.width
wrapMode: TextEdit.WordWrap
Component.onCompleted: {
const data = JSON.parse(Backend.callLuaFunction("GetRoomConfig", []));
let cardpack = JSON.parse(Backend.callLuaFunction("GetAllCardPack", []));
const data = lcall("GetRoomConfig");
let cardpack = lcall("GetAllCardPack");
cardpack = cardpack.filter(p => !data.disabledPack.includes(p));
text = Backend.translate("GameMode") + Backend.translate(data.gameMode) + "<br />"
+ Backend.translate("LuckCardNum") + "<b>" + data.luckTime + "</b><br />"
+ Backend.translate("ResponseTime") + "<b>" + config.roomTimeout + "</b><br />"
+ Backend.translate("GeneralBoxNum") + "<b>" + data.generalNum + "</b>"
+ (data.enableFreeAssign ? "<br />" + Backend.translate("IncludeFreeAssign") : "")
+ (data.enableDeputy ? " " + Backend.translate("IncludeDeputy") : "")
+ '<br />' + Backend.translate('CardPackages') + cardpack.map(e => {
let ret = Backend.translate(e);
if (ret.search(/特殊牌|衍生牌/) === -1) { // TODO: 西= =
text = luatr("GameMode") + luatr(data.gameMode) + "<br />"
+ luatr("LuckCardNum") + "<b>" + data.luckTime + "</b><br />"
+ luatr("ResponseTime") + "<b>" + config.roomTimeout + "</b><br />"
+ luatr("GeneralBoxNum") + "<b>" + data.generalNum + "</b>"
+ (data.enableFreeAssign ? "<br />" + luatr("IncludeFreeAssign")
: "")
+ (data.enableDeputy ? " " + luatr("IncludeDeputy") : "")
+ '<br />' + luatr('CardPackages') + cardpack.map(e => {
let ret = luatr(e);
// TODO: 西= =
if (ret.search(/特殊牌|衍生牌/) === -1) {
ret = "<b>" + ret + "</b>";
}
return ret;
}).join('')
//+ '<br /><b></b>' + data.disabledPack.map(e => Backend.translate(e)).join('')
//+ '<br /><b></b>' + data.disabledGenerals.map(e => Backend.translate(e)).join('')
}).join('');
}
}
}
@ -436,13 +440,14 @@ Item {
anchors.leftMargin: 8
ColumnLayout {
MetroButton {
text: Backend.translate("Choose one handcard")
text: luatr("Choose one handcard")
textFont.pixelSize: 28
visible: {
if (dashboard.handcardArea.length <= 15) {
return false;
}
if (roomScene.state == "notactive" || roomScene.state == "replying") {
if (roomScene.state === "notactive"
|| roomScene.state === "replying") {
return false;
}
return true;
@ -450,21 +455,21 @@ Item {
onClicked: roomScene.startCheat("../RoomElement/ChooseHandcard");
}
MetroButton {
text: Backend.translate("Revert Selection")
text: luatr("Revert Selection")
textFont.pixelSize: 28
enabled: dashboard.pending_skill !== ""
onClicked: dashboard.revertSelection();
}
// MetroButton {
// text: Backend.translate("Trust")
// text: luatr("Trust")
// }
MetroButton {
text: Backend.translate("Sort Cards")
text: luatr("Sort Cards")
textFont.pixelSize: 28
onClicked: Logic.resortHandcards();
}
MetroButton {
text: Backend.translate("Chat")
text: luatr("Chat")
textFont.pixelSize: 28
onClicked: roomDrawer.open();
}
@ -479,21 +484,21 @@ Item {
onCardSelected: function(card) {
Logic.enableTargets(card);
if (typeof card === "number" && card !== -1 && roomScene.state === "playing"
&& JSON.parse(Backend.callLuaFunction("GetPlayerHandcards", [Self.id])).includes(card)) {
if (typeof card === "number" && card !== -1
&& roomScene.state === "playing"
&& lcall("GetPlayerHandcards", Self.id).includes(card)) {
const skills = JSON.parse(Backend.callLuaFunction("GetCardSpecialSkills", [card]));
if (JSON.parse(Backend.callLuaFunction("CanUseCard", [card, Self.id, JSON.stringify(roomScene.extra_data)]))) {
const skills = lcall("GetCardSpecialSkills", card);
if (lcall("CanUseCard", card, Self.id,
JSON.stringify(roomScene.extra_data))) {
skills.unshift("_normal_use");
}
specialCardSkills.model = skills;
const skillName = Backend.callLuaFunction("GetCardSkill", [card]);
const prompt = JSON.parse(Backend.callLuaFunction(
"ActiveSkillPrompt",
[skillName, card, selected_targets]
));
const skillName = lcall("GetCardSkill", card);
const prompt = lcall("ActiveSkillPrompt", skillName, card,
selected_targets);
if (prompt !== "") {
roomScene.setPrompt(processPrompt(prompt));
roomScene.setPrompt(Util.processPrompt(prompt));
}
} else {
specialCardSkills.model = [];
@ -524,18 +529,19 @@ Item {
const totalMin = Math.floor(replayerDuration / 60);
const totalSec = replayerDuration % 60;
return elapsedMin.toString() + ":" + elapsedSec + "/" + totalMin + ":" + totalSec;
return elapsedMin.toString() + ":" + elapsedSec + "/" + totalMin
+ ":" + totalSec;
}
}
Switch {
text: Backend.translate("Speed Resume")
text: luatr("Speed Resume")
checked: false
onCheckedChanged: Backend.controlReplayer("uniform");
}
Button {
text: Backend.translate("Speed Down")
text: luatr("Speed Down")
onClicked: Backend.controlReplayer("slowdown");
}
@ -546,13 +552,13 @@ Item {
}
Button {
text: Backend.translate("Speed Up")
text: luatr("Speed Up")
onClicked: Backend.controlReplayer("speedup");
}
Button {
property bool running: true
text: Backend.translate(running ? "Pause" : "Resume")
text: luatr(running ? "Pause" : "Resume")
onClicked: {
running = !running;
Backend.controlReplayer("toggle");
@ -657,7 +663,7 @@ Item {
id: specialCardSkills
RadioButton {
property string orig_text: modelData
text: Backend.translate(modelData)
text: luatr(modelData)
checked: index === 0
onCheckedChanged: {
roomScene.resetPrompt();
@ -665,23 +671,19 @@ Item {
let prompt = ""
if (modelData === "_normal_use") {
Logic.enableTargets(card);
const skillName = Backend.callLuaFunction("GetCardSkill", [card]);
prompt = JSON.parse(Backend.callLuaFunction(
"ActiveSkillPrompt",
[skillName, card, selected_targets]
));
const skillName = lcall("GetCardSkill", card);
prompt = lcall("ActiveSkillPrompt", skillName, card,
selected_targets);
} else {
Logic.enableTargets(JSON.stringify({
skill: modelData,
subcards: [card],
}));
prompt = JSON.parse(Backend.callLuaFunction(
"ActiveSkillPrompt",
[modelData, card, selected_targets]
));
prompt = lcall("ActiveSkillPrompt", modelData, card,
selected_targets);
}
if (prompt !== "") {
roomScene.setPrompt(processPrompt(prompt));
roomScene.setPrompt(Util.processPrompt(prompt));
}
}
}
@ -707,8 +709,9 @@ Item {
Button {
id: skipNullificationButton
text: Backend.translate("SkipNullification")
visible: !!extra_data.useEventId && !skippedUseEventId.find(id => id === extra_data.useEventId)
text: luatr("SkipNullification")
visible: !!extra_data.useEventId
&& !skippedUseEventId.find(id => id === extra_data.useEventId)
onClicked: {
skippedUseEventId.push(extra_data.useEventId);
Logic.doCancelButton();
@ -717,20 +720,20 @@ Item {
Button {
id: okButton
text: Backend.translate("OK")
text: luatr("OK")
onClicked: Logic.doOkButton();
}
Button {
id: cancelButton
text: Backend.translate("Cancel")
text: luatr("Cancel")
onClicked: Logic.doCancelButton();
}
}
Button {
id: endPhaseButton
text: Backend.translate("End")
text: luatr("End")
anchors.bottom: parent.bottom
anchors.bottomMargin: 40
anchors.right: parent.right
@ -793,12 +796,13 @@ Item {
function activateSkill(skill_name, pressed) {
if (pressed) {
const data = JSON.parse(Backend.callLuaFunction("GetInteractionOfSkill", [skill_name]));
const data = lcall("GetInteractionOfSkill", skill_name);
if (data) {
Backend.callLuaFunction("SetInteractionDataOfSkill", [skill_name, "null"]);
lcall("SetInteractionDataOfSkill", skill_name, "null");
switch (data.type) {
case "combo":
skillInteraction.sourceComponent = Qt.createComponent("../SkillInteraction/SkillCombo.qml");
skillInteraction.sourceComponent =
Qt.createComponent("../SkillInteraction/SkillCombo.qml");
skillInteraction.item.skill = skill_name;
skillInteraction.item.default_choice = data["default"];
skillInteraction.item.choices = data.choices;
@ -807,7 +811,8 @@ Item {
// skillInteraction.item.clicked();
break;
case "spin":
skillInteraction.sourceComponent = Qt.createComponent("../SkillInteraction/SkillSpin.qml");
skillInteraction.sourceComponent =
Qt.createComponent("../SkillInteraction/SkillSpin.qml");
skillInteraction.item.skill = skill_name;
skillInteraction.item.from = data.from;
skillInteraction.item.to = data.to;
@ -866,11 +871,11 @@ Item {
width: roomDrawer.width
TabButton {
width: roomDrawer.width / 2
text: Backend.translate("Log")
text: luatr("Log")
}
TabButton {
width: roomDrawer.width / 2
text: Backend.translate("Chat")
text: luatr("Chat")
}
}
}
@ -913,8 +918,8 @@ Item {
MessageDialog {
id: quitDialog
title: Backend.translate("Quit")
informativeText: Backend.translate("Are you sure to quit?")
title: luatr("Quit")
informativeText: luatr("Are you sure to quit?")
buttons: MessageDialog.Ok | MessageDialog.Cancel
onButtonClicked: function (button) {
switch (button) {
@ -931,14 +936,17 @@ Item {
MessageDialog {
id: surrenderDialog
title: Backend.translate("Surrender")
title: luatr("Surrender")
informativeText: ''
buttons: MessageDialog.Ok | MessageDialog.Cancel
onButtonClicked: function (button, role) {
switch (button) {
case MessageDialog.Ok: {
const surrenderCheck = JSON.parse(Backend.callLuaFunction('CheckSurrenderAvailable', [miscStatus.playedTime]));
if (surrenderCheck.length && !surrenderCheck.find(check => !check.passed)) {
const surrenderCheck =
lcall('CheckSurrenderAvailable', miscStatus.playedTime);
if (surrenderCheck.length &&
!surrenderCheck.find(check => !check.passed)) {
ClientInstance.notifyServer("PushRequest", [
"surrender", true
]);
@ -977,7 +985,7 @@ Item {
GlowText {
anchors.centerIn: dashboard
visible: Logic.getPhoto(Self.id).rest > 0 && !config.observing
text: Backend.translate("Resting, don't leave!")
text: luatr("Resting, don't leave!")
color: "#DBCC69"
font.family: fontLibian.name
font.pixelSize: 28
@ -991,7 +999,7 @@ Item {
color: "transparent"
GlowText {
anchors.centerIn: parent
text: Backend.translate("Observing ...")
text: luatr("Observing ...")
color: "#4B83CD"
font.family: fontLi2.name
font.pixelSize: 48
@ -1096,20 +1104,9 @@ Item {
onActivated: Logic.doCancelButton();
}
function processPrompt(prompt) {
const data = prompt.split(":");
let raw = Backend.translate(data[0]);
const src = parseInt(data[1]);
const dest = parseInt(data[2]);
if (raw.match("%src")) raw = raw.replace(/%src/g, Backend.translate(getPhoto(src).general));
if (raw.match("%dest")) raw = raw.replace(/%dest/g, Backend.translate(getPhoto(dest).general));
if (raw.match("%arg2")) raw = raw.replace(/%arg2/g, Backend.translate(data[4]));
if (raw.match("%arg")) raw = raw.replace(/%arg/g, Backend.translate(data[3]));
return raw;
}
function getCurrentCardUseMethod() {
if (specialCardSkills.count === 1 && specialCardSkills.model[0] !== "_normal_use") {
if (specialCardSkills.count === 1
&& specialCardSkills.model[0] !== "_normal_use") {
return specialCardSkills.model[0];
}
@ -1125,8 +1122,10 @@ Item {
function addToChat(pid, raw, msg) {
if (raw.type === 1) return;
msg = msg.replace(/\{emoji([0-9]+)\}/g, '<img src="../../image/emoji/$1.png" height="24" width="24" />');
raw.msg = raw.msg.replace(/\{emoji([0-9]+)\}/g, '<img src="../../image/emoji/$1.png" height="24" width="24" />');
msg = msg.replace(/\{emoji([0-9]+)\}/g,
'<img src="../../image/emoji/$1.png" height="24" width="24" />');
raw.msg = raw.msg.replace(/\{emoji([0-9]+)\}/g,
'<img src="../../image/emoji/$1.png" height="24" width="24" />');
if (raw.msg.startsWith("$")) {
if (specialChat(pid, raw, raw.msg.slice(1))) return;
@ -1149,7 +1148,7 @@ Item {
const time = data.time;
const userName = data.userName;
const general = Backend.translate(data.general);
const general = luatr(data.general);
if (msg.startsWith("!")) {
const splited = msg.split(":");
@ -1167,10 +1166,15 @@ Item {
// return false;
const fromItem = Logic.getPhotoOrDashboard(fromId);
const fromPos = mapFromItem(fromItem, fromItem.width / 2, fromItem.height / 2);
const fromPos = mapFromItem(fromItem, fromItem.width / 2,
fromItem.height / 2);
const toItem = Logic.getPhoto(toId);
const toPos = mapFromItem(toItem, toItem.width / 2, toItem.height / 2);
const egg = component.createObject(roomScene, { start: fromPos, end: toPos });
const toPos = mapFromItem(toItem, toItem.width / 2,
toItem.height / 2);
const egg = component.createObject(roomScene, {
start: fromPos,
end: toPos
});
egg.finished.connect(() => egg.destroy());
egg.running = true;
@ -1181,11 +1185,11 @@ Item {
}
} else if (msg.startsWith("~")) {
const g = msg.slice(1);
const extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [g])).extension;
const extension = lcall("GetGeneralData", g).extension;
if (!config.disableMsgAudio)
Backend.playSound("./packages/" + extension + "/audio/death/" + g);
const m = Backend.translate("~" + g);
const m = luatr("~" + g);
data.msg = m;
if (general === "")
chat.append(`[${time}] ${userName}: ${m}`, data);
@ -1215,7 +1219,8 @@ Item {
i: idx,
}));
} catch (e) {}
const m = Backend.translate("$" + skill + (gene ? "_" + gene : "") + (idx ? idx.toString() : ""));
const m = luatr("$" + skill + (gene ? "_" + gene : "")
+ (idx ? idx.toString() : ""));
data.msg = m;
if (general === "")
chat.append(`[${time}] ${userName}: ${m}`, data);
@ -1253,8 +1258,7 @@ Item {
for (let i = 0; i < photoModel.count; i++) {
const item = photos.itemAt(i);
if (show) {
const dis = Backend.callLuaFunction("DistanceTo",[Self.id, item.playerid]);
item.distance = parseInt(dis);
item.distance = lcall("DistanceTo", Self.id, item.playerid);
} else {
item.distance = -1;
}
@ -1273,7 +1277,7 @@ Item {
const item = photoModel.get(i);
let gameData;
try {
gameData = JSON.parse(Backend.callLuaFunction("GetPlayerGameData", [item.id]));
gameData = lcall("GetPlayerGameData", item.id);
} catch (e) {
console.log(e);
gameData = [0, 0, 0, 0];
@ -1290,7 +1294,7 @@ Item {
}
}
mainStack.pop();
Backend.callLuaFunction("ResetClientLua", []);
lcall("ResetClientLua");
mainStack.push(room);
mainStack.currentItem.loadPlayerData(datalist);
}
@ -1306,12 +1310,13 @@ Item {
function loadPlayerData(datalist) {
datalist.forEach(d => {
if (d.id == Self.id) {
if (d.id === Self.id) {
roomScene.isOwner = d.isOwner;
} else {
Backend.callLuaFunction("ResetAddPlayer", [JSON.stringify([d.id, d.name, d.avatar, d.ready, d.gameData[3]])]);
lcall("ResetAddPlayer",
JSON.stringify([d.id, d.name, d.avatar, d.ready, d.gameData[3]]));
}
Backend.callLuaFunction("SetPlayerGameData", [d.id, d.gameData]);
lcall("SetPlayerGameData", d.id, d.gameData);
Logic.getPhotoModel(d.id).isOwner = d.isOwner;
});
}
@ -1321,7 +1326,7 @@ Item {
}
Component.onCompleted: {
toast.show(Backend.translate("$EnterRoom"));
toast.show(luatr("$EnterRoom"));
playerNum = config.roomCapacity;
for (let i = 0; i < playerNum; i++) {

View File

@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
.import Fk.Util as Util
const Card = {
Unknown : 0,
PlayerHand : 1,
@ -28,11 +30,13 @@ function arrangeManyPhotos() {
const roomAreaPadding = -16;
let horizontalSpacing = 8;
let photoWidth = (roomArea.width - horizontalSpacing * playerNum) / (playerNum - 1);
let photoWidth = (roomArea.width - horizontalSpacing * playerNum)
/ (playerNum - 1);
let photoScale = 0.75;
if (photoWidth > photoMaxWidth) {
photoWidth = photoMaxWidth;
horizontalSpacing = (roomArea.width - photoWidth * (playerNum - 1)) / playerNum;
horizontalSpacing = (roomArea.width - photoWidth * (playerNum - 1))
/ playerNum;
} else {
photoScale = photoWidth / photoBaseWidth;
}
@ -134,14 +138,13 @@ function arrangePhotos() {
function doOkButton() {
if (roomScene.state === "playing" || roomScene.state === "responding") {
const reply = JSON.stringify(
{
const reply = JSON.stringify({
card: dashboard.getSelectedCard(),
targets: selected_targets,
special_skill: roomScene.getCurrentCardUseMethod(),
interaction_data: roomScene.skillInteraction.item ? roomScene.skillInteraction.item.answer : undefined,
}
);
interaction_data: roomScene.skillInteraction.item ?
roomScene.skillInteraction.item.answer : undefined,
});
replyToServer(reply);
return;
}
@ -244,7 +247,8 @@ function getPhotoOrDashboard(id) {
function getAreaItem(area, id) {
if (area === Card.DrawPile) {
return drawPile;
} else if (area === Card.DiscardPile || area === Card.Processing || area === Card.Void) {
} else if (area === Card.DiscardPile || area === Card.Processing ||
area === Card.Void) {
return tablePile;
} else if (area === Card.AG) {
return popupBox.item;
@ -372,7 +376,8 @@ function setEmotion(id, emotion, isCardId) {
}
}
const animation = component.createObject(photo, {source: (OS === "Win" ? "file:///" : "") + path});
const animation = component.createObject(photo,
{ source: (OS === "Win" ? "file:///" : "") + path });
animation.anchors.centerIn = photo;
if (isCardId) {
animation.started.connect(() => photo.busy = true);
@ -452,7 +457,8 @@ function doIndicate(from, tos) {
return;
const fromItem = getPhotoOrDashboard(from);
const fromPos = mapFromItem(fromItem, fromItem.width / 2, fromItem.height / 2);
const fromPos = mapFromItem(fromItem, fromItem.width / 2,
fromItem.height / 2);
const end = [];
for (let i = 0; i < tos.length; i++) {
@ -464,7 +470,11 @@ function doIndicate(from, tos) {
}
const color = "#96943D";
const line = component.createObject(roomScene, {start: fromPos, end: end, color: color});
const line = component.createObject(roomScene, {
start: fromPos,
end: end,
color: color
});
line.finished.connect(() => line.destroy());
line.running = true;
}
@ -480,7 +490,7 @@ callbacks["MaxCard"] = (jsonData) => {
}
function changeSelf(id) {
Backend.callLuaFunction("ChangeSelf", [id]);
lcall("ChangeSelf", id);
// move new selfPhoto to dashboard
let order = new Array(photoModel.count);
@ -533,15 +543,15 @@ callbacks["AddPlayer"] = (jsonData) => {
}
}
function enableTargets(card) { // card: int | { skill: string, subcards: int[] }
// card: int | { skill: string, subcards: int[] }
function enableTargets(card) {
if (roomScene.respond_play) {
const candidate = (!isNaN(card) && card !== -1) || typeof(card) === "string";
const candidate = (!isNaN(card) && card !== -1)
|| typeof(card) === "string";
if (candidate) {
okButton.enabled = JSON.parse(Backend.callLuaFunction(
"CardFitPattern",
[card, roomScene.responding_card]
)) && !JSON.parse(Backend.callLuaFunction(
"CardProhibitedResponse", [card]));
okButton.enabled =
lcall("CardFitPattern", card, roomScene.responding_card) &&
!lcall("CardProhibitedResponse", card);
} else {
okButton.enabled = false;
}
@ -568,10 +578,8 @@ function enableTargets(card) { // card: int | { skill: string, subcards: int[] }
all_photos.forEach(photo => {
photo.state = "candidate";
const id = photo.playerid;
const ret = JSON.parse(Backend.callLuaFunction(
"CanUseCardToTarget",
[card, id, selected_targets, JSON.stringify(roomScene.extra_data)]
));
const ret = lcall("CanUseCardToTarget", card, id, selected_targets,
JSON.stringify(roomScene.extra_data));
photo.selectable = ret;
if (roomScene.extra_data instanceof Object) {
const must = roomScene.extra_data.must_targets;
@ -588,22 +596,20 @@ function enableTargets(card) { // card: int | { skill: string, subcards: int[] }
if (included instanceof Array) {
if (included.filter((val) => {
return selected_targets.indexOf(val) !== -1;
}).length === 0 && included.indexOf(id) === -1) photo.selectable = false;
}).length === 0 && included.indexOf(id) === -1)
photo.selectable = false;
}
}
})
okButton.enabled = JSON.parse(Backend.callLuaFunction(
"CardFeasible", [card, selected_targets]
));
okButton.enabled = lcall("CardFeasible", card, selected_targets);
if (okButton.enabled && roomScene.state === "responding") {
okButton.enabled = JSON.parse(Backend.callLuaFunction(
"CardFitPattern",
[card, roomScene.responding_card]
)) && (roomScene.autoPending || !JSON.parse(Backend.callLuaFunction(
"CardProhibitedUse", [card])));
okButton.enabled =
lcall("CardFitPattern", card, roomScene.responding_card) &&
(roomScene.autoPending || !lcall("CardProhibitedUse", card));
} else if (okButton.enabled && roomScene.state === "playing") {
okButton.enabled = JSON.parse(Backend.callLuaFunction("CanUseCard", [card, Self.id, JSON.stringify(roomScene.extra_data)]));
okButton.enabled = lcall("CanUseCard", card, Self.id,
JSON.stringify(roomScene.extra_data));
}
if (okButton.enabled) {
if (roomScene.extra_data instanceof Object) {
@ -646,10 +652,8 @@ function updateSelectedTargets(playerid, selected) {
all_photos.forEach(photo => {
if (photo.selected) return;
const id = photo.playerid;
const ret = JSON.parse(Backend.callLuaFunction(
"CanUseCardToTarget",
[card, id, selected_targets, JSON.stringify(roomScene.extra_data)]
));
const ret = lcall("CanUseCardToTarget", card, id, selected_targets,
JSON.stringify(roomScene.extra_data));
photo.selectable = ret;
if (roomScene.extra_data instanceof Object) {
const must = roomScene.extra_data.must_targets;
@ -666,22 +670,20 @@ function updateSelectedTargets(playerid, selected) {
if (included instanceof Array) {
if (included.filter((val) => {
return selected_targets.indexOf(val) !== -1;
}).length === 0 && included.indexOf(id) === -1) photo.selectable = false;
}).length === 0 && included.indexOf(id) === -1)
photo.selectable = false;
}
}
})
okButton.enabled = JSON.parse(Backend.callLuaFunction(
"CardFeasible", [card, selected_targets]
));
okButton.enabled = lcall("CardFeasible", card, selected_targets);
if (okButton.enabled && roomScene.state === "responding") {
okButton.enabled = JSON.parse(Backend.callLuaFunction(
"CardFitPattern",
[card, roomScene.responding_card]
)) && (roomScene.autoPending || !JSON.parse(Backend.callLuaFunction(
"CardProhibitedUse", [card])));
okButton.enabled =
lcall("CardFitPattern", card, roomScene.responding_card) &&
(roomScene.autoPending || !lcall("CardProhibitedUse", card));
} else if (okButton.enabled && roomScene.state === "playing") {
okButton.enabled = JSON.parse(Backend.callLuaFunction("CanUseCard", [card, Self.id, JSON.stringify(roomScene.extra_data)]));
okButton.enabled = lcall("CanUseCard", card, Self.id,
JSON.stringify(roomScene.extra_data));
}
if (okButton.enabled) {
if (roomScene.extra_data instanceof Object) {
@ -819,8 +821,7 @@ callbacks["UpdateCard"] = (j) => {
return;
}
const data = JSON.parse(Backend.callLuaFunction("GetCardData", [id]));
card.setData(data);
card.setData(lcall("GetCardData", id));
}
callbacks["StartGame"] = (jsonData) => {
@ -878,8 +879,8 @@ callbacks["MoveFocus"] = (jsonData) => {
if (focuses.indexOf(model.id) != -1) {
item = photos.itemAt(i);
item.progressBar.visible = true;
item.progressTip = Backend.translate(command)
+ Backend.translate(" thinking...");
item.progressTip = luatr(command)
+ luatr(" thinking...");
/*
if (command === "PlayCard") {
@ -914,9 +915,10 @@ callbacks["AskForGeneral"] = (jsonData) => {
const n = data[1];
const convert = data[2];
const heg = data[3];
roomScene.setPrompt(Backend.translate("#AskForGeneral"), true);
roomScene.setPrompt(luatr("#AskForGeneral"), true);
roomScene.state = "replying";
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/ChooseGeneralBox.qml");
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/ChooseGeneralBox.qml");
const box = roomScene.popupBox.item;
box.accepted.connect(() => {
replyToServer(JSON.stringify(box.choices));
@ -934,8 +936,8 @@ callbacks["AskForSkillInvoke"] = (jsonData) => {
const data = JSON.parse(jsonData);
const skill = data[0];
const prompt = data[1];
roomScene.promptText = prompt ? processPrompt(prompt) : Backend.translate("#AskForSkillInvoke")
.arg(Backend.translate(skill));
roomScene.promptText = prompt ? Util.processPrompt(prompt)
: luatr("#AskForSkillInvoke").arg(luatr(skill));
roomScene.state = "replying";
roomScene.okCancel.visible = true;
roomScene.okButton.enabled = true;
@ -953,26 +955,24 @@ callbacks["AskForGuanxing"] = (jsonData) => {
const bottom_area_name = data.bottom_area_name;
const prompt = data.prompt;
roomScene.state = "replying";
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/GuanxingBox.qml");
data.cards.forEach(id => {
const d = Backend.callLuaFunction("GetCardData", [id]);
cards.push(JSON.parse(d));
});
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/GuanxingBox.qml");
data.cards.forEach(id => cards.push(lcall("GetCardData", id)));
const box = roomScene.popupBox.item;
box.prompt = prompt;
if (max_top_cards === 0) {
box.areaCapacities = [max_bottom_cards];
box.areaLimits = [min_bottom_cards];
box.areaNames = [Backend.translate(bottom_area_name)];
box.areaNames = [luatr(bottom_area_name)];
} else {
if (max_bottom_cards === 0) {
box.areaCapacities = [max_top_cards];
box.areaLimits = [min_top_cards];
box.areaNames = [Backend.translate(top_area_name)];
box.areaNames = [luatr(top_area_name)];
} else {
box.areaCapacities = [max_top_cards, max_bottom_cards];
box.areaLimits = [min_top_cards, min_bottom_cards];
box.areaNames = [Backend.translate(top_area_name), Backend.translate(bottom_area_name)];
box.areaNames = [luatr(top_area_name), luatr(bottom_area_name)];
}
}
box.cards = cards;
@ -989,18 +989,16 @@ callbacks["AskForExchange"] = (jsonData) => {
const capacities = [];
const limits = [];
roomScene.state = "replying";
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/GuanxingBox.qml");
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/GuanxingBox.qml");
let for_i = 0;
const box = roomScene.popupBox.item;
data.piles.forEach(ids => {
if (ids.length > 0) {
ids.forEach(id => {
const d = Backend.callLuaFunction("GetCardData", [id]);
cards.push(JSON.parse(d));
});
ids.forEach(id => cards.push(lcall("GetCardData", id)));
capacities.push(ids.length);
limits.push(0);
cards_name.push(Backend.translate(data.piles_name[for_i]));
cards_name.push(luatr(data.piles_name[for_i]));
for_i ++;
}
});
@ -1024,10 +1022,10 @@ callbacks["AskForChoice"] = (jsonData) => {
const prompt = data[3];
const detailed = data[4];
if (prompt === "") {
roomScene.promptText = Backend.translate("#AskForChoice")
.arg(Backend.translate(skill_name));
roomScene.promptText = luatr("#AskForChoice")
.arg(luatr(skill_name));
} else {
roomScene.setPrompt(processPrompt(prompt), true);
roomScene.setPrompt(Util.processPrompt(prompt), true);
}
roomScene.state = "replying";
let qmlSrc;
@ -1059,10 +1057,10 @@ callbacks["AskForChoices"] = (jsonData) => {
const prompt = data[5];
const detailed = data[6];
if (prompt === "") {
roomScene.promptText = Backend.translate("#AskForChoices")
.arg(Backend.translate(skill_name));
roomScene.promptText = luatr("#AskForChoices")
.arg(luatr(skill_name));
} else {
roomScene.setPrompt(processPrompt(prompt), true);
roomScene.setPrompt(Util.processPrompt(prompt), true);
}
roomScene.state = "replying";
let qmlSrc;
@ -1095,13 +1093,14 @@ callbacks["AskForCardChosen"] = (jsonData) => {
const reason = data._reason;
const prompt = data._prompt;
if (prompt === "") {
roomScene.promptText = Backend.translate("#AskForChooseCard")
.arg(Backend.translate(reason));
roomScene.promptText = luatr("#AskForChooseCard")
.arg(luatr(reason));
} else {
roomScene.setPrompt(processPrompt(prompt), true);
roomScene.setPrompt(Util.processPrompt(prompt), true);
}
roomScene.state = "replying";
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/PlayerCardBox.qml");
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/PlayerCardBox.qml");
const box = roomScene.popupBox.item;
box.prompt = prompt;
@ -1109,17 +1108,12 @@ callbacks["AskForCardChosen"] = (jsonData) => {
const arr = [];
const ids = d[1];
ids.forEach(id => {
const card_data = JSON.parse(Backend.callLuaFunction("GetCardData", [id]));
arr.push(card_data);
});
ids.forEach(id => arr.push(lcall("GetCardData", id)));
box.addCustomCards(d[0], arr);
}
roomScene.popupBox.moveToCenter();
box.cardSelected.connect(function(cid){
replyToServer(cid);
});
box.cardSelected.connect(cid => replyToServer(cid));
}
callbacks["AskForCardsChosen"] = (jsonData) => {
@ -1131,14 +1125,15 @@ callbacks["AskForCardsChosen"] = (jsonData) => {
const reason = data._reason;
const prompt = data._prompt;
if (prompt === "") {
roomScene.promptText = Backend.translate("#AskForChooseCards")
.arg(Backend.translate(reason)).arg(min).arg(max);
roomScene.promptText = luatr("#AskForChooseCards")
.arg(luatr(reason)).arg(min).arg(max);
} else {
roomScene.setPrompt(processPrompt(prompt), true);
roomScene.setPrompt(Util.processPrompt(prompt), true);
}
roomScene.state = "replying";
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/PlayerCardBox.qml");
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/PlayerCardBox.qml");
const box = roomScene.popupBox.item;
box.multiChoose = true;
box.min = min;
@ -1148,10 +1143,7 @@ callbacks["AskForCardsChosen"] = (jsonData) => {
const arr = [];
const ids = d[1];
ids.forEach(id => {
const card_data = JSON.parse(Backend.callLuaFunction("GetCardData", [id]));
arr.push(card_data);
});
ids.forEach(id => arr.push(lcall("GetCardData", id)));
box.addCustomCards(d[0], arr);
}
@ -1165,7 +1157,8 @@ callbacks["AskForPoxi"] = (jsonData) => {
const { type, data, extra_data, cancelable } = JSON.parse(jsonData);
roomScene.state = "replying";
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/PoxiBox.qml");
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/PoxiBox.qml");
const box = roomScene.popupBox.item;
box.poxi_type = type;
box.card_data = data;
@ -1175,10 +1168,7 @@ callbacks["AskForPoxi"] = (jsonData) => {
const arr = [];
const ids = d[1];
ids.forEach(id => {
const card_data = JSON.parse(Backend.callLuaFunction("GetCardData", [id]));
arr.push(card_data);
});
ids.forEach(id => arr.push(lcall("GetCardData", id)));
box.addCustomCards(d[0], arr);
}
@ -1193,13 +1183,14 @@ callbacks["AskForMoveCardInBoard"] = (jsonData) => {
const { cards, cardsPosition, generalNames, playerIds } = data;
roomScene.state = "replying";
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/MoveCardInBoardBox.qml");
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/MoveCardInBoardBox.qml");
const boxCards = [];
cards.forEach(id => {
const cardPos = cardsPosition[cards.findIndex(cid => cid === id)];
const d = Backend.callLuaFunction("GetCardData", [id, playerIds[cardPos]]);
boxCards.push(JSON.parse(d));
const d = lcall("GetCardData", id, playerIds[cardPos]);
boxCards.push(d);
});
const box = roomScene.popupBox.item;
@ -1208,7 +1199,10 @@ callbacks["AskForMoveCardInBoard"] = (jsonData) => {
box.playerIds = playerIds;
box.generalNames = generalNames.map(name => {
const namesSplited = name.split('/');
return namesSplited.length > 1 ? namesSplited.map(nameSplited => Backend.translate(nameSplited)).join('/') : Backend.translate(name)
if (namesSplited.length > 1) {
return namesSplited.map(nameSplited => luatr(nameSplited)).join('/');
}
return luatr(name);
});
box.arrangeCards();
@ -1227,7 +1221,7 @@ callbacks["PlayCard"] = (jsonData) => {
// jsonData: int playerId
const playerId = parseInt(jsonData);
if (playerId === Self.id) {
roomScene.setPrompt(Backend.translate("#PlayCard"), true);
roomScene.setPrompt(luatr("#PlayCard"), true);
roomScene.state = "playing";
okButton.enabled = false;
}
@ -1263,19 +1257,6 @@ callbacks["PrelightSkill"] = (jsonData) => {
dashboard.prelightSkill(skill_name, prelight);
}
// prompt: 'string:<src>:<dest>:<arg>:<arg2>'
function processPrompt(prompt) {
const data = prompt.split(":");
let raw = Backend.translate(data[0]);
const src = parseInt(data[1]);
const dest = parseInt(data[2]);
if (raw.match("%src")) raw = raw.replace(/%src/g, Backend.translate(getPhoto(src).general));
if (raw.match("%dest")) raw = raw.replace(/%dest/g, Backend.translate(getPhoto(dest).general));
if (raw.match("%arg2")) raw = raw.replace(/%arg2/g, Backend.translate(data[4]));
if (raw.match("%arg")) raw = raw.replace(/%arg/g, Backend.translate(data[3]));
return raw;
}
callbacks["AskForUseActiveSkill"] = (jsonData) => {
// jsonData: string skill_name, string prompt
const data = JSON.parse(jsonData);
@ -1284,16 +1265,16 @@ callbacks["AskForUseActiveSkill"] = (jsonData) => {
const cancelable = data[2];
const extra_data = data[3] ?? {};
if (prompt === "") {
roomScene.promptText = Backend.translate("#AskForUseActiveSkill")
.arg(Backend.translate(skill_name));
roomScene.promptText = luatr("#AskForUseActiveSkill")
.arg(luatr(skill_name));
} else {
roomScene.setPrompt(processPrompt(prompt), true);
roomScene.setPrompt(Util.processPrompt(prompt), true);
}
roomScene.respond_play = false;
roomScene.state = "responding";
if (JSON.parse(Backend.callLuaFunction('GetSkillData', [skill_name])).isViewAsSkill) {
if (lcall('GetSkillData', skill_name).isViewAsSkill) {
roomScene.responding_card = ".";
}
@ -1321,7 +1302,8 @@ callbacks["AskForUseCard"] = (jsonData) => {
const extra_data = data[4];
const disabledSkillNames = data[5];
if (extra_data != null) {
if (extra_data.effectTo !== Self.id && roomScene.skippedUseEventId.find(id => id === extra_data.useEventId)) {
if (extra_data.effectTo !== Self.id &&
roomScene.skippedUseEventId.find(id => id === extra_data.useEventId)) {
doCancelButton();
return;
} else {
@ -1330,10 +1312,10 @@ callbacks["AskForUseCard"] = (jsonData) => {
}
if (prompt === "") {
roomScene.promptText = Backend.translate("#AskForUseCard")
.arg(Backend.translate(cardname));
roomScene.promptText = luatr("#AskForUseCard")
.arg(luatr(cardname));
} else {
roomScene.setPrompt(processPrompt(prompt), true);
roomScene.setPrompt(Util.processPrompt(prompt), true);
}
roomScene.responding_card = pattern;
roomScene.respond_play = false;
@ -1352,10 +1334,10 @@ callbacks["AskForResponseCard"] = (jsonData) => {
const disabledSkillNames = data[5];
if (prompt === "") {
roomScene.promptText = Backend.translate("#AskForResponseCard")
.arg(Backend.translate(cardname));
roomScene.promptText = luatr("#AskForResponseCard")
.arg(luatr(cardname));
} else {
roomScene.setPrompt(processPrompt(prompt), true);
roomScene.setPrompt(Util.processPrompt(prompt), true);
}
roomScene.responding_card = pattern;
roomScene.respond_play = true;
@ -1422,7 +1404,8 @@ callbacks["Animate"] = (jsonData) => {
}
case "InvokeSkill": {
const id = data.player;
const component = Qt.createComponent("../RoomElement/SkillInvokeAnimation.qml");
const component =
Qt.createComponent("../RoomElement/SkillInvokeAnimation.qml");
if (component.status !== Component.Ready)
return;
@ -1432,7 +1415,7 @@ callbacks["Animate"] = (jsonData) => {
}
const animation = component.createObject(photo, {
skill_name: Backend.translate(data.name),
skill_name: luatr(data.name),
skill_type: (data.skill_type ? data.skill_type : "special"),
});
animation.anchors.centerIn = photo;
@ -1467,7 +1450,8 @@ callbacks["LogEvent"] = (jsonData) => {
setEmotion(data.to, "damage");
item.tremble();
data.damageType = data.damageType || "normal_damage";
Backend.playSound("./audio/system/" + data.damageType + (data.damageNum > 1 ? "2" : ""));
Backend.playSound("./audio/system/" + data.damageType +
(data.damageNum > 1 ? "2" : ""));
break;
}
case "LoseHP": {
@ -1489,9 +1473,10 @@ callbacks["LogEvent"] = (jsonData) => {
// try main general
if (data.general) {
dat = JSON.parse(Backend.callLuaFunction("GetGeneralData", [data.general]));
dat = lcall("GetGeneralData", data.general);
extension = dat.extension;
path = "./packages/" + extension + "/audio/skill/" + skill + "_" + data.general;
path = "./packages/" + extension + "/audio/skill/" + skill + "_"
+ data.general;
if (Backend.exists(path + ".mp3") || Backend.exists(path + "1.mp3")) {
Backend.playSound(path, data.i);
break;
@ -1500,9 +1485,10 @@ callbacks["LogEvent"] = (jsonData) => {
// secondly try deputy general
if (data.deputy) {
dat = JSON.parse(Backend.callLuaFunction("GetGeneralData", [data.deputy]));
dat = lcall("GetGeneralData", data.deputy);
extension = dat.extension;
path = "./packages/" + extension + "/audio/skill/" + skill + "_" + data.deputy;
path = "./packages/" + extension + "/audio/skill/" + skill + "_"
+ data.deputy;
if (Backend.exists(path + ".mp3") || Backend.exists(path + "1.mp3")) {
Backend.playSound(path, data.i);
break;
@ -1510,7 +1496,7 @@ callbacks["LogEvent"] = (jsonData) => {
}
// finally normal skill
dat = JSON.parse(Backend.callLuaFunction("GetSkillData", [skill]));
dat = lcall("GetSkillData", skill);
extension = dat.extension;
path = "./packages/" + extension + "/audio/skill/" + skill;
Backend.playSound(path, data.i);
@ -1522,8 +1508,10 @@ callbacks["LogEvent"] = (jsonData) => {
}
case "Death": {
const item = getPhoto(data.to);
const extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [item.general])).extension;
Backend.playSound("./packages/" + extension + "/audio/death/" + item.general);
const extension = lcall("GetGeneralData", item.general).extension;
Backend.playSound("./packages/" + extension + "/audio/death/"
+ item.general);
break;
}
default:
break;
@ -1532,7 +1520,8 @@ callbacks["LogEvent"] = (jsonData) => {
callbacks["GameOver"] = (jsonData) => {
roomScene.state = "notactive";
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/GameOverBox.qml");
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/GameOverBox.qml");
const box = roomScene.popupBox.item;
box.winner = jsonData;
// roomScene.isStarted = false;
@ -1541,7 +1530,8 @@ callbacks["GameOver"] = (jsonData) => {
callbacks["FillAG"] = (j) => {
const data = JSON.parse(j);
const ids = data[0];
roomScene.manualBox.sourceComponent = Qt.createComponent("../RoomElement/AG.qml");
roomScene.manualBox.sourceComponent =
Qt.createComponent("../RoomElement/AG.qml");
roomScene.manualBox.item.addIds(ids);
}
@ -1556,7 +1546,7 @@ callbacks["TakeAG"] = (j) => {
const pid = data[0];
const cid = data[1];
const item = getPhoto(pid);
const general = Backend.translate(item.general);
const general = luatr(item.general);
// the item should be AG box
roomScene.manualBox.item.takeAG(general, cid);
@ -1579,7 +1569,7 @@ callbacks["MiniGame"] = (j) => {
const data = JSON.parse(j);
const game = data.type;
const dat = data.data;
const gdata = JSON.parse(Backend.callLuaFunction("GetMiniGame", [game, Self.id, JSON.stringify(dat)]));
const gdata = lcall("GetMiniGame", game, Self.id, JSON.stringify(dat));
roomScene.state = "replying";
roomScene.popupBox.source = AppPath + "/" + gdata.qml_path + ".qml";
if (dat) {
@ -1652,7 +1642,7 @@ callbacks["AskForLuckCard"] = (j) => {
// jsonData: int time
if (config.observing || config.replaying) return;
const time = parseInt(j);
roomScene.setPrompt(Backend.translate("#AskForLuckCard").arg(time), true);
roomScene.setPrompt(luatr("#AskForLuckCard").arg(time), true);
roomScene.state = "replying";
roomScene.extra_data = {
luckCard: true,

View File

@ -35,7 +35,7 @@ Item {
Image {
height: 55 * 0.8
width: 47 * 0.8
source: SkinBank.getDelayedTrickPicture(name) // SkinBank.DELAYED_TRICK_DIR + name
source: SkinBank.getDelayedTrickPicture(name)
}
}
}
@ -47,7 +47,7 @@ Item {
inputs = [inputs];
}
inputs.forEach(card => {
const v = JSON.parse(Backend.callLuaFunction("GetVirtualEquip", [parent.playerid, card.cid]));
const v = lcall("GetVirtualEquip", parent.playerid, card.cid);
if (v !== null) {
cards.append(v);
} else {

View File

@ -17,9 +17,15 @@ Item {
height: 70
width: 138
property int itemHeight: (treasureItem.name === "" && !treasureItem.sealed) ? height / 3 : height / 4
property var items: [treasureItem, weaponItem, armorItem, defensiveHorseItem, offensiveHorseItem]
property var subtypes: ["treasure", "weapon", "armor", "defensive_horse", "offensive_horse"]
property int itemHeight: {
if (treasureItem.name === "" && !treasureItem.sealed)
return height / 3;
return height / 4;
}
property var items: [treasureItem, weaponItem, armorItem,
defensiveHorseItem, offensiveHorseItem]
property var subtypes: ["treasure", "weapon", "armor",
"defensive_horse", "offensive_horse"]
property int length: area.length
// FIXME: Qt 6.6

View File

@ -30,7 +30,11 @@ Item {
anchors.verticalCenter: parent.verticalCenter
x: 3
source: sealed ? (SkinBank.EQUIP_ICON_DIR + "sealed") : (icon ? SkinBank.getEquipIcon(cid, icon) : "")
source: {
if (sealed)
return SkinBank.EQUIP_ICON_DIR + "sealed";
return icon ? SkinBank.getEquipIcon(cid, icon) : "";
}
}
Image {
@ -44,7 +48,7 @@ Item {
GlowText {
id: numberItem
visible: !sealed && number > 0 && number < 14
text: Utility.convertNumber(number)
text: Util.convertNumber(number)
color: "white"
font.family: fontLibian.name
font.pixelSize: 16
@ -132,7 +136,7 @@ Item {
text = "-1"
icon = "horse";
} else {
text = Backend.translate(name);
text = luatr(name);
if (card.virt_name) {
icon = card.virt_name;
} else {
@ -159,6 +163,6 @@ Item {
x = 0;
opacity = sealed ? 1 : 0;
text = ' ' + Backend.translate(subtype + "_sealed")
text = ' ' + luatr(subtype + "_sealed")
}
}

View File

@ -20,13 +20,24 @@ Column {
id: repeater
model: column.visible ? 0 : maxValue
Magatama {
state: (maxValue - 1 - index) >= value ? 0 : (value >= 3 || value >= maxValue ? 3 : (value <= 0 ? 0 : value))
state: {
if (maxValue - 1 - index >= value) {
return 0;
} else if (value >= 3 || value >= maxValue) {
return 3;
} else if (value <= 0) {
return 0;
} else {
return value;
}
}
}
}
Column {
id: column
visible: maxValue > 4 || value > maxValue || (shieldNum > 0 && maxValue > 3)
visible: maxValue > 4 || value > maxValue ||
(shieldNum > 0 && maxValue > 3)
spacing: -4
Magatama {
@ -37,7 +48,17 @@ Column {
id: hpItem
width: root.width
text: value
color: root.colors[(value >= 3 || value >= maxValue) ? 3 : (value <= 0 ? 0 : value)]
color: {
let idx;
if (value >= 3 || value >= maxValue) {
idx = 3;
} else if (value <= 0) {
idx = 0;
} else {
idx = value;
}
return root.colors[idx];
}
font.family: fontLibian.name
font.pixelSize: 22
font.bold: true

View File

@ -25,7 +25,7 @@ Item {
font.family: fontLi2.name
style: Text.Outline
styleColor: "#3D2D1C"
text: Backend.translate(skillname);
text: luatr(skillname);
}
Text {
@ -39,7 +39,7 @@ Item {
}
onSkillnameChanged: {
let data = Backend.callLuaFunction("GetSkillData", [skillname]);
let data = lcall("GetSkillData", skillname);
data = JSON.parse(data);
if (data.frequency || data.switchSkillName) {
skilltype = data.switchSkillName ? 'switch' : data.frequency;
@ -64,7 +64,8 @@ Item {
}
} else if (skilltype === 'switch') {
visible = true;
bg.source = SkinBank.LIMIT_SKILL_DIR + (usedtimes < 1 ? 'switch' : 'switch-yin');
bg.source = SkinBank.LIMIT_SKILL_DIR +
(usedtimes < 1 ? 'switch' : 'switch-yin');
} else if (skilltype === 'quest') {
visible = true
if (usedtimes > 1) {

View File

@ -34,7 +34,8 @@ Item {
width: childrenRect.width
height: 22
Text {
text: Backend.translate(mark_name) + ' ' + (special_value !== '' ? special_value : mark_extra)
text: luatr(mark_name) + ' '
+ (special_value !== '' ? special_value : mark_extra)
font.family: fontLibian.name
font.pixelSize: 22
font.letterSpacing: -0.6
@ -76,7 +77,8 @@ Item {
const mark_type = mark_name.slice(2, close_br);
const _data = mark_extra;
let data = JSON.parse(Backend.callLuaFunction("GetQmlMark", [mark_type, mark_name, _data, root.parent?.playerid]));
let data = lcall("GetQmlMark", mark_type, mark_name, _data,
root.parent?.playerid);
if (data && data.qml_path) {
params.data = JSON.parse(_data);
roomScene.startCheat("../../" + data.qml_path, params);
@ -84,7 +86,7 @@ Item {
return;
} else {
if (!root.parent.playerid) return;
let data = JSON.parse(Backend.callLuaFunction("GetPile", [root.parent.playerid, mark_name]));
let data = lcall("GetPile", root.parent.playerid, mark_name);
data = data.filter((e) => e !== -1);
if (data.length === 0)
return;
@ -123,13 +125,16 @@ Item {
if (close_br !== -1) {
const mark_type = mark.slice(2, close_br);
data = JSON.stringify(data);
const _data = JSON.parse(Backend.callLuaFunction("GetQmlMark", [mark_type, mark, data, root.parent?.playerid]));
const _data = lcall("GetQmlMark", mark_type, mark, data,
root.parent?.playerid);
if (_data && _data.text) {
special_value = _data.text;
}
}
} else {
data = data instanceof Array ? data.map((markText) => Backend.translate(markText)).join(' ') : Backend.translate(data);
data = data instanceof Array
? data.map((markText) => luatr(markText)).join(' ')
: luatr(data);
}
if (modelItem) {

View File

@ -8,7 +8,7 @@ GraphicsBox {
property bool interactive: false
id: root
title.text: Backend.translate("Please choose cards")
title.text: luatr("Please choose cards")
width: cards.count * 100 + spacing * (cards.count - 1) + 25
height: 180
@ -46,7 +46,7 @@ GraphicsBox {
function addIds(ids) {
ids.forEach((id) => {
let data = Backend.callLuaFunction("GetCardData", [id]);
let data = lcall("GetCardData", id);
data = JSON.parse(data);
data.selectable = true;
data.footnote = "";

View File

@ -26,7 +26,7 @@ Item {
for (let j = 0; j < outputs.length; j++) {
for (let i = cards.length - 1; i >= 0; i--) {
if (outputs[j] === cards[i].cid) {
const state = JSON.parse(Backend.callLuaFunction("GetCardData", [cards[i].cid]));
const state = lcall("GetCardData", cards[i].cid);
cards[i].setData(state);
result.push(cards[i]);
cards.splice(i, 1);

View File

@ -102,7 +102,8 @@ Item {
Image {
id: suitItem
visible: known
source: (suit !== "" && suit !== "nosuit") ? SkinBank.CARD_SUIT_DIR + suit : ""
source: (suit !== "" && suit !== "nosuit") ? SkinBank.CARD_SUIT_DIR + suit
: ""
x: 3
y: 19
width: 21
@ -122,8 +123,10 @@ Item {
Image {
id: colorItem
visible: known && (suit === "" || suit === "nosuit") // && number <= 0 // <- FIXME:
source: (visible && color !== "") ? SkinBank.CARD_SUIT_DIR + "/" + color : ""
visible: known && (suit === "" || suit === "nosuit")
// && number <= 0 // <- FIXME:
source: (visible && color !== "") ? SkinBank.CARD_SUIT_DIR + "/" + color
: ""
x: 1
}
@ -146,7 +149,7 @@ Item {
font.pixelSize: 16
font.family: fontLibian.name
font.letterSpacing: -0.6
text: Backend.translate(root.virt_name)
text: luatr(root.virt_name)
}
Text {
@ -195,7 +198,7 @@ Item {
font.family: fontLibian.name
font.letterSpacing: -0.6
text: {
let ret = Backend.translate(modelData.k);
let ret = luatr(modelData.k);
if (!modelData.k.startsWith("@@")) {
ret += modelData.v.toString();
}

View File

@ -2,6 +2,7 @@
import QtQuick
import QtQuick.Layouts
import Fk
import Fk.Pages
GraphicsBox {
@ -14,22 +15,10 @@ GraphicsBox {
property var result: []
id: root
title.text: Backend.translate("$Choice").arg(Backend.translate(skill_name))
title.text: luatr("$Choice").arg(luatr(skill_name))
width: Math.max(140, body.width + 20)
height: buttons.height + body.height + title.height + 20
function processPrompt(prompt) {
const data = prompt.split(":");
let raw = Backend.translate(data[0]);
const src = parseInt(data[1]);
const dest = parseInt(data[2]);
if (raw.match("%src")) raw = raw.replace(/%src/g, Backend.translate(getPhoto(src).general));
if (raw.match("%dest")) raw = raw.replace(/%dest/g, Backend.translate(getPhoto(dest).general));
if (raw.match("%arg2")) raw = raw.replace(/%arg2/g, Backend.translate(data[4]));
if (raw.match("%arg")) raw = raw.replace(/%arg/g, Backend.translate(data[3]));
return raw;
}
GridLayout {
id: body
// x: 10
@ -44,8 +33,9 @@ GraphicsBox {
MetroToggleButton {
Layout.fillWidth: true
text: processPrompt(modelData)
enabled: options.indexOf(modelData) !== -1 && (root.result.length < max_num || triggered)
text: Util.processPrompt(modelData)
enabled: options.indexOf(modelData) !== -1
&& (root.result.length < max_num || triggered)
onClicked: {
if (triggered) {
@ -68,7 +58,7 @@ GraphicsBox {
MetroButton {
Layout.fillWidth: true
text: processPrompt("OK")
text: Util.processPrompt("OK")
enabled: root.result.length >= min_num
onClicked: {

View File

@ -2,6 +2,7 @@
import QtQuick
import QtQuick.Layouts
import Fk
import Fk.Pages
GraphicsBox {
@ -11,22 +12,10 @@ GraphicsBox {
property int result
id: root
title.text: Backend.translate("$Choice").arg(Backend.translate(skill_name))
title.text: luatr("$Choice").arg(luatr(skill_name))
width: Math.max(140, body.width + 20)
height: body.height + title.height + 20
function processPrompt(prompt) {
const data = prompt.split(":");
let raw = Backend.translate(data[0]);
const src = parseInt(data[1]);
const dest = parseInt(data[2]);
if (raw.match("%src")) raw = raw.replace(/%src/g, Backend.translate(getPhoto(src).general));
if (raw.match("%dest")) raw = raw.replace(/%dest/g, Backend.translate(getPhoto(dest).general));
if (raw.match("%arg2")) raw = raw.replace(/%arg2/g, Backend.translate(data[4]));
if (raw.match("%arg")) raw = raw.replace(/%arg/g, Backend.translate(data[3]));
return raw;
}
GridLayout {
id: body
x: 10
@ -40,7 +29,7 @@ GraphicsBox {
MetroButton {
Layout.fillWidth: true
text: processPrompt(modelData)
text: Util.processPrompt(modelData)
enabled: options.indexOf(modelData) !== -1
onClicked: {

View File

@ -19,10 +19,11 @@ GraphicsBox {
}
id: root
title.text: Backend.translate("$ChooseGeneral").arg(choiceNum) +
(config.enableFreeAssign ? "(" + Backend.translate("Enable free assign") + ")" : "")
title.text: luatr("$ChooseGeneral").arg(choiceNum) +
(config.enableFreeAssign ? "(" + luatr("Enable free assign") + ")" : "")
width: generalArea.width + body.anchors.leftMargin + body.anchors.rightMargin
height: body.implicitHeight + body.anchors.topMargin + body.anchors.bottomMargin
height: body.implicitHeight + body.anchors.topMargin +
body.anchors.bottomMargin
Column {
id: body
@ -32,7 +33,8 @@ GraphicsBox {
Item {
id: generalArea
width: (generalList.count > 8 ? Math.ceil(generalList.count / 2) : Math.max(3, generalList.count)) * 97
width: (generalList.count > 8 ? Math.ceil(generalList.count / 2)
: Math.max(3, generalList.count)) * 97
height: generalList.count > 8 ? 290 : 150
z: 1
@ -43,8 +45,23 @@ GraphicsBox {
Item {
width: 93
height: 130
x: (index % Math.ceil(generalList.count / (generalList.count > 8 ? 2 : 1))) * 98 + (generalList.count > 8 && index > generalList.count / 2 && generalList.count % 2 == 1 ? 50 : 0)
y: generalList.count <= 8 ? 0 : (index < generalList.count / 2 ? 0 : 135)
x: {
const count = generalList.count;
let columns = generalList.count;
if (columns > 8) {
columns = Math.ceil(columns / 2);
}
let ret = (index % columns) * 98;
if (count > 8 && index > count / 2 && count % 2 == 1)
ret += 50;
return ret;
}
y: {
if (generalList.count <= 8)
return 0;
return index < generalList.count / 2 ? 0 : 135;
}
}
}
}
@ -93,13 +110,15 @@ GraphicsBox {
MetroButton {
id: convertBtn
visible: !convertDisabled
text: Backend.translate("Same General Convert")
onClicked: roomScene.startCheat("SameConvert", { cards: generalList });
text: luatr("Same General Convert")
onClicked: {
roomScene.startCheat("SameConvert", { cards: generalList });
}
}
MetroButton {
id: fightButton
text: Backend.translate("Fight")
text: luatr("Fight")
width: 120
height: 35
enabled: false
@ -110,7 +129,7 @@ GraphicsBox {
MetroButton {
id: detailBtn
enabled: choices.length > 0
text: Backend.translate("Show General Detail")
text: luatr("Show General Detail")
onClicked: roomScene.startCheat(
"GeneralDetail",
{ generals: choices }
@ -233,7 +252,8 @@ GraphicsBox {
for (i = 0; i < generalCardList.count; i++) {
item = generalCardList.itemAt(i);
item.selectable = needSameKingdom ? isHegPair(selectedItem[0], item) : true;
item.selectable = needSameKingdom ? isHegPair(selectedItem[0], item)
: true;
if (selectedItem.indexOf(item) != -1)
continue;
@ -247,9 +267,7 @@ GraphicsBox {
}
for (let i = 0; i < generalList.count; i++) {
if (JSON.parse(Backend.callLuaFunction(
"GetSameGenerals", [generalList.get(i).name])
).length > 0) {
if (lcall("GetSameGenerals", generalList.get(i).name).length > 0) {
convertBtn.enabled = true;
return;
}

View File

@ -13,7 +13,7 @@ ColumnLayout {
property var cards: []
Text {
text: Backend.translate("Handcard selector")
text: luatr("Handcard selector")
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 18
@ -46,7 +46,7 @@ ColumnLayout {
}
}
Component.onCompleted: {
setData(JSON.parse(Backend.callLuaFunction("GetCardData", [modelData.cid])));
setData(lcall("GetCardData", modelData.cid));
}
}
}

View File

@ -3,6 +3,7 @@
import QtQuick
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import Fk
RowLayout {
id: root
@ -86,19 +87,19 @@ RowLayout {
data.y = parentPos.y;
const card = component.createObject(roomScene, data);
card.footnoteVisible = true;
card.footnote = Backend.translate("$Equip");
card.footnote = luatr("$Equip");
handcardAreaItem.add(card);
})
handcardAreaItem.updateCardPosition();
} else {
const ids = JSON.parse(Backend.callLuaFunction("GetPile", [self.playerid, pile]));
const ids = lcall("GetPile", self.playerid, pile);
ids.forEach(id => {
const data = JSON.parse(Backend.callLuaFunction("GetCardData", [id]));
const data = lcall("GetCardData", id);
data.x = parentPos.x;
data.y = parentPos.y;
const card = component.createObject(roomScene, data);
card.footnoteVisible = true;
card.footnote = Backend.translate(pile);
card.footnote = luatr(pile);
handcardAreaItem.add(card);
});
handcardAreaItem.updateCardPosition();
@ -124,7 +125,7 @@ RowLayout {
})
handcardAreaItem.updateCardPosition();
} else {
const ids = JSON.parse(Backend.callLuaFunction("GetPile", [self.playerid, pile]));
const ids = lcall("GetPile", self.playerid, pile);
ids.forEach(id => {
const card = handcardAreaItem.remove([id])[0];
card.origX = parentPos.x;
@ -145,25 +146,23 @@ RowLayout {
// If cname is set, we are responding card.
function enableCards(cname) {
const cardValid = (cid, cname) => {
let ret = JSON.parse(Backend.callLuaFunction(
"CardFitPattern", [cid, cname]));
let ret = lcall("CardFitPattern", cid, cname);
if (ret) {
if (roomScene.respond_play) {
ret = ret && !JSON.parse(Backend.callLuaFunction(
"CardProhibitedResponse", [cid]));
ret = ret && !lcall("CardProhibitedResponse", cid);
} else {
ret = ret && !JSON.parse(Backend.callLuaFunction(
"CardProhibitedUse", [cid]));
ret = ret && !lcall("CardProhibitedUse", cid);
}
}
return ret;
}
const pile_data = JSON.parse(Backend.callLuaFunction("GetAllPiles", [self.playerid]));
const pile_data = lcall("GetAllPiles", self.playerid);
extractWoodenOx();
const handleMethod = roomScene.respond_play ? "response" : "use";
if (cname) {
const ids = [];
let cards = handcardAreaItem.cards;
@ -172,10 +171,8 @@ RowLayout {
if (cardValid(cards[i].cid, cname)) {
ids.push(cards[i].cid);
} else {
const prohibitReason = Backend.callLuaFunction(
"GetCardProhibitReason",
[cards[i].cid, roomScene.respond_play ? "response" : "use", cname]
);
const prohibitReason = lcall("GetCardProhibitReason", cards[i].cid,
handleMethod, cname);
if (prohibitReason) {
cards[i].prohibitReason = prohibitReason;
}
@ -190,10 +187,8 @@ RowLayout {
expandPile("_equip");
}
} else {
const prohibitReason = Backend.callLuaFunction(
"GetCardProhibitReason",
[c.cid, roomScene.respond_play ? "response" : "use", cname]
);
const prohibitReason = lcall("GetCardProhibitReason", c.cid,
handleMethod, cname);
if (prohibitReason) {
c.prohibitReason = prohibitReason;
}
@ -223,14 +218,15 @@ RowLayout {
const ids = [], cards = handcardAreaItem.cards;
for (let i = 0; i < cards.length; i++) {
cards[i].prohibitReason = "";
if (JSON.parse(Backend.callLuaFunction("CanUseCard", [cards[i].cid, Self.id, JSON.stringify(roomScene.extra_data)]))) {
if (lcall("CanUseCard", cards[i].cid, Self.id,
JSON.stringify(roomScene.extra_data))) {
ids.push(cards[i].cid);
} else {
// cannot use? considering special_skills
const skills = JSON.parse(Backend.callLuaFunction("GetCardSpecialSkills", [cards[i].cid]));
const skills = lcall("GetCardSpecialSkills", cards[i].cid);
for (let j = 0; j < skills.length; j++) {
const s = skills[j];
if (JSON.parse(Backend.callLuaFunction("ActiveCanUse", [s, JSON.stringify(roomScene.extra_data)]))) {
if (lcall("ActiveCanUse", s, JSON.stringify(roomScene.extra_data))) {
ids.push(cards[i].cid);
break;
}
@ -238,7 +234,8 @@ RowLayout {
// still cannot use? show message on card
if (!ids.includes(cards[i].cid)) {
const prohibitReason = Backend.callLuaFunction("GetCardProhibitReason", [cards[i].cid, "play"]);
const prohibitReason = lcall("GetCardProhibitReason", cards[i].cid,
"play");
if (prohibitReason) {
cards[i].prohibitReason = prohibitReason;
}
@ -304,21 +301,10 @@ RowLayout {
}
}
function processPrompt(prompt) {
const data = prompt.split(":");
let raw = Backend.translate(data[0]);
const src = parseInt(data[1]);
const dest = parseInt(data[2]);
if (raw.match("%src")) raw = raw.replace(/%src/g, Backend.translate(getPhoto(src).general));
if (raw.match("%dest")) raw = raw.replace(/%dest/g, Backend.translate(getPhoto(dest).general));
if (raw.match("%arg2")) raw = raw.replace(/%arg2/g, Backend.translate(data[4]));
if (raw.match("%arg")) raw = raw.replace(/%arg/g, Backend.translate(data[3]));
return raw;
}
function extractWoodenOx() {
const pile_data = JSON.parse(Backend.callLuaFunction("GetAllPiles", [self.playerid]));
if (!roomScene.autoPending) { // AskForUseActiveSkill使
const pile_data = lcall("GetAllPiles", self.playerid);
if (!roomScene.autoPending) {
// AskForUseActiveSkill使
for (let name in pile_data) {
if (name.endsWith("&")) expandPile(name);
}
@ -331,28 +317,21 @@ RowLayout {
const enabled_cards = [];
const targets = roomScene.selected_targets;
const prompt = JSON.parse(Backend.callLuaFunction(
"ActiveSkillPrompt",
[pending_skill, pendings, targets]
));
const prompt = lcall("ActiveSkillPrompt", pending_skill, pendings,
targets);
if (prompt !== "") {
roomScene.setPrompt(processPrompt(prompt));
roomScene.setPrompt(Util.processPrompt(prompt));
}
handcardAreaItem.cards.forEach((card) => {
if (card.selected || JSON.parse(Backend.callLuaFunction(
"ActiveCardFilter",
[pending_skill, card.cid, pendings, targets]
)))
if (card.selected || lcall("ActiveCardFilter", pending_skill, card.cid,
pendings, targets))
enabled_cards.push(card.cid);
});
const cards = self.equipArea.getAllCards();
cards.forEach(c => {
if (JSON.parse(Backend.callLuaFunction(
"ActiveCardFilter",
[pending_skill, c.cid, pendings, targets]
))) {
if (lcall("ActiveCardFilter", pending_skill, c.cid, pendings, targets)) {
enabled_cards.push(c.cid);
if (!expanded_piles["_equip"]) {
expandPile("_equip");
@ -360,13 +339,10 @@ RowLayout {
}
})
const pile = Backend.callLuaFunction("GetExpandPileOfSkill", [pending_skill]);
const pile_ids = JSON.parse(Backend.callLuaFunction("GetPile", [self.playerid, pile]));
const pile = lcall("GetExpandPileOfSkill", pending_skill);
const pile_ids = lcall("GetPile", self.playerid, pile);
pile_ids.forEach(cid => {
if (JSON.parse(Backend.callLuaFunction(
"ActiveCardFilter",
[pending_skill, cid, pendings, targets]
))) {
if (lcall("ActiveCardFilter", pending_skill, cid, pendings, targets)) {
enabled_cards.push(cid);
};
if (!expanded_piles[pile]) {
@ -376,10 +352,7 @@ RowLayout {
handcardAreaItem.enableCards(enabled_cards);
if (JSON.parse(Backend.callLuaFunction(
"CanViewAs",
[pending_skill, pendings]
))) {
if (lcall("CanViewAs", pending_skill, pendings)) {
pending_card = {
skill: pending_skill,
subcards: pendings
@ -462,8 +435,8 @@ RowLayout {
continue;
}
const fitpattern = JSON.parse(Backend.callLuaFunction("SkillFitPattern", [item.orig, cname]));
const canresp = JSON.parse(Backend.callLuaFunction("SkillCanResponse", [item.orig, cardResponsing]));
const fitpattern = lcall("SkillFitPattern", item.orig, cname);
const canresp = lcall("SkillCanResponse", item.orig, cardResponsing);
item.enabled = fitpattern && canresp;
}
return;
@ -475,7 +448,8 @@ RowLayout {
continue;
}
item.enabled = JSON.parse(Backend.callLuaFunction("ActiveCanUse", [item.orig, JSON.stringify(roomScene.extra_data)]));
item.enabled = lcall("ActiveCanUse", item.orig,
JSON.stringify(roomScene.extra_data));
}
}
@ -490,10 +464,9 @@ RowLayout {
}
function updateHandcards() {
Backend.callLuaFunction("FilterMyHandcards", []);
lcall("FilterMyHandcards");
handcardAreaItem.cards.forEach(v => {
const data = JSON.parse(Backend.callLuaFunction("GetCardData", [v.cid]));
v.setData(data);
v.setData(lcall("GetCardData", v.cid));
});
}
@ -514,12 +487,12 @@ RowLayout {
skillPanel.clearSkills();
const skills = JSON.parse(Backend.callLuaFunction("GetPlayerSkills", [Self.id]));
const skills = lcall("GetPlayerSkills", Self.id);
for (let s of skills) {
addSkill(s.name);
}
cards = roomScene.drawPile.remove(JSON.parse(Backend.callLuaFunction("GetPlayerHandcards", [Self.id])));
cards = roomScene.drawPile.remove(lcall("GetPlayerHandcards", Self.id));
handcardAreaItem.add(cards);
}
}

View File

@ -15,7 +15,7 @@ GraphicsBox {
property var result: []
id: root
title.text: Backend.translate("$Choice").arg(Backend.translate(skill_name))
title.text: luatr("$Choice").arg(luatr(skill_name))
width: Math.max(140, body.width + 20)
height: buttons.height + body.height + title.height + 20
@ -38,8 +38,9 @@ GraphicsBox {
MetroToggleButton {
id: choicetitle
width: parent.width
text: Backend.translate(modelData)
enabled: options.indexOf(modelData) !== -1 && (root.result.length < max_num || triggered)
text: luatr(modelData)
enabled: options.indexOf(modelData) !== -1
&& (root.result.length < max_num || triggered)
textFont.pixelSize: 24
anchors.top: choiceDetail.bottom
anchors.topMargin: 8
@ -64,7 +65,7 @@ GraphicsBox {
Text {
id: detail
width: parent.width
text: Backend.translate(":" + modelData)
text: luatr(":" + modelData)
color: "white"
wrapMode: Text.WordWrap
font.pixelSize: 16
@ -84,7 +85,7 @@ GraphicsBox {
MetroButton {
width: 120
height: 35
text: Backend.translate("OK")
text: luatr("OK")
enabled: root.result.length >= min_num
onClicked: {
@ -95,7 +96,7 @@ GraphicsBox {
MetroButton {
width: 120
height: 35
text: Backend.translate("Cancel")
text: luatr("Cancel")
visible: root.cancelable
onClicked: {

View File

@ -12,7 +12,7 @@ GraphicsBox {
property int result
id: root
title.text: Backend.translate("$Choice").arg(Backend.translate(skill_name))
title.text: luatr("$Choice").arg(luatr(skill_name))
width: Math.max(140, body.width + 20)
height: body.height + title.height + 20
@ -35,7 +35,7 @@ GraphicsBox {
MetroButton {
id: choicetitle
width: parent.width
text: Backend.translate(modelData)
text: luatr(modelData)
enabled: options.indexOf(modelData) !== -1
textFont.pixelSize: 24
anchors.top: choiceDetail.bottom
@ -57,7 +57,7 @@ GraphicsBox {
Text {
id: detail
width: parent.width
text: Backend.translate(":" + modelData)
text: luatr(":" + modelData)
color: "white"
wrapMode: Text.WordWrap
font.pixelSize: 16

View File

@ -7,7 +7,7 @@ GraphicsBox {
property string winner: ""
id: root
title.text: Backend.translate("$GameOver")
title.text: luatr("$GameOver")
width: Math.max(140, body.width + 20)
height: body.height + title.height + 20
@ -18,12 +18,13 @@ GraphicsBox {
spacing: 10
Text {
text: winner !== "" ? Backend.translate("$Winner").arg(Backend.translate(winner)) : Backend.translate("$NoWinner")
text: winner !== "" ? luatr("$Winner").arg(luatr(winner))
: luatr("$NoWinner")
color: "#E4D5A0"
}
MetroButton {
text: Backend.translate("Back To Room")
text: luatr("Back To Room")
anchors.horizontalCenter: parent.horizontalCenter
visible: !config.observing
@ -34,7 +35,7 @@ GraphicsBox {
}
MetroButton {
text: Backend.translate("Back To Lobby")
text: luatr("Back To Lobby")
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
@ -49,13 +50,13 @@ GraphicsBox {
MetroButton {
id: repBtn
text: Backend.translate("Save Replay")
text: luatr("Save Replay")
anchors.horizontalCenter: parent.horizontalCenter
visible: !config.replaying
onClicked: {
repBtn.visible = false;
Backend.callLuaFunction("SaveRecord", []);
lcall("SaveRecord");
toast.show("OK.");
}
}

View File

@ -29,11 +29,13 @@ CardItem {
suit: ""
number: 0
footnote: ""
card.source: known ? SkinBank.getGeneralPicture(name) : (SkinBank.GENERALCARD_DIR + 'card-back')
card.source: known ? SkinBank.getGeneralPicture(name)
: (SkinBank.GENERALCARD_DIR + 'card-back')
glow.color: "white" //Engine.kingdomColor[kingdom]
// FIXME:
property bool heg: name.startsWith('hs__') || name.startsWith('ld__') || name.includes('heg__')
property bool heg: name.startsWith('hs__') || name.startsWith('ld__') ||
name.includes('heg__')
Image {
source: known ? (SkinBank.GENERALCARD_DIR + "border") : ""
@ -51,7 +53,8 @@ CardItem {
scale: 0.6; x: 9; y: 12
transformOrigin: Item.TopLeft
width: 34; fillMode: Image.PreserveAspectFit
source: subkingdom ? SkinBank.getGeneralCardDir(subkingdom) + subkingdom : ""
source: subkingdom ? SkinBank.getGeneralCardDir(subkingdom) + subkingdom
: ""
visible: detailed && known
}
@ -72,7 +75,8 @@ CardItem {
Image {
id: subkingdomMagatama
visible: false
source: subkingdom ? SkinBank.getGeneralCardDir(subkingdom) + subkingdom + "-magatama" : ""
source: subkingdom ? SkinBank.getGeneralCardDir(subkingdom) +
subkingdom + "-magatama" : ""
}
LinearGradient {
id: subkingdomMask
@ -153,8 +157,8 @@ CardItem {
height: 80
x: 2
y: lineCount > 6 ? 30 : 34
text: name !== "" ? Backend.translate(name) : "nil"
visible: Backend.translate(name).length <= 6 && detailed && known
text: name !== "" ? luatr(name) : "nil"
visible: luatr(name).length <= 6 && detailed && known
color: "white"
font.family: fontLibian.name
font.pixelSize: 18
@ -168,8 +172,8 @@ CardItem {
y: 12
rotation: 90
transformOrigin: Item.BottomLeft
text: Backend.translate(name)
visible: Backend.translate(name).length > 6 && detailed && known
text: luatr(name)
visible: luatr(name).length > 6 && detailed && known
color: "white"
font.family: fontLibian.name
font.pixelSize: 18
@ -191,7 +195,7 @@ CardItem {
border.color: "white"
border.width: 1
Text {
text: Backend.translate(pkgName)
text: luatr(pkgName)
x: 2; y: 1
font.family: fontLibian.name
font.pixelSize: 14
@ -202,7 +206,7 @@ CardItem {
}
onNameChanged: {
const data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name]));
const data = lcall("GetGeneralData", name);
kingdom = data.kingdom;
subkingdom = (data.subkingdom !== kingdom && data.subkingdom) || "";
hp = data.hp;

View File

@ -14,7 +14,7 @@ GraphicsBox {
property var areaNames: []
property int padding: 25
title.text: Backend.translate(prompt !== "" ? prompt : "Please arrange cards")
title.text: luatr(prompt !== "" ? prompt : "Please arrange cards")
width: body.width + padding * 2
height: title.height + body.height + padding * 2
@ -32,7 +32,8 @@ GraphicsBox {
spacing: 5
property int areaCapacity: modelData
property string areaName: index < areaNames.length ? qsTr(areaNames[index]) : ""
property string areaName: index < areaNames.length
? qsTr(areaNames[index]) : ""
Rectangle {
anchors.verticalCenter: parent.verticalCenter
@ -81,7 +82,7 @@ GraphicsBox {
MetroButton {
Layout.alignment: Qt.AlignHCenter
id: buttonConfirm
text: Backend.translate("OK")
text: luatr("OK")
width: 120
height: 35

View File

@ -46,7 +46,7 @@ Item {
card = result[i];
card.draggable = false;
card.selectable = false;
card.showDetail = false;
// card.showDetail = false;
card.selectedChanged.disconnect(adjustCards);
card.prohibitReason = "";
}
@ -57,7 +57,7 @@ Item {
{
let card, i;
cards.forEach(card => {
card.selectable = cardIds.contains(card.cid);
card.selectable = cardIds.includes(card.cid);
if (!card.selectable) {
card.selected = false;
unselectCard(card);
@ -93,10 +93,10 @@ Item {
for (let i = 0; i < cards.length; i++) {
const card = cards[i];
if (card.selected) {
if (!selectedCards.contains(card))
if (!selectedCards.includes(card))
selectCard(card);
} else {
if (selectedCards.contains(card))
if (selectedCards.includes(card))
unselectCard(card);
}
}

View File

@ -20,7 +20,8 @@ Item {
Rectangle {
width: 6
height: Math.sqrt(Math.pow(modelData.x - start.x, 2) + Math.pow(modelData.y - start.y, 2)) * ratio
height: Math.sqrt(Math.pow(modelData.x - start.x, 2) +
Math.pow(modelData.y - start.y, 2)) * ratio
x: start.x
y: start.y
antialiasing: true

View File

@ -59,11 +59,12 @@ Item {
const items = [];
for (let i = 0; i < outputs.length; i++) {
if (_contains(outputs[i])) {
const state = JSON.parse(Backend.callLuaFunction("GetCardData", [outputs[i]]))
const state = lcall("GetCardData", outputs[i]);
state.x = parentPos.x;
state.y = parentPos.y;
state.opacity = 0;
card = component.createObject(roomScene.dynamicCardArea, state);
card.showDetail = true
card.x -= card.width / 2;
card.x += (i - outputs.length / 2) * 15;
card.y -= card.height / 2;
@ -93,7 +94,8 @@ Item {
const parentPos = roomScene.mapFromItem(root, 0, 0);
for (i = 0; i < pendingInput.length; i++) {
card = pendingInput[i];
card.origX = parentPos.x - card.width / 2 + ((i - pendingInput.length / 2) * 15);
card.origX = parentPos.x - card.width / 2
+ ((i - pendingInput.length / 2) * 15);
card.origY = parentPos.y - card.height / 2;
card.origOpacity = 0;
card.destroyOnStop();

View File

@ -19,7 +19,7 @@ Item {
Text {
id: roundTxt
anchors.right: parent.right
text: Backend.translate("#currentRoundNum").arg(roundNum)
text: luatr("#currentRoundNum").arg(roundNum)
color: "#F0E5DA"
font.pixelSize: 18
font.family: fontLibian.name

View File

@ -13,7 +13,7 @@ GraphicsBox {
property var result
property int padding: 25
title.text: Backend.translate("Please click to move card")
title.text: luatr("Please click to move card")
width: body.width + padding * 2
height: title.height + body.height + padding * 2
@ -65,7 +65,7 @@ GraphicsBox {
Text {
horizontalAlignment: Text.AlignHCenter
anchors.centerIn: parent
text: Backend.translate(modelData.subtype)
text: luatr(modelData.subtype)
color: "#90765F"
font.family: fontLibian.name
font.pixelSize: 16
@ -81,7 +81,7 @@ GraphicsBox {
MetroButton {
Layout.alignment: Qt.AlignHCenter
id: buttonConfirm
text: Backend.translate("OK")
text: luatr("OK")
width: 120
height: 35
enabled: false
@ -131,7 +131,8 @@ GraphicsBox {
const index = cards.findIndex(data => item.cid === data.cid);
result && (result.pos = cardsPosition[index]);
const cardPos = cardsPosition[index] === 0 ? (result ? 1 : 0) : (result ? 0 : 1);
const cardPos = cardsPosition[index] === 0 ? (result ? 1 : 0)
: (result ? 0 : 1);
const curArea = areaRepeater.itemAt(cardPos);
const curBox = curArea.cardRepeater.itemAt(index);
const curPos = mapFromItem(curArea, curBox.x, curBox.y);

View File

@ -187,7 +187,8 @@ Item {
return "";
}
if (deputyGeneral) {
return SkinBank.getGeneralExtraPic(general, "dual/") ?? SkinBank.getGeneralPicture(general);
return SkinBank.getGeneralExtraPic(general, "dual/")
?? SkinBank.getGeneralPicture(general);
} else {
return SkinBank.getGeneralPicture(general)
}
@ -204,7 +205,8 @@ Item {
source: {
const general = deputyGeneral;
if (deputyGeneral != "") {
return SkinBank.getGeneralExtraPic(general, "dual/") ?? SkinBank.getGeneralPicture(general);
return SkinBank.getGeneralExtraPic(general, "dual/")
?? SkinBank.getGeneralPicture(general);
} else {
return "";
}
@ -231,7 +233,7 @@ Item {
color: "white"
width: 24
wrapMode: Text.WrapAnywhere
text: Backend.translate(deputyGeneral)
text: luatr(deputyGeneral)
style: Text.Outline
}
}
@ -280,7 +282,7 @@ Item {
GlowText {
Layout.alignment: Qt.AlignCenter
text: Backend.translate("resting...")
text: luatr("resting...")
font.family: fontLibian.name
font.pixelSize: 40
font.bold: true
@ -304,7 +306,7 @@ Item {
GlowText {
Layout.alignment: Qt.AlignCenter
visible: root.rest > 0 && root.rest < 999
text: Backend.translate("rest round num")
text: luatr("rest round num")
font.family: fontLibian.name
font.pixelSize: 28
color: "#F0E5D6"
@ -334,11 +336,11 @@ Item {
style: Text.Outline
text: {
if (totalGame === 0) {
return Backend.translate("Newbie");
return luatr("Newbie");
}
const winRate = (winGame / totalGame) * 100;
const runRate = (runGame / totalGame) * 100;
return Backend.translate("Win=%1\nRun=%2\nTotal=%3")
return luatr("Win=%1\nRun=%2\nTotal=%3")
.arg(winRate.toFixed(2))
.arg(runRate.toFixed(2))
.arg(totalGame);
@ -351,7 +353,8 @@ Item {
anchors.right: parent.right
anchors.bottomMargin: -8
anchors.rightMargin: 4
source: SkinBank.PHOTO_DIR + (isOwner ? "owner" : (ready ? "ready" : "notready"))
source: SkinBank.PHOTO_DIR +
(isOwner ? "owner" : (ready ? "ready" : "notready"))
visible: screenName != "" && !roomScene.isStarted
}
@ -393,7 +396,7 @@ Item {
}
function updatePileInfo(areaName) {
const data = JSON.parse(Backend.callLuaFunction("GetPile", [root.playerid, areaName]));
const data = lcall("GetPile", root.playerid, areaName);
if (data.length === 0) {
root.markArea.removeMark(areaName);
} else {
@ -460,7 +463,14 @@ Item {
x: -6
Text {
text: (root.maxCard === root.hp || root.hp < 0 ) ? (root.handcards) : (root.handcards + "/" + (root.maxCard < 900 ? root.maxCard : "∞"))
text: {
if (root.maxCard === root.hp || root.hp < 0) {
return root.handcards;
} else {
const maxCard = root.maxCard < 900 ? root.maxCard : "∞";
return root.handcards + "/" + maxCard;
}
}
font.family: fontLibian.name
font.pixelSize: (root.maxCard === root.hp || root.hp < 0 ) ? 32 : 27
//font.weight: 30
@ -472,10 +482,11 @@ Item {
}
TapHandler {
enabled: (root.state != "candidate" || !root.selectable) && root.playerid !== Self.id
enabled: (root.state != "candidate" || !root.selectable)
&& root.playerid !== Self.id
onTapped: {
const params = { name: "hand_card" };
let data = JSON.parse(Backend.callLuaFunction("GetPlayerHandcards", [root.playerid]));
let data = lcall("GetPlayerHandcards", root.playerid);
data = data.filter((e) => e !== -1);
if (data.length === 0)
return;
@ -532,7 +543,12 @@ Item {
anchors.topMargin: 2
font.pixelSize: 16
text: (config.blockedUsers && config.blockedUsers.includes(screenName) ? Backend.translate("<Blocked> ") : "") + screenName
text: {
let ret = screenName;
if (config.blockedUsers?.includes(screenName))
ret = luatr("<Blocked> ") + ret;
return ret;
}
glow.radius: 8
}
@ -549,7 +565,10 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: -32
property var seatChr: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"]
property var seatChr: [
"一", "二", "三", "四", "五", "六",
"七", "八", "九", "十", "十一", "十二",
]
font.family: fontLi2.name
font.pixelSize: 32
text: seatChr[seatNumber - 1]
@ -705,7 +724,7 @@ Item {
onGeneralChanged: {
if (!roomScene.isStarted) return;
const text = Backend.translate(general);
const text = luatr(general);
if (text.length > 6) {
generalName.text = "";
longGeneralName.text = text;
@ -713,8 +732,6 @@ Item {
generalName.text = text;
longGeneralName.text = "";
}
// let data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [general]));
// kingdom = data.kingdom;
}
function chat(msg) {

View File

@ -2,13 +2,18 @@
import QtQuick
import QtQuick.Layouts
import Fk
import Fk.Pages
GraphicsBox {
id: root
property string prompt
title.text: prompt === "" ? (root.multiChoose ? Backend.translate("$ChooseCards").arg(root.min).arg(root.max) : Backend.translate("$ChooseCard")) : processPrompt(prompt)
title.text: prompt === "" ?
(root.multiChoose ?
luatr("$ChooseCards").arg(root.min).arg(root.max)
: luatr("$ChooseCard"))
: Util.processPrompt(prompt)
// TODO: Adjust the UI design in case there are more than 7 cards
width: 70 + 700
@ -50,7 +55,7 @@ GraphicsBox {
Text {
color: "#E4D5A0"
text: Backend.translate(areaName)
text: luatr(areaName)
anchors.fill: parent
wrapMode: Text.WrapAnywhere
verticalAlignment: Text.AlignVCenter
@ -95,26 +100,15 @@ GraphicsBox {
MetroButton {
anchors.bottom: parent.bottom
text: Backend.translate("OK")
text: luatr("OK")
visible: root.multiChoose
enabled: root.selected_ids.length <= root.max && root.selected_ids.length >= root.min
enabled: root.selected_ids.length <= root.max
&& root.selected_ids.length >= root.min
onClicked: root.cardsSelected(root.selected_ids)
}
onCardSelected: finished();
function processPrompt(prompt) {
const data = prompt.split(":");
let raw = Backend.translate(data[0]);
const src = parseInt(data[1]);
const dest = parseInt(data[2]);
if (raw.match("%src")) raw = raw.replace(/%src/g, Backend.translate(getPhoto(src).general));
if (raw.match("%dest")) raw = raw.replace(/%dest/g, Backend.translate(getPhoto(dest).general));
if (raw.match("%arg2")) raw = raw.replace(/%arg2/g, Backend.translate(data[4]));
if (raw.match("%arg")) raw = raw.replace(/%arg/g, Backend.translate(data[3]));
return raw;
}
function findAreaModel(name) {
let ret;
for (let i = 0; i < cardModel.count; i++) {

View File

@ -7,7 +7,7 @@ import Fk.Pages
GraphicsBox {
id: root
title.text: Backend.callLuaFunction("PoxiPrompt", [poxi_type, card_data, extra_data])
title.text: lcall("PoxiPrompt", poxi_type, card_data, extra_data)
// TODO: Adjust the UI design in case there are more than 7 cards
width: 70 + 700
@ -50,7 +50,7 @@ GraphicsBox {
Text {
color: "#E4D5A0"
text: Backend.translate(areaName)
text: luatr(areaName)
anchors.fill: parent
wrapMode: Text.WrapAnywhere
verticalAlignment: Text.AlignVCenter
@ -71,12 +71,10 @@ GraphicsBox {
number: model.number || 0
autoBack: false
known: model.cid !== -1
selectable: {
return root.selected_ids.includes(model.cid) || JSON.parse(Backend.callLuaFunction(
"PoxiFilter",
[root.poxi_type, model.cid, root.selected_ids, root.card_data, root.extra_data]
));
}
selectable: root.selected_ids.includes(model.cid) ||
lcall("PoxiFilter", root.poxi_type, model.cid, root.selected_ids,
root.card_data, root.extra_data);
onSelectedChanged: {
if (selected) {
chosenInBox = true;
@ -102,20 +100,16 @@ GraphicsBox {
MetroButton {
width: 120
height: 35
text: Backend.translate("OK")
enabled: {
return JSON.parse(Backend.callLuaFunction(
"PoxiFeasible",
[root.poxi_type, root.selected_ids, root.card_data, root.extra_data]
));
}
text: luatr("OK")
enabled: lcall("PoxiFeasible", root.poxi_type, root.selected_ids,
root.card_data, root.extra_data);
onClicked: root.cardsSelected(root.selected_ids)
}
MetroButton {
width: 120
height: 35
text: Backend.translate("Cancel")
text: luatr("Cancel")
visible: root.cancelable
onClicked: root.cardsSelected([])
}

View File

@ -112,10 +112,7 @@ Flickable {
return false;
};
const data = JSON.parse(Backend.callLuaFunction(
"GetSkillData",
[skill_name]
));
const data = lcall("GetSkillData", skill_name);
if (prelight) {
if (!modelContains(prelight_skills, data))

View File

@ -28,12 +28,12 @@ Item {
Text {
text: {
let o = "$" + skillName + "_" + generalName + (index % 2 + 1);
let p = Backend.translate(o);
let p = luatr(o);
if (o !== p) {
return p;
}
o = "$" + skillName + (index % 2 + 1);
p = Backend.translate(o);
p = luatr(o);
if (o === p) {
return "Ultimate Skill Invoked!";
}
@ -59,12 +59,12 @@ Item {
Text {
text: {
let o = "$" + skillName + "_" + generalName + ((index + 1) % 2 + 1);
let p = Backend.translate(o);
let p = luatr(o);
if (o !== p) {
return p;
}
o = "$" + skillName + ((index + 1) % 2 + 1);
p = Backend.translate(o);
p = luatr(o);
if (o === p) {
return "Ultimate Skill Invoked!";
}
@ -90,7 +90,7 @@ Item {
Text {
topPadding: 5
id: skill
text: Backend.translate(skillName)
text: luatr(skillName)
font.family: fontLi2.name
font.pixelSize: 40
x: root.width / 2 + 100

View File

@ -13,7 +13,7 @@ ColumnLayout {
Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height + 4
text: Backend.translate(extra_data.name)
text: luatr(extra_data.name)
}
GridView {

View File

@ -13,7 +13,7 @@ ColumnLayout {
Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height + 4
text: Backend.translate(extra_data.name)
text: luatr(extra_data.name)
}
GridView {
@ -32,7 +32,7 @@ ColumnLayout {
Component.onCompleted: {
let data = {}
if (extra_data.ids) {
data = JSON.parse(Backend.callLuaFunction("GetCardData", [modelData]));
data = lcall("GetCardData", modelData);
} else {
data.cid = 0;
data.name = modelData;

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import Fk
import Fk.Pages
MetroButton {
@ -12,34 +13,21 @@ MetroButton {
property string answer: default_choice
property bool detailed: false
function processPrompt(prompt) {
const data = prompt.split(":");
let raw = Backend.translate(data[0]);
const src = parseInt(data[1]);
const dest = parseInt(data[2]);
if (raw.match("%src")) raw = raw.replace(/%src/g, Backend.translate(getPhoto(src).general));
if (raw.match("%dest")) raw = raw.replace(/%dest/g, Backend.translate(getPhoto(dest).general));
if (raw.match("%arg2")) raw = raw.replace(/%arg2/g, Backend.translate(data[4]));
if (raw.match("%arg")) raw = raw.replace(/%arg/g, Backend.translate(data[3]));
return raw;
}
text: processPrompt(answer)
text: Util.processPrompt(answer)
onAnswerChanged: {
if (!answer) return;
Backend.callLuaFunction(
"SetInteractionDataOfSkill",
[skill, JSON.stringify(answer)]
);
lcall("SetInteractionDataOfSkill", skill, JSON.stringify(answer));
roomScene.dashboard.startPending(skill);
}
onClicked: {
if (detailed) {
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/DetailedChoiceBox.qml");
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/DetailedChoiceBox.qml");
} else {
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/ChoiceBox.qml");
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/ChoiceBox.qml");
}
const box = roomScene.popupBox.item;
box.options = choices;

View File

@ -10,11 +10,7 @@ SpinBox {
// from, to
onValueChanged: {
Backend.callLuaFunction(
"SetInteractionDataOfSkill",
[skill, JSON.stringify(answer)]
);
lcall("SetInteractionDataOfSkill", skill, JSON.stringify(answer));
roomScene.dashboard.startPending(skill);
}
}

View File

@ -89,8 +89,14 @@ Rectangle {
id: textAni
running: false
loops: Animation.Infinite
NumberAnimation { from: 0; to: 1; duration: 1600; easing.type: Easing.InOutQuad; }
NumberAnimation { from: 1; to: 0; duration: 1600; easing.type: Easing.InOutQuad; }
NumberAnimation {
from: 0; to: 1; duration: 1600
easing.type: Easing.InOutQuad
}
NumberAnimation {
from: 1; to: 0; duration: 1600
easing.type: Easing.InOutQuad
}
}
}

View File

@ -15,7 +15,8 @@ Rectangle {
property real time: defaultTime
readonly property real fadeTime: 300
anchors.horizontalCenter: parent != null ? parent.horizontalCenter : undefined
anchors.horizontalCenter: parent != null ? parent.horizontalCenter
: undefined
height: message.height + 20
width: message.width + 40
radius: 16

View File

@ -2,8 +2,8 @@
import QtQuick
// copy from https://gist.github.com/jonmcclung/bae669101d17b103e94790341301c129
// and modified some code
// https://gist.github.com/jonmcclung/bae669101d17b103e94790341301c129
// modified some code
ListView {
function show(text, duration) {
if (duration === undefined) {

View File

@ -45,7 +45,8 @@ Window {
StackView {
id: mainStack
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: init
anchors.fill: parent
}
@ -159,7 +160,10 @@ Window {
return;
}
if (mainWindow.is_pending && command !== "ChangeSelf") {
mainWindow.pending_message.push({ command: command, jsonData: jsonData });
mainWindow.pending_message.push({
command: command,
jsonData: jsonData,
});
} else {
if (command === "StartChangeSelf") {
mainWindow.is_pending = true;
@ -254,4 +258,18 @@ Window {
exitMessageDialog.open();
}
}
// fake global functions
function lcall(funcName, ...params) {
const ret = Backend.callLuaFunction(funcName, [...params]);
try {
return JSON.parse(ret);
} catch (e) {
return ret;
}
}
function luatr(src) {
return Backend.translate(src);
}
}

View File

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

View File

@ -31,18 +31,20 @@ const searchPkgResource = function(path, name, suffix) {
}
function getGeneralExtraPic(name, extra) {
const data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name]));
const data = lcall("GetGeneralData", name);
const extension = data.extension;
const path = AppPath + "/packages/" + extension + "/image/generals/" + extra + name + ".jpg";
const path = AppPath + "/packages/" + extension + "/image/generals/"
+ extra + name + ".jpg";
if (Backend.exists(path)) {
return path;
}
}
function getGeneralPicture(name) {
const data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name]));
const data = lcall("GetGeneralData", name);
const extension = data.extension;
const path = AppPath + "/packages/" + extension + "/image/generals/" + name + ".jpg";
const path = AppPath + "/packages/" + extension + "/image/generals/"
+ name + ".jpg";
if (Backend.exists(path)) {
return path;
}
@ -54,14 +56,15 @@ function getCardPicture(cidOrName) {
let name = "unknown";
if (typeof cidOrName === 'string') {
name = cidOrName;
extension = Backend.callLuaFunction("GetCardExtensionByName", [cidOrName]);
extension = lcall("GetCardExtensionByName", cidOrName);
} else {
const data = JSON.parse(Backend.callLuaFunction("GetCardData", [cid]));
const data = lcall("GetCardData", cid);
extension = data.extension;
name = data.name;
}
let path = AppPath + "/packages/" + extension + "/image/card/" + name + ".png";
let path = AppPath + "/packages/" + extension + "/image/card/"
+ name + ".png";
if (Backend.exists(path)) {
return path;
} else {
@ -72,9 +75,10 @@ function getCardPicture(cidOrName) {
}
function getDelayedTrickPicture(name) {
const extension = Backend.callLuaFunction("GetCardExtensionByName", [name]);
const extension = lcall("GetCardExtensionByName", name);
let path = AppPath + "/packages/" + extension + "/image/card/delayedTrick/" + name + ".png";
let path = AppPath + "/packages/" + extension + "/image/card/delayedTrick/"
+ name + ".png";
if (Backend.exists(path)) {
return path;
} else {
@ -86,10 +90,11 @@ function getDelayedTrickPicture(name) {
function getEquipIcon(cid, icon) {
const data = JSON.parse(Backend.callLuaFunction("GetCardData", [cid]));
const data = lcall("GetCardData", cid);
const extension = data.extension;
const name = icon || data.name;
let path = AppPath + "/packages/" + extension + "/image/card/equipIcon/" + name + ".png";
let path = AppPath + "/packages/" + extension + "/image/card/equipIcon/"
+ name + ".png";
if (Backend.exists(path)) {
return path;
} else {

View File

@ -1,7 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
.pragma library
function convertNumber(number) {
if (number === 1)
return "A";
@ -14,8 +12,20 @@ function convertNumber(number) {
return "";
}
Array.prototype.contains = function(element) {
return this.indexOf(element) != -1;
function processPrompt(prompt) {
const data = prompt.split(":");
let raw = luatr(data[0]);
const src = parseInt(data[1]);
const dest = parseInt(data[2]);
if (raw.match("%src"))
raw = raw.replace(/%src/g, luatr(getPhoto(src).general));
if (raw.match("%dest"))
raw = raw.replace(/%dest/g, luatr(getPhoto(dest).general));
if (raw.match("%arg2"))
raw = raw.replace(/%arg2/g, luatr(data[4]));
if (raw.match("%arg"))
raw = raw.replace(/%arg/g, luatr(data[3]));
return raw;
}
Array.prototype.prepend = function() {

View File

@ -127,6 +127,10 @@ function GetCardExtensionByName(cardName)
return card and card.package.extensionName or ""
end
function GetAllMods()
return json.encode(Fk.extensions)
end
function GetAllGeneralPack()
local ret = {}
for _, name in ipairs(Fk.package_names) do

View File

@ -171,7 +171,7 @@ local function updateColorAndNumber(card)
local different_color = false
for i, id in ipairs(card.subcards) do
local c = Fk:getCardById(id)
number = math.min(number + c.number, 13)
number = #card.subcards == 1 and math.min(number + c.number, 13) or 0
if i == 1 then
card.suit = c.suit
else

View File

@ -7,6 +7,7 @@
--- 同时也提供了许多常用的函数。
---
---@class Engine : Object
---@field public extensions table<string, string[]> @ 所有mod列表及其包含的拓展包
---@field public packages table<string, Package> @ 所有拓展包的列表
---@field public package_names string[] @ 含所有拓展包名字的数组,为了方便排序
---@field public skills table<string, Skill> @ 所有的技能
@ -44,6 +45,11 @@ function Engine:initialize()
Fk = self
self.extensions = {
["standard"] = { "standard" },
["standard_cards"] = { "standard_cards" },
["maneuvering"] = { "maneuvering" },
}
self.packages = {} -- name --> Package
self.package_names = {}
self.skills = {} -- name --> Skill
@ -142,10 +148,13 @@ function Engine:loadPackages()
-- so dont use type(pack) == "table" here
if type(pack) == "table" then
if pack[1] ~= nil then
self.extensions[dir] = {}
for _, p in ipairs(pack) do
table.insert(self.extensions[dir], p.name)
self:loadPackage(p)
end
else
self.extensions[dir] = { pack.name }
self:loadPackage(pack)
end
end

View File

@ -128,9 +128,10 @@ end
GameEvent.functions[GameEvent.ClearEvent] = function(self)
local event = self.data[1]
local logic = self.room.logic
event:clear_func()
-- 不可中断
Pcall(event.clear_func, event)
for _, f in ipairs(event.extra_clear_funcs) do
if type(f) == "function" then f(event) end
if type(f) == "function" then Pcall(f, event) end
end
-- cleaner顺利执行完了出栈吧

View File

@ -16,7 +16,7 @@ ColumnLayout {
Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height + 4
text: Backend.translate(extra_data.name)
text: luatr(extra_data.name)
}
PathView {

View File

@ -393,7 +393,7 @@ clean:
int PackMan::status(const QString &name) {
git_repository *repo = NULL;
int error;
git_status_list *status_list;
git_status_list *status_list = NULL;
size_t i, maxi;
const git_status_entry *s;
auto path = QString("packages/%1").arg(name).toUtf8();