Mad Props!

Omniscience is just a Google-search away.

Login

You're reading Mabsterama, the weblog of Matt Hamilton. Enjoy your stay.

BioShock Weekend

On Saturday I went down to the local Big W and picked up BioShock for the Xbox 360. Needless to say the bulk of my weekend was taken up immersed in the world of Rapture, under the sea.

BioShock is one creepy game. It's dark, atmospheric and claustrophobic. As you wander the halls of Rapture, you'll hear creaks from the walls around you from the pressure of the sea outside. You'll hear the mindless ravings of splicers (citizens of Rapture driven mad by genetic upgrades gone wrong) in nearby rooms, waiting to assault you as you enter. You'll feel cold, wet and genuinely freaked out most of the time.

Because the city of Rapture is at the bottom of the ocean, BioShock makes full use of cutting-edge water effects. The pools of water on the ground ripples as you cross. Waterfalls formed by cracks in the ceiling blur your vision as you walk through them, and the water "sheets" off the "camera" as you emerge. Large icy stalagmites melt into puddles of water when you hit them with fire. It all looks amazing.

Speaking of fire: The amount of weapons and weapon customization is just ridiculous! There are seven or eight 'traditional' weapons (pistol, machine gun, shotgun etc), each with up to three kinds of ammunition. But on top of that, there is a whole system of genetic upgrades known as 'plasmids', which give you superhuman powers. For example, you can use the Electro Bolt plasmid to shock an opponent, stunning him long enough to shoot him down or bludgeon him to death with your wrench. Or use the Incinerate! plasmid to light an enemy on fire, causing him to run around in confused pain while you pick him off (or simply wait for him to burn to death).

The cool part is the innovative ways you can combine plasmids. For example, you can light an enemy on fire, and wait for him to dive into the nearest pool of water. Once he's there, hit him with an electric shock to kill him outright.

As well as weapons and plasmids, there is another category of upgrades known as 'gene tonics'. These give you special physical abilities such as reduced damage in combat, faster movement or better hacking skills.

Hacking! That's a whole new facet to the game. Throughout rapture there are numerous mechanical devices, some helpful, some dangerous. For example, security cameras will send autonomous flying bots to kill you if they see you. Vending machines allow you to purchase first aid kits or ammunition. You can hack any of these machines in a number of ways (the default being a great little mini-game reminiscent of Pipe-Mania). Once hacked, the machines work for you. Security cameras will scan for enemies. Gun turrets will ignore you but shoot bad guys. Vending machines have more stuff available at cheaper prices. You get the idea.

Adding to the overall creepiness of the game are the 'Little Sisters' and their protectors, the 'Big Daddies'. Little Sisters are young girls who have been corrupted somehow, and stalk the halls looking for corpses from which to harvest genetic material. The Big Daddies are ... well, at this point I don't know what they are. All I know is that they're big, and incredibly difficult to kill. The way they shake the environment as they walk is enough to make you want to turn off the Xbox and curl up in a foetal position behind the couch.

As you explore Rapture, you find small audio clips which help unravel the underlying story. It's a great way to get to know the history of the place without resorting to cut-scenes etc. I'm only a few hours into the game so I don't know much yet, but I'm listening to every audio clip I find, slowly getting to know the characters (some long dead, others still alive somewhere in the city).

So far this has been one awesome game, and I expect it to only get better the deeper I get. I can definitely see myself playing through it again so that I get a chance to explore all the nooks and crannies that I've missed so far. Highly recommended!

Shattered

This morning at about five o'clock we were both awoken by a loud ... well ... cracking sound. An abrupt sound followed by a few drips of water from the shower in the en suite adjacent to our bedroom. When Sal first asked what it was, I replied that it was simply the shower head having "fallen down" (ie loosened on its hinge and swung down to hit the wall). Unconvinced, she got up to investigate.

Turns out our bathroom window has shattered. For seemingly no reason, it has completely cracked. Not in a spider-web pattern as if something had hit it - just completely shattered. Here's a photo, with the other, intact half in the picture for comparison:

shattered

If you click on this and get the big version, you'll see that there are minute cracks in the glass, some of which are large enough that you can see through them to outside.

