mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 00:01:54 +08:00
Adding ADR to Github
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Module that registers the notification box and handles messages
|
||||
*/
|
||||
var Notifications = {
|
||||
|
||||
init: function(options) {
|
||||
this.options = $.extend(
|
||||
this.options,
|
||||
options
|
||||
);
|
||||
|
||||
// Create the notifications box
|
||||
elem = $('<div>').attr({
|
||||
id: 'notifications',
|
||||
className: 'notifications'
|
||||
});
|
||||
// Create the transparency gradient
|
||||
$('<div>').attr('id', 'notifyGradient').appendTo(elem);
|
||||
|
||||
elem.appendTo('div#wrapper');
|
||||
},
|
||||
|
||||
options: {}, // Nothing for now
|
||||
|
||||
elem: null,
|
||||
|
||||
notifyQueue: {},
|
||||
|
||||
// Allow notification to the player
|
||||
notify: function(module, text, noQueue) {
|
||||
if(typeof text == 'undefined') return;
|
||||
if(text.slice(-1) != ".") text += ".";
|
||||
if(module != null && Engine.activeModule != module) {
|
||||
if(!noQueue) {
|
||||
if(typeof this.notifyQueue[module] == 'undefined') {
|
||||
this.notifyQueue[module] = new Array();
|
||||
}
|
||||
this.notifyQueue[module].push(text);
|
||||
}
|
||||
} else {
|
||||
Notifications.printMessage(text);
|
||||
}
|
||||
Engine.saveGame();
|
||||
},
|
||||
|
||||
printMessage: function(text) {
|
||||
var text = $('<div>').addClass('notification').css('opacity', '0').text(text).prependTo('div#notifications');
|
||||
text.animate({opacity: 1}, 500, 'linear');
|
||||
},
|
||||
|
||||
printQueue: function(module) {
|
||||
if(typeof this.notifyQueue[module] != 'undefined') {
|
||||
while(this.notifyQueue[module].length > 0) {
|
||||
Notifications.printMessage(this.notifyQueue[module].shift());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user