New Fun Blog – Scott Bilas

Take what you want, and leave the rest (just like your salad bar).

Dungeon Siege Page Posted

without comments

By popular request, I just posted a new page that has everything I could find that I’ve done related to Dungeon Siege. It’s got the good, the bad, and the ugly. A large, memorable chapter of my early game development life.

Until now, this stuff has been scattered all over four different defunct websites in a mess of broken links. This new page fixes all of that for good.

Dungeon SiegeI worked at Gas Powered Games between November 1999 and October 2003, back when it was a fresh startup. In that time, I lectured and wrote about some of the technology we used to build Dungeon Siege and later projects. I also released specifications for some of the internals of the engine to help the mod community.

This page collects all of my published Dungeon Siege work.

…continued here

Written by Scott

February 2nd, 2010 at 8:49 pm

Posted in blog, dungeon siege

Finally Onto WPF

with 11 comments

In Lima I’ve been learning WPF for some GUI tools I’m building, and it’s a whole new world. I feel like I’m back with .NET 1.0 in the late 90’s trying to inhale a bunch of new technology and patterns all at once.

It’s pretty exciting, even if I am joining this game very late.

As I work in the WPF world (and maybe WCF and other techs as I start messing around with them) I’ll be posting odds and ends here about research I do and dead-end paths I go down.

Not WinForms++

The first thing I learned is that WPF isn’t WinForms++ or even “WinForms in XML”. It lives in an entirely different universe. Though, for folks like me that have been stuck in that old world too long, WPF is initially going to feel like a simple upgrade of an old framework. There are a lot of similar-sounding classes and concepts in the new framework. These are merely false cognates.

I’ve been learning that it’s better for me to enter into new WPF concepts like a 101 student: by reading books and MSDN docs. I haven’t done that in a while. Normally I just bang on code and refine, using Google and StackOverflow to guide my way (and surfclarity to filter out spam sites like experts-exchange.com). I’m still doing that as I pick up WPF, but adding on top of it some serious reading.

Pro WPF in C# 2008 Pro WPF in C# 2008 (available at Safari where I’m reading it) is my current favorite book for learning WPF concepts. Most books I come across are lame reference manuals disguised as tutorials, or sensationalized drooling over new tech with no real experience to back it up. The author does great things like quickly explaining a cool-sounding WPF concept, then telling you not to use it and why. Not all of WPF turned out to be a good idea, after all.

So, here are some of the key benefits I’ve noticed in the short time I’ve worked in WPF:

Layout and Composition

The problem of control layout (wrap, dock, table, stretch, fill, and so on) is solved. It’s nice of WPF to catch up with where HTML has been for a while, though in a much cleaner and more internally consistent way. Later versions of WinForms started to get somewhere with TableLayoutPanel and friends, but it’s still the same old underlying framework, where you run into limitations very quickly.

WPF lets you easily nest any control within nearly any other, and has a sensible system for guiding layout containers (attached properties rather than Control-derived least-common-denominator properties). It’s simple, for example, to put a pair of icons and a few checkboxes into each element of a ListView, and make it look good. Virtualization is automatic as well, given certain constraints. Trying to make any of that work in old WinForms requires a lot of custom code.

Easy to code, hard to follow In fact, it was enough work in WinForms that I tended to avoid doing anything complicated. This led to UI’s that were easier to program but harder to use due to the need to break out elements or hide things behind the ubiquitous “more” or “advanced” buttons. Consider your average Tools|Options dialog and the custom toolwork required to make that work in a Form. This is why “field of checkboxes” settings dialogs proliferate in so many apps (see pic at right).

With WPF I’ve found it easy to not only wire up the initial draft of the UI, but also to go back and do a big reorg without any real trouble, and usually without significantly changing any code. I Just did it three times today, in fact!

A Special Note on XAML

Layout and composition are now typically done in XML, using Microsoft’s XAML. At first I was tentative on XAML compared to MXML due to the total lack of support for writing code inline in the attributes. Well, it turns out that viewmodels eliminate the need for much of that inline code (with the glaring exception of value converters – more on this in a future post). It’s also probably a good idea to keep code out of the XAML if you’re splitting the work with a designer. Having code in those attributes would not only get in the way, but would be brittle and hard to maintain.

The bottom line is that WinForms’ crazy InitializeComponent is gone. Bye bye merge problems and periodic, inexplicable total reorganization of that function by Visual Studio. Instead, we lay things out hierarchically in nice, simple, consistent, and nearly unreadable XML. Well, that’s what the visual designer is for.

Data Binding

I’ll admit I didn’t mess around with data binding much in the WinForms world. It just felt like too much work for what was a simple thing to do by hand. And WPF is vastly more complicated and capable than Forms, so it was intimidating at first.

But in WPF you really need to fully embrace data binding. I suppose it’s possible to do old UI-driven Visual Basic style state management in WPF, by putting everything in the codebehind, but you’re not going to get much support for this. All samples and tutorials you’ll find online use data binding. It really is how the entire system was designed to be used. Data binding is about a lot more than simply tying a textbox to a text string member. It’s about separation of concerns.

Thankfully, it’s not difficult to pick up. There’s some crazy complicated 20-levels-deep-stack logic that makes it all work under the hood, but the end result is that you just cover your eyes and type {Binding SomeName} on whatever field you want bound to your viewmodel and it magically works. “Except”, as they say, “when it doesn’t”. So far it’s been rare for me when something fails to bind, or binds to the wrong place, and I’m developing a bag of tricks to debug these issues. I’ll try to post some of these in the future.