So I've taken the day off - at 9am I'll start ringing glaziers until I find someone who can come out today to take a look at it. Hopefully they'll know what can cause this to happen! Maybe I was singing soprano in my sleep or something.

A ListBox with Columns

So here is some XAML to make a ListBox display its data in columns, for those cases where you don't want to use a ListView. Hope someone finds this useful.

First, we set up a ControlTemplate for the ListBox that gives us some headers in a UniformGrid, which is a grid whose columns are all the same width:

<ControlTemplate x:Key="CityListBoxTemplate"> <StackPanel> <UniformGrid Columns="4"  TextBlock.Foreground="Silver"  TextBlock.FontSize="9pt"> <TextBlock Text="City"/> <TextBlock Text="State"/> <TextBlock Text="Postcode"/> <TextBlock Text="Population"/>  </UniformGrid> <StackPanel IsItemsHost="True"/> </StackPanel> </ControlTemplate> 

Next, we set up a DataTemplate for each item in the ListBox that also uses a UniformGrid. I've made the first column bold and slightly bigger in this particular list.

<DataTemplate x:Key="CityListItemTemplate"> <UniformGrid Columns="4" Margin="0,2,0,2"> <TextBlock Text="{Binding City}" FontSize="10pt" FontWeight="Bold"/> <TextBlock Text="{Binding State}" FontSize="9pt" /> <TextBlock Text="{Binding Postcode}" FontSize="9pt" /> <TextBlock Text="{Binding Population}" FontSize="9pt" />  </UniformGrid> </DataTemplate> 

Lastly, we set up a style so you can just apply this style to the ListBox, and both of the above templates will be applied for you:

<Style TargetType="ListBox" x:Key="CityListStyle"  BasedOn="{StaticResource {x:Type ListBox}}"> <Setter Property="Template" Value="{StaticResource CityListBoxTemplate}"/> <Setter Property="ItemTemplate" Value="{StaticResource CityListItemTemplate}"/> </Style> 

So now all you have to do is apply this style to your ListBox, like this:

<ListBox ItemsSource="{StaticResource myCities}" Style="{StaticResource CityListStyle}"/> 

Give it a try and see how you go!

Binding to the First Element of a Collection

Yes! It's another in a long series of posts that fall under the category of, "things many people already knew but I just discovered"!

Today I had a form with an ObjectDataProvider that retrieved a collection of objects. However, I didn't want to display the entire collection. See, in 99% of cases I knew that this collection would only contain one item; and in the other 1% of cases I knew that the user wouldn't care. So all I ever wanted to do was display the first item in the collection.

So I had dropped a ContentPresenter on the form, and set its content to my ObjectDataProvider. But now when the form displayed it simply showed the text "(Collection)". This was obviously not what I wanted.

So how then do you bind to just the first element of a collection? My first instinct was to write an IValueConverter, which I did, and that worked well. However, I've just discovered an easier way.

It turns out that Binding.Path supports indexers into collections! You can actually say this on your ContentPresenter:

<ContentPresenter Content="{Binding Source={StaticResource MyObjectDataProvider},Path=[0]}"/>  

How cool is that? That binds to the first element of the collection provided by "MyObjectDataProvider"! Works a treat! Another insight into the power that is WPF.

AWDNUG August

