Theme can be changed qmlfrontend
authorunc0rr
Mon, 03 Nov 2014 23:56:51 +0300
branchqmlfrontend
changeset 10456 6fd99bb73524
parent 10454 2b590e7972b1
child 10458 f7a199346c3e
Theme can be changed
hedgewars/hwLibrary.pas
hedgewars/uFLGameConfig.pas
qmlFrontend/flib.h
qmlFrontend/hwengine.cpp
qmlFrontend/hwengine.h
qmlFrontend/qml/qmlFrontend/GameConfig.qml
--- a/hedgewars/hwLibrary.pas	Mon Nov 03 23:36:53 2014 +0300
+++ b/hedgewars/hwLibrary.pas	Mon Nov 03 23:56:51 2014 +0300
@@ -154,6 +154,7 @@
     resetGameConfig,
     setSeed,
     getSeed,
+    setTheme,
     getThemesList,
     freeThemesList,
     getThemeIcon,
@@ -161,6 +162,7 @@
     tryAddTeam,
     tryRemoveTeam,
     changeTeamColor,
+    
     // dunno what these are
     RunEngine,
     LoadLocaleWrapper,
--- a/hedgewars/uFLGameConfig.pas	Mon Nov 03 23:36:53 2014 +0300
+++ b/hedgewars/uFLGameConfig.pas	Mon Nov 03 23:56:51 2014 +0300
@@ -11,6 +11,7 @@
 
 procedure setSeed(seed: PChar); cdecl;
 function  getSeed: PChar; cdecl;
+procedure setTheme(themeName: PChar); cdecl;
 
 procedure tryAddTeam(teamName: PChar); cdecl;
 procedure tryRemoveTeam(teamName: PChar); cdecl;
@@ -57,6 +58,7 @@
     gtLocal: begin
             ipcToEngine('eseed ' + seed);
             ipcToEngine('e$mapgen ' + intToStr(mapgen));
+            ipcToEngine('e$theme ' + theme);
             i:= 0;
             while (i < 8) and (teams[i].hogsNumber > 0) do
                 begin
@@ -302,4 +304,9 @@
     end
 end;
 
+procedure setTheme(themeName: PChar); cdecl;
+begin
+    currentConfig.theme:= themeName
+end;
+
 end.
--- a/qmlFrontend/flib.h	Mon Nov 03 23:36:53 2014 +0300
+++ b/qmlFrontend/flib.h	Mon Nov 03 23:56:51 2014 +0300
@@ -35,6 +35,7 @@
 typedef void resetGameConfig_t();
 typedef void setSeed_t(const char * seed);
 typedef char *getSeed_t();
+typedef void setTheme_t(const char * theme);
 typedef void flibInit_t(const char * localPrefix, const char * userPrefix);
 typedef void flibFree_t();
 
--- a/qmlFrontend/hwengine.cpp	Mon Nov 03 23:36:53 2014 +0300
+++ b/qmlFrontend/hwengine.cpp	Mon Nov 03 23:56:51 2014 +0300
@@ -13,6 +13,7 @@
     registerGUIMessagesCallback_t *flibRegisterGUIMessagesCallback;
     setSeed_t *flibSetSeed;
     getSeed_t *flibGetSeed;
+    setTheme_t *flibSetTheme;
     getPreview_t *flibGetPreview;
     runQuickGame_t *flibRunQuickGame;
     runLocalGame_t *flibRunLocalGame;
@@ -45,6 +46,7 @@
     flibRegisterGUIMessagesCallback = (registerGUIMessagesCallback_t*) hwlib.resolve("registerGUIMessagesCallback");
     flibSetSeed = (setSeed_t*) hwlib.resolve("setSeed");
     flibGetSeed = (getSeed_t*) hwlib.resolve("getSeed");
+    flibSetTheme = (setTheme_t*) hwlib.resolve("setTheme");
     flibGetPreview = (getPreview_t*) hwlib.resolve("getPreview");
     flibRunQuickGame = (runQuickGame_t*) hwlib.resolve("runQuickGame");
     flibRunLocalGame = (runLocalGame_t*) hwlib.resolve("runLocalGame");
@@ -202,3 +204,8 @@
 {
     flibChangeTeamColor(teamName.toUtf8().constData(), dir);
 }
+
+void HWEngine::setTheme(const QString &theme)
+{
+    flibSetTheme(theme.toUtf8().constData());
+}
--- a/qmlFrontend/hwengine.h	Mon Nov 03 23:36:53 2014 +0300
+++ b/qmlFrontend/hwengine.h	Mon Nov 03 23:56:51 2014 +0300
@@ -24,6 +24,7 @@
     Q_INVOKABLE QString currentSeed();
     Q_INVOKABLE void getTeamsList();
     Q_INVOKABLE void resetGameConfig();
+    Q_INVOKABLE void setTheme(const QString & theme);
 
     Q_INVOKABLE void tryAddTeam(const QString & teamName);
     Q_INVOKABLE void tryRemoveTeam(const QString & teamName);
--- a/qmlFrontend/qml/qmlFrontend/GameConfig.qml	Mon Nov 03 23:36:53 2014 +0300
+++ b/qmlFrontend/qml/qmlFrontend/GameConfig.qml	Mon Nov 03 23:56:51 2014 +0300
@@ -76,6 +76,7 @@
                      onClicked: {
                          themeImage.source = "image://theme/" + themeName.text
                          themesList.currentIndex = index
+                         HWEngine.setTheme(themeName.text)
                      }
                 }
             }