16 November 2007

How Mac Games Should Save

Putting on my GameHouse hat, I’d like to post on how games should save their state. (I often receive games that do it wrong.)

Games should not save state within the game bundle.

Games should not save state next to the application.

Both will fail if the game is run from a read-only volume (such as a disk image), or if the user doesn’t have write permissions to the /Applications folder (where someone may have installed the game).

I recommend saving to ~/Library/Preferences (or a folder therein). Locate this with FSFindFolder if you’re not using CFPreferences or NSPreferences.

Why not ~Library/Application Support? I figure most games track options such as sound effect and music volume. These are definitely preferences. Apple says of ~/Library/Application Support: “This directory should never contain any kind of user data.” And saved games are definitely user data.

So I’d say: anything the game saves goes in ~/Library/Preferences. Additional levels, downloaded user avatar images, etc. would go in ~/Library/Application Support.

10 November 2007

Stacks in Leopard

One cool thing about a stack: you can click on its Dock icon, then drag a file. I’ve found this especially handy with the Downloads folder: you can drag a file right to the Trash, or to the Dock icon of an application you want to open it in.

I’ve written before about how the Downloads stack is useful because you can sort by date added. It’s thus easy to get at whatever I most recently downloaded. (I set this stack to View as Fan because it looks cooler, and because I have over 200 items. There’s really no point in seeing the whole thing in a menu.)

Although stacks can be fun and useful, sometimes the old standard menu was handier (especially if you had a folder of folders in the Dock). It would be great if the menu were View as > Fan | Grid | Menu — don’t get rid of stacks, but let us use the old way as well.

09 November 2007

Leopard Spotlight searches any metadata

In Leopard, much more of Spotlight’s functionality is exposed. You can now search on any defined attribute. Several tips are floating around on how to search for system files, but the search window is far more flexible — it lets you query metadata from any application with a Spotlight importer. For example, here’s how to search for all Opal outlines with a lot of topics:

1. Open a search window (in Finder, choose File > Find)
2. Click the Kind popup
3. Choose “Other...” from the bottom of this menu (not from the “is” menu)
4. Locate “Topics,” select it, and click OK.
5. Choose “is greater than”
6. Type the number of topics

04 November 2007

Programming in Leopard

As a developer, getting to use Leopard on a daily basis means getting to use Xcode 3.0 on a daily basis. I’m pretty happy with this update, though some of the changes simply take a bit of getting used to. The new SCM integration is much better, though it also introduces the concept of a project root. SCM applies to all files in the root. With Opal, this isn’t a problem. With a GameHouse game, it is, because each game uses 4 libraries and one game-specific folder from the root. Getting SCM info for the other 50 game-specific folders takes a lot of time, and showing said info confuses things.

It’s a little disconcerting that rebuilding a Cocoa application changes its behavior. For example, Opal’s Export as command used NSExportableAs to specify the possible types. Under Leopard, this requires the use of UTIs, which Opal didn’t use. So Export as (which worked fine in Leopard) broke as soon as I rebuilt. Another change was the preview pane in Print dialogs. This showed up only after I rebuilt in Leopard. That was cool, new behavior for free! Except it wasn’t quite right. So I had to figure out how to hook Opal’s print dialog controls so that they updated the preview. Bottom line: an application that works fine in Tiger may require significant work as soon as you touch it under Leopard.

I haven’t seen anything similar in the Carbon world (which GameHouse games use).

27 October 2007

24 Hours with Leopard

I managed to download (as a developer) Mac OS X 10.5 yesterday. I’d looked at it while it was in development, but I’d never used it as my primary operating system. Here’s some impressions after the first day.

I was impressed at how well my custom settings were retained (I did an Archive and Install), including the login window. And all my widgets were still there when I pressed F12 (a good thing, since I don’t think there’s any other way to see the stickies!

Pretty much everything just works. Even odd stuff like VPN (via Tunnelblick). The only real problem I had was RSS not working in Safari or Mail. I ended up deleting a couple of Syndication-related folders and logged out. Things then worked.

It’s a bit odd when the external hard disk spins up to do a Time Machine backup. I haven’t had occasion to use Time Machine in the last day, but it does look like it behaves as advertised (which I was never able to be sure of in beta). I rather like the custom disk icon. My external disk had been partitioned inefficiently for use with Time Machine (I’d earlier used it as a temporary startup disk when Elise’s PowerBook drive failed), so I’ll be trying to repartition it with Disk Utility. This looks like it may be possible, but it’s not quite as simple as I’d hoped.

I really like how Apple changed the Print dialog. 2-sided printing is now instantly available (my Brother HL-5250DN duplexes), and application-specific options (like Opal’s choice of what to print) is in the default dialog (instead of buried behind a popup).

Quick Look was far more useful than I’d expected, once I was using real data. It was super easy to look at the first page of a bunch of downloaded files and see what they were so I could organize them.

I would have hated the new Dock appearance, except that I’d already executed the Terminal command 
defaults write com.apple.dock no-glass -boolean YES 
which makes it non-reflective. (This was one of those custom settings I referred to.) I rather like the new look, with the bright lights under (unlike the blue light which blends into the reflection in the official look).
 
I’m still not sure about Spaces. I like setting up a separate workspace for development, though switching between spaces still seems a bit flaky (it didn’t work at all this morning, but then began working again).
 
And Coverflow in Finder still seems gratuitous. Maybe it’ll be useful. I did notice that one of my image folders has a number of black images with transparent backgrounds — these don’t show up at all in Coverflow!
 
It was a pain that fanned stacks (in the Dock) are limited to 10 items — this is the best way to use them as replacements for the old hierarchical menus. And stacks don’t work as well with Dock zooming (since they may appear, and then move when you aim for them.) Still, setting the Download folder to sort by date added should be useful.
 
So after a day, it’s obvious that Leopard isn’t perfect. Many of the aesthetic complaints are justified. But it seems like a solid and reliable upgrade, and I can’t wait to start taking advantage of some of the new features for developers.
 
And as a developer, the release of Xcode 3.0 was perhaps as important. There are a lot of improvements here that I’ve been waiting for. I’d already booted into a prerelease Leopard so I could use Instruments (née Xray), and the SCM improvements are welcome.

23 October 2007

Gmail has IMAP

Apparently you can now enable IMAP for your Gmail account! This makes it a lot more suitable for use on an iPhone (as an IMAP client essentially mirrors the server, rather than extracting the messages).

The one drawback seems to be that if a message is assigned multiple labels in Gmail, it ends up in multiple folders in your IMAP client — taking up extra disk space on your hard drive (or flash memory in the case of iPhone). I think I’ll be removing a label or two…

Enable IMAP under Settings, then follow the directions for your client. (I set it up in Apple Mail, then synched to my iPhone. It seemed to default to SSL, which didn’t quite match the instructions, but was what I wanted.)

21 October 2007

Resume Advice

I hope to be hiring soon (for a game developer at GameHouse), so I hope people have read this advice from Steve Yegge.

(By the way, I know the word is “résumé,” but the weblog software doesn’t do a good job with non-ASCII titles.)