78 lines
1.9 KiB
JavaScript
78 lines
1.9 KiB
JavaScript
var baseResDir = 'file:///E:/everlastingsummer/';
|
|
//var baseResDir = '/resources/es/';
|
|
|
|
function FadeInfo() {
|
|
this.fadeIn = false;
|
|
this.fadeOut = false;
|
|
this.duration = 0;
|
|
}
|
|
|
|
|
|
function TextUtilsImpl() { }
|
|
|
|
TextUtilsImpl.prototype.isEmpty = function (text) {
|
|
if (text === undefined) return true;
|
|
return text.length === 0;
|
|
};
|
|
|
|
var TextUtils = new TextUtilsImpl();
|
|
|
|
|
|
String.prototype.equalsIgnoreCase = function(text) {
|
|
return this.toLowerCase() == text.toLowerCase();
|
|
};
|
|
|
|
String.prototype.equals = function(text) {
|
|
return this == text;
|
|
};
|
|
|
|
String.prototype.contains = function(text) {
|
|
return this.indexOf(text) >= 0;
|
|
};
|
|
|
|
String.prototype.replaceAll = function(search, replace) {
|
|
return this.split(search).join(replace);
|
|
};
|
|
|
|
String.prototype.startsWith = function(text) {
|
|
return this.indexOf(text) == 0;
|
|
};
|
|
|
|
String.prototype.replaceAll = function (find, replace) {
|
|
var str = this;
|
|
return str.replace(new RegExp(find, 'g'), replace);
|
|
};
|
|
|
|
|
|
function toColor(num) {
|
|
num >>>= 0;
|
|
var b = num & 0xFF,
|
|
g = (num & 0xFF00) >>> 8,
|
|
r = (num & 0xFF0000) >>> 16,
|
|
a = ( (num & 0xFF000000) >>> 24 ) / 255 ;
|
|
return "rgba(" + [r, g, b, a].join(",") + ")";
|
|
}
|
|
|
|
|
|
var PathResolver = new function () {
|
|
this.background = function (type, name) {
|
|
return baseResDir + type.toLowerCase() + "/" + name + ".jpg";
|
|
};
|
|
this.sprite = function (whoid, params) {
|
|
var path = baseResDir + "sprites/";
|
|
path += whoid.toLowerCase() + "/";
|
|
path += (TextUtils.isEmpty(params) ? "normal" : params);
|
|
path += ".png";
|
|
return path;
|
|
};
|
|
this.music = function (name) {
|
|
return baseResDir + "music/" + name + ".ogg";
|
|
};
|
|
this.sound = function (name) {
|
|
var path = baseResDir + "sfx/";
|
|
if (path.startsWith("sfx_")) path += name.substring(4);
|
|
else path += name;
|
|
path += ".ogg";
|
|
return path;
|
|
};
|
|
}; |