Now, about that viewmodel thing. It’s also practically required to embrace the MVVM pattern in building up nontrivial WPF-based UI’s. This is the “separation” I mentioned previously. Now, this takes a lot of practice to figure out and to start applying correctly. It took me about two months to really grok WPF+MVVM. So be sure to budget time to learn and practice this. Read the article I just linked for a good introduction.

Styling

The problem of styling controls and windows is hugely improved. It simply isn’t possible to modify controls in WinForms without writing a totally custom solution. WPF takes a big step forward in enabling simple as well as complex styling of the standard controls. You can completely alter the look and visual behavior of any WPF control without a lot of work.

Expression Blend 3 And then there’s Expression Blend, my new love interest. Blend is a tool for the design and styling of WPF UI’s, and permits dividing responsibilities between engineers writing code and designers building the look & feel. We have this exact split at work, in fact. Engineers will poke out a rough UI, and later on one of the game UI designers will take some time to upgrade elements to look cool and be consistent with the rest of the tool.

Blend has a goofy, nerdy interface, but it’s really growing on me as I use it every day. It’s far from intuitive, but is powerful in terms of designing controls and styles, previewing it all live, live live! in its awesome designer. It can even build your full Visual Studio solution from within itself. I do almost all of my design work within Blend, partially because VS2008’s designer is so awful as to be almost useless (haven’t used 2010’s enough yet to comment) but mostly because it’s more familiar to the Flash programmer within me. What can I say, I like arty tools.

Rendering

One of the reasons styling can be done so easily is that WPF doesn’t rely on the underlying OS window manager to draw checkboxes and so on. This removes all limitations on what you can change. If you use a tool like Snoop or Mole to take apart a UI control, you can see that every little graphical piece and state of it resolves down to primitive WPF objects that you can inspect.

ResizeGrip taken apart in BlendResizeGrip controlFor fun, I edited the template of the ResizeGrip control in Blend to see what makes it tick. This is the little triangular dotted thingy that sits in the lower right corner of most sizable windows. Blend showed me that it’s rendered using a simple brush that has a repeated pattern of gradient squares clipped to a little stair-step box. All vector so it scales nicely.

How does this new rendering model affect Remote Desktop, by the way? Custom-rendered windows typically perform poorly through RDP. Try running Chrome or iTunes through RDP, or nearly any app through VNC, on a low bandwidth VPN connection to see what I mean. In earlier versions of .NET, if a DWM existed on both sides, the WPF graphics primitives would get remoted directly. However, it seems that in .NET 3.5SP1 and newer, WPF is remoted completely as bitmaps.

Microsoft is saying that this should actually improve performance in many cases. Well, we can only expect a future of more complex, denser GUI construction (I mean complex in the UI tree sense, not in the end user’s perception of complexity). So the 100%-bitmap-remoting solution may be needed in the long term anyway. But I’m not sure I agree with the timing of this decision. Bitmap remoting so far performs an order of magnitude slower for me than graphic primitive remoting, at least in the everyday apps I use through RDP.

Bye Bye WinForms

It’s clear to me that anyone working in WinForms should ditch it as soon as possible in favor of WPF. Rewriting old tools is always a cost-benefit analysis, but for new tools, this is clearly the way to go. Especially if you’re in control of your user environment, such as within the enterprise, where you can force install the framework on every machine.

If you’re still hanging out in the WinForms world, or considering buying an expensive Forms-based UI package to pick up the pace on building UI’s, you really ought to take a hard look at WPF.

Don’t expect to be productive immediately, or even within a month. It will take a while to get used to it, learn the framework, and develop patterns to use in building UI. It’s time well spent. This is clearly the future.

Written by Scott

January 14th, 2010 at 7:00 am

Posted in wpf

You Have Slain A Magic Mushroom!

without comments

Sword of FargoalI’m excited. The classic Sword of Fargoal has been remade for the iPhonepod platform!

Sword of Fargoal is an ancient Rogue-style game for the C-64, written by Jeff McCord in BASIC (I remember curiously walking through the source code) and published by the long-defunct Epyx, one of my favorite publishers from back in the day. When I was a kid I played the hell out of this game and I’m excited to see some game developers who are even bigger fans than me have gone and remade this awesome game.

Thud!

I’ve been playing Fargoal LLC’s remake on my iPhone (available here at the App Store for only five bucks!) and it’s clearly a labor of love. Most remakes of classics are disappointing. Someone writes an emulator and they just run the old game on new hardware. It’s 100% authentic and all, but that’s not necessarily a good thing.

You’re all excited to play the game you loved as a kid, and then, five minutes in you realize that..oh..this game is kind of frustrating, annoying even.. It’s not because the game is bad, it’s because the world of gaming has changed since then.

As an industry we’ve moved far past the primitive control techniques and UI’s of the past. We expect to have tutorials and hint screens, auto-save and context-sensitive UI gizmos that help us out.

Old games just didn’t have room for any of that in their 8K or whatever of ROM. While this gave some insane replayability, and created a small sub-industry of invisible ink cheat books, learn-by-dying is just a thing of the past. It’s no fun.

I’m happy to report that the developers of the new Sword of Fargoal did more than just slap some upgraded graphics on this game. They’ve added help, auto-save, and a great control scheme (moving diagonally on the C-64 joysticks was always a dicey affair). But my favorite is a great new feature called the “Smart button” that gives you context-sensitive actions, such as using a teleport spell right when the ceiling is about to collapse on you.

Fargoal LLC has big respect from me. I’m already in love with this game again and now I can bring it everywhere with me. All I need is some OpenFeint (or similar) integration to compete with my brother.

Anyway, go buy Sword of Fargoal immediately. Swoosh! Clang! Thud!!

Written by Scott

December 27th, 2009 at 12:00 pm

Posted in game review, iphone, ipod

Switch to our mobile site