[Kde-games-devel] Review Request 109365: Support for QtQuick in libkdegames
Viranch Mehta
viranch.mehta at gmail.com
Sat Mar 9 08:48:27 UTC 2013
> On March 9, 2013, 8:29 a.m., Viranch Mehta wrote:
> > David Edmundson (Aug. 9, 2012, 10:50 p.m.):
> > If you tried inserting two KgDeclarativeViews in an app, this now breaks heavily.
> >
> > In the context of KBattleship (for example) that would be a perfectly sensible looking thing to do.
> >
> > However, given a QML creatable item needs to have a default constructor, I can see why you've done this.
> >
> > Viranch Mehta (Aug. 11, 2012, 12:54 p.m.):
> > Well I could add a check before to decide whether to call this. This would be assuming, of course, that you want to use a common KGameRenderer for both the KgDeclarativeViews.
> >
> > Is it possible that a single game uses two different KGameRenderers?
> >
> > David Edmundson (Aug. 11, 2012, 1:10 p.m.):
> > Then it's KGameRenderer that needs to be a singleton, not a static pointer in the classes using it.
> >
> > Ian Wadham (Aug. 11, 2012, 11:05 p.m.):
> > Yes. KGoldrunner when ported to QGV will be using two, because each theme has two SVG files: one for the runners and the other for the background and tiles. Also I believe Granatier already has more than two KGameRenderers.
We no more have static members within QML plugins context, KgThemeProvider objects are declared by the game itself and simply supplied to QML, and a ImageProvider is constructed corresponding to each of KgThemeProviders, enabling usage of multiple providers. Example of how we use this:
in mainwindow.cpp:
KgThemeProvider *tileProv = new KgThemeProvider; tileProv->discoverThemes(...);
KgThemeProvider *bgProv = new KgThemeProvider; bgProv->discoverThemes(...);
KgDeclarativeView *m_view = new KgDeclarativeView();
m_view->registerProvider("tileProvider", tileProv); // first argument is id of the object to be set for use in QML
m_view->registerProvider("bgProvider", bgProv);
in main.qml:
KgCore.KgItem {
id: oneTile
provider: tileProvider
spriteKey: "tile1"
}
KgCore.KgItem {
id: theBackground
provider: bgProvider
spriteKey: "backgroundOne"
}
The KgItem gets the sprite pixmap from the KgImageProvider object corresponding to the "provider" property and paints it on the view.
- Viranch
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/109365/#review28823
-----------------------------------------------------------
On March 9, 2013, 8:11 a.m., Viranch Mehta wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/109365/
> -----------------------------------------------------------
>
> (Updated March 9, 2013, 8:11 a.m.)
>
>
> Review request for KDE Games.
>
>
> Description
> -------
>
> This is a copy of review request #7017 in SVN review board because I needed to update the patch (it won't accept git diffs). Updated description:
>
> This patch contains support for QtQuick in libkdegames for future porting QML. Post this patch, libkdeclarative becomes a dependency for libkdegames.
>
> We have some new classes:
>
> 1. KgImageProvider:
> This is a QDeclarativeImageProvider, and a sort-of replacement for KGameRenderer for QML ports. This class is supplied with a KgThemeProvider which it uses to discover SVG locations, reads them using QSvgRenderer and returns the requested sprite pixmap. QDeclarativeImageProvider has inbuilt ability of caching and asynchronous loading of pixmaps, which is why can replace usages of KGameRenderer in QML ports.
>
> 2. KgDeclarativeView:
> This is a QDeclarativeView with KDE-specific import paths for QML components configured and javascript functions bindings added (like i18n() methods) using the KDeclarative library. Game's KgThemeProviders are supplied to this class which in turn registers them with the underlying QML engine, and adds KgImageProviders corresponding to each KgThemeProvider.
>
> 3. KgItem QML component:
> This is simple QML Image element wrapper for showing sprites on QML views using the KgImageProviders. We specify which one of the KgImageProviders we want to use and which sprite key we want to show, and it will be painted on the view.
>
> The patch may not stay up-to-date, relevant code is in "viranch/qtquick" branch in libkdegames's git repo.
>
>
> Diffs
> -----
>
> CMakeLists.txt 67b8b40
> declarativeimports/CMakeLists.txt PRE-CREATION
> declarativeimports/corebindingsplugin.h PRE-CREATION
> declarativeimports/corebindingsplugin.cpp PRE-CREATION
> declarativeimports/qml/KgItem.qml PRE-CREATION
> declarativeimports/qml/qmldir PRE-CREATION
> includes/CMakeLists.txt 8756a50
> includes/KgDeclarativeView PRE-CREATION
> kgdeclarativeview.h PRE-CREATION
> kgdeclarativeview.cpp PRE-CREATION
> kgimageprovider.h PRE-CREATION
> kgimageprovider.cpp PRE-CREATION
> kgthemeprovider.h 6ca9b63
> kgthemeprovider.cpp e186106
>
> Diff: http://git.reviewboard.kde.org/r/109365/diff/
>
>
> Testing
> -------
>
> I'm using KBreakout to test all of this. The relevant port can be found in "qtquick/provider" branch in KBreakout's git repo.
>
>
> Thanks,
>
> Viranch Mehta
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-games-devel/attachments/20130309/1568e876/attachment.html>
More information about the kde-games-devel
mailing list