Posts Tagged ‘CGT’

CGT finally works on Windows

So after some work, some more frustration and even more complaining, the thing actually builds, links and runs without crashing.

CGT on Windows

After reading many times the famous Qt tagline “Code once, deploy everywhere”, I expected that porting CGT to Window would be quick and painless.

It wasn’t. There were a great number of issue to make it even compile, and then some for running and installing. But I admit at least some of them were my fault:

  • CGT_EXPORT macros in public classes in libraries are not needed on Linux, but reqiured on Windows and present in virtually all libraries I looked into. Only my laziness is at fault here.
  • passing an integer to ceil() works on Linux, but not in Windows. I had to change ceil(something) to ceil(1.0 * something) globally.
  • getting application data path (AppData) is different, as there’s no cross-platform method for that in Qt.
  • Qt is comiled with “Treat WChar_t as built-in type” set to “No”, unlike the Visual Studio default. So I had to change that, and it’s not the easiest thing to find in the maze mess of configuration menus.
  • CMake targets for libraries had to be fixed to separate dll’s and lib’s.
  • cmake && make install doesn’t have permission to install into Program Files, so I had to use CPack to build an installer. That’s actually a good thing that had to be done anyway, but it’s another hurdle. It also doesn’t work right now, and I don’t know why.
  • For some reason, Qt binaries install to a location outside of PATH, so they’re not found when I try to start the program (but are found by CMake for linking).
  • You can’t link to libraries built with Visual Studio 2008 from an application built with VS 2010. And heaven forbid that told that to me, the lowly developer. No, all they told me is: The application was unable to start correctly. Go figure. It might be me (the lowly developer again, spoiled by Qt/KDE/Linux), but I haven’t the slightest clue why would the same code, only compiled with a different version of the same compiler be binary incompatible. Why can’t the .lib file, the public interface to the .dll object, be compatible?
  • I had to put up with using Windows (but that’s a subject for another post).

I suppose I could compile Qt with VS2010, and then it would work (maybe), but how’s tht for deployability? I’d like to offer this program to other people without shipping the whole 200MB of Qt libs in the package. Does it really have to be that complicated to write software?

Animations in KChess and CGT

Qt 4.6 release brought many improvements, most notably the Animation Framework. Though it works for any QObject and any property, I’ve only implemented it for graphics items and their position. The API is very simple: all I had to do was replace calls such as:


to this:

QPropertyAnimation* animation = new QPropertyAnimation(item, "pos");

Now, opponent’s moves in KChess and moving or reordering cards in CGTable feels smoother and much more natural.

Current CGT project status

I spent the last two days fixing CGT so it compiles on Windows with VS 2010. I had troubles with the Q_DECL_EXPORT macros, lack of love between CMake and VS, and ultimately, finding the right directory to store data in. It builds succesfully now, so I can focus again on adding necessary gameplay features. Here’s what can now be done:

  • Moving cards from zone to zone, complete with restrictions about their visibility
  • Tapping and flipping cards in play
  • Shuffling
  • Attaching a card to another

These are basicly the requirements for a usual game. However, there are still some features that should be added to support more card effects:

  • Dice rolling and random selection, as simple as it is, is not yet implemented
  • Exchanging control of cards
  • Face-down moving of cards (for example: Morph)

The visual representation is also somewhat lacking, particularly I’m planning to use the Qt animation framework for zone reordering.

The default connection protocol has been changed to an XML based format which makes it easier to detect errors that the previous binary one. I’m also intrigued by the idea of a GGZ connection plugin. In theory, it might probably be possible to add a plugin to interface with GCCG, Apprentice or other similar platforms. Note that I did no research into this and I don’t know how similar their protocols are.