[Kde-games-devel] Tileset format for KMahjongg
Henrique Pinto
henrique.pinto at kdemail.net
Fri Nov 17 21:15:51 CET 2006
On Fri 17 Nov 2006 16:03, Mauricio Piacentini wrote:
> Henrique Pinto wrote:
> > Have you thought of using .desktop files instead of XML? KDE has
>
> already a
>
> > large infrastructure for i18n of .desktop files.
>
> Hi, Henrique! Not really, I thought that .desktop files were for icons
> and menus only. How could we adapt or use them (or the same
> infrastructure) for game levels and artwork? Maybe this is a nice
> solution indeed, I am just ignorant on how they work exactly... Is there
> some description somewhere of the infrastructure in place for handling
> them?
For a nice example of how they can be used, you can check the Background
kcontrol module
($KDESVN/trunk/KDE/kdebase/workspace/kcontrol/background/bgdialog.cpp,
method BGDialog::loadWallpaperFilesList()).
A desktop file for a theme could look like:
[KDEGamesTileset]
Name=My Crazy Made-Up Weirdo Theme
Name[pt_BR]=Meu Tema Maluco
Author=John Doe
FileName=default_tileset.svgz
TileWidth=96
TileHeight=116
TileFaceWidth=69
TileFaceHeight=89
LevelOffset=12
The translated "Name" entries would be added automatically by scripty, so
you won't have to worry about them.
For reading the desktop files in the code, you can use KSimpleConfig:
KSimpleConfig themeFile(themeFileName);
themeFile.setGroup("KDEGamesTileset");
QString themeName = themeFile.readEntry("Name"); // Returns translated data
int themeTileWidth = themeFile.readNumEntry("TileWidth");
> I think this abstraction of level/artwork data is a real need now, since
> we are going to offer themability with SVG skins. It should be possible
> to localize the theme somehow, and the only way I can see it working
> nicely is with an intermediary description, some sort of XML or similar
> file that is read by the game, and includes localized information. This
> approach is also better imo compared with direct loading all information
> from the SVG or level file, as parsing multiple SVGs is going to be much
> slower and use much more memory (think of perhaps trying to extract
> information about 10 tilesets to assemble a dialog box.)
I was thinking of coding a theme selection dialog for KSame this weekend.
Perhaps I should try to make it generic and add it to libkdegames?
I thought of a simple list, contaning, for each theme, the theme name,
author, and a preview image. I intended to generate the preview image from
the SVG, asynchronously, but, if the dialog is to be made generic, I
believe it might be easier to have a pre-rendered PNG as the preview.
What do you think?
--
Henrique Pinto
henrique.pinto at kdemail.net
More information about the kde-games-devel
mailing list