{"id":1240,"date":"2010-04-26T23:41:43","date_gmt":"2010-04-26T12:41:43","guid":{"rendered":"http:\/\/www.vectorstorm.org\/?p=1240"},"modified":"2010-04-26T23:41:43","modified_gmt":"2010-04-26T12:41:43","slug":"action-bar-data","status":"publish","type":"post","link":"https:\/\/www.vectorstorm.com.au\/2010\/04\/26\/action-bar-data\/","title":{"rendered":"Action Bar Data"},"content":{"rendered":"

\"\"<\/a>A friend of mine has often been heard to say that he’s never regretted making something configurable via data. \u00a0I tend to agree.. although my usual development process for home stuff is to do a lot more in code than I do in data. \u00a0But MMORPG Tycoon is becoming large enough that I’m really starting to see the benefit of doing more and more data-driven design.<\/p>\n

And of course, this’ll be nice for anyone who wants to modify the game, since the data is all unprotected text files. \u00a0It’s trivial to make new buttons, move old ones around, etc.<\/p>\n

In this shot, you can see the “On Foot” action bar, used when you’re just walking around. \u00a0As you can see, it provides a “Kick”, a “Punch”, and a “Mind” button, which actually send “Attack 1”, “Attack 2”, and “Attack 3” commands to the game. \u00a0In practice, this “On Foot” action bar will (eventually, post-MS1) have buttons set by the design choices you make in the game. \u00a0But most other action bars will have a static set of content, and this “ActionBars.cfg” file declares their default state, plus other information about orientation and where they fit on the screen.<\/p>\n

But most of the day today was spent on revamping the file reading code. \u00a0Gratuitous technical details are below the fold. \u00a0Short version: \u00a0“Stuff is better now.”<\/p>\n

[technical details]<\/p>\n

Anybody who’s looked under the hood of the VectorStorm source code will have noticed that the “FS” file reading system is nicely defined at the top level (the “fsFile”) and the bottom level (parsing individual “fsToken”s out of a string), but that the middle level (the “fsRecord”) is horrible horrible horrible, with awful, unmaintainable code, particularly in regards to “blocks” of data.<\/p>\n

In the fsFile text format, data consists of lines, where each line begins with an optional label, and then an arbitrary number of “tokens”. \u00a0For example:<\/p>\n

Color 1.0 0.0 0.0 1.0<\/pre>\n

In the above, “Color” is the label (used by a game to make sure it knows what it’s reading), and the four numbers are the RGBA values defining the color. \u00a0We also support “blocks” of data:<\/p>\n

VertexArray{\r\n0.0 0.0\r\n1.0 0.0\r\n1.0 1.0\r\n0.0 1.0\r\n}<\/pre>\n

The curly braces {} define a larger “block” of data, with each line getting its own (optional) label, followed by some data values.<\/p>\n

There were two annoying things about this; \u00a0one was that it only worked for a single level of data block. \u00a0That is, you couldn’t embed a block of data inside another block of data. \u00a0The other annoying thing was that you had to put the opening brace on the same line with the label for the block, when most programmers would expect to put that opening brace on its own line.<\/p>\n

Well, today I fixed both problems; \u00a0that opening brace can now be placed on its own line (the parser “reads ahead” to detect this), and you can now have nested blocks of data (as you can see in the screenshot), so you can have an ActionBar which contains a Button or a Tab which can, themselves, contain their own data.<\/p>\n

And as if that wasn’t enough, I also dramatically cleaned up the ‘fsRecord’ code, so it should be easier to maintain and fix any further bugs that might turn up. \u00a0If you couldn’t tell from the sheer volume of text that I’ve written about it, I’m very, very happy to have straightened out that mountain of tangled code!<\/p>\n

Tomorrow, hooking up quest editing with the new action bars.<\/p>\n","protected":false},"excerpt":{"rendered":"

A friend of mine has often been heard to say that he’s never regretted making something configurable via data. \u00a0I tend to agree.. although my usual development process for home stuff is to do a lot more in code than I do in data. \u00a0But MMORPG Tycoon is becoming large enough that I’m really starting…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[24,25],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/po9WK-k0","_links":{"self":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/1240"}],"collection":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/comments?post=1240"}],"version-history":[{"count":0,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/1240\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media?parent=1240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/categories?post=1240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/tags?post=1240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}