240
235
will be changed so that you cannot use IDs below IdUser in the future. Then you
241
236
have to specify the dataHandler(). You can also use a KGame or KPlayer pointer.
242
237
This will automatically use KGame::dataHandler() or KPlayer::dataHandler().
243
Finally you *can* provide a name for the property. This will be used for
244
debugging in KGameDebugDialog. If you want to save some memory you can leave
238
Finally you *can* provide a name for the property.
246
239
Note that if you use pointers to create the properties dynamically they are
247
240
*not* deleted automatically! You MUST delete them yourself!
248
241
Now you can use the KGameProperty like every variable else. See also Section
339
The general debugging concept (if there is one at all) or general debugging
340
hints are not yet written. Feel free to do so
344
A nice way of debugging a KGame based game is the KGameDebugDialog. Basically
345
all you have to do is to add something like "Debug" to your game's menu and add
349
KGameDebugDialog* dialog = new KGameDebugDialog(mGame, this);
350
connect(dialog, SIGNAL(finished()), dialog, SLOT(slotDelayedDestruct()));
354
You can now click on that menu entry and you get a non-modal dialog where you
355
can start to debug :-)
356
The dialog consist of several pages. You can easily add your own using
357
KDialogBase::addVBoxPage() (for example).
361
The first page, "Debug KGame" shows on the left most or even all status values of
362
KGame. That contains e.g. minPlayers(), isAdmin(), gameStatus(), ...
363
The right side is probably the more important one. It lists *all* KGameProperties
364
which have been inserted to this KGame object (only to this KGame object - not
365
the ones that have been added to the players!). Most of the status variables of
366
the left side are here again as they are implemented as KGameProperty. You can
367
see the name of the property (together with its ID), its value and the policy
368
this property uses. Note that "unknwon" will be displayed as name of the
369
property if you haven't supplied one. See KGamePropertyBase::registerData() for
370
info. You probably always want to supply a name for the property to debug it
371
easily. In the future there will be something like
372
KGamePropertyHandler::setDebug() so that you can switch off debugging and save
373
the memory of the names in a release version.
374
For as long as you use standard types for your properties (int, long, bool,
375
...) you should always be able to see the value of the property. If you just see
376
"unknown" then this type has not been implemented. You can connect to the signal
377
KGamePropertyHandler::signalRequestValue() and supply a QString with the value
378
yourself. If you do so for a standard type please also submit a bug report!
380
Currently the dialog does *not* update automatically! So you alway have to click
381
the "update" button when you want a current value. There are several reasons for
382
this (and one of them is that i'm too lazy to implement the update ;)). E.g.
383
often (very often) a property is just in the background - stores e.g. the
384
available money in a game. But you don't want it to update whenever the value
385
changes (a player receives/pays money) but only when the value on the screen
390
This page consists of three widgets. On the very left there is a list of all
391
players in the game. Only the IDs are displayed to save space. If you click one
392
the other widgets are filled with content. These widgets are quite much the same
393
as the ones in "Debug KGame" - the left shows the value of the functions and the
394
right one displays all KProperties of a player. Not much to say here - except:
397
If you change to another player the value are also updated.
401
This page is probably not as important as the other ones. It displays *every*
402
message that is sent through the KGame object. As a KGameProperry also send
403
messages you probably get a lot of them...
404
You can exclude message IDs from being displayed (e.g. all game properties).
405
You can also change the sorting of the list to see all messages of a certain ID.
406
The default is to sort by time (which is displayed on the left side).