XAML: Attribute Order Matters

•November 8, 2009 • Leave a Comment

I think the most annoying thing about WPF is that for any given task everything goes fine, for a few hours, then you do something and you’re stumped why it’s not working. One such issue I hit recently is that some properties have built-in dependency on other properties but since there’s no way to express such a dependency if the control doesn’t correctly handle out-of-order processing of the attributes, order becomes important and is easy to overlook.

For example, you might write something like this for your buttons command binding to the corresponding view model:

<Button Command="{Binding Path=GoCommand}"
CommandParameter="{Binding Path=Thing}">Go!</Button>

Now, for most people that’s not actually a problem. Because if in the process of creating the control focus is shifted to the window that contains it, you’ll fire enough checks that the command will be evaluated multiple times and the button will become enabled. But if you’re creating the control on another window or control that doesn’t contain the focus, the order of the above code will result in a disabled button (assuming that your command requires having a non-null parameter) until you shift focus.

To correct this problem, it’s really simple, but not immediately obvious because order of attributes in XAML isn’t something you’d normally think was important. If you just swap the attributes so that you bind the CommandParameter first, then the Command will have the correct parameter when it gets evaluated.

<Button CommandParameter="{Binding Path=Thing}"
Command="{Binding Path=GoCommand}">Go!</Button>

MSIL Command 2: The Visualizing

•October 19, 2009 • Leave a Comment

When generating MSIL it’s often very useful to be able to see what you’re doing.  One very handy debugging visualizer I’ve used is Haibo Luo’s DynamicMethod Visualizer.  It’s extremely handy in seeing the code you’ve generated, I encourage you to check it out.

http://blogs.msdn.com/haibo_luo/archive/2005/10/25/484861.aspx

Filters

•October 18, 2009 • Leave a Comment

The two most common filters used in any UI are “Begins With” and “Contains” substring. However, both of these filters are non optimal because they tend to fail to find what the user wants in a few scenarios.

“Begins With”, is usually a very poor choice, it’s no doubt the fastest, but with the ease at which a search can be threaded in .Net and the number of cores on machines these days it’s really not a big plus. The filter itself only works well when users always know how the items they are looking for start, which is pretty rare.

“Contains”, is a much better choice but it fails to deal well with the situation where the string in question actually contains 3 or more unique words, the order of which is not known to the user or consistent. For example, lets say you have the following list of search-able strings:

LargeRedDragon01
LargeBlueDragon01
LargeOgre01
SmallOgre01
RedDragonCaptain01

Assume there’s hundreds more entities in this list, now using “Contains” the user could search for “Red” or “RedDragon” and will likely find the red dragons he is after. But what if the user wants to find all the large dragons? The “Contains” filter starts to fall down.

There’s always RegEx, but only your power users will use that and unless they do it often they may need to look-up a few things. This option would be good to have in a text editor, but a lot less useful for searching things like entity names, or properties or other fairly short multi-word strings.

You could use wildcard searches that just use ‘*’ to support for any number of characters separating two words, but this isn’t as natural of a filtering mechanism as I’d like.

So what would I do?

“Contains Ordered Characters”, instead of searching for a single substring, imagine attempting to match each character in order with an implied wildcard between every character.

So taking that same example again I could find the large dragons by just searching for LargeDragon, now you may ask, why is this that any better than “Large*Dragon”? Well it’s more natural, by which I mean I don’t need to be told about the existence of wildcard capability, I just enter LargeDragon expecting to find any and all large dragons, I don’t care if they are red or blue. It’s also valuable for things like intellisense where you don’t want your users entering characters that are not part of the standard syntax.

Another enhancement might be to treat capital letters as separators for searching for words. So in addition to matching a list of characters in order, you also match each word denoted by a capital letter inside the word you’re parsing in any order. This would solve problems with users who don’t know large comes before the color, so I could search LargeRedDragon or RedLargeDragon and still get the same result.

Now with a much more natural input style, the user is free to quickly add and remove characters to quickly filter, for example, I know there’s some large red dragons in the world, so I type, redrag or laredrag, which of course just looks like a mass of nonsense but it’s a more natural input mechanism for looking for red dragons or large red dragons, where with wild cards I would have had to type re*drag or la*re*drag to find what I’m looking for.

