482 lines
16 KiB
JavaScript
482 lines
16 KiB
JavaScript
// --------------------------------------------------------------------
|
|
// @author: shiraho@syg.com(必填, 创建模块的人员)
|
|
// @description:
|
|
// 获取资源路径的接口
|
|
// <br/>Create: new Date().toISOString()
|
|
// --------------------------------------------------------------------
|
|
const { PlayerAction } = require( "define" );
|
|
|
|
// 图标资源目录划分
|
|
const 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( _iconId ) {
|
|
|
|
// 无效编号
|
|
let id = parseInt( _iconId );
|
|
if( !nx.dt.numPositive( id, false ) ) {
|
|
|
|
// 特殊字符图标
|
|
if( nx.dt.strNEmpty( _iconId ) ) {
|
|
return cc.path.join( "resDB/icons", _iconId );
|
|
}
|
|
|
|
return this.BadIcon;
|
|
}
|
|
|
|
// 目录查找
|
|
let sub = "";
|
|
for( let i in IconFolders ) {
|
|
let 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( _iconId ) {
|
|
|
|
// 无效编号
|
|
let id = parseInt( _iconId );
|
|
if( !nx.dt.numPositive( id, false ) ) {
|
|
id = 0;
|
|
}
|
|
|
|
return cc.path.join( "resDB/icons/small", id );
|
|
},
|
|
|
|
/**
|
|
* 获取spine路径
|
|
*/
|
|
getSpinePath: function( res_id, res_name, _addpostfix = true ) {
|
|
|
|
// 判空
|
|
res_id += '';
|
|
if( nx.dt.strEmpty( res_id ) ) {
|
|
return "";
|
|
}
|
|
|
|
// 文件名补全
|
|
if( nx.dt.strEmpty( res_name ) ) {
|
|
res_name = PlayerAction.action
|
|
}
|
|
|
|
// 组合资源所在路径
|
|
let 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" );
|
|
}
|
|
|
|
// 多级拆分(有_则形成多级子目录)
|
|
let arr = res_id.split( "_" ) || [ res_id ];
|
|
arr.forEach( _k => {
|
|
path = cc.path.join( path, _k );
|
|
} );
|
|
|
|
path = cc.path.join( path, res_name );
|
|
return _addpostfix ? ( path + ".atlas" ) : path;
|
|
},
|
|
|
|
/**
|
|
* 获取预制资源路径
|
|
*/
|
|
getPrefabPath: function( module_name, file_name ) {
|
|
// return "prefab/" + module_name + "/" + file_name + ".prefab";
|
|
let path = cc.path.join( "prefab", module_name, file_name + ".prefab" );
|
|
return path;
|
|
},
|
|
|
|
// 获取属性图标
|
|
getAttrIconRes: function( _key ) {
|
|
return cc.path.join( "coms/images", "ico_" + _key );
|
|
},
|
|
|
|
// 获取剧情副本的战斗背景
|
|
getBattleDrameBg: function( 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( res_id ) {
|
|
return "resDB/battles/" + res_id + "/b_bg";
|
|
},
|
|
|
|
// 获取动态资源
|
|
getIconPath: function( module_name, file_name, type ) {
|
|
var suffix = "png"
|
|
if( type ) suffix = type
|
|
return "resDB/" + module_name + "/" + file_name;
|
|
},
|
|
|
|
// 伤害字体
|
|
getPlistPath: function( module_name, file_name ) {
|
|
return "resDB/" + module_name + "/" + file_name + ".plist";
|
|
},
|
|
|
|
getSkillRes: function( id ) {
|
|
nx.warn( "getSkillRes该方法已弃用,请使用queryIconPath" );
|
|
return this.queryIconPath( id );
|
|
// var suffix = ".png";
|
|
// return "res/skillicon/" + id + suffix;
|
|
},
|
|
|
|
// 获取动态资源
|
|
getUIIconPath: function( 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( 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( file_name ) {
|
|
nx.warn( "getCamicoPath该方法已弃用,请使用queryIconPath" );
|
|
return this.queryIconPath( file_name );
|
|
// return "res/campicon/" + file_name + ".png";
|
|
},
|
|
|
|
// 已经废弃
|
|
getResFrame: function( packageName, resName ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
// cc.error(null, "不再使用加载合图的方式加载资源 faild--->" + resName);
|
|
// return
|
|
resName = resName || packageName;
|
|
return "res/" + packageName + "/" + resName + ".plist";
|
|
},
|
|
|
|
getHeadRes: function( res_id, iscache = false ) {
|
|
nx.warn( "getHeadRes该方法已弃用,请使用queryIconPath" );
|
|
return this.queryIconPath( res_id );
|
|
// return "resDB/headicon/" + res_id + ".png";
|
|
},
|
|
getHeadcircle: function( res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
return "res/headcircle/txt_cn_headcircle_" + res_id + ".png";
|
|
},
|
|
|
|
// 获取活动大图路径
|
|
getActivityBigRes: function( _fname ) {
|
|
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
let path = cc.path.join( "uiRes/mods/coms/locals",
|
|
nx.getLocLanguage(),
|
|
"activityB",
|
|
_fname );
|
|
return path;
|
|
},
|
|
|
|
// 称号资源路径
|
|
getHonorRes: function( _fname ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
let path = cc.path.join( "res/honor", "txt_cn_honor_" + _fname );
|
|
return path;
|
|
},
|
|
|
|
getWelfareBannerRes: function( res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
return "res/welfare/welfare_banner/" + res_id + ".png"
|
|
},
|
|
|
|
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( 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( 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( icon_name ) {
|
|
nx.warn( "getCommonIcomPath该方法已弃用,请使用queryIconPath" );
|
|
return this.queryIconPath( icon_name );
|
|
// return "res/common/" + icon_name + ".png";
|
|
},
|
|
|
|
// 获取世界地图图标
|
|
getWorldMapRes: function( res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
return "res/worldmapicon/" + res_id + ".png";
|
|
},
|
|
|
|
// 用于从cdn下载战斗资源的接口
|
|
getBattleSceneRes: function( 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( res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
return "res/bufficon/" + res_id + ".png";
|
|
},
|
|
|
|
//获取游戏图标的接口
|
|
getFunctionRes: function( res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
return cc.path.join( "uiRes/mods/coms/funcIcons", res_id );
|
|
},
|
|
|
|
getSpineByName( spine_name, action_name ) {
|
|
let spine_path = this.getSpinePath( spine_name, action_name, false );
|
|
let skel = cc.js.formatStr( "%s.skel", spine_path )
|
|
let atlas = cc.js.formatStr( "%s.atlas", spine_path )
|
|
let png = cc.js.formatStr( "%s.png", spine_path )
|
|
return skel, atlas, png, spine_path, spine_name
|
|
},
|
|
|
|
// 获取战斗中的阵法图标
|
|
getBattleFormIcon: function( res_name ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
return "res/battleformicon/" + "battle_form_icon_" + res_name + ".png";
|
|
},
|
|
|
|
// 获取战斗中的阵营图标
|
|
getBattleCampIcon: function( res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
return "res/battlecamp/battlecamp_" + res_id + ".png";
|
|
},
|
|
|
|
// 获取战斗中的阵营图标
|
|
getBattleCampIconByType: function( 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( 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( id ) {
|
|
return gdata( "effect_data", "data_effect_info", [ id ] ) || "E88888";
|
|
},
|
|
|
|
// 根据物品品质色获取指定的图集ia
|
|
getItemQualityBG: function( quality ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
},
|
|
|
|
getElfinEggRes: function( sprite, res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
},
|
|
|
|
getElfinEggContainerRes: function( sprite, name ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
},
|
|
|
|
// 获取精灵图标
|
|
getElfinRes: function( sprite, res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
},
|
|
|
|
// 获取物品图标
|
|
getItemRes: function( res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
// return cc.path.join( "res/items", res_id + ".png" );
|
|
},
|
|
|
|
// 获取图鉴套装图片
|
|
getSuitRes: function( res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
// return cc.path.join( "res/holy_eqm_icon/", res_id + ".png" );
|
|
},
|
|
|
|
// 获取物品图标
|
|
getSpriteRes: function( res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
// return cc.path.join( "res/sprite", res_id + ".png" );
|
|
},
|
|
|
|
// 获取阵营资源
|
|
getHeroCampRes: function( camp ) {
|
|
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
// camp = camp || 1;
|
|
// if( camp > 6 ) {
|
|
// camp = 1;
|
|
// }
|
|
// return cc.path.join( "res/camps", "icon_camp_" + camp );
|
|
},
|
|
|
|
//这类单位是没有show动作的,所以要特殊处理
|
|
specialBSModel: function( id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return false;
|
|
// return id == 37300 || id == 37301 || id == 37302
|
|
},
|
|
|
|
//获取伙伴类型的,坦克法师这些
|
|
getPartnerTypeIcon: function( _type ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
// _type = _type || 1;
|
|
// var _index = 45 + _type;
|
|
// return this.getCommonIcomPath( "common_900" + _index );
|
|
},
|
|
|
|
//获取伙伴半身像资源
|
|
getPartnerBustRes: function( bust_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
bust_id = bust_id || 10000;
|
|
return this.getIconPath( "partner", bust_id );
|
|
},
|
|
|
|
getLogoRes: function() {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
},
|
|
|
|
//获取选中背景,通用
|
|
getSelectBg() {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
return this.getUIIconPath( "common", "common_90019" )
|
|
},
|
|
|
|
// 获取神装空白图
|
|
getGodItmeBg: function( res_id ) {
|
|
nx.warn( "已弃用,遇到请及时修改!" );
|
|
return "";
|
|
return "uiRes/mods/heaven/god_item_" + res_id + ".png";
|
|
},
|
|
|
|
// 获取天界副本关卡图标
|
|
getHeavenCustomsIconRes: function( 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;
|