Skip to content

Commit

Permalink
Moved the Message Window class into its own source files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohann Ferreira committed Apr 8, 2014
1 parent 3f8b665 commit 2b0f118
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 88 deletions.
2 changes: 2 additions & 0 deletions ValyriaTear.cbp
Expand Up @@ -232,6 +232,8 @@
<Unit filename="src/common/common_bindings.cpp" />
<Unit filename="src/common/dialogue.cpp" />
<Unit filename="src/common/dialogue.h" />
<Unit filename="src/common/message_window.cpp" />
<Unit filename="src/common/message_window.h" />
<Unit filename="src/common/global/global.cpp">
<Option weight="60" />
</Unit>
Expand Down
43 changes: 22 additions & 21 deletions src/CMakeLists.txt
Expand Up @@ -267,10 +267,6 @@ utils/utils_strings.cpp
)

SET(SRCS
main.cpp
common/common_bindings.cpp
common/common.cpp
common/dialogue.cpp
common/global/global.cpp
common/global/global.h
common/global/global_actors.cpp
Expand All @@ -284,14 +280,18 @@ common/global/global_skills.h
common/global/global_utils.cpp
common/global/global_utils.h
common/gui/option.h
common/gui/option.cpp
common/gui/menu_window.cpp
common/gui/menu_window.h
common/gui/gui.h
common/gui/textbox.cpp
common/gui/textbox.h
common/gui/option.cpp
common/gui/gui.cpp
common/gui/gui.h
common/message_window.cpp
common/message_window.h
common/dialogue.cpp
common/dialogue.h
common/common.cpp
common/common.h
common/common_bindings.cpp
engine/audio/audio.h
Expand All @@ -314,6 +314,16 @@ engine/indicator_supervisor.h
engine/indicator_supervisor.cpp
engine/system.cpp
engine/system.h
engine/input.h
engine/input.cpp
engine/engine_bindings.cpp
engine/video/screen_rect.h
engine/video/color.h
engine/video/particle_emitter.h
engine/video/particle_keyframe.h
engine/video/context.h
engine/video/particle.h
engine/video/coord_sys.h
engine/video/video.h
engine/video/video.cpp
engine/video/texture_controller.h
Expand All @@ -337,8 +347,6 @@ engine/video/particle_effect.h
engine/video/particle_effect.cpp
engine/video/particle_system.h
engine/video/particle_system.cpp
main_options.h
modes/pause.cpp
modes/shop/shop_root.h
modes/shop/shop_buy.cpp
modes/shop/shop_sell.cpp
Expand All @@ -351,9 +359,6 @@ modes/shop/shop_buy.h
modes/shop/shop_utils.cpp
modes/shop/shop.h
modes/shop/shop_sell.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
Expand Down Expand Up @@ -404,22 +409,18 @@ modes/menu/menu.h
modes/menu/menu.cpp
modes/menu/menu_views.cpp
modes/menu/menu_views.h
modes/pause.cpp
modes/pause.h
modes/mode_bindings.cpp
modes/mode_help_window.h
modes/mode_help_window.cpp
utils/ustring.h
utils/ustring.cpp
utils/exception.h
utils/exception.cpp
engine/input.h
engine/input.cpp
engine/engine_bindings.cpp
engine/video/screen_rect.h
engine/video/color.h
engine/video/particle_emitter.h
engine/video/particle_keyframe.h
engine/video/context.h
engine/video/particle.h
engine/video/coord_sys.h
main_options.h
main_options.cpp
main.cpp
)

IF (WIN32)
Expand Down
57 changes: 57 additions & 0 deletions src/common/message_window.cpp
@@ -0,0 +1,57 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2004-2011 by The Allacrost Project
// Copyright (C) 2012-2014 by Bertram (Valyria Tear)
// All Rights Reserved
//
// This code is licensed under the GNU GPL version 2. It is free software
// and you may modify it and/or redistribute it under the terms of this license.
// See http://www.gnu.org/copyleft/gpl.html for details.
///////////////////////////////////////////////////////////////////////////////