Problem Steps Recorder

•October 17, 2009 • Leave a Comment

I haven’t actually tried using this in the field, but this little tool comes with Windows 7 and after playing around with it a little it seems really handy. It records the users actions as a series of screen shots and bakes them into a single *.mht file (which I’ve actually never seen before) but it’s several html pages baked into a single page that IE knows how to open.

PSR

Unfortunately it only seems to be available for Windows 7, which is seriously disappointing because it will be a long time before I could just expect users to be able to run it when reporting support issues with tools.

Quis Custodiet Ipsos Threadis

•June 15, 2009 • Leave a Comment

Who watches the threads? Apparently the Visual Studio 2008 debugger. Though, this should come as no surprise to anyone… except for the fact that they watch the threads even when you’re not at a break point.

The result of which is a massive lockup in your application if you try to do anything fancy like always naming your worker threads as they are spun up by the asynchronous WPF binding thread pool. I thought that it would be a good idea as it makes looking at the thread window easy to find the active worker threads you care about. But, I was wrong…

Anyway, a little sniffing around with Reflector and I ran across this little gem on the Thread class:

internal static extern void InformThreadNameChangeEx(Thread t, string name);

I wonder if the Visual Studio debugger is hooking this and bringing my application to a dead stop when this callback gets called…

Natal Arcade

•June 9, 2009 • Leave a Comment

Does anyone remember Nick(elodeon) Arcade? I think they must have used a a physical area for the users to move in, but I wonder if an intrepid game programmer could use Project Natal to pull off a similar…but hopefully a lot more entertaining effect. The whole additive spacial moving thing will be a fun nut to crack…but hey who doesn’t love a challenge?

I know Microsoft’s whole pitch with Natal is controller-less gaming which is cool, but what’s so bad about a controller? Imagine how difficult pulling off a game like Wii Bowling would be with just Natal. There would be no precision or fine control over the ball, nor would there be a great way to alert natal when I released the ball. Opening and closing my fist may or may not be good enough to be picked up. Though, I suppose you could use voice recognition to say something like “Go” or “Release”. But I’m not so sure that’s an optimal solution, given that voice recognition (in general) as far as I’ve seen is never perfect and also tends to break down in areas of use that are time critical. I guess there’s something to be said for being able to provide input in discrete units to a game.

Now If I had a power-glove, nunchuck and wiimote to go along with Natal…

and maybe throw in eMotive for good measure…

Collaborative Game Editing

•June 8, 2009 • Leave a Comment

Collaborative Game Editing

All in all it’s a pretty good article worth reading by Mick West. Though it kind of leaves the reader hanging at the end because I don’t think he goes into enough of the very glaring problems someone would need to address for the solution to be workable. Files are a pain to deal with, but they are simple and users understand them. Sure they have their problems, but the alternative he suggests (a database) will have many more that will require a very bullet-proof solution if you don’t want your studio grinding to a halt because a bug just corrupted the central database.

He doesn’t really address the issue of sandboxing and offline development. Often users will want to be able to sandbox some ideas, but this is in direct opposition to the “live edit” environment he envisions. However as soon as you introduce a sandbox system to database back-ended solution it adds the complexity of no longer having a centralized database with transactional operations for everything. Now everything is disconnected and things are being developed in separate branched environments, which eventually will need to be merged back together.

This merge will likely require a very complicated tool designed to take the database differences and present them to the user in a way that will allow them to resolve conflicts. This tool will also need to be able to present the work the user has done in very logical blocks. With files a user can work on a section of the world, find it’s not ready to be checked in for other users to pull down, and decide to leave it on their machine, or they may decide they want to revert that work and only check in another part of the world they modified.

So how would you break it down, by sessions the user worked in, regions of the world, per entity, per property change. There are many choices, maybe the tool offers them all, but still something to consider. Because if the user is unable to revert some of the work they’ve done offline in their sandbox, it kind of defeats the purpose of a sandbox or at the very least cripples its usefulness severely.

