|
From: Tapio V. <aa...@us...> - 2009-11-08 08:30:37
|
Module: performous
Branch: dance
Commit: e10f75822df68bb103fc0d4d4e58f4f18b86c9dc
Author: Tapio Vierros <tap...@gm...>
Date: Thu Oct 29 23:51:18 2009 +0200
Integrated backgrounds class to the game.
---
game/main.cc | 4 +++-
game/screen_sing.cc | 14 +++++++++++++-
game/screen_sing.hh | 6 ++++--
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/game/main.cc b/game/main.cc
index 92aae16..d593777 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -4,6 +4,7 @@
#include "screen.hh"
#include "joystick.hh"
#include "songs.hh"
+#include "backgrounds.hh"
#include "xtime.hh"
#include "video_driver.hh"
@@ -139,13 +140,14 @@ void mainLoop() {
Capture capture;
Audio audio;
audioSetup(capture, audio);
+ Backgrounds backgrounds;
Songs songs(songlist);
Players players(getHomeDir() / ".config" / "performous" / "players.xml");
ScreenManager sm;
Window window(config["graphic/window_width"].i(), config["graphic/window_height"].i(), config["graphic/fullscreen"].b());
sm.addScreen(new ScreenIntro("Intro", audio, capture));
sm.addScreen(new ScreenSongs("Songs", audio, songs));
- sm.addScreen(new ScreenSing("Sing", audio, capture, players));
+ sm.addScreen(new ScreenSing("Sing", audio, capture, players, backgrounds));
sm.addScreen(new ScreenPractice("Practice", audio, capture));
sm.addScreen(new ScreenConfiguration("Configuration", audio));
sm.addScreen(new ScreenPlayers("Players", audio, players));
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 0e682f0..94061c5 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -19,14 +19,26 @@ namespace {
void ScreenSing::enter() {
theme.reset(new ThemeSing());
+ bool foundbg = false;
if (!m_song->background.empty()) {
try {
m_background.reset(new Surface(m_song->path + m_song->background, true));
+ foundbg = true;
} catch (std::exception& e) {
std::cerr << e.what() << std::endl;
}
}
- if (!m_song->video.empty() && config["graphic/video"].b()) m_video.reset(new Video(m_song->path + m_song->video, m_song->videoGap));
+ if (!m_song->video.empty() && config["graphic/video"].b()) {
+ m_video.reset(new Video(m_song->path + m_song->video, m_song->videoGap));
+ foundbg = true;
+ }
+ if (foundbg == false) {
+ try {
+ m_background.reset(new Surface(m_backgrounds.getRandom(), true));
+ } catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ }
m_pause_icon.reset(new Surface(getThemePath("sing_pause.svg")));
m_help.reset(new Surface(getThemePath("instrumenthelp.svg")));
m_progress.reset(new ProgressBar(getThemePath("sing_progressbg.svg"), getThemePath("sing_progressfg.svg"), ProgressBar::HORIZONTAL, 0.01f, 0.01f, true));
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index a14a7b8..98d3fb5 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -8,6 +8,7 @@
#include "engine.hh"
#include "guitargraph.hh"
#include "screen.hh"
+#include "backgrounds.hh"
#include "theme.hh"
#include "video.hh"
#include "surface.hh"
@@ -42,8 +43,8 @@ class ScoreWindow {
class ScreenSing: public Screen {
public:
/// constructor
- ScreenSing(std::string const& name, Audio& audio, Capture& capture, Players & players):
- Screen(name), m_audio(audio), m_capture(capture), m_players(players), m_latencyAV()
+ ScreenSing(std::string const& name, Audio& audio, Capture& capture, Players& players, Backgrounds& bgs):
+ Screen(name), m_audio(audio), m_capture(capture), m_players(players), m_backgrounds(bgs), m_latencyAV()
{}
void enter();
void exit();
@@ -67,6 +68,7 @@ class ScreenSing: public Screen {
Audio& m_audio;
Capture& m_capture;
Players& m_players;
+ Backgrounds& m_backgrounds;
boost::shared_ptr<Song> m_song; /// Pointer to the current song
boost::scoped_ptr<ScoreWindow> m_score_window;
boost::scoped_ptr<ProgressBar> m_progress;
|