"use strict"; cc._RF.push(module, '5c24ew9BclME7NqSzhzS5RV', 'pathtool'); // Scripts/util/pathtool.js "use strict"; // -------------------------------------------------------------------- // @author: shiraho@syg.com(必填, 创建模块的人员) // @description: // 获取资源路径的接口 //
Create: new Date().toISOString() // -------------------------------------------------------------------- var _require = require("define"), PlayerAction = _require.PlayerAction; // 图标资源目录划分 var IconFolders = [{ range: [1, 999], folder: "coms", desc: "资产类" }, { range: [1000, 9999], folder: "drops", desc: "掉落ID" }, { range: [10000, 19999], folder: "items", desc: "游戏日常道具" }, { range: [20000, 29999], folder: "partners", desc: "英雄碎片/英雄" }, { range: [30000, 39999], folder: "gifts", desc: "游戏日常礼包" }, { range: [40000, 49999], folder: "equips", desc: "装备相关" }, { range: [50000, 59999], folder: "headers", desc: "头像框&聊天气泡" }, { range: [60000, 79999], folder: "mings", desc: "命格" }, { range: [80000, 89999], folder: "acts", desc: "活动相关物品" }, { range: [100000, 109999], folder: "pets", desc: "萌宠道具" }, { range: [110000, 119999], folder: "sprites", desc: "精灵" }, { range: [200000, 299999], folder: "furnitures", desc: "家具" }, { range: [300000, 399999], folder: "buffs", desc: "角色buff" }, { range: [400000, 499999], folder: "skills", desc: "额外技能" }, { range: [500000, 699999], folder: "partnerskills", desc: "伙伴技能" }, { range: [1010001, 14010004], folder: "holy", desc: "神装" }, { range: [9010101, 9912999], folder: "gods", desc: "神装礼包" }]; window.PathTool = { // 无效图标 BadIcon: "resDB/empty/icon", BadIconS: "resDB/empty/iconS", BadAvatar: "resDB/empty/avatar", BadAvatarFrame: "resDB/aframes/1000", BadChatBubble: "resDB/chatskin/1000", /** * 获取图标的资源路径 */ queryIconPath: function queryIconPath(_iconId) { // 无效编号 var id = parseInt(_iconId); if (!nx.dt.numPositive(id, false)) { // 特殊字符图标 if (nx.dt.strNEmpty(_iconId)) { return cc.path.join("resDB/icons", _iconId); } return this.BadIcon; } // 目录查找 var sub = ""; for (var i in IconFolders) { var tm = IconFolders[i]; if (id >= tm.range[0] && id <= tm.range[1]) { sub = tm.folder; break; } } // 无效编号 if (nx.dt.strEmpty(sub)) { nx.error("未找到图标资源:", id); return this.BadIcon; } return cc.path.join("resDB/icons", sub, id); }, /** * 获取小图标的资源路径 */ querySmallIconPath: function querySmallIconPath(_iconId) { // 无效编号 var id = parseInt(_iconId); if (!nx.dt.numPositive(id, false)) { id = 0; } return cc.path.join("resDB/icons/small", id); }, /** * 获取spine路径 */ getSpinePath: function getSpinePath(res_id, res_name, _addpostfix) { if (_addpostfix === void 0) { _addpostfix = true; } // 判空 res_id += ''; if (nx.dt.strEmpty(res_id)) { return ""; } // 文件名补全 if (nx.dt.strEmpty(res_name)) { res_name = PlayerAction.action; } // 组合资源所在路径 var path = "resDB"; // E开头转定向resDB/effects if (res_id[0] == "E" || res_id[0] == "e") { path = cc.path.join(path, "effects"); } // H开头转定向resDB/models else if (res_id[0] == "H" || res_id[0] == "h") { path = cc.path.join(path, "models"); } // 其他转定向resDB/spines else { path = cc.path.join(path, "spines"); } // 多级拆分(有_则形成多级子目录) var arr = res_id.split("_") || [res_id]; arr.forEach(function (_k) { path = cc.path.join(path, _k); }); path = cc.path.join(path, res_name); return _addpostfix ? path + ".atlas" : path; }, /** * 获取预制资源路径 */ getPrefabPath: function getPrefabPath(module_name, file_name) { // return "prefab/" + module_name + "/" + file_name + ".prefab"; var path = cc.path.join("prefab", module_name, file_name + ".prefab"); return path; }, // 获取属性图标 getAttrIconRes: function getAttrIconRes(_key) { return cc.path.join("coms/images", "ico_" + _key); }, // 获取剧情副本的战斗背景 getBattleDrameBg: function getBattleDrameBg(res_id) { var bg_path = "resDB/battles/" + res_id; return { s: bg_path + "/map_bg", f: bg_path + "/m_bg", l: bg_path + "/l_bg" }; }, // 获取单战斗场景的资源 getBattleSingleBg: function getBattleSingleBg(res_id) { return "resDB/battles/" + res_id + "/b_bg"; }, // 获取动态资源 getIconPath: function getIconPath(module_name, file_name, type) { var suffix = "png"; if (type) suffix = type; return "resDB/" + module_name + "/" + file_name; }, // 伤害字体 getPlistPath: function getPlistPath(module_name, file_name) { return "resDB/" + module_name + "/" + file_name + ".plist"; }, getSkillRes: function getSkillRes(id) { nx.warn("getSkillRes该方法已弃用,请使用queryIconPath"); return this.queryIconPath(id); // var suffix = ".png"; // return "res/skillicon/" + id + suffix; }, // 获取动态资源 getUIIconPath: function getUIIconPath(module_name, file_name, type) { nx.warn("getUIIconPath该方法已弃用,请使用queryIconPath"); return this.queryIconPath(file_name); // var suffix = "png" // if( type ) suffix = type // return "resDB/" + module_name + "/" + file_name + "." + suffix; }, // 获取UIRes动态资源 getUIResIconPath: function getUIResIconPath(module_name, file_name, type) { nx.warn("getUIResIconPath该方法已弃用,请使用queryIconPath"); return this.queryIconPath(file_name); // var suffix = "png" // if( type ) suffix = type // return "uiRes/mods/" + module_name + "/" + file_name + "." + suffix; }, getCamicoPath: function getCamicoPath(file_name) { nx.warn("getCamicoPath该方法已弃用,请使用queryIconPath"); return this.queryIconPath(file_name); // return "res/campicon/" + file_name + ".png"; }, // 已经废弃 getResFrame: function getResFrame(packageName, resName) { nx.warn("已弃用,遇到请及时修改!"); return ""; // cc.error(null, "不再使用加载合图的方式加载资源 faild--->" + resName); // return resName = resName || packageName; return "res/" + packageName + "/" + resName + ".plist"; }, getHeadRes: function getHeadRes(res_id, iscache) { if (iscache === void 0) { iscache = false; } nx.warn("getHeadRes该方法已弃用,请使用queryIconPath"); return this.queryIconPath(res_id); // return "resDB/headicon/" + res_id + ".png"; }, getHeadcircle: function getHeadcircle(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; return "res/headcircle/txt_cn_headcircle_" + res_id + ".png"; }, // 获取活动大图路径 getActivityBigRes: function getActivityBigRes(_fname) { nx.warn("已弃用,遇到请及时修改!"); return ""; var path = cc.path.join("uiRes/mods/coms/locals", nx.getLocLanguage(), "activityB", _fname); return path; }, // 称号资源路径 getHonorRes: function getHonorRes(_fname) { nx.warn("已弃用,遇到请及时修改!"); return ""; var path = cc.path.join("res/honor", "txt_cn_honor_" + _fname); return path; }, getWelfareBannerRes: function getWelfareBannerRes(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; return "res/welfare/welfare_banner/" + res_id + ".png"; }, getBigBuffRes: function getBigBuffRes(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; return "res/bigbufficon/" + res_id + ".png"; }, // COMMON = "common", // SCENE = "scene", // BATTLE = "battle", // DUBBING = "dubbing", // Recruit = "recruit", // Drama = "drama", getSoundRes: function getSoundRes(res_type, res_name) { nx.warn("已弃用,遇到请及时修改!"); return ""; if (!res_type || !res_name) return; // return "sound/common/" + res_id + ".mp3"; // var res_path = null; return cc.js.formatStr("sound/%s/%s.mp3", res_type, res_name); }, // 获取大图 getBigBg: function getBigBg(res_id, bgType, module_name) { nx.warn("已弃用,遇到请及时修改!"); return ""; if (module_name) { module_name += "/"; } else { module_name = ""; } return "ui_res/bigbg/" + module_name + res_id + "." + (bgType || "png"); }, getCommonIcomPath: function getCommonIcomPath(icon_name) { nx.warn("getCommonIcomPath该方法已弃用,请使用queryIconPath"); return this.queryIconPath(icon_name); // return "res/common/" + icon_name + ".png"; }, // 获取世界地图图标 getWorldMapRes: function getWorldMapRes(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; return "res/worldmapicon/" + res_id + ".png"; }, // 用于从cdn下载战斗资源的接口 getBattleSceneRes: function getBattleSceneRes(resName, is_jpg) { nx.warn("已弃用,遇到请及时修改!"); return ""; if (is_jpg == true) { return "res/bigbg/battle_bg/" + resName + ".jpg"; } else { return "res/bigbg/battle_bg/" + resName + ".png"; } }, // 获取buff资源路径 getBuffRes: function getBuffRes(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; return "res/bufficon/" + res_id + ".png"; }, //获取游戏图标的接口 getFunctionRes: function getFunctionRes(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; return cc.path.join("uiRes/mods/coms/funcIcons", res_id); }, getSpineByName: function getSpineByName(spine_name, action_name) { var spine_path = this.getSpinePath(spine_name, action_name, false); var skel = cc.js.formatStr("%s.skel", spine_path); var atlas = cc.js.formatStr("%s.atlas", spine_path); var png = cc.js.formatStr("%s.png", spine_path); return skel, atlas, png, spine_path, spine_name; }, // 获取战斗中的阵法图标 getBattleFormIcon: function getBattleFormIcon(res_name) { nx.warn("已弃用,遇到请及时修改!"); return ""; return "res/battleformicon/" + "battle_form_icon_" + res_name + ".png"; }, // 获取战斗中的阵营图标 getBattleCampIcon: function getBattleCampIcon(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; return "res/battlecamp/battlecamp_" + res_id + ".png"; }, // 获取战斗中的阵营图标 getBattleCampIconByType: function getBattleCampIconByType(camp_type) { nx.warn("已弃用,遇到请及时修改!"); return ""; if (camp_type == null) { camp_type = 1; } var HeroConst = require("hero_const"); if (camp_type == HeroConst.CampType.eWater) { return "res/battlecamp/battlecamp_1001.png"; } else if (camp_type == HeroConst.CampType.eFire) { return "res/battlecamp/battlecamp_1002.png"; } else if (camp_type == HeroConst.CampType.eWind) { return "res/battlecamp/battlecamp_1003.png"; } else if (camp_type == HeroConst.CampType.eLight) { return "res/battlecamp/battlecamp_1004.png"; } else if (camp_type == HeroConst.CampType.eDark) { return "res/battlecamp/battlecamp_1005.png"; } else { return "res/battlecamp/battlecamp_1000.png"; } }, // 获取品质框背景(圆形的) getRoundQualityBg: function getRoundQualityBg(quality) { var quality = quality || 1; if (quality > 5) { quality = 5; } quality = 2000 + quality; var res_id = "mainui_" + quality; return cc.js.formatStr("ui_res/mainui/%s.png", res_id); //PathTool.getUIIconPath( "mainui", res_id ); }, //获取配置表中的effect资源id吧 getEffectRes: function getEffectRes(id) { return gdata("effect_data", "data_effect_info", [id]) || "E88888"; }, // 根据物品品质色获取指定的图集ia getItemQualityBG: function getItemQualityBG(quality) { nx.warn("已弃用,遇到请及时修改!"); return ""; }, getElfinEggRes: function getElfinEggRes(sprite, res_id) { nx.warn("已弃用,遇到请及时修改!"); }, getElfinEggContainerRes: function getElfinEggContainerRes(sprite, name) { nx.warn("已弃用,遇到请及时修改!"); }, // 获取精灵图标 getElfinRes: function getElfinRes(sprite, res_id) { nx.warn("已弃用,遇到请及时修改!"); }, // 获取物品图标 getItemRes: function getItemRes(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; // return cc.path.join( "res/items", res_id + ".png" ); }, // 获取图鉴套装图片 getSuitRes: function getSuitRes(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; // return cc.path.join( "res/holy_eqm_icon/", res_id + ".png" ); }, // 获取物品图标 getSpriteRes: function getSpriteRes(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; // return cc.path.join( "res/sprite", res_id + ".png" ); }, // 获取阵营资源 getHeroCampRes: function getHeroCampRes(camp) { nx.warn("已弃用,遇到请及时修改!"); return ""; // camp = camp || 1; // if( camp > 6 ) { // camp = 1; // } // return cc.path.join( "res/camps", "icon_camp_" + camp ); }, //这类单位是没有show动作的,所以要特殊处理 specialBSModel: function specialBSModel(id) { nx.warn("已弃用,遇到请及时修改!"); return false; // return id == 37300 || id == 37301 || id == 37302 }, //获取伙伴类型的,坦克法师这些 getPartnerTypeIcon: function getPartnerTypeIcon(_type) { nx.warn("已弃用,遇到请及时修改!"); return ""; // _type = _type || 1; // var _index = 45 + _type; // return this.getCommonIcomPath( "common_900" + _index ); }, //获取伙伴半身像资源 getPartnerBustRes: function getPartnerBustRes(bust_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; bust_id = bust_id || 10000; return this.getIconPath("partner", bust_id); }, getLogoRes: function getLogoRes() { nx.warn("已弃用,遇到请及时修改!"); return ""; }, //获取选中背景,通用 getSelectBg: function getSelectBg() { nx.warn("已弃用,遇到请及时修改!"); return ""; return this.getUIIconPath("common", "common_90019"); }, // 获取神装空白图 getGodItmeBg: function getGodItmeBg(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; return "uiRes/mods/heaven/god_item_" + res_id + ".png"; }, // 获取天界副本关卡图标 getHeavenCustomsIconRes: function getHeavenCustomsIconRes(res_id) { nx.warn("已弃用,遇到请及时修改!"); return ""; res_id = res_id || 1; return cc.js.formatStr("uiRes/mods/heavencustoms/heavencustoms_%s.png", Number(res_id)); } }; module.exports = PathTool; cc._RF.pop();