summaryrefslogtreecommitdiffstats
path: root/pacman-c++
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-04-07 19:35:53 +0200
committermanuel <manuel@mausz.at>2011-04-07 19:35:53 +0200
commitdd99879ab004dd1d81b5942ad35d5ea6c1476c10 (patch)
tree8750906915f33a1dc9a1ad1750d6620abd1bf4e2 /pacman-c++
parent9ef1e89e3ec01a5a34863b1b0aa3483b49404560 (diff)
downloadfoop-dd99879ab004dd1d81b5942ad35d5ea6c1476c10.tar.gz
foop-dd99879ab004dd1d81b5942ad35d5ea6c1476c10.tar.bz2
foop-dd99879ab004dd1d81b5942ad35d5ea6c1476c10.zip
fixing app icon on windows
add audio player
Diffstat (limited to 'pacman-c++')
-rw-r--r--pacman-c++/audioplayer.cpp55
-rw-r--r--pacman-c++/audioplayer.h38
-rw-r--r--pacman-c++/client.cpp2
-rw-r--r--pacman-c++/mainwidget.cpp12
-rw-r--r--pacman-c++/mainwidget.h1
-rw-r--r--pacman-c++/pacman.pro6
-rw-r--r--pacman-c++/pacman.rc2
7 files changed, 104 insertions, 12 deletions
diff --git a/pacman-c++/audioplayer.cpp b/pacman-c++/audioplayer.cpp
new file mode 100644
index 0000000..8620190
--- /dev/null
+++ b/pacman-c++/audioplayer.cpp
@@ -0,0 +1,55 @@
1#include "audioplayer.h"
2#include <phonon/AudioOutput>
3#include <phonon/MediaObject>
4#include <QFile>
5#include <QDebug>
6
7// the universe's only audio player
8AudioPlayer *AudioPlayer::m_instance = 0;
9
10AudioPlayer::AudioPlayer()
11{
12 m_player = new Phonon::MediaObject(this);
13
14 connect(m_player, SIGNAL(finished()), this, SLOT(finished_p()));
15 connect(m_player, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged_p(Phonon::State, Phonon::State)));
16
17 m_output = new Phonon::AudioOutput(Phonon::MusicCategory, this);
18 Phonon::createPath(m_player, m_output);
19}
20
21AudioPlayer *AudioPlayer::self()
22{
23 if (!m_instance)
24 m_instance = new AudioPlayer();
25 return m_instance;
26}
27
28void AudioPlayer::stop()
29{
30 m_player->stop();
31}
32
33void AudioPlayer::setMuted(bool mute)
34{
35 m_output->setMuted(mute);
36}
37
38void AudioPlayer::playIntro()
39{
40 m_player->stop();
41 m_player->setCurrentSource(new QFile(":/sound/intro"));
42 m_player->play();
43}
44
45void AudioPlayer::finished_p()
46{
47 qDebug() << "finished";
48 emit finished();
49}
50
51void AudioPlayer::stateChanged_p(Phonon::State newstate, Phonon::State oldstate)
52{
53 qDebug() << "old=" << oldstate << "new=" << newstate;
54}
55
diff --git a/pacman-c++/audioplayer.h b/pacman-c++/audioplayer.h
new file mode 100644
index 0000000..3dc3cfd
--- /dev/null
+++ b/pacman-c++/audioplayer.h
@@ -0,0 +1,38 @@
1#ifndef AUDIOPLAYER_H
2#define AUDIOPLAYER_H
3
4#include <QObject>
5#include <phonon/phononnamespace.h>
6
7namespace Phonon
8{
9 class MediaObject;
10 class AudioOutput;
11}
12
13class AudioPlayer
14 : public QObject
15{
16 Q_OBJECT
17
18public:
19 AudioPlayer();
20 static AudioPlayer *self();
21 void stop();
22 void setMuted(bool mute = true);
23 void playIntro();
24
25signals:
26 void finished();
27
28private slots:
29 void finished_p();
30 void stateChanged_p(Phonon::State newstate, Phonon::State oldstate);
31
32private:
33 Phonon::MediaObject *m_player;
34 Phonon::AudioOutput *m_output;
35 static AudioPlayer *m_instance;
36};
37
38#endif // AUDIOPLAYER_H
diff --git a/pacman-c++/client.cpp b/pacman-c++/client.cpp
index 47bbc4e..ebbcff2 100644
--- a/pacman-c++/client.cpp
+++ b/pacman-c++/client.cpp
@@ -15,7 +15,7 @@ Client::Client()
15 15
16int main(int argc, char ** argv) { 16int main(int argc, char ** argv) {
17 QApplication app(argc, argv); 17 QApplication app(argc, argv);
18 app.setApplicationName("pacman-client"); 18 app.setApplicationName("Pacman Client");
19 app.setWindowIcon(QIcon(":/appicon")); 19 app.setWindowIcon(QIcon(":/appicon"));
20 20
21 qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); 21 qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp
index 96cf62f..537c5ad 100644
--- a/pacman-c++/mainwidget.cpp
+++ b/pacman-c++/mainwidget.cpp
@@ -4,9 +4,7 @@
4#include "bonuspoint.h" 4#include "bonuspoint.h"
5#include "point.h" 5#include "point.h"
6#include "constants.h" 6#include "constants.h"
7 7#include "audioplayer.h"
8#include <phonon/MediaObject>
9#include <QFile>
10 8
11// temporary 9// temporary
12Transmission::map_t createDummyMap() 10Transmission::map_t createDummyMap()
@@ -94,13 +92,11 @@ MainWidget::MainWidget()
94 createGui(); 92 createGui();
95 updateMap(createDummyMap()); 93 updateMap(createDummyMap());
96 94
97#if 1 95#if 0
98 emit startGame(); 96 emit startGame();
99#else 97#else
100 Phonon::MediaObject *player = Phonon::createPlayer(Phonon::MusicCategory, 98 AudioPlayer::self()->playIntro();
101 Phonon::MediaSource(new QFile(":/sound/intro"))); 99 connect(AudioPlayer::self(), SIGNAL(finished()), this, SLOT(startGame()));
102 connect(player, SIGNAL(finished()), this, SLOT(startGame()));
103 player->play();
104#endif 100#endif
105} 101}
106 102
diff --git a/pacman-c++/mainwidget.h b/pacman-c++/mainwidget.h
index f5703db..8d21649 100644
--- a/pacman-c++/mainwidget.h
+++ b/pacman-c++/mainwidget.h
@@ -5,6 +5,7 @@
5#include "pixmapitem.h" 5#include "pixmapitem.h"
6#include <QtGui> 6#include <QtGui>
7#include <QtCore> 7#include <QtCore>
8#include <phonon/MediaObject>
8 9
9class Actor; 10class Actor;
10 11
diff --git a/pacman-c++/pacman.pro b/pacman-c++/pacman.pro
index 3826852..f95625b 100644
--- a/pacman-c++/pacman.pro
+++ b/pacman-c++/pacman.pro
@@ -6,7 +6,8 @@ SOURCES += pixmapitem.cpp \
6 client.cpp \ 6 client.cpp \
7 bonuspoint.cpp \ 7 bonuspoint.cpp \
8 mainwidget.cpp \ 8 mainwidget.cpp \
9 point.cpp 9 point.cpp \
10 audioplayer.cpp
10HEADERS += pixmapitem.h \ 11HEADERS += pixmapitem.h \
11 actor.h \ 12 actor.h \
12 animationmanager.h \ 13 animationmanager.h \
@@ -15,7 +16,8 @@ HEADERS += pixmapitem.h \
15 bonuspoint.h \ 16 bonuspoint.h \
16 mainwidget.h \ 17 mainwidget.h \
17 constants.h \ 18 constants.h \
18 point.h 19 point.h \
20 audioplayer.h
19RESOURCES += pacman.qrc 21RESOURCES += pacman.qrc
20 22
21OBJECTS_DIR = .obj 23OBJECTS_DIR = .obj
diff --git a/pacman-c++/pacman.rc b/pacman-c++/pacman.rc
index 808718b..8c9f03b 100644
--- a/pacman-c++/pacman.rc
+++ b/pacman-c++/pacman.rc
@@ -1 +1 @@
IDI_ICON1 ICON DISCARDABLE "pics/pacman.ico" IDI_ICON1 ICON DISCARDABLE "pics/app.ico"