Another problem you would need to solve is the interaction with the undo stack (assuming this is a live edit environment). If you don’t want angry designers wielding pitchforks it would probably be wise for this collaborative game editing tool to be able to maintain an undo stack. However, this presents all kinds of dependency/order of operations problems that would need to be solved. Such as, in a live editing environment how can I undo my own work, without undoing other users work that may have become dependent on my work. For example, user A adds an Orc. User B immediately, scales the Orc. User A then attempts to undo his last action, then attempts to redo it. What is now the state of the world? Did the Orc get put back into the world, and does it have the change in scale that user B made?

My immediate reaction would be to say, you just figure out the database modifications that would need to occur to remove the Orc, properties and all and any other change that would occur because of the loss of the Orc, and store those as actions in some kind of undo action table that could be replayed should I decide to redo the operation. That way the state of the world is exactly as expected, an Orc with user B’s scale applied.

Ah, but what if while deciding to redo the operation, user B decides the Orc ‘type’, the definition of this entity that you’ve been stamping around the world is no longer needed. So user B deletes it from the list of types, which in turn deletes all Orcs currently in the world. Now, user A attempts to perform the redo, placing an Orc instance back into the world. But this operation is no longer valid, Orcs no longer exist as a type because of user B’s actions.

Blocking off the world would alleviate some of these problems, as long as you threw away the undo stack as soon as the blocked off area is unblocked, but when a user wants to change something that affects all regions (like the removal of the ‘Orc’ type) those types of changes could be a bit more complicated.

The long drawn out point here, is that your database and editor would need to be incredibly error tolerant as would the capability of your runtime to deal with bad/intermediate-state situations that would be a likely occurrence.

Now of course these problems and more could be avoided, but it may mean changing the way users work and the way they have become accustomed to working and could also mean flat out denying them certain capabilities they’ve been used to having as far back as they can remember.

Though, I do wonder if a day will come where it just becomes second nature to turn to databases to solve the problems of world editors.

Project Natal’alishus

•June 4, 2009 • Leave a Comment

If you haven’t gotten a chance yet to check out what Microsoft has planned for the 360 in the coming year, you should check out this video about Project Natal.

I watched that video and could only think of one thing, Human Tetris.

Tell me that wouldn’t be perfectly suited for Natal.

I <3 The Vitality Sensor

•June 3, 2009 • 1 Comment

The Wii Vitality Sensor was just announced at E3 and I’m thrilled. I’ve wanted this type of peripheral for a long time. Think of what knowing the heart rate of a player can tell you.

Finally when playing that horror game you can round that corner have a zombie jump out at you; struggling, you attempt to shoot the zombie in the head. But oh crap, your heart is pounding and you’re having trouble focusing, the music becomes darker, faster, a specially tuned shader starts to blur the screen.

In the case of an action game, higher heart rate becomes a sign that the user is getting into the game, the music starts to get louder, the darkened area begins to light up, a shader starts to brighten enemies to make their bodies form become more obvious against the background, maybe even time slows down just a bit.

Now you’re a spy and you’re trying your best to sneak around. But your heart is pounding and your character is having trouble keeping his breathing pattern normal.

Its the last quarter of the game, the clock is counting down. You line up the shot and let fire. Your heart is pounding, adrenalin is rushing through your body, and it was just enough. An increased heart rate gets translated into an extra 5% chance to make that shot, and swish, you win by a point.

I hope one day this becomes standard on controllers, as natural as the start button. It would be easy to integrate to a typical controller if it functioned like the metallic heart senors you see on the handles of a treadmill.

360 Mockup

360 Mockup

Well, I can dream anyway.

Toolbench

•May 14, 2009 • Leave a Comment

We posted a series of demo videos over at our YouTube channel. They are videos we created prior to GDC’09 for customers and such. These videos demonstrate several of the new features in Gamebryo Lightspeed, along with our new tool; Toolbench.

Toolbench is my primary/only focus since I started working at Emergent nearly 2 years ago. Most of my work has been on Toolbench’s infrastructure both core and satellite systems; along with World Builder, which is a plug-in into Toolbench. Toolbench barrows heavily from many of the concepts laid out in Eclipse for extension and we’ve made it really easy for customers and partners to extend Toolbench and its associated plug-ins. I’ve linked some of the videos from the channel that demo Toolbench and several of its plug-ins very nicely.