hoa_video::MenuWindow Class Reference

Represents GUI menu windows and handles their operation. More...

#include <menu_window.h>

Inheritance diagram for hoa_video::MenuWindow:

Inheritance graph
[legend]
Collaboration diagram for hoa_video::MenuWindow:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void ChangeEdgeSharedFlags (int32 flags)
 Changes the shared edge flags after the menu window has been created.
void ChangeEdgeVisibleFlags (int32 flags)
 Changes the visible edge flags after the menu window has been created.
void ChangeMenuSkin (std::string &skin_name)
 Changes which menu skin is used by the window after it has been created.
bool Create (float w, float h, int32 visible_flags=VIDEO_MENU_EDGE_ALL, int32 shared_flags=0)
 
Note:
This version of the create function does not take a skin_name argument. It uses the default menu skin.

bool Create (std::string skin_name, float w, float h, int32 visible_flags=VIDEO_MENU_EDGE_ALL, int32 shared_flags=0)
 Sets the width and height of the menu.
void Destroy ()
 You must call this method when you are finished using a menu. Failure to neglect this call may result in problems like texture memory not being freed.
void Draw ()
 Draws the menu window to the screen.
void Hide ()
 Causes the menu to begin making itself not visible. Depending on the display mode, the menu might hide instantly or gradually. If it's gradual, you should still continue calling Draw() even after you call Hide() until it's fully hidden. You can check if it's fully hidden by checking if GetState() returns VIDEO_MENU_STATE_HIDDEN (until then, it will be VIDEO_MENU_STATE_HIDING).
bool IsInitialized (std::string &errors)
 Does a self-check on all its members to see if all its members have been set to valid values.
 MenuWindow ()
void Show ()
 Causes the menu to begin making itself visible. Depending on the display mode, the menu might show instantly or gradually. You can check for when the menu is fully shown by checking if GetState() returns VIDEO_MENU_STATE_SHOWN (until then, it is VIDEO_MENU_STATE_SHOWING).
void Update (uint32 frame_time)
 Updates the menu window, used for gradual show/hide effects.
 ~MenuWindow ()
Class Member Access Functions
void GetDimensions (float &w, float &h) const
VIDEO_MENU_DISPLAY_MODE GetDisplayMode () const
ScreenRect GetScissorRect () const
VIDEO_MENU_STATE GetState () const
void SetDisplayMode (VIDEO_MENU_DISPLAY_MODE mode)

Private Member Functions

bool _RecreateImage ()
 Used to create the menu window's image when the visible properties of the window change.

Private Attributes

VIDEO_MENU_DISPLAY_MODE _display_mode
 The window's display mode (instant, expand from center, etc).
int32 _display_timer
 The number of milliseconds that have passed since the menu was shown.
int32 _edge_shared_flags
 Flags used to tell which edges are shared with other windows.
int32 _edge_visible_flags
 Flags used to tell which edges of the menu window are visible.
float _height
int32 _id
 The current id of this object.
float _inner_height
float _inner_width
 The dimensions of the space inside the window borders.
bool _is_scissored
 Set to true if scissoring needs to be used on the window.
StillImage _menu_image
 The image that creates the window.
ScreenRect _scissor_rect
 The rectangle used for scissoring, set during each call to Update().
private_video::MenuSkin_skin
 A pointer to the menu skin that the menu window currently uses.
float _width
 The dimensions of the menu window, in pixels.
VIDEO_MENU_STATE _window_state
 The state of the menu window (hidden, shown, hiding, showing).

Friends

class private_video::GUISupervisor

Detailed Description

Represents GUI menu windows and handles their operation.

****************************************************************************

A menu window is simply a rectangle drawn on the screen that has a border image and a background. Menu windows exist to provide a base upon which to draw text and images that are not a part of the regular game environment.

Todo:
Allow the user to specify an arbitrary amount of time for showing/ hiding the menu window.

Definition at line 144 of file menu_window.h.


Constructor & Destructor Documentation

hoa_video::MenuWindow::MenuWindow (  ) 

Definition at line 25 of file menu_window.cpp.

References _id, hoa_video::private_video::GUIElement::_initialization_errors, hoa_video::private_video::GUIElement::_initialized, hoa_video::private_video::GUISupervisor::GetNextMenuWindowID(), hoa_video::private_video::GUIManager, and IsInitialized().

Here is the call graph for this function:

hoa_video::MenuWindow::~MenuWindow (  )  [inline]

Definition at line 149 of file menu_window.h.


Member Function Documentation

