RpyPlayerWeb/public_html/resources/js/Utils.js

73 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-12-06 13:49:35 +02:00
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.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 "resources/images/" + type.toLowerCase() + "/" + name + ".jpg";
};
this.sprite = function (whoid, params) {
var path = "file:///E:/everlastingsummer/sprites/";
path += whoid.toLowerCase() + "/";
path += (TextUtils.isEmpty(params) ? "normal" : params);
path += ".png";
return path;
};
this.music = function (name) {
// return "resources/music/" + name + ".ogg";
return "file:///E:/everlastingsummer/music/" + name + ".ogg";
};
this.sound = function (name) {
var path = "file:///E:/everlastingsummer/sfx/";
if (path.startsWith("sfx_")) path += name.substring(4);
else path += name;
path += ".ogg";
return path;
// return "resources/music/" + name + ".ogg";
};
};