Commit d5cd7d3a authored by Stefan Majewsky's avatar Stefan Majewsky

Allow split build for all games except libkmahjongg dependencies.

Most of this is straightforward. Some more complicated changes are in
1. libkdegames: I needed to fix the headers <KgAudioScene> and
   <KgSound>, which did not refer to the right include location when
   installed.
2. kgoldrunner: Its CMake code may not depend on OpenAL and libsndfile
   anymore. KGoldRunner therefore now uses the new
   <libkdegames_capabilities.h> header and enables sound only if
   KGAUDIO_BACKEND_OPENAL is set.

KMahjongg and KShisen are not done yet. I could not create a
config-script for KMahjongg because CMake currently gets confused over
exported targets in multiple source directories. (D'oh...)

svn path=/trunk/KDE/kdegames/kgoldrunner/; revision=1294007
parent 24e0c123
project(kgoldrunner)
if(NOT COMPILING_KDEGAMES)
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
include(MacroLibrary)
find_package(KDEGames REQUIRED)
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
include_directories(${QDBUS_INCLUDE_DIRS} ${KDE4_INCLUDES} ${KDEGAMES_INCLUDE_DIRS})
endif(NOT COMPILING_KDEGAMES)
add_subdirectory( src )
add_subdirectory( gamedata )
add_subdirectory( themes )
......
########### next target ###############
if (OPENAL_FOUND AND SNDFILE_FOUND AND SNDFILE_WORKS)
# Compile and link KgSound and KGrSounds. Can load and play .ogg with OpenAL.
ADD_DEFINITIONS(-DOPENAL_AND_OGG_SOUNDS)
endif (OPENAL_FOUND AND SNDFILE_FOUND AND SNDFILE_WORKS)
set(kgoldrunner_SRCS
kgrplayfield.cpp
kgrsprite.cpp
......
......@@ -50,6 +50,8 @@
#include <KCmdLineArgs>
#include <KAboutData>
#include <libkdegames_capabilities.h> //defines KGAUDIO_BACKEND_OPENAL (or not)
#include "kgrcanvas.h"
#include "kgrgame.h"
......@@ -378,7 +380,7 @@ void KGoldrunner::setupActions()
(this, SLOT (viewFullScreen(bool)), this, this);
actionCollection()->addAction (fullScreen->objectName(), fullScreen);
#ifdef OPENAL_AND_OGG_SOUNDS
#ifdef KGAUDIO_BACKEND_OPENAL
// Sound effects on/off
settingAction ("options_sounds", PLAY_SOUNDS,
i18n ("&Play Sounds"),
......
......@@ -26,7 +26,8 @@
// KGoldrunner loads and plays .ogg files and requires OpenAL + SndFile > v0.21.
// Fallback to Phonon by the KgSound library does not give good results.
#ifdef OPENAL_AND_OGG_SOUNDS
#include <libkdegames_capabilities.h>
#ifdef KGAUDIO_BACKEND_OPENAL
#include "kgrsounds.h"
#endif
......@@ -416,7 +417,7 @@ void KGrGame::setInitialTheme (const QString & themeFilepath)
void KGrGame::initGame()
{
#ifndef OPENAL_AND_OGG_SOUNDS
#ifndef KGAUDIO_BACKEND_OPENAL
KGrMessage::information (view, i18n ("No Sound"),
i18n ("Warning: This copy of KGoldrunner has no sound.\n"
"\n"
......@@ -468,7 +469,7 @@ void KGrGame::initGame()
"champion_speed"), true);
timeScale = gameGroup.readEntry ("ActualSpeed", 10);
#ifdef OPENAL_AND_OGG_SOUNDS
#ifdef KGAUDIO_BACKEND_OPENAL
// Set up sounds, if required in config.
soundOn = gameGroup.readEntry ("Sound", false);
kDebug() << "Sound" << soundOn;
......@@ -899,7 +900,7 @@ void KGrGame::incScore (const int n)
void KGrGame::playSound (const int n, const bool onOff)
{
#ifdef OPENAL_AND_OGG_SOUNDS
#ifdef KGAUDIO_BACKEND_OPENAL
if (! effects) {
return; // Sound is off and not yet loaded.
}
......@@ -925,7 +926,7 @@ void KGrGame::endLevel (const int result)
{
dbk << "Return to KGrGame, result:" << result;
#ifdef OPENAL_AND_OGG_SOUNDS
#ifdef KGAUDIO_BACKEND_OPENAL
if (effects) { // If sounds have been loaded, cut off
effects->stopAllSounds(); // all sounds that are in progress.
}
......@@ -1159,7 +1160,7 @@ void KGrGame::toggleSoundsOnOff (const int action)
stepsOn = soundOnOff;
}
#ifdef OPENAL_AND_OGG_SOUNDS
#ifdef KGAUDIO_BACKEND_OPENAL
if (action == PLAY_SOUNDS) {
if (soundOn && (effects == 0)) {
loadSounds(); // Sounds were not loaded when the game started.
......@@ -1175,7 +1176,7 @@ void KGrGame::freeze (const bool userAction, const bool on_off)
kDebug() << "PAUSE:" << type << on_off;
kDebug() << "gameFrozen" << gameFrozen << "programFreeze" << programFreeze;
#ifdef OPENAL_AND_OGG_SOUNDS
#ifdef KGAUDIO_BACKEND_OPENAL
if (on_off && effects) { // If pausing and sounds are loaded, cut
effects->stopAllSounds(); // off all sounds that are in progress.
}
......@@ -2165,7 +2166,7 @@ bool KGrGame::loadRecording (const QString & dir, const QString & prefix,
void KGrGame::loadSounds()
{
#ifdef OPENAL_AND_OGG_SOUNDS
#ifdef KGAUDIO_BACKEND_OPENAL
const qreal volumes [NumSounds] = {0.6, 0.3, 0.3, 0.6, 0.6, 1.8, 1.0, 1.0, 1.0, 1.0};
effects = new KGrSounds();
effects->setParent (this); // Delete at end of KGrGame.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment