2015-03-19 05:08:23 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
2015-03-23 04:52:04 +00:00
|
|
|
var PluginModule = require('./plugin_module.js').PluginModule;
|
|
|
|
var theme = require('./theme.js');
|
|
|
|
|
|
|
|
var async = require('async');
|
|
|
|
var assert = require('assert');
|
2015-03-19 05:08:23 +00:00
|
|
|
|
|
|
|
exports.MenuModule = MenuModule;
|
|
|
|
|
2015-03-23 04:52:04 +00:00
|
|
|
function MenuModule(menuConfig) {
|
2015-03-19 05:08:23 +00:00
|
|
|
PluginModule.call(this);
|
|
|
|
|
2015-03-23 04:52:04 +00:00
|
|
|
var self = this;
|
|
|
|
this.menuConfig = menuConfig;
|
|
|
|
|
|
|
|
this.viewControllers = [];
|
|
|
|
|
2015-03-24 05:12:19 +00:00
|
|
|
this.initSequence = function() {
|
2015-03-23 04:52:04 +00:00
|
|
|
async.waterfall(
|
|
|
|
[
|
2015-03-24 05:12:19 +00:00
|
|
|
function beforeDisplayArt(callback) {
|
|
|
|
self.beforeArt();
|
|
|
|
callback(null);
|
|
|
|
},
|
2015-03-23 04:52:04 +00:00
|
|
|
function displayArt(callback) {
|
|
|
|
theme.displayThemeArt(self.menuConfig.art, self.client, function onArt(err, mciMap) {
|
2015-03-24 05:12:19 +00:00
|
|
|
// :TODO: If the art simply is not found, or failed to load... we need to continue
|
|
|
|
if(err) {
|
|
|
|
console.log('TODO: log this error properly... maybe handle slightly diff.');
|
|
|
|
}
|
|
|
|
callback(null, mciMap);
|
2015-03-23 04:52:04 +00:00
|
|
|
});
|
|
|
|
},
|
2015-03-24 05:12:19 +00:00
|
|
|
function afterArtDisplayed(mciMap, callback) {
|
|
|
|
if(mciMap) {
|
2015-03-23 04:52:04 +00:00
|
|
|
self.mciReady(mciMap);
|
|
|
|
}
|
2015-03-24 05:12:19 +00:00
|
|
|
|
|
|
|
callback(null);
|
2015-03-23 04:52:04 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
function onComplete(err) {
|
|
|
|
if(err) {
|
|
|
|
// :TODO: Log me!!! ... and what else?
|
2015-03-24 05:12:19 +00:00
|
|
|
console.log(err);
|
2015-03-23 04:52:04 +00:00
|
|
|
}
|
2015-03-24 05:12:19 +00:00
|
|
|
|
|
|
|
self.finishedLoading();
|
2015-03-23 04:52:04 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
2015-03-19 05:08:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
require('util').inherits(MenuModule, PluginModule);
|
|
|
|
|
|
|
|
MenuModule.prototype.enter = function(client) {
|
2015-03-23 04:52:04 +00:00
|
|
|
this.client = client;
|
|
|
|
assert(typeof client !== 'undefined');
|
2015-03-24 05:12:19 +00:00
|
|
|
|
|
|
|
this.initSequence();
|
2015-03-19 05:08:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
MenuModule.prototype.leave = function() {
|
2015-03-24 05:12:19 +00:00
|
|
|
|
|
|
|
var count = this.viewControllers.length;
|
|
|
|
for(var i = 0; i < count; ++i) {
|
|
|
|
this.viewControllers[i].detachClientEvents();
|
|
|
|
}
|
2015-03-19 05:08:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
MenuModule.prototype.addViewController = function(vc) {
|
|
|
|
this.viewControllers.push(vc);
|
2015-03-23 04:52:04 +00:00
|
|
|
return vc;
|
|
|
|
};
|
|
|
|
|
2015-03-24 05:12:19 +00:00
|
|
|
MenuModule.prototype.beforeArt = function() {
|
|
|
|
};
|
|
|
|
|
2015-03-23 04:52:04 +00:00
|
|
|
MenuModule.prototype.mciReady = function(mciMap) {
|
2015-03-24 05:12:19 +00:00
|
|
|
console.log('mciReady')
|
|
|
|
};
|
|
|
|
|
|
|
|
MenuModule.prototype.finishedLoading = function() {
|
|
|
|
console.log('finishedLoading')
|
2015-03-19 05:08:23 +00:00
|
|
|
};
|