Skip to content

Commit

Permalink
add setStats, log, and error to CommonUI
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Nov 17, 2014
1 parent b5c4587 commit 0c4867c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/api-versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,10 @@ the correct version
handle this in CSS so we needed a way to check for a specific phone and change
the CSS programatically.

* v1.6.0

* CommonUI.setStatus, CommonUI.log, CommonUI.error

These work the same as the corresponding GameSupport functions
except for the controller.

2 changes: 1 addition & 1 deletion hft.hanson
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
game: "templates/0.x.x/game.gameview.html",
},
},
"1.5.0": {
"1.6.0": {
templates: {
controller: "templates/0.x.x/controller.index.html",
game: "templates/0.x.x/game.gameview.html",
Expand Down
48 changes: 46 additions & 2 deletions public/hft/0.x.x/scripts/commonui.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,26 @@ define([
'./hft-splash',
'./hft-system',
'./misc/fullscreen',
'./misc/logger',
'./misc/misc',
'./misc/playername',
], function(
IO,
HFTSplash,
HFTSystem,
FullScreen,
Logger,
Misc,
PlayerNameHandler) {

var $ = function(id) {
return document.getElementById(id);
};

var g = {
logger: new Logger.NullLogger(),
};

/**
* @typedef {Object} ControllerUI~Options
* @property {callback?} function to call when controller
Expand All @@ -62,6 +68,7 @@ define([
* disconncted from game.
* @property {boolean?} debug True displays a status and debug
* html element
* @property {number?} numConsoleLines number of lines to show for the debug console.
* @memberOf module:CommonUI
*/

Expand Down Expand Up @@ -185,14 +192,51 @@ define([
});

if (options.debug) {
var statusNode = document.createTextNode("");
$("hft-status").appendChild(statusNode);
g.statusNode = document.createTextNode("");
$("hft-status").appendChild(g.statusNode);
var debugCSS = Misc.findCSSStyleRule("#hft-debug");
debugCSS.style.display = "block";

g.logger = new Logger.HTMLLogger($("hft-console"), options.numConsoleLines);
}
};

/**
* Sets the content of the status element. Only visible of debug
* is true.
* @memberOf module:CommonUI
* @param {string} str value to set the status
*/
var setStatus = function(msg) {
if (g.statusNode) {
g.statusNode.nodeValue = msg;
}
};

/**
* Logs a msg to the HTML based console that is only visible
* when debug = true.
* @memberOf module:CommonUI
* @param {string} str msg to add to log
*/
var log = function(str) {
g.logger.log(str);
};

/**
* Logs an error to the HTML based console that is only visible
* when debug = true.
* @memberOf module:CommonUI
* @param {string} str msg to add to log
*/
var error = function(str) {
g.logger.error(str);
};

return {
log: log,
error: error,
setStatus: setStatus,
setupStandardControllerUI: setupStandardControllerUI,
};
});
Expand Down
1 change: 1 addition & 0 deletions todo.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
To Do
=====

* figure out err msg for un-added games. As it is controllers just get JS errors.
* move tiled support to hft-tiled?
* add tiled support to jumpjump
* add glow processing to powpow?
Expand Down

0 comments on commit 0c4867c

Please sign in to comment.