Skip to content
Browse files

Backward compatibility with LibKDEGames 4.8.x or older

  • Loading branch information...
1 parent a4e2014 commit 291ea78e0f072a4f1f23093a2be62c6b1e2a00e9 @Ignotus committed Aug 24, 2012
Showing with 70 additions and 12 deletions.
  1. +9 −2 CMakeLists.txt
  2. +1 −1 graph.cpp
  3. +7 −3 include/mainwindow.hpp
  4. +34 −5 mainwindow.cpp
  5. +7 −1 plugins/ipconnect/rival.cpp
  6. +6 −0 plugins/simpleai/rival.cpp
  7. +6 −0 plugins/singlepc/plugin.hpp
View
11 CMakeLists.txt
@@ -3,7 +3,13 @@ PROJECT (kdots)
FIND_PACKAGE (Qt4 REQUIRED)
FIND_PACKAGE (KDE4 REQUIRED)
-FIND_PACKAGE (KDEGames 4.9 REQUIRED)
+
+FIND_PACKAGE (LibKDEGames)
+
+IF (NOT KDEGAMES_FOUND)
+ FIND_PACKAGE (KDEGames REQUIRED)
+ ADD_DEFINITIONS (-DKDEGAMES_4_9)
+ENDIF (NOT KDEGAMES_FOUND)
INCLUDE (KDE4Defaults)
@@ -19,6 +25,7 @@ SET (QT_USE_QTCORE TRUE)
INCLUDE (${QT_USE_FILE})
+MESSAGE( STATUS "${KDEGAMES_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES (
${CMAKE_CURRENT_SOURCE_DIR}
@@ -151,4 +158,4 @@ ADD_CUSTOM_TARGET (uninstall
ADD_SUBDIRECTORY (plugins)
#INCLUDE (MacroOptionalAddSubdirectory)
-#MACRO_OPTIONAL_ADD_SUBDIRECTORY (po)
+#MACRO_OPTIONAL_ADD_SUBDIRECTORY (po)
View
2 graph.cpp
@@ -65,4 +65,4 @@ namespace KDots
m_graph[first.x ()][first.y ()].edges ().removeEdge (second);
m_graph[second.x ()][second.y ()].edges ().removeEdge (first);
}
-}
+}
View
10 include/mainwindow.hpp
@@ -27,7 +27,7 @@
#define KDOTS_MAINWINDOW_HPP
#include <memory>
#include <KXmlGuiWindow>
-#include <KgDifficulty>
+#include <KGameDifficulty>
#include "constants.hpp"
namespace Ui
@@ -53,8 +53,9 @@ namespace KDots
std::shared_ptr<IRival> m_rival;
bool m_destroyTable;
TableWidget *m_table;
+#ifdef KDEGAMES_4_9
KgDifficulty *m_difficulty;
-
+#endif
void initMenu ();
private slots:
@@ -63,8 +64,11 @@ namespace KDots
void onPreferences ();
void undo ();
void endGame ();
+#ifdef KDEGAMES_4_9
void difficultyHandler (const KgDifficultyLevel *level);
-
+#else
+ void difficultyHandler (KGameDifficulty::standardLevel level);
+#endif
signals:
void undoActionEnable (bool);
void endActionEnable (bool);
View
39 mainwindow.cpp
@@ -48,10 +48,13 @@ namespace KDots
, m_ui (new Ui::MainWindow)
, m_destroyTable (false)
, m_table (NULL)
+#ifdef KDEGAMES_4_9
, m_difficulty (new KgDifficulty (this))
+#endif
{
m_ui->setupUi (this);
-
+
+#ifdef KDEGAMES_4_9
m_difficulty->addStandardLevel (KgDifficultyLevel::Easy);
m_difficulty->addStandardLevel (KgDifficultyLevel::Medium);
m_difficulty->addStandardLevel (KgDifficultyLevel::Hard);
@@ -62,7 +65,14 @@ namespace KDots
SLOT (difficultyHandler (const KgDifficultyLevel*)));
KgDifficultyGUI::init (this, m_difficulty);
-
+#else
+ KGameDifficulty::init (this, this, SLOT (difficultyHandler (KGameDifficulty::standardLevel)));
+ KGameDifficulty::addStandardLevel (KGameDifficulty::Easy);
+ KGameDifficulty::addStandardLevel (KGameDifficulty::Medium);
+ KGameDifficulty::addStandardLevel (KGameDifficulty::Hard);
+
+ KGameDifficulty::setEnabled (false);
+#endif
statusBar ()->show ();
setCentralWidget (new QWidget (this));
initMenu ();
@@ -74,9 +84,15 @@ namespace KDots
m_rival.reset ();
}
+#ifdef KDEGAMES_4_9
void MainWindow::difficultyHandler (const KgDifficultyLevel *level)
+#else
+ void MainWindow::difficultyHandler (KGameDifficulty::standardLevel level)
+#endif
{
int diff;
+
+#ifdef KDEGAMES_4_9
switch (level->standardLevel ())
{
case KgDifficultyLevel::Easy:
@@ -86,6 +102,17 @@ namespace KDots
default:
diff = 3;
}
+#else
+ switch (level)
+ {
+ case KGameDifficulty::Easy:
+ diff = 1;
+ case KGameDifficulty::Medium:
+ diff = 2;
+ default:
+ diff = 3;
+ }
+#endif
if (m_rival)
m_rival->setDifficulty (diff);
@@ -177,9 +204,11 @@ namespace KDots
m_rival = dialog.rival ();
m_rival->setStatusBar (statusBar ());
-
+#ifdef KDEGAMES_4_9
difficultyHandler (m_difficulty->currentLevel ());
-
+#else
+ difficultyHandler (KGameDifficulty::level ());
+#endif
emit undoActionEnable (m_rival->canUndo ());
connect (m_rival.get (),
@@ -222,4 +251,4 @@ namespace KDots
}
}
-#include "include/mainwindow.moc"
+#include "include/mainwindow.moc"
View
8 plugins/ipconnect/rival.cpp
@@ -26,6 +26,9 @@
#include "rival.hpp"
#include <QMessageBox>
#include <KLocalizedString>
+#ifndef KDEGAMES_4_9
+# include <KGameDifficulty>
+#endif
#include <include/stepqueue.hpp>
#include "connectdialog.hpp"
@@ -39,6 +42,9 @@ namespace KDots
, m_server (NULL)
, m_me (NONE)
{
+#ifndef KDEGAMES_4_9
+ KGameDifficulty::setEnabled (false);
+#endif
}
Rival::~Rival ()
@@ -227,4 +233,4 @@ namespace KDots
}
}
-#include "rival.moc"
+#include "rival.moc"
View
6 plugins/simpleai/rival.cpp
@@ -28,6 +28,9 @@
#include <algorithm>
#include <QStatusBar>
#include <QLabel>
+#ifndef KDEGAMES_4_9
+# include <KGameDifficulty>
+#endif
#include <include/point.hpp>
#include <include/dottable.hpp>
#include <include/stepqueue.hpp>
@@ -47,6 +50,9 @@ namespace KDots
, m_statusBar (NULL)
{
PriorityMap::instance ();
+#ifndef KDEGAMES_4_9
+ KGameDifficulty::setEnabled (true);
+#endif
}
void Rival::setDifficulty (int diff)
View
6 plugins/singlepc/plugin.hpp
@@ -25,6 +25,9 @@
*/
#ifndef KDOTS_PLUGINS_SINGLEPC_PLUGIN_HPP
#define KDOTS_PLUGINS_SINGLEPC_PLUGIN_HPP
+#ifndef KDEGAMES_4_9
+# include <KGameDifficulty>
+#endif
#include <interface/iplugin.hpp>
#include <interface/irival.hpp>
@@ -40,6 +43,9 @@ namespace KDots
Rival (QObject *parent = 0)
: IRival (parent)
{
+#ifndef KDEGAMES_4_9
+ KGameDifficulty::setEnabled (false);
+#endif
}
bool isAllow () const

0 comments on commit 291ea78

Please sign in to comment.
Something went wrong with that request. Please try again.