Friday, December 31, 2010

Building a CLASSPATH in Windows

Thanks to Real's How To:

@echo off
setlocal ENABLEDELAYEDEXPANSION
if defined CLASSPATH (set CLASSPATH=%CLASSPATH%;.) else (set CLASSPATH=.)
FOR /R .\lib %%G IN (*.jar) DO set CLASSPATH=!CLASSPATH!;%%G
Echo The Classpath definition is %CLASSPATH%
...
java MyClass

Tuesday, December 14, 2010

Notepad++, The New Editor King (or, jEdit Dethroned)

I finally gave Notepad++ an honest going over, and it is unquestionably the most flexible tool for editing text the internet has to offer. It:
  • handles my keybinding scheme
  • is fast(er than jEdit)
  • handles large files without choking
You can customize it to a ridiculous degree, and because it uses Scintilla for the editor, schemes should be portable across platforms (Geany, others).

Notepad++'s only real deficiency is its lack of full regex support.

Wednesday, December 1, 2010

Generalizing for Pathfinder Compatibility

I've looking at Pathfinder for a while (bought the core rulebooks and a few modules), but since listening the Chronicles: Pathfinder Podcast I'm energized to fix up the Grendel to be compatible with the core rules.

As always, I need knowledgeable testers to validate my suspicions (also some data entry help would be a huge help):


If you're unfamiliar with Pathfinder, it's essentially a light extension of the 3.5 rules in a well-articulated campaign setting. It's published by the old publishing arm of Wizards of the Coast, Paizo Publishing.

Interesting fact about Paizo: the publisher writes modules.

Monday, October 4, 2010

Fixing XP

Here's a list of utility programs that make Windows XP a little nicer:

Alwact Clock: Onscreen click-through clock
AutoHotkey: keyboard mapping and scripting
SetCapsLockState, AlwaysOff

CapsLock & a::
IfWinExist jEdit
WinActivate
else
Run C:\PROGRA~1\jEdit\jedit.bat
return

CapsLock & q::
IfWinExist ahk_class Chrome_WidgetWin_0
WinActivate
else
Run "C:\Program Files\Chrome\chrome.exe" --enable-accelerated-compositing
return

CapsLock & s::
IfWinExist xplorer²
WinActivate
else
Run "C:\Program Files\zabkat\xplorer2_lite\xplorer2_lite.exe""
return
PathTooLong: If you can't delete a directory because the path is too long
Power Menu: Window always-on-top
Power Resizer: Windows 7-style window resizing (half-screen on edge)
WizMouse: Scroll the window under the mouse

Monday, September 6, 2010

Also, Character Sheets

Here it is, a character sheet:


The nice thing is, if you don't like it, they're easy to make and easy to fill in with character data.

Saturday, August 14, 2010

multi-class in motion


Help me test v0.6!

This version is undergoing regular development, so the usual caveats apply. If you find what think is a bug, please create an issue on my Google Code project site, or leave a comment on a recent blog posting.

Batch upload script for CouchDB (using curl and jsawk)

I looked all over for something small and simple like this, but couldn't find anything.

Dependencies:
spidermonkey (required by jsawk)
libmozjs2d (required by spidermonkey)
jsawk (for parsing CouchDB response)
curl

Ubuntu doesn't include spidermonkey in the repositories (it uses rhino instead) so you'll have to grab spidermonkey from the Debian.

