Tuesday, October 6, 2009

v0.3 available for download

After fixing the Load character data functionality, I felt a small celebration was in order. Thus a new zip is available for download. This release has some boring improvements, like Special Abilities (though this isn't data-complete) and more spell and skill data, but the major change was a refactoring of how weapon and armor selector work on the edit page.

Javascript's flexible typing and giant hash object reference model(?) lets you do some neat tricks to reuse code. Essentially you can pass in the string names of attributes or functions to be acted on, rather than defining interfaces as you would in Java. For example, weapons and armor have a similar structure, and the edit UI for both behaves in exactly the same way. Some stuff about the code below.


function populate_data_part(chardata, data_name, id_name) {
for (var j in chardata[data_name]) {
var item = window[data_name].first( {
id : chardata[data_name][j][id_name + '_id']
});
$("#" + id_name + "_" + j + " option[id='" + id_name + "_" + j + "_option_" + item.id + "']").attr("selected", true);
// TODO - this part might be better in recalc
for(var i in window[id_name + "_edit_data"]) {
var edit_attr_name = window[id_name + "_edit_data"][i];
var value = chardata[data_name][j][edit_attr_name] == null ? item[edit_attr_name] : chardata[data_name][j][edit_attr_name];
$("#" + id_name + "_" + j + edit_attr_name).val(value == null ? "" : value);
}
}
}


For 0.4, I'll refactor the steaming pile that is feats.

Saturday, October 3, 2009

Windows 7 window tricks in XP

The most (only?) compelling feature of Windows 7 for me is the automatic window resizing. When you grab a window and bang it against an edge, the window is resized to fill half the screen (either horizontally or vertically).

You can get the same functionality for XP with PowerResizer. Brilliant.