Permalink
Browse files

Turned the welcome window into a help window.

I made it available to every game mode when pushing F1 key.
Also, I made the text displayed be dependent of the current
game mode, making it possible to have in-game help!

On the low side of things:
- I didn't finish all the texts for now, so certain game modes
still have a generic one.
- The text isn't scriptable and the positions are hard-coded.
(I guess it'll stay like that for a while.)
- That changes showed up that the editor is heavily depending
on the VideoManager because of simply using a StillImage
in the Tileset Editor. Something I'll need to take care of.

Hence, I'll polish all that in other commits.
  • Loading branch information...
Yohann Ferreira
Yohann Ferreira committed Aug 21, 2012
1 parent 8591c41 commit 72c2ad26389b9ebf8e542fd83538c9bf4608dca2
View
@@ -447,8 +447,6 @@
<Unit filename="src\modes\boot\boot.h" />
<Unit filename="src\modes\boot\boot_menu.cpp" />
<Unit filename="src\modes\boot\boot_menu.h" />
- <Unit filename="src\modes\boot\boot_welcome.cpp" />
- <Unit filename="src\modes\boot\boot_welcome.h" />
<Unit filename="src\modes\map\map.cpp" />
<Unit filename="src\modes\map\map.h" />
<Unit filename="src\modes\map\map_dialogue.cpp" />
@@ -472,6 +470,8 @@
<Unit filename="src\modes\menu\menu_views.cpp" />
<Unit filename="src\modes\menu\menu_views.h" />
<Unit filename="src\modes\mode_bindings.cpp" />
+ <Unit filename="src\modes\mode_help_window.cpp" />
+ <Unit filename="src\modes\mode_help_window.h" />
<Unit filename="src\modes\pause.cpp" />
<Unit filename="src\modes\pause.h" />
<Unit filename="src\modes\save\save_mode.cpp" />
View
@@ -11,7 +11,7 @@ settings.key_defaults.cancel = 100
settings.key_defaults.down = 274
settings.key_defaults.pause = 32
settings.key_defaults.left_select = 119
-settings.welcome = 1
+settings.first_start = 1
settings.joystick_settings = {}
settings.joystick_settings.input_disabled = false
settings.joystick_settings.swap = 3
View
@@ -273,12 +273,6 @@ luabind/luabind/wrapper_base.hpp
# Files used by both the game and the editor
SET(SRCS_COMMON
-engine/effect_supervisor.h
-engine/effect_supervisor.cpp
-engine/mode_manager.h
-engine/mode_manager.cpp
-engine/script_supervisor.h
-engine/script_supervisor.cpp
engine/system.cpp
engine/system.h
engine/video/video.h
@@ -305,16 +299,6 @@ engine/video/particle_effect.h
engine/video/particle_effect.cpp
engine/video/particle_system.h
engine/video/particle_system.cpp
-engine/audio/audio.h
-engine/audio/audio.cpp
-engine/audio/audio_descriptor.h
-engine/audio/audio_descriptor.cpp
-engine/audio/audio_input.cpp
-engine/audio/audio_stream.h
-engine/audio/audio_stream.cpp
-engine/audio/audio_input.h
-engine/audio/audio_effects.h
-engine/audio/audio_effects.cpp
engine/script/script.h
engine/script/script.cpp
engine/script/script_read.h
@@ -354,6 +338,22 @@ common/gui/gui.cpp
common/dialogue.h
common/common.h
common/common_bindings.cpp
+engine/audio/audio.h
+engine/audio/audio.cpp
+engine/audio/audio_descriptor.h
+engine/audio/audio_descriptor.cpp
+engine/audio/audio_input.cpp
+engine/audio/audio_stream.h
+engine/audio/audio_stream.cpp
+engine/audio/audio_input.h
+engine/audio/audio_effects.h
+engine/audio/audio_effects.cpp
+engine/effect_supervisor.h
+engine/effect_supervisor.cpp
+engine/mode_manager.h
+engine/mode_manager.cpp
+engine/script_supervisor.h
+engine/script_supervisor.cpp
main_options.h
modes/pause.cpp
modes/shop/shop_root.h
@@ -374,6 +374,8 @@ modes/shop/shop.h
modes/shop/shop_sell.h
modes/scene.h
modes/mode_bindings.cpp
+modes/mode_help_window.h
+modes/mode_help_window.cpp
modes/battle/battle_effects.cpp
modes/battle/battle_sequence.h
modes/battle/battle_actors.cpp
@@ -397,9 +399,7 @@ modes/battle/battle_sequence.cpp
modes/scene.cpp
modes/boot/boot.h
modes/boot/boot.cpp
-modes/boot/boot_welcome.cpp
modes/boot/boot_menu.h
-modes/boot/boot_welcome.h
modes/boot/boot_menu.cpp
modes/save/save_mode.h
modes/save/save_mode.cpp
@@ -536,5 +536,5 @@ IF (EDITOR_SUPPORT)
)
INSTALL(TARGETS vt-editor RUNTIME DESTINATION ${PKG_BINDIR})
- SET_TARGET_PROPERTIES(vt-editor PROPERTIES COMPILE_FLAGS "${FLAGS} -DQT3_SUPPORT")
+ SET_TARGET_PROPERTIES(vt-editor PROPERTIES COMPILE_FLAGS "${FLAGS} -DQT3_SUPPORT -DEDITOR_BUILD")
ENDIF(EDITOR_SUPPORT)
View
@@ -271,7 +271,6 @@ namespace hoa_boot {
namespace private_boot {
class BootMenu;
- class WelcomeWindow;
}
}
View
@@ -123,6 +123,7 @@ class Tileset
QString tileset_name;
//! \brief Contains the StillImage tiles of the tileset, used in grid.cpp.
+ // FIXME Turn this into a QT object, so that one can remove the editor dependency upon the videomanager
std::vector<hoa_video::StillImage> tiles;
//! \brief Contains walkability information for each tile.
@@ -22,6 +22,7 @@
#include "engine/audio/audio.h"
#include "engine/system.h"
+#include "engine/mode_manager.h"
using namespace std;
using namespace hoa_utils;
View
@@ -17,6 +17,8 @@
#include "engine/video/video.h"
#include "engine/script/script_read.h"
+#include "modes/mode_help_window.h"
+
#include "mode_manager.h"
#include "system.h"
@@ -75,6 +77,7 @@ InputEngine::InputEngine() {
_pause_press = false;
_quit_press = false;
+ _help_press = false;
_joyaxis_x_first = true;
_joyaxis_y_first = true;
@@ -179,7 +182,7 @@ bool InputEngine::RestoreDefaultJoyButtons()
_joystick.left_select = static_cast<uint8>(settings_file.ReadInt("left_select"));
_joystick.right_select = static_cast<uint8>(settings_file.ReadInt("right_select"));
_joystick.pause = static_cast<uint8>(settings_file.ReadInt("pause"));
- _joystick.quit = static_cast<uint8>(settings_file.ReadInt("quit"));
+ _joystick.quit = static_cast<uint8>(settings_file.ReadInt("quit"));
settings_file.CloseTable();
settings_file.CloseTable();
@@ -232,6 +235,7 @@ void InputEngine::EventHandler() {
_pause_press = false;
_quit_press = false;
+ _help_press = false;
// Loops until there are no remaining events to process
while (SDL_PollEvent(&event)) {
@@ -294,11 +298,7 @@ void InputEngine::_KeyEventHandler(SDL_KeyboardEvent& key_event) {
_any_key_press = false; // CTRL isn't "any key"! :)
- if (key_event.keysym.sym == SDLK_a) {
- // Toggle the display of debug visual engine information
- VideoManager->ToggleDebugInfo();
- }
- else if (key_event.keysym.sym == SDLK_f) {
+ if (key_event.keysym.sym == SDLK_f) {
// Toggle between full-screen and windowed mode
VideoManager->ToggleFullscreen();
VideoManager->ApplySettings();
@@ -307,10 +307,6 @@ void InputEngine::_KeyEventHandler(SDL_KeyboardEvent& key_event) {
else if (key_event.keysym.sym == SDLK_q) {
_quit_press = true;
}
- else if (key_event.keysym.sym == SDLK_r) {
- VideoManager->ToggleFPS();
- return;
- }
else if (key_event.keysym.sym == SDLK_s) {
// Take a screenshot of the current game
static uint32 i = 1;
@@ -325,18 +321,37 @@ void InputEngine::_KeyEventHandler(SDL_KeyboardEvent& key_event) {
VideoManager->MakeScreenshot(path);
return;
}
+#ifdef DEBUG_MENU
+ // Insert developers options here.
+ else if (key_event.keysym.sym == SDLK_r) {
+ VideoManager->ToggleFPS();
+ return;
+ }
+ else if (key_event.keysym.sym == SDLK_a) {
+ // Toggle the display of debug visual engine information
+ VideoManager->ToggleDebugInfo();
+ }
else if (key_event.keysym.sym == SDLK_t) {
// Display and cycle through the texture sheets
VideoManager->Textures()->DEBUG_NextTexSheet();
return;
}
+#endif
//return;
} // endif CTRL pressed
// Note: a switch-case statement won't work here because Key.up is not an
// integer value the compiler will whine and cry about it ;_;
if (key_event.keysym.sym == SDLK_ESCAPE) {
+ // Hide the help window if shown
+ HelpWindow *help_window = ModeManager->GetHelpWindow();
+ if (help_window && help_window->IsActive()) {
+ help_window->Hide();
+ return;
+ }
+
+ // Handle the normal events otherwise.
_quit_press = true;
return;
}
@@ -394,8 +409,19 @@ void InputEngine::_KeyEventHandler(SDL_KeyboardEvent& key_event) {
_pause_press = true;
return;
}
+ else if (key_event.keysym.sym == SDLK_F1) {
+ _help_press = true;
+ // Toggle the help window visibility
+ HelpWindow *help_window = ModeManager->GetHelpWindow();
+ if (!help_window)
+ return;
+ if (!help_window->IsActive())
+ help_window->Show();
+ else
+ help_window->Hide();
+ return;
+ }
}
-
else { // Key was released
_any_key_press = false;
@@ -590,7 +616,11 @@ void InputEngine::_JoystickEventHandler(SDL_Event& js_event) {
// Sets a new key over an older one. If the same key is used elsewhere, the older one is removed
-void InputEngine::_SetNewKey(SDLKey & old_key, SDLKey new_key) {
+void InputEngine::_SetNewKey(SDLKey& old_key, SDLKey new_key) {
+ // Don't permit system keys (Quit and help)
+ if (new_key == SDLK_ESCAPE || new_key == SDLK_F1)
+ return;
+
if (_key.up == new_key) { // up key used already
_key.up = old_key;
old_key = new_key;
View
@@ -64,6 +64,7 @@ class KeyState {
public:
/** \name Generic key names
*** \brief Each member holds the actual keyboard key that corresponds to the named key event.
+ *** \note that SDLK_ESCAPE and SDLK_F1 are reserved for Quit, and Help.
**/
//@{
SDLKey up;
@@ -230,6 +231,7 @@ class InputEngine : public hoa_utils::Singleton<InputEngine> {
bool _right_select_press;
bool _pause_press;
bool _quit_press;
+ bool _help_press;
//@}
/** \name Input Release Members
@@ -284,7 +286,7 @@ class InputEngine : public hoa_utils::Singleton<InputEngine> {
public:
~InputEngine();
- bool SingletonInitialize ();
+ bool SingletonInitialize();
//! \brief Initialize the joysticks with SDL, delayed because we need info from the lua settings file first.
void InitializeJoysticks();
@@ -403,6 +405,9 @@ class InputEngine : public hoa_utils::Singleton<InputEngine> {
bool QuitPress() const
{ return _quit_press; }
+
+ bool HelpPress() const
+ { return _help_press; }
//@}
/** \name Input release member access functions
@@ -445,37 +450,43 @@ class InputEngine : public hoa_utils::Singleton<InputEngine> {
**/
//@{
std::string GetUpKeyName() const
- { return SDL_GetKeyName(_key.up); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.up)); }
std::string GetDownKeyName() const
- { return SDL_GetKeyName(_key.down); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.down)); }
std::string GetLeftKeyName() const
- { return SDL_GetKeyName(_key.left); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.left)); }
std::string GetRightKeyName() const
- { return SDL_GetKeyName(_key.right); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.right)); }
std::string GetConfirmKeyName() const
- { return SDL_GetKeyName(_key.confirm); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.confirm)); }
std::string GetCancelKeyName() const
- { return SDL_GetKeyName(_key.cancel); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.cancel)); }
std::string GetMenuKeyName() const
- { return SDL_GetKeyName(_key.menu); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.menu)); }
std::string GetSwapKeyName() const
- { return SDL_GetKeyName(_key.swap); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.swap)); }
std::string GetLeftSelectKeyName() const
- { return SDL_GetKeyName(_key.left_select); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.left_select)); }
std::string GetRightSelectKeyName() const
- { return SDL_GetKeyName(_key.right_select); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.right_select)); }
std::string GetPauseKeyName() const
- { return SDL_GetKeyName(_key.pause); }
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(_key.pause)); }
+
+ std::string GetHelpKeyName() const
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(SDLK_F1)); }
+
+ std::string GetQuitKeyName() const
+ { return hoa_utils::UpcaseFirst(SDL_GetKeyName(SDLK_ESCAPE)); }
//@}
/** \name Joystick axis access functions
@@ -19,6 +19,8 @@
#include "engine/video/video.h"
#include "engine/audio/audio.h"
+#include "modes/mode_help_window.h"
+
using namespace std;
using namespace hoa_utils;
@@ -88,6 +90,9 @@ ModeEngine::ModeEngine() {
_state_change = false;
_fade_out = false;
_fade_out_finished = false;
+
+ // Initialized in Push()
+ _help_window = 0;
}
@@ -105,6 +110,8 @@ ModeEngine::~ModeEngine() {
delete _push_stack.back();
_push_stack.pop_back();
}
+
+ delete _help_window;
}
@@ -172,6 +179,11 @@ void ModeEngine::Push(GameMode* gm, bool fade_out, bool fade_in) {
_fade_out = false;
_fade_out_finished = true;
}
+
+ // We init the help window only at first game mode push, so give time to
+ // every game sub-engine to init properly.
+ if (!_help_window)
+ _help_window = new HelpWindow();
}
@@ -289,6 +301,9 @@ void ModeEngine::DrawPostEffects() {
return;
_game_stack.back()->DrawPostEffects();
+
+ if (_help_window && _help_window->IsActive())
+ _help_window->Draw();
}
Oops, something went wrong.

0 comments on commit 72c2ad2

Please sign in to comment.