bool hoa_video::MenuWindow::_RecreateImage (  )  [private]

Used to create the menu window's image when the visible properties of the window change.

Returns:
True if the menu image was successfully created, false otherwise.
Note:
This function may not create a window that is exactly the width and height requested. It will automatically adjust the dimneions to minimalize warping. So for example, if the border artwork is all 8x8 pixel images and you try to create a menu that is 117x69, it will get rounded up to 120x72.

Definition at line 336 of file menu_window.cpp.

References _edge_shared_flags, _edge_visible_flags, _height, _inner_height, _inner_width, _menu_image, _skin, _width, hoa_video::StillImage::AddImage(), hoa_video::private_video::MenuSkin::background, hoa_video::private_video::MenuSkin::borders, hoa_video::StillImage::Clear(), hoa_video::private_video::MenuSkin::connectors, hoa_video::GameVideo::DeleteImage(), hoa_video::StillImage::GetHeight(), hoa_video::StillImage::GetVertexColor(), hoa_video::StillImage::GetWidth(), hoa_video::GameVideo::LoadImage(), hoa_video::StillImage::SetDimensions(), hoa_video::StillImage::SetVertexColors(), hoa_video::VIDEO_DEBUG, hoa_video::VIDEO_MENU_EDGE_BOTTOM, hoa_video::VIDEO_MENU_EDGE_LEFT, hoa_video::VIDEO_MENU_EDGE_RIGHT, hoa_video::VIDEO_MENU_EDGE_TOP, and hoa_video::VideoManager.

Referenced by ChangeEdgeSharedFlags(), ChangeEdgeVisibleFlags(), and Create().

Here is the call graph for this function:

void hoa_video::MenuWindow::ChangeEdgeSharedFlags ( int32  flags  ) 

Changes the shared edge flags after the menu window has been created.

Parameters:
flags Bit flags to specify which edges are shared with other windows.
Note:
This call is somewhat expensive since it has to recreate the menu window image.

Definition at line 302 of file menu_window.cpp.

References _edge_shared_flags, and _RecreateImage().

Here is the call graph for this function:

void hoa_video::MenuWindow::ChangeEdgeVisibleFlags ( int32  flags  ) 

Changes the visible edge flags after the menu window has been created.

Parameters:
flags Bit flags to specify which edges are visible and which are not.
Note:
This call is somewhat expensive since it has to recreate the menu window image.

Definition at line 295 of file menu_window.cpp.

References _edge_visible_flags, and _RecreateImage().

Here is the call graph for this function:

void hoa_video::MenuWindow::ChangeMenuSkin ( std::string &  skin_name  ) 

Changes which menu skin is used by the window after it has been created.

Parameters:
skin_name The name to which the skin is referred by
Note:
If the skin_name is invalid, a warning mesage will be printed and no change will take place. This call is somewhat expensive since it has to recreate the menu window image.

bool hoa_video::MenuWindow::Create ( float  w,
float  h,
int32  visible_flags = VIDEO_MENU_EDGE_ALL,
int32  shared_flags = 0 
)

Note:
This version of the create function does not take a skin_name argument. It uses the default menu skin.

Definition at line 54 of file menu_window.cpp.

References _edge_shared_flags, _edge_visible_flags, _height, hoa_video::private_video::GUIElement::_initialization_errors, hoa_video::private_video::GUIElement::_initialized, _RecreateImage(), _skin, _width, hoa_video::private_video::GUISupervisor::AddMenuWindow(), hoa_video::private_video::GUISupervisor::GetDefaultMenuSkin(), hoa_video::private_video::GUIManager, IsInitialized(), and hoa_video::VIDEO_DEBUG.

Here is the call graph for this function:

bool hoa_video::MenuWindow::Create ( std::string  skin_name,
float  w,
float  h,
int32  visible_flags = VIDEO_MENU_EDGE_ALL,
int32  shared_flags = 0 
)

Sets the width and height of the menu.

Parameters:
skin_name The name of the menu skin with which to construct this menu window.
w The window width in pixels, which must be within the range of [0.0f, 1024.f].
h The window height in pixels, which must be within the range of [0.0f, 768.f].
visible_flags A combination of bit flags, VIDEO_MENU_EDGE_LEFT, etc. that indicate which edges are visible. A non-visible edge means that the border image gets stripped off.
shared_flags A combination of bitflags, VIDEO_MENU_EDGE_LEFT, etc. that tell which edges are shared with other menus so they can use the appropriate connector images.
Returns:
False and print an error message on failure. Otherwise return true upon success.
Note:
This function must be called before you attempt to draw the window.