/** ****************************************************************************
*** \file message_window.cpp
*** \author Daniel Steuernol steu@allacrost.org
*** \author Andy Gardner chopperdave@allacrost.org
*** \author Nik Nadig (IkarusDowned) nihonnik@gmail.com
*** \author Yohann Ferreira, yohann ferreira orange fr
*** \brief Source file for a common message window.
*** ***************************************************************************/

#include "utils/utils_pch.h"
#include "message_window.h"

#include "engine/video/video.h"

namespace vt_common
{

MessageWindow::MessageWindow(const vt_utils::ustring& message, float w, float h)
{
float start_x = (1024 - w) / 2;
float start_y = (768 - h) / 2;

MenuWindow::Create(w, h);
MenuWindow::SetPosition(start_x, start_y);
MenuWindow::Show();

_textbox.SetPosition(30, 5);
_textbox.SetDimensions(w, h);
_textbox.SetTextStyle(vt_video::TextStyle("text22"));
_textbox.SetDisplayMode(vt_gui::VIDEO_TEXT_INSTANT);
_textbox.SetTextAlignment(vt_video::VIDEO_X_LEFT, vt_video::VIDEO_Y_CENTER);
_textbox.SetDisplayText(message);
_textbox.SetOwner(this);
}

MessageWindow::~MessageWindow()
{
MenuWindow::Destroy();
}

void MessageWindow::Draw()
{
MenuWindow::Draw();
_textbox.Draw();
}

} // namespace vt_common
59 changes: 59 additions & 0 deletions src/common/message_window.h
@@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2004-2011 by The Allacrost Project
// Copyright (C) 2012-2014 by Bertram (Valyria Tear)
// All Rights Reserved
//
// This code is licensed under the GNU GPL version 2. It is free software
// and you may modify it and/or redistribute it under the terms of this license.
// See http://www.gnu.org/copyleft/gpl.html for details.
///////////////////////////////////////////////////////////////////////////////

/** ****************************************************************************
*** \file message_window.h
*** \author Daniel Steuernol steu@allacrost.org
*** \author Andy Gardner chopperdave@allacrost.org
*** \author Nik Nadig (IkarusDowned) nihonnik@gmail.com
*** \author Yohann Ferreira, yohann ferreira orange fr
*** \brief Header file for a common message window.
*** ***************************************************************************/

#ifndef __MESSAGE_WINDOW_HEADER__
#define __MESSAGE_WINDOW_HEADER__

#include "common/gui/menu_window.h"

#include "common/gui/textbox.h"

namespace vt_common
{

/** **************************************************************************
*** \brief A window to display a message to the player
*** Displays a message to the user in the center of the screen
*** This class is not private because it's a handy message box and
*** it could be used else where.
*** **************************************************************************/
class MessageWindow : public vt_gui::MenuWindow
{
public:
MessageWindow(const vt_utils::ustring& message, float w, float h);
~MessageWindow();

//! \brief Set the text to display in the window
void SetText(const vt_utils::ustring& message) {
_textbox.SetDisplayText(message);
}

//! \brief Standard Window Functions
//@{
void Draw();
//@}

private:
//! \brief used to display the message
vt_gui::TextBox _textbox;
}; // class MessageWindow

} // namespace vt_common

#endif // __MESSAGE_WINDOW_HEADER__
4 changes: 3 additions & 1 deletion src/modes/boot/boot_menu.cpp
Expand Up @@ -28,6 +28,8 @@

#include "utils/utils_files.h"

#include "common/global/global.h"