Last night's meeting of the Albury/Wodonga .NET User Group was all about code generation. Anthony took us through some tools that he'd found while researching the topic, including DeKlarit and (one I hadn't heard of) Iron Speed.

We had a great discussion about the pros and cons of code generation, despite there only being six of us present. I wish I knew what happened to the other dozen-or-so people who used to turn up. Perhaps we're doing something wrong. Anybody out there involved in a user group with tips on getting and/or keeping members?

Anyway, I'm still keen to attend AWDNUG every month, even if it's the same five or six people showing up each time. It's great to talk to others about what they're up to and how they're solving problems ... particularly if they're from a completely different industry.

Keyboard Lookup in a ListBox

Y'know how in plain-old Windows ListBox controls, you can type the first few letters of an item, and it'll move the selection to that item for you?

In Windows Presentation Foundation, you lose that behaviour if you assign an ItemTemplate to the ListBox. Because you're no longer just displaying a simple line of text, the ListBox can't know which item you're trying to select when you start typing.

However, I've just discovered a little trick to get that behaviour back when you have an ItemTemplate set. All you have to do is set the DisplayMemberPath property on the ListBox to point to the (text-based) property of the source item that you want to use to look it up.

So let's say you have a list of items with a "Name" property. You can do this:

<ListBox DisplayMemberPath="Name" ItemsSource="{Binding Source={StaticResource MyItemCollection}}" ItemTemplate="{StaticResource MyItemTemplate}"/>

... and now you'll be able to type the first few letters of an item's Name to jump straight to it!

The only caveat is that Visual Studio shows a whole bunch of silent exceptions that it's swallowing in the background, with this message:

System.Windows.Data Error: 20 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set;  'ContentTemplateSelector' will be ignored.

It looks harmless, but it concerns me that this is happening. Still - it's worth it for that keyboard lookup!

AutoCorrect in Orcas?

Check it out - when I accidentally mistype the word "string" as "strign" in Visual C# Express 2008 beta 2, it automatically corrects it for me! It doesn't do that in 2005! I don't think I've seen any references to AutoCorrect in Orcas ... that's pretty impressive!

Specialization vs Generalization

The topic of specialization vs generalization in the software development world seems to come up more and more nowadays. On .NET Rocks a few weeks ago I remember the guys talking about the fact that you can even specialize within .NET development nowadays - you can be a WCF guru, for example, or an ADO.NET specialist.

In a typical week at my job, I have to have a decent handle on the .NET framework (including ADO.NET, web services, Windows Forms and Compact Framework), SharePoint administration, SQL Server (both T-SQL development and administration), SQL Reporting Services, Lotus Notes (both administration and development) ... the list goes on.

Would my job be more boring if I were just a database administrator and only had to worry about SQL Server? Probably. Would I be better at it? Definitely.

That's not to say that I want to specialize. I just wonder sometimes whether my life would be easier if I could focus on one aspect of the job, and delegate responsibility for, say, our SQL Server merge replication infrastructure, to a dedicated database administrator.

What do you think? For those who don't work with me (I already know that you guys are in the same boat), do you generalize or specialize? Would you prefer one over the other?

Reporting out of SharePoint

Oh man, this is a good find.

Enesys Software have a free (as well as a commercial version with more features) SQL Server Reporting Services data extension for SharePoint lists.

It lets you build SQLRS reports from data stored in lists (any kind of list) in your SharePoint server.

The setup is a bit manual right now - it's just an xcopy of a DLL and a few hacks to XML config files - but I can at least confirm that it works at design time.

I still believe that any hard number-crunching kind of application belongs in a "real" database rather than SharePoint, but this at least will allow some simple charting and reporting out of some of the custom lists that our power-users put together.

Check out their blog, too. It looks to be pretty new but I'm sure it'll have some good stuff on it.

Cider Compatibility?

On the weekend I installed beta 2 of Visual C# Express 2008. This is the first time I've had a hands-on go of .NET 3.5 or VS 2008, and from my brief look on Saturday it looks great. Not too different visually from Visual Studio 2005, but hey - when you're on a good thing, stick to it.

The current version of Comicster compiled just fine, but the newer, WPF version had some issues. While it compiled, I couldn't open the main form in the XAML form designer (code-named "Cider"). I just got the new "White Screen of Darn" where it tells you that the form couldn't be displayed. This is obviously due to my hand-coding the XAML rather than using a visual designer from scratch, but it leaves me with something of a conundrum:

Do I restart the main form's design from scratch using Cider, so that I know I have a level of compatibility with the visual form designer? Or do I abandon the current form designer and continue with my (possibly incorrect but still working) hand-coded XAML?

Both options have merit. I don't know exactly what it is with my current form that stops it from loading in the designer, but it could be anything. I'm thinking it's probably something to do with references to templates, styles and code-based template selectors in other files within the project.

Anyone else had enough hands-on experience with Cider to have an opinion one way or the other?