Copy the below script (change http://localhost:5984/cm-dev/hrothgar to your server/db/document) and save yourself a lot of clicks in Futon.


Usage: upload.sh [path containing the files to upload]

hput () {
eval hash"$1"='$2'
}

hget () {
eval echo '${hash'"$1"'#hash}'
}
hput js javascript
hput html html
hput css css

directory=$@
if [ -z "$directory" ]
then
directory="."
fi

filetypes="$directory/*.css
$directory/*.html
$directory/*.js"

for file in $filetypes
do
filename=`basename "$file"`
ext=`hget ${filename##*.}`
rev=`curl -sX GET 'http://grendel.cloudant.com/cm-dev/hrothgar/' | jsawk 'return this._rev'`
echo File : $file
echo Current revision : $rev
echo Uploading document: $filename
echo "${ext}"
echo curl : curl -X PUT http://grendel.cloudant.com/cm-dev/hrothgar/$filename?rev=$rev --data-binary @$file -H 'Content-Type: text/'$ext

curl -X PUT http://grendel.cloudant.com/cm-dev/hrothgar/$filename?rev=$rev --data-binary @$file -H 'Content-Type: text/'$ext
echo --------------------------------------------
echo
done

Thanks to Micha for jsawk.

Tuesday, July 20, 2010

Multi-class support

The major feature for v0.6 will be multi-class character support.

Post your thoughts on what to put in the space created by the edit page rearrangement.

chardata.class_name => chardata.classes[name]=level

edit: current look





Wednesday, May 26, 2010

Flexible UI



I'm cooking the new UIs for v0.6, starting with 768x1024 (and 1024x768), since that's the iPad resolution, and I know a couple people with iPads (it also maps nicely to a sheet of paper). Everyone has opinions on what makes a good character sheet and pretty much everybody can draw, I'd appreciate some feedback on the new layout.

If you're feeling particularly contributory, send me a note and I'll add you to the drawing so you manipulate the bits yourself.


Sunday, May 16, 2010

Ideas for v0.6

If I ever get v0.5 to run on an iPhone, here are some ideas for v0.6:

Expandable UI
Depending on the size of browser viewport, the UI will reconfigure itself to better utilize the available space. Thinking the 2-column sections go 3 or 4, eliminate multiple edit screens (leaving just main and edit).

Also, the Google Drawing app is just about "good enough". Still needs connectors.

Multi-class support
See later post for details.

Fast character switching
Currently, switching between characters requires a full reload of the webapp, should be able to change change character data without loading all the application data.

Use Google CDN for JQuery resources
The images for the JQueryUI haven't displayed correctly since I moved to CouchDB. Hopefully will fix that.

Friday, May 14, 2010

Firebug to the rescue

Firebug has a more readable and perhaps more insightful profiler than Chrome:

My reckless use of TaffyDB is the biggest offender, with isNumeric() way out of proportion (I mean, is it a number, or isn't it?).

UPDATE:
It appears the horrendous performance suction was caused my ordering of all static data elements:
  spells.orderBy({name:"logical"});
feats.orderBy({name:"logical"});
races.orderBy({name:"logical"});
domains.orderBy({name:"logical"});
classs.orderBy({name:"logical"});
schools.orderBy({name:"logical"});
weapons.orderBy({name:"logical"});
armors.orderBy({name:"logical"});
skills.orderBy({name:"logical"});
languages.orderBy({name:"logical"});
deitys.orderBy({name:"logical"});
specials.orderBy({name:"logical"});
favored_enemys.orderBy({name:"logical"});

I found the offending block by starting and stopping the Firebug profiler between breakpoints. It posts the results in the console, in the context of the logging. Just phenomenal tool.
Down to 4 secs:This doesn't mean it will work on the iPhone, but it can't hurt.

Thursday, May 13, 2010

localStorage for offline use

I've put in some caching for the static data using the HTML5 feature "localStorage", localStorage is essentially a cookie, but without a cookie's size limit, and it will not get sent to the server (something I didn't even know about cookies). The Player's Companion should now be able to function offline, but unfortunately it does not appear to have any impact on load performance.

Sunday, May 2, 2010

v0.5 in Testing

v0.5 involved a complete rewrite of the data load scheme, and the way rules are handled. Basically, to add feat attack effects before, I had to add some JS to the calc_attack function (messy and does not scale). Now, I ask for all feats with an attack attribute (which is a function), and execute that block of code:

feat description:

attack: "if(weapon.category == 'exotic') { attacks.weapon_proficiency = 0; } return attacks;",


function calc_attack() {
...
char_feats.get({ attack : { "!is": null } }).forEach( function(feat, i) {
// TODO - can we do this by reference
console.log("attack: " + feat.name);
attacks = feat.attack(attacks, weapon);
return attacks;
});

While it's probably technically better, an unfortunate side-effect is that it no longer works on my friends' iPhones or my Android emulator. Must be my IBM training to write software for next-next generation hardware (I'm still waiting for a machine to run Lotus Notes).

Friday, April 2, 2010

jEdit, Lord of the Text Editors

After a brief dalliance Sublime Text, I'm back to jEdit. Faster with large files, customizable keybinding, cross platform, truly awesome find/replace and it's Open Source (Sublime Text costs $60).

Plugins:
JDiffPlugin
TextTools
FirstMate (http://www.rutherfurd.net/jedit/plugins/firstmate/)
Minimap
Whitespace
Beauty

Two features I'm missing are next/previous recent buffer, and true full screen (a la Darkroom).

Thank you, jEdit!

Wednesday, March 10, 2010

jEdit Maths

Search: ^(\s+)"(.+?)" : ([0-9])(,?)
Replace: _1 + "\"" + _2 + "\":" + (Integer.parseInt(_3) + 1) + _4

Tuesday, February 9, 2010

Favored Enemies

"Operational" favored enemies for Ranger class are now on http://bit.ly/wiglaf.

Sunday, January 24, 2010

Remote Storage, Part II

The remote store is up and running at:

http://bit.ly/wiglaf

The practical effect of this is the ability to create your character on a computer, and load it on your portable device. Character data is automatically synced to the remote store, and can be retrieved using the char->load menu by entering the character name.

At this time (since I'm the only one using it), THERE IS NO OVERWRITE PROTECTION!!! If you create a character named "Bob" and some other dood creates a "Bob", the last guy's data will blow away the Bob data. I have a fix in mind where you enter an owner name to distinguish your Bob the other guy.

Friday, January 15, 2010

Storing data online with CouchDB

I'm looking at using a remote CouchDB as a store for character data. With some sync code, characters should be transparently available on any device you're using.

CouchDB looks cool, but the documentation is horrible (at least for starting out using Javascript).

Something I didn't fully appreciate is that you can't call out to different a server from Javascript directly (this is "cross-site scripting", and there are workarounds). Essentially, it's assumed any connections will be performed on the server side and the client (browser) connects to a single server. The quick-and-dirty solution is to host the Player's Companion from my local CouchDB instance:
  1. Log in to Futon: http://localhost:5984/_utils/index.html

  2. Create a database (charmgr) to host the files

  3. Create a document (id: "charmgr")

  4. Upload all the files as attachments to the document

  5. Go to: http://localhost:5984/charmgr/charmgr/charmgr.html, et voila!


In the code, writing out the data is direct:

var db = new CouchDB(cookie_name.toLowerCase(), {"X-Couch-Full-Commit":"false"});
db.createDb();
db.save(data);


Thanks to Justin Walgran: http://mail-archives.apache.org/mod_mbox/couchdb-user/200812.mbox/%3Cf893e2810812262119k3163421ds372d4b7a2eac22c1@mail.gmail.com%3E

Useful: http://sitr.us/2009/06/30/database-queries-the-couchdb-way.html

Sunday, January 10, 2010

Multi-character Support




Some refactoring and now I can switch between multiple character sheets. Basically names the cookie after the character name, and lists all "named cookies" in the file menu.

Addition of the file menu is something of a failure, since now it's no longer a toaster.