|
From: Tapio V. <aa...@us...> - 2010-10-19 18:16:48
|
Module: performous
Branch: master
Commit: 9a4963b4addf3fbb91b6114daa168182da8e52a4
Author: Tapio Vierros <tap...@gm...>
Date: Tue Oct 19 21:15:06 2010 +0300
Added a dummy screen_paths.
---
game/main.cc | 2 +
game/screen_intro.cc | 4 +--
game/screen_paths.cc | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++
game/screen_paths.hh | 26 +++++++++++++++++
4 files changed, 104 insertions(+), 3 deletions(-)
diff --git a/game/main.cc b/game/main.cc
index f542705..a694de5 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -17,6 +17,7 @@
#include "screen_sing.hh"
#include "screen_practice.hh"
#include "screen_audiodevices.hh"
+#include "screen_paths.hh"
#include "screen_players.hh"
#include <boost/format.hpp>
@@ -151,6 +152,7 @@ void mainLoop(std::string const& songlist) {
sm.addScreen(new ScreenSing("Sing", audio, database, backgrounds));
sm.addScreen(new ScreenPractice("Practice", audio));
sm.addScreen(new ScreenAudioDevices("AudioDevices", audio));
+ sm.addScreen(new ScreenPaths("Paths", audio));
sm.addScreen(new ScreenPlayers("Players", audio, database));
sm.activateScreen("Intro");
sm.loading(_("Entering main menu"), 0.8);
diff --git a/game/screen_intro.cc b/game/screen_intro.cc
index bbf919c..1da49db 100644
--- a/game/screen_intro.cc
+++ b/game/screen_intro.cc
@@ -135,7 +135,6 @@ void ScreenIntro::populateMenu() {
MenuOptions audiomenu;
MenuOptions gfxmenu;
MenuOptions gamemenu;
- MenuOptions pathsmenu; // FIXME: Dummy (just to get a gray option to the menu)
// Populate the submenus
for (Config::iterator it = config.begin(); it != config.end(); ++it) {
// Skip items that are configured elsewhere
@@ -153,8 +152,7 @@ void ScreenIntro::populateMenu() {
configmain.push_back(MenuOption(_("Audio"), _("Configure general audio settings"), audiomenu, "intro_configure.svg"));
configmain.push_back(MenuOption(_("Graphics"), _("Configure rendering and video settings"), gfxmenu, "intro_configure.svg"));
configmain.push_back(MenuOption(_("Game"), _("Gameplay related options"), gamemenu, "intro_configure.svg"));
- // FIXME: 'Paths' should open a screen
- configmain.push_back(MenuOption(_("Paths"), _("Setup song and data paths"), pathsmenu, "intro_configure.svg"));
+ configmain.push_back(MenuOption(_("Paths"), _("Setup song and data paths"), "Paths", "intro_configure.svg"));
configmain.back().image.reset(new Surface(getThemePath("intro_quit.svg")));
// Add to root menu
m_menu.add(MenuOption(_("Configure"), _("Configure audio and game options"), configmain, "intro_configure.svg"));
diff --git a/game/screen_paths.cc b/game/screen_paths.cc
new file mode 100644
index 0000000..9169e44
--- /dev/null
+++ b/game/screen_paths.cc
@@ -0,0 +1,75 @@
+#include "screen_paths.hh"
+
+#include "configuration.hh"
+#include "joystick.hh"
+#include "theme.hh"
+#include "audio.hh"
+#include "i18n.hh"
+#include <boost/thread.hpp>
+#include <boost/bind.hpp>
+
+namespace {
+ const float yoff = 0.18; // Offset from center where to place top row
+ const float xoff = 0.45; // Offset from middle where to place first column
+}
+
+ScreenPaths::ScreenPaths(std::string const& name, Audio& audio): Screen(name), m_audio(audio) {}
+
+void ScreenPaths::enter() {
+ m_theme.reset(new ThemeAudioDevices());
+ m_txtinp.text.clear();
+
+ // FIXME: Temp error message
+ ScreenManager::getSingletonPtr()->dialog(
+ _("This tool is not yet available.\n"
+ "Configure paths by adding them\n"
+ "as command line parameters and\n"
+ "then save them in configuration menu."));
+}
+
+void ScreenPaths::exit() { m_theme.reset(); }
+
+void ScreenPaths::manageEvent(SDL_Event event) {
+ ScreenManager* sm = ScreenManager::getSingletonPtr();
+ input::NavButton nav(input::getNav(event));
+ if (nav != input::NONE) {
+ if (nav == input::CANCEL || nav == input::SELECT) {
+ if (m_txtinp.text.empty()) sm->activateScreen("Intro");
+ else m_txtinp.text.clear();
+ }
+ else if (nav == input::PAUSE) m_audio.togglePause();
+ else if (nav == input::START) {
+ // TODO: Save config
+ sm->activateScreen("Intro");
+ }
+ } else if (event.type == SDL_KEYDOWN) {
+ return; // FIXME: Remove
+ SDLKey key = event.key.keysym.sym;
+ SDLMod modifier = event.key.keysym.mod;
+ if (m_txtinp.process(event.key.keysym)) /* Nop */ ;
+ // Reset to defaults
+ else if (key == SDLK_r && modifier & KMOD_CTRL) {
+ config["paths/songs"].reset(modifier & KMOD_ALT);
+ config["paths/system"].reset(modifier & KMOD_ALT);
+ // TODO: Save
+ }
+ }
+}
+
+void ScreenPaths::draw() {
+ if (!ScreenManager::getSingletonPtr()->isDialogOpen())
+ ScreenManager::getSingletonPtr()->activateScreen("Intro"); // FIXME: Remove
+
+ m_theme->bg.draw();
+
+ // Key help
+ m_theme->comment_bg.dimensions.stretch(1.0, 0.025).middle().screenBottom(-0.054);
+ m_theme->comment_bg.draw();
+ m_theme->comment.dimensions.left(-0.48).screenBottom(-0.067);
+ m_theme->comment.draw(_("Press any key to exit."));
+ // Additional info
+ m_theme->comment_bg.dimensions.middle().screenBottom(-0.01);
+ m_theme->comment_bg.draw();
+ m_theme->comment.dimensions.left(-0.48).screenBottom(-0.023);
+ m_theme->comment.draw(_("Windows users can also use ConfigureSongDirectory.bat in the bin-directory."));
+}
diff --git a/game/screen_paths.hh b/game/screen_paths.hh
new file mode 100644
index 0000000..3b739b6
--- /dev/null
+++ b/game/screen_paths.hh
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <map>
+#include <boost/scoped_ptr.hpp>
+#include "screen.hh"
+#include "textinput.hh"
+
+class Audio;
+class ThemeAudioDevices;
+
+/// options dialogue
+class ScreenPaths: public Screen {
+ public:
+ /// constructor
+ ScreenPaths(std::string const& name, Audio& m_audio);
+ void enter();
+ void exit();
+ void manageEvent(SDL_Event event);
+ void draw();
+
+ private:
+ Audio& m_audio;
+ boost::scoped_ptr<ThemeAudioDevices> m_theme;
+ TextInput m_txtinp;
+};
+
|