using namespace vt_utils;
using namespace vt_video;
using namespace vt_input;
Expand Down Expand Up @@ -137,7 +139,7 @@ GameOptionsMenuHandler::GameOptionsMenuHandler(vt_mode_manager::GameMode* parent
_key_setting_function(NULL),
_joy_setting_function(NULL),
_joy_axis_setting_function(NULL),
_message_window(ustring(), 210.0f, 733.0f),
_message_window(ustring(), 310.0f, 233.0f),
_parent_mode(parent_mode)
{
// Create the option window used as background
Expand Down
5 changes: 2 additions & 3 deletions src/modes/boot/boot_menu.h
Expand Up @@ -23,8 +23,7 @@
#include "common/gui/option.h"
#include "common/gui/menu_window.h"

//TODO: Move the message window class to commmon/gui and remove that include to the menu mode.
#include "modes/menu/menu_views.h"
#include "common/message_window.h"

namespace vt_gui
{
Expand Down Expand Up @@ -188,7 +187,7 @@ class GameOptionsMenuHandler {
void (GameOptionsMenuHandler::*_joy_axis_setting_function)(int8 axis);

//! \brief Window display message for "select a key"
vt_menu::MessageWindow _message_window;
vt_common::MessageWindow _message_window;

//! \brief The parent game mode the handler is a component of. Don't delete this.
vt_mode_manager::GameMode* _parent_mode;
Expand Down
3 changes: 2 additions & 1 deletion src/modes/menu/menu.h
Expand Up @@ -27,6 +27,7 @@
#include "menu_views.h"
#include "engine/video/video.h"

#include "common/message_window.h"
#include "common/global/global.h"

#include "engine/mode_manager.h"
Expand Down Expand Up @@ -523,7 +524,7 @@ class MenuMode : public vt_mode_manager::GameMode
private_menu::QuestWindow _quest_window;
private_menu::WorldMapWindow _world_map_window;

MessageWindow *_message_window;
vt_common::MessageWindow* _message_window;

//! \name Option boxes that are used in the various menu windows
//@{
Expand Down
31 changes: 0 additions & 31 deletions src/modes/menu/menu_views.cpp
Expand Up @@ -2615,35 +2615,4 @@ void WorldMapWindow::Activate(bool new_state)

} // namespace private_menu


MessageWindow::MessageWindow(const ustring &message, float w, float h) :
_message(message)
{
float start_x = (1024 - w) / 2;
float start_y = (768 - h) / 2;

MenuWindow::Create(w, h);
MenuWindow::SetPosition(start_x, start_y);
MenuWindow::Show();

_textbox.SetPosition(30, 5);
_textbox.SetDimensions(w, h);
_textbox.SetTextStyle(TextStyle("text22"));
_textbox.SetDisplayMode(VIDEO_TEXT_INSTANT);
_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
_textbox.SetDisplayText(_message);
_textbox.SetOwner(this);
}

MessageWindow::~MessageWindow()
{
MenuWindow::Destroy();
}

void MessageWindow::Draw()
{
MenuWindow::Draw();
_textbox.Draw();
}

} // namespace vt_menu
31 changes: 0 additions & 31 deletions src/modes/menu/menu_views.h
Expand Up @@ -831,37 +831,6 @@ template <class T> std::vector<vt_global::GlobalObject *> InventoryWindow::_GetI

} // namespace private_menu

/** **************************************************************************
*** \brief A window to display a message to the player
*** Displays a message to the user in the center of the screen
*** This class is not private because it's a handy message box and
*** it could be used else where.
*** **************************************************************************/
class MessageWindow : public vt_gui::MenuWindow
{
public:
MessageWindow(const vt_utils::ustring &message, float w, float h);
~MessageWindow();

//! \brief Set the text to display in the window
void SetText(const vt_utils::ustring &message) {
_message = message;
_textbox.SetDisplayText(message);
}

//! \brief Standard Window Functions
//@{
void Draw();
//@}

private:
//! \brief the message to display
vt_utils::ustring _message;

//! \brief used to display the message
vt_gui::TextBox _textbox;
}; // class MessageWindow

} // namespace vt_menu

#endif

0 comments on commit 2b0f118

Please sign in to comment.