All UI and No Play Makes Yak a Dull Boy
June 12, 2008
I haven’t been working on much the last week. Since it’s summer in this part of the world, and since our summer is short, I tend to spend the weekends outdoors as much as possible. Didn’t get much done this week because of work and low energy, but I did put the UI stuff in the background again, and return to campaign work. Joemac and Sick are changing a lot of stuff right now with the UI code, so I’m going to let the dust settle there before going back. Also, the TR team is still working on how they want the new web site and UI to look, so it’s a good time to pause on the UI.
Have Terrain, Will Travel
I don’t think the Mac bug with “tool” has been fixed yet, so I got a windows copy from Joemac and built a TR terrain using Parallels VM. (And no, I don’t care that you think VMware is better: I paid for Parallels early on before VMware could be bothered with Mac users, and it works just fine for my purposes). I haven’t hooked up the new terrain yet, I’ll do that next week I hope.
Next Task: Saving/Restoring Campaign State
My next job is to start moving away from my campaign testing script, which ran a kind of accelerated campaign when you clicked a button. Pilot actions were all simulated. What I’ve been working on this week (or meaning to work on, anyway) is adapting the code so that you can have cold starts (fresh campaign) or re-starts based on the last saved campaign data. Based on my comments in the campaign code, I see that I’m targeting a campaign length of about 3 weeks long. More than enough chances for the server to crash (probably same “Chinese hackers” that are hitting up those congressman’s pcs!), Bloo to stumble through and yank out the power cord, or the server to collapse in self-pity when faced with 300 raving TR fans shooting each other down all night long (Hey! I can dream, can’t I!?). Smooth sailing so far, thanks to these little TW lua gems:
UI-fer Madness
June 4, 2008
I have a new UI for TR2 now. Graphically, it’s based on Popgirl’s design for the TR web site (the current TR web site, not the new Joomla one the team is working on). Internally, it’s based on a UI sketch Joemac (from TW) let me crib from. And let me just say that I love steal… err, recycling, other people’s code. Especially when it’s in a language I don’t have a lot of experience with. Nothing like debugging code you didn’t write to teach you new things! Anyway, I got a handle on the code, made the modifications I needed to make, and figured out the texture mapping functions Sick programmed for the GUI, and it’s all good. The only thing I didn’t bother to do was make a TR-specific UI Theme, I just used one of Raff’s old themes. Looks pretty good to me, but I think the TR Dev Team may want to go a different direction visually. And that’s fine: all we need is a new texture drawn, and a theme to control how the widgets are drawn. Here are a couple screenshots, one English, one Japanese (slightly different buttons, Japanese version is 1 day newer):
In case it’s not obvious, I should point out that there are no elements of this UI that involve text “frozen” in images. Those buttons are all dynamically generated, with the graphical appearance controlled by Raff’s UI theme, and the text being inserted on top of that by the lua UI. The advantage of that is that you can change text whenever you want, you don’t need to go to a graphics program, save a new image, etc. Localization also becomes dead simple, as you can see from the snapshots.
Lua Tidbit of the Day: GUI Event Handlers
I’d like to start a new segment that introduces a little bit of lua. The concept I introduce will probably always been related, if not specific to, Targetware 2. Please feel free to post suggestions for topics you’d like to see covered. I don’t have time to cover anything in depth, as every minute I spent on the blog is another I don’t spend on TR2 development!
Probably because I’ve been working on UI stuff for the last few days, I’m going to talk about event handlers. In the TW2 UI system, every control (“widget” in TW parlance) on the screen needs to have an event handler if you want it to do anything. An event handler is nothing more than a function that is called when something happens to the widget. Every UI is going to have a “logoff” or “quit” button of some kind, so let’s use that as an example. Let’s say you have created a widget, and it’s a button, and it’s named “myquitbutton”:
-- event handler for quit/logoff button function logoff( w, e ) if e == gui.action then client.quit() end end
There is only one line in this code that actually does something: the 4th line, client.quit(). “client” in this case is the TW2 “client application”, running against a server. Executing this command would return you to the TW startup screen.
So what are “w” and “e”, you ask? In TW2, gui event handlers must be able to handle w and e. The game passes these automatically to the handler. w is the widget that was acted on, and e is the event that occurred. So in line 3, we’re testing to see if the event was a gui action. Most of the time, that’s what you’re going to be wanting to handle. In other words, if this function is set as the event handler for a button, in plain English, it means: “If somebody clicks my button, then log off the server ASAP. If some other event happens, don’t do anything.”
So you’ve written the event handler for your button. The only thing left to do is to teach TW you want the event handler associated with your widget. All you need is a line like this:
myquitbutton:eventhandler():add( logoff )
That’s it for today.
In the Mood
June 1, 2008
A couple of fun videos on Youtube:
- Ki-43s and P-40s and Buffalos, all footage shot by a Japanese film crew. I don’t know the origin:
http://www.youtube.com/watch?v=18gR1Y0XMp4&feature=related - Ki-43 (two-blade prop, so probably Ki-43-I) test flight. Note the awesome snap rolls:
http://www.youtube.com/watch?v=EDt6jOOIkpU&NR=1
Now if that doesn’t get you in the mood for Target Rabaul 2, nothing will!
Progress Update
Almost got tool working on my OS X box, it started to download terrain files, then curl ran into a segmentation fault. Wade is working on it. Closer, but no cigar yet.
Codewise, I cleaned up some things, made the localization code more robust, and then started to implement a new UI, based on some code from Joemac. I realized it’s really not that hard to make a decently pretty interface. In fact, it reminds me of the old days (I won’t say good old days) of laying out web sites in HTML using tables. I should have a screenshot to post pretty soon. Still working on making Joemac’s code my code (ie, figuring out what the hell it’s doing)…
TR Web Site Getting an Upgrade
The TR Dev team is working on a new home for targetrabaul.com. It’s not up yet, so don’t go looking. Looks like the team has settled on Joomla, which is an open source system with a content management system in the background (as I understand it anyway). This should make it a lot easier for us to add new web content.
This and That
May 20, 2008
Tool Progress Update
I was able to build “tool” yesterday, but it was missing some libraries or something, Wade is going to take another look at the xcode set up. I’ll check back in on that as soon as I have a chance to play with it and make some terrain. Here’s the command I’ll be using:
tool terrain 143.0 0 163.216 13
Being geographically challenged, I’m not sure I got that right, but I’m led to believe it’s about the same territory we use in TR in 0.64.
Lua Update
I’ve been working on the localization code for the TW UI, and for mod UIs and servers. I’ll put this out as a library anyone can use in their mod. Nothing too sexy to report, because I did all the fun parts already. Right now I’m writing some routines to traverse a file directory, find .lua files, and vacuum up any localizable strings it finds, and add them to an xliff file so you can translate them. I’ll talk more about localization in another post. It’s one of those things you want to design in from the very beginning, because it’s painful to add it in later. I must say I’m looking forward to finishing up that module, and get on to the next thing in my project plan, “have supply targets increase for winning side”.

