2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-04-14 18:22:00 +08:00
|
|
|
//var AppPath = "file:///home/notify/develop/FreeKill";
|
2022-03-23 19:40:28 +08:00
|
|
|
var PHOTO_BACK_DIR = AppPath + "/image/photo/back/";
|
|
|
|
var PHOTO_DIR = AppPath + "/image/photo/";
|
|
|
|
var GENERAL_DIR = AppPath + "/image/generals/";
|
2022-05-01 18:37:13 +08:00
|
|
|
var GENERALCARD_DIR = AppPath + "/image/card/general/";
|
2022-03-23 19:40:28 +08:00
|
|
|
var STATE_DIR = AppPath + "/image/photo/state/";
|
2022-04-14 18:22:00 +08:00
|
|
|
var STATUS_DIR = AppPath + "/image/photo/status/";
|
2022-03-23 19:40:28 +08:00
|
|
|
var ROLE_DIR = AppPath + "/image/photo/role/";
|
|
|
|
var DEATH_DIR = AppPath + "/image/photo/death/";
|
|
|
|
var MAGATAMA_DIR = AppPath + "/image/photo/magatama/";
|
2023-04-05 01:05:06 +08:00
|
|
|
var LIMIT_SKILL_DIR = AppPath + "/image/photo/skill/";
|
2022-03-23 19:40:28 +08:00
|
|
|
var CARD_DIR = AppPath + "/image/card/";
|
|
|
|
var CARD_SUIT_DIR = AppPath + "/image/card/suit/";
|
2022-04-14 18:22:00 +08:00
|
|
|
var DELAYED_TRICK_DIR = AppPath + "/image/card/delayedTrick/";
|
|
|
|
var EQUIP_ICON_DIR = AppPath + "/image/card/equipIcon/";
|
|
|
|
var PIXANIM_DIR = AppPath + "/image/anim/"
|
2023-01-12 22:53:22 +08:00
|
|
|
var TILE_ICON_DIR = AppPath + "/image/button/tileicon/"
|
2023-03-20 14:53:56 +08:00
|
|
|
var LOBBY_IMG_DIR = AppPath + "/image/lobby/";
|
2024-07-03 01:31:22 +08:00
|
|
|
var MISC_DIR = AppPath + "/image/misc/";
|
2023-02-15 19:54:35 +08:00
|
|
|
|
2023-08-27 20:21:37 +08:00
|
|
|
const searchPkgResource = function(path, name, suffix) {
|
|
|
|
let ret;
|
|
|
|
for (let dir of Backend.ls(AppPath + "/packages/")) {
|
|
|
|
if (Pacman.getDisabledPacks().includes(dir) ||
|
|
|
|
dir.endsWith(".disabled") // in case
|
|
|
|
) continue;
|
|
|
|
ret = AppPath + "/packages/" + dir + path + name + suffix;
|
|
|
|
if (Backend.exists(ret)) return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-16 15:32:16 +08:00
|
|
|
function getGeneralExtraPic(name, extra) {
|
2024-01-25 03:23:29 +08:00
|
|
|
const data = lcall("GetGeneralData", name);
|
2023-07-16 15:32:16 +08:00
|
|
|
const extension = data.extension;
|
2024-01-25 03:23:29 +08:00
|
|
|
const path = AppPath + "/packages/" + extension + "/image/generals/"
|
|
|
|
+ extra + name + ".jpg";
|
2023-07-16 15:32:16 +08:00
|
|
|
if (Backend.exists(path)) {
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-15 19:54:35 +08:00
|
|
|
function getGeneralPicture(name) {
|
2024-01-25 03:23:29 +08:00
|
|
|
const data = lcall("GetGeneralData", name);
|
2023-06-09 17:23:02 +08:00
|
|
|
const extension = data.extension;
|
2024-01-25 03:23:29 +08:00
|
|
|
const path = AppPath + "/packages/" + extension + "/image/generals/"
|
|
|
|
+ name + ".jpg";
|
2023-02-15 19:54:35 +08:00
|
|
|
if (Backend.exists(path)) {
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
return GENERAL_DIR + "0.jpg";
|
|
|
|
}
|
|
|
|
|
2023-05-20 16:00:03 +08:00
|
|
|
function getCardPicture(cidOrName) {
|
|
|
|
let extension = "";
|
|
|
|
let name = "unknown";
|
|
|
|
if (typeof cidOrName === 'string') {
|
|
|
|
name = cidOrName;
|
2024-01-25 03:23:29 +08:00
|
|
|
extension = lcall("GetCardExtensionByName", cidOrName);
|
2023-05-20 16:00:03 +08:00
|
|
|
} else {
|
2024-01-25 03:23:29 +08:00
|
|
|
const data = lcall("GetCardData", cid);
|
2023-05-20 16:00:03 +08:00
|
|
|
extension = data.extension;
|
|
|
|
name = data.name;
|
|
|
|
}
|
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
let path = AppPath + "/packages/" + extension + "/image/card/"
|
|
|
|
+ name + ".png";
|
2023-02-15 19:54:35 +08:00
|
|
|
if (Backend.exists(path)) {
|
|
|
|
return path;
|
2023-03-09 12:19:16 +08:00
|
|
|
} else {
|
2023-08-27 20:21:37 +08:00
|
|
|
let ret = searchPkgResource("/image/card/", name, ".png");
|
|
|
|
if (ret) return ret;
|
2023-02-15 19:54:35 +08:00
|
|
|
}
|
|
|
|
return CARD_DIR + "unknown.png";
|
|
|
|
}
|
2023-04-05 02:21:59 +08:00
|
|
|
|
2023-06-04 19:31:44 +08:00
|
|
|
function getDelayedTrickPicture(name) {
|
2024-01-25 03:23:29 +08:00
|
|
|
const extension = lcall("GetCardExtensionByName", name);
|
2023-06-04 19:31:44 +08:00
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
let path = AppPath + "/packages/" + extension + "/image/card/delayedTrick/"
|
|
|
|
+ name + ".png";
|
2023-06-04 19:31:44 +08:00
|
|
|
if (Backend.exists(path)) {
|
|
|
|
return path;
|
|
|
|
} else {
|
2023-08-27 20:21:37 +08:00
|
|
|
let ret = searchPkgResource("/image/card/delayedTrick/", name, ".png");
|
|
|
|
if (ret) return ret;
|
2023-06-04 19:31:44 +08:00
|
|
|
}
|
|
|
|
return DELAYED_TRICK_DIR + "unknown.png";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-05 02:21:59 +08:00
|
|
|
function getEquipIcon(cid, icon) {
|
2024-01-25 03:23:29 +08:00
|
|
|
const data = lcall("GetCardData", cid);
|
2023-06-09 17:23:02 +08:00
|
|
|
const extension = data.extension;
|
|
|
|
const name = icon || data.name;
|
2024-01-25 03:23:29 +08:00
|
|
|
let path = AppPath + "/packages/" + extension + "/image/card/equipIcon/"
|
|
|
|
+ name + ".png";
|
2023-04-05 02:21:59 +08:00
|
|
|
if (Backend.exists(path)) {
|
|
|
|
return path;
|
|
|
|
} else {
|
2023-08-27 20:21:37 +08:00
|
|
|
let ret = searchPkgResource("/image/card/equipIcon/", name, ".png");
|
|
|
|
if (ret) return ret;
|
2023-04-05 02:21:59 +08:00
|
|
|
}
|
|
|
|
return EQUIP_ICON_DIR + "unknown.png";
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPhotoBack(kingdom) {
|
|
|
|
let path = PHOTO_BACK_DIR + kingdom + ".png";
|
|
|
|
if (!Backend.exists(path)) {
|
2023-08-27 20:21:37 +08:00
|
|
|
let ret = searchPkgResource("/image/kingdom/", kingdom, "-back.png");
|
|
|
|
if (ret) return ret;
|
2023-04-05 02:21:59 +08:00
|
|
|
} else {
|
|
|
|
return path;
|
|
|
|
}
|
2023-04-23 21:10:07 +08:00
|
|
|
return PHOTO_BACK_DIR + "unknown";
|
2023-04-05 02:21:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function getGeneralCardDir(kingdom) {
|
|
|
|
let path = GENERALCARD_DIR + kingdom + ".png";
|
|
|
|
if (!Backend.exists(path)) {
|
2023-08-27 20:21:37 +08:00
|
|
|
let ret = searchPkgResource("/image/kingdom/", kingdom, "-back.png");
|
|
|
|
if (ret) return ret.slice(0, ret.lastIndexOf('/')) + "/";
|
2023-04-05 02:21:59 +08:00
|
|
|
} else {
|
|
|
|
return GENERALCARD_DIR;
|
|
|
|
}
|
|
|
|
}
|
2023-08-09 22:25:15 +08:00
|
|
|
|
|
|
|
function getRolePic(role) {
|
|
|
|
let path = ROLE_DIR + role + ".png";
|
|
|
|
if (Backend.exists(path)) {
|
|
|
|
return path;
|
|
|
|
} else {
|
2023-08-27 20:21:37 +08:00
|
|
|
let ret = searchPkgResource("/image/role/", role, ".png");
|
|
|
|
if (ret) return ret;
|
2023-08-09 22:25:15 +08:00
|
|
|
}
|
|
|
|
return ROLE_DIR + "unknown.png";
|
|
|
|
}
|
2023-08-13 01:39:45 +08:00
|
|
|
|
2023-08-27 20:21:37 +08:00
|
|
|
function getRoleDeathPic(role) {
|
|
|
|
let path = DEATH_DIR + role + ".png";
|
|
|
|
if (Backend.exists(path)) {
|
|
|
|
return path;
|
|
|
|
} else {
|
|
|
|
let ret = searchPkgResource("/image/role/death/", role, ".png");
|
|
|
|
if (ret) return ret;
|
2023-08-13 01:39:45 +08:00
|
|
|
}
|
2023-08-27 20:21:37 +08:00
|
|
|
return DEATH_DIR + "hidden.png";
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMarkPic(mark) {
|
|
|
|
let ret = searchPkgResource("/image/mark/", mark, ".png");
|
|
|
|
if (ret) return ret;
|
2023-08-13 01:39:45 +08:00
|
|
|
return "";
|
|
|
|
}
|