Referenced by hoa_boot::BootMenu::_InitWindow(), hoa_boot::CreditsScreen::CreditsScreen(), and hoa_boot::WelcomeScreen::WelcomeScreen().

void hoa_video::MenuWindow::Destroy (  ) 

You must call this method when you are finished using a menu. Failure to neglect this call may result in problems like texture memory not being freed.

Definition at line 91 of file menu_window.cpp.

References _menu_image, _skin, hoa_video::GameVideo::DeleteImage(), hoa_video::private_video::GUIManager, hoa_video::private_video::GUISupervisor::RemoveMenuWindow(), and hoa_video::VideoManager.

Referenced by hoa_boot::BootMenu::~BootMenu(), hoa_boot::CreditsScreen::~CreditsScreen(), hoa_menu::MenuMode::~MenuMode(), and hoa_boot::WelcomeScreen::~WelcomeScreen().

Here is the call graph for this function:

void hoa_video::MenuWindow::Draw (  )  [virtual]

Draws the menu window to the screen.

Implements hoa_video::private_video::GUIElement.

Reimplemented in hoa_battle::private_battle::ActionWindow, hoa_battle::private_battle::FinishWindow, hoa_map::private_map::DialogueManager, hoa_menu::private_menu::CharacterWindow, hoa_menu::private_menu::InventoryWindow, hoa_menu::private_menu::StatusWindow, hoa_menu::private_menu::SkillsWindow, hoa_menu::private_menu::EquipWindow, hoa_menu::private_menu::FormationWindow, hoa_shop::private_shop::ShopActionWindow, hoa_shop::private_shop::ObjectListWindow, hoa_shop::private_shop::ObjectSellListWindow, hoa_shop::private_shop::ObjectInfoWindow, and hoa_shop::private_shop::ConfirmWindow.

Definition at line 178 of file menu_window.cpp.

References hoa_video::private_video::GUIElement::_initialization_errors, hoa_video::private_video::GUIElement::_initialized, _is_scissored, _menu_image, hoa_video::GameVideo::_PopContext(), hoa_video::GameVideo::_PushContext(), _scissor_rect, _window_state, hoa_video::private_video::GUIElement::_x_position, hoa_video::private_video::GUIElement::_xalign, hoa_video::private_video::GUIElement::_y_position, hoa_video::private_video::GUIElement::_yalign, hoa_video::GameVideo::DrawImage(), hoa_video::GameVideo::EnableScissoring(), hoa_video::GameVideo::GetScissorRect(), hoa_video::ScreenRect::Intersect(), hoa_video::GameVideo::IsScissoringEnabled(), hoa_video::GameVideo::Move(), hoa_video::GameVideo::SetDrawFlags(), hoa_video::GameVideo::SetScissorRect(), hoa_video::VIDEO_BLEND, hoa_video::VIDEO_DEBUG, hoa_video::VIDEO_MENU_STATE_HIDDEN, hoa_video::VideoManager, and hoa_video::Color::white.

Referenced by hoa_menu::MenuMode::_DrawBottomMenu(), hoa_shop::private_shop::ShopActionWindow::Draw(), hoa_menu::MenuMode::Draw(), hoa_boot::WelcomeScreen::Draw(), hoa_boot::BootMenu::Draw(), and hoa_boot::CreditsScreen::Draw().

Here is the call graph for this function:

void hoa_video::MenuWindow::GetDimensions ( float &  w,
float &  h 
) const [inline]

Definition at line 232 of file menu_window.h.

References _height, and _width.

Referenced by hoa_video::private_video::GUIControl::CalculateAlignedRect(), and hoa_menu::private_menu::CharacterWindow::Draw().

VIDEO_MENU_DISPLAY_MODE hoa_video::MenuWindow::GetDisplayMode (  )  const [inline]

Definition at line 235 of file menu_window.h.

References _display_mode.

ScreenRect hoa_video::MenuWindow::GetScissorRect (  )  const [inline]

Definition at line 241 of file menu_window.h.

References _scissor_rect.

Referenced by hoa_video::OptionBox::Draw(), and hoa_boot::CreditsScreen::Draw().

VIDEO_MENU_STATE hoa_video::MenuWindow::GetState (  )  const [inline]

Reimplemented in hoa_battle::private_battle::ActionWindow, and hoa_battle::private_battle::FinishWindow.

Definition at line 238 of file menu_window.h.

References _window_state.

Referenced by hoa_boot::WelcomeScreen::Draw(), and hoa_boot::CreditsScreen::Draw().

void hoa_video::MenuWindow::Hide (  ) 

Causes the menu to begin making itself not visible. Depending on the display mode, the menu might hide instantly or gradually. If it's gradual, you should still continue calling Draw() even after you call Hide() until it's fully hidden. You can check if it's fully hidden by checking if GetState() returns VIDEO_MENU_STATE_HIDDEN (until then, it will be VIDEO_MENU_STATE_HIDING).

Note:
The time it takes for the menu to show is VIDEO_MENU_SCROLL_TIME

Definition at line 232 of file menu_window.cpp.

References _display_mode, _display_timer, hoa_video::private_video::GUIElement::_initialization_errors, hoa_video::private_video::GUIElement::_initialized, _window_state, hoa_video::VIDEO_DEBUG, hoa_video::VIDEO_MENU_INSTANT, hoa_video::VIDEO_MENU_STATE_HIDDEN, and hoa_video::VIDEO_MENU_STATE_HIDING.

Referenced by hoa_boot::BootMenu::_InitWindow(), hoa_boot::CreditsScreen::CreditsScreen(), hoa_boot::WelcomeScreen::Hide(), hoa_boot::CreditsScreen::Hide(), hoa_boot::BootMenu::ShowWindow(), hoa_shop::private_shop::ShopActionWindow::Update(), and hoa_boot::WelcomeScreen::WelcomeScreen().

bool hoa_video::MenuWindow::IsInitialized ( std::string &  errors  )  [virtual]

Does a self-check on all its members to see if all its members have been set to valid values.

Parameters:
&errors A reference to a string to be filled if any errors are found.
Returns:
True if menu window is properly initialized, false if it is not.
This is used internally to make sure we have a valid object before doing any complicated operations. If it detects any problems, it generates a list of errors and returns it by reference so they can be displayed

Implements hoa_video::private_video::GUIElement.

Referenced by Create(), MenuWindow(), and SetDisplayMode().

void hoa_video::MenuWindow::SetDisplayMode ( VIDEO_MENU_DISPLAY_MODE  mode  ) 

Definition at line 323 of file menu_window.cpp.

References _display_mode, hoa_video::private_video::GUIElement::_initialization_errors, hoa_video::private_video::GUIElement::_initialized, IsInitialized(), hoa_video::VIDEO_DEBUG, and hoa_video::VIDEO_MENU_TOTAL.

Referenced by hoa_boot::BootMenu::_InitWindow(), and hoa_boot::CreditsScreen::CreditsScreen().

Here is the call graph for this function:

void hoa_video::MenuWindow::Show (  ) 

Causes the menu to begin making itself visible. Depending on the display mode, the menu might show instantly or gradually. You can check for when the menu is fully shown by checking if GetState() returns VIDEO_MENU_STATE_SHOWN (until then, it is VIDEO_MENU_STATE_SHOWING).

Note:
The time it takes for the menu to show is VIDEO_MENU_SCROLL_TIME.

Definition at line 211 of file menu_window.cpp.

References _display_mode, _display_timer, hoa_video::private_video::GUIElement::_initialization_errors, hoa_video::private_video::GUIElement::_initialized, _window_state, hoa_video::VIDEO_DEBUG, hoa_video::VIDEO_MENU_INSTANT, hoa_video::VIDEO_MENU_STATE_SHOWING, and hoa_video::VIDEO_MENU_STATE_SHOWN.

Referenced by hoa_menu::MenuMode::Reset(), hoa_boot::WelcomeScreen::Show(), hoa_boot::CreditsScreen::Show(), hoa_boot::BootMenu::ShowWindow(), hoa_shop::private_shop::ObjectSellListWindow::Update(), hoa_shop::private_shop::ObjectListWindow::Update(), and hoa_shop::private_shop::ShopActionWindow::Update().

void hoa_video::MenuWindow::Update ( uint32  frame_time  )  [virtual]

Updates the menu window, used for gradual show/hide effects.

Parameters:
frame_time The time that has elapsed since the previous frame, in milliseconds.

Implements hoa_video::private_video::GUIElement.

Definition at line 99 of file menu_window.cpp.

References _display_mode, _display_timer, _height, _inner_height, _inner_width, _is_scissored, _scissor_rect, _width, _window_state, hoa_video::private_video::GUIElement::_xalign, hoa_video::private_video::GUIElement::_yalign, hoa_video::private_video::GUIElement::CalculateAlignedRect(), hoa_video::GameVideo::CalculateScreenRect(), hoa_video::ScreenRect::height, hoa_video::ScreenRect::left, hoa_video::GameVideo::PopState(), hoa_video::GameVideo::PushState(), hoa_video::GameVideo::SetDrawFlags(), hoa_video::ScreenRect::top, hoa_video::VIDEO_MENU_EXPAND_FROM_CENTER, hoa_video::VIDEO_MENU_INSTANT, hoa_video::VIDEO_MENU_SCROLL_TIME, hoa_video::VIDEO_MENU_STATE_HIDDEN, hoa_video::VIDEO_MENU_STATE_HIDING, hoa_video::VIDEO_MENU_STATE_SHOWING, hoa_video::VIDEO_MENU_STATE_SHOWN, hoa_video::VideoManager, and hoa_video::ScreenRect::width.

Referenced by hoa_boot::BootMenu::UpdateWindow(), and hoa_boot::CreditsScreen::UpdateWindow().

Here is the call graph for this function:


Friends And Related Function Documentation

friend class private_video::GUISupervisor [friend]

Definition at line 145 of file menu_window.h.


Member Data Documentation

VIDEO_MENU_DISPLAY_MODE hoa_video::MenuWindow::_display_mode [private]

The window's display mode (instant, expand from center, etc).

Definition at line 274 of file menu_window.h.

Referenced by GetDisplayMode(), Hide(), SetDisplayMode(), Show(), and Update().

int32 hoa_video::MenuWindow::_display_timer [private]

The number of milliseconds that have passed since the menu was shown.

Definition at line 268 of file menu_window.h.

Referenced by Hide(), Show(), and Update().

int32 hoa_video::MenuWindow::_edge_shared_flags [private]

Flags used to tell which edges are shared with other windows.

Definition at line 259 of file menu_window.h.

Referenced by _RecreateImage(), ChangeEdgeSharedFlags(), and Create().

int32 hoa_video::MenuWindow::_edge_visible_flags [private]

Flags used to tell which edges of the menu window are visible.

Definition at line 256 of file menu_window.h.

Referenced by _RecreateImage(), ChangeEdgeVisibleFlags(), and Create().

float hoa_video::MenuWindow::_height [private]

Definition at line 250 of file menu_window.h.

Referenced by _RecreateImage(), Create(), GetDimensions(), and Update().

int32 hoa_video::MenuWindow::_id [private]

The current id of this object.

Definition at line 247 of file menu_window.h.

Referenced by hoa_video::private_video::GUISupervisor::AddMenuWindow(), MenuWindow(), and hoa_video::private_video::GUISupervisor::RemoveMenuWindow().

float hoa_video::MenuWindow::_inner_height [private]

Definition at line 253 of file menu_window.h.

Referenced by _RecreateImage(), and Update().

float hoa_video::MenuWindow::_inner_width [private]

The dimensions of the space inside the window borders.

Definition at line 253 of file menu_window.h.

Referenced by _RecreateImage(), and Update().

bool hoa_video::MenuWindow::_is_scissored [private]

Set to true if scissoring needs to be used on the window.

Definition at line 277 of file menu_window.h.

Referenced by Draw(), and Update().

StillImage hoa_video::MenuWindow::_menu_image [private]

The image that creates the window.

Definition at line 271 of file menu_window.h.

Referenced by _RecreateImage(), Destroy(), and Draw().

ScreenRect hoa_video::MenuWindow::_scissor_rect [private]

The rectangle used for scissoring, set during each call to Update().

Definition at line 280 of file menu_window.h.

Referenced by Draw(), GetScissorRect(), and Update().

private_video::MenuSkin* hoa_video::MenuWindow::_skin [private]

A pointer to the menu skin that the menu window currently uses.

Definition at line 262 of file menu_window.h.

Referenced by _RecreateImage(), Create(), and Destroy().

float hoa_video::MenuWindow::_width [private]

The dimensions of the menu window, in pixels.

Definition at line 250 of file menu_window.h.

Referenced by _RecreateImage(), Create(), GetDimensions(), and Update().

VIDEO_MENU_STATE hoa_video::MenuWindow::_window_state [private]

The state of the menu window (hidden, shown, hiding, showing).

Definition at line 265 of file menu_window.h.

Referenced by Draw(), GetState(), Hide(), Show(), and Update().


The documentation for this class was generated from the following files:
Generated on Fri Jul 6 23:16:35 2007 for Hero of Allacrost by  doxygen 1.5.1