boot_welcome.cpp

Go to the documentation of this file.
00001 
00002 //            Copyright (C) 2004-2007 by The Allacrost Project
00003 //                         All Rights Reserved
00004 //
00005 // This code is licensed under the GNU GPL version 2. It is free software 
00006 // and you may modify it and/or redistribute it under the terms of this license.
00007 // See http://www.gnu.org/copyleft/gpl.html for details.
00009 
00016 #include "video.h"
00017 #include "script.h"
00018 
00019 #include "boot_welcome.h"
00020 
00021 using namespace std;
00022 
00023 using namespace hoa_utils;
00024 using namespace hoa_video;
00025 using namespace hoa_script;
00026 
00027 namespace hoa_boot {
00028 
00029 WelcomeScreen::WelcomeScreen() :
00030   _visible(false),
00031   _welcome_rendered(NULL),
00032   _welcome_text(
00033 "If you have not read the MANUAL, the game controls follow:\n\
00034     (press any key to continue)\n\
00035 \n\
00036 \n\
00037 \n\
00038 Command Name    Default Key Map    General Purpose                                                            \n\
00039 Up                  'up arrow'            Move sprite or cursor upwards                                        \n\
00040 Down               'down arrow'       Move sprite or cursor downwards                                      \n\
00041 Left                 'left arrow'         Move sprite or cursor to the left                                       \n\
00042 Right               'right arrow'        Move sprite or cursor to the right                                     \n\
00043 Confirm             'f'                     Confirm an action or menu command                                   \n\
00044 Cancel              'd'                     Cancel an action or menu command                                     \n\
00045 Menu                's'                     Display the main menu                                                    \n\
00046 Swap                'a'                     Swap the character being displayed                                     \n\
00047 Left Select         'w'                     Select multiple targets or page scroll up                             \n\
00048 Right Select        'e'                     Select multiple targets or page scroll down                          \n\
00049 Pause               'spacebar'            Pause/unpause the game                                                   \n\
00050 Quit                'ESC'                 Quit the game                                                            \n\
00051 Fullscreen          'Ctrl+f'              Toggles between full screen mode and windowed mode              \n\
00052 Quit                'Ctrl+q'              Quit the game                                                           \n\
00053 FPS Display         'Ctrl+r'       Toggles display of the frames per second in the upper right hand corner\n\
00054 Screenshot         'Ctrl+s'              Takes a screenshot and saves it to 'screenshot.jpg'                    ")
00055 
00056 {
00057   // Init the background window
00058   _window.Create(1024.0f, 600.0f);
00059   _window.SetPosition(0.0f, 630.0f);
00060   _window.Hide();
00061 }
00062 
00063 
00064 WelcomeScreen::~WelcomeScreen()
00065 {
00066   _window.Destroy();
00067   if (_welcome_rendered != NULL) {
00068     delete(_welcome_rendered);
00069     _welcome_rendered = NULL;
00070   }
00071 }
00072 
00073 
00074 // Draws the welcome window on the screen if it is set visible
00075 void WelcomeScreen::Draw()
00076 {
00077   // Draw the background window
00078   _window.Draw();
00079     
00080   if (_window.GetState() != VIDEO_MENU_STATE_SHOWN) // Don't draw any text until the window is ready for drawing
00081     return;
00082 
00083   // Set clip region for the text and draw the visible part of it
00084   VideoManager->Move(512.0f, 450.0f);
00085   if (_welcome_rendered) {
00086     _welcome_rendered->Draw();
00087   }
00088 }
00089 
00090 
00091 // Shows the welcome window
00092 void WelcomeScreen::Show()
00093 {
00094   _window.Show();
00095   _visible = true;
00096   VideoManager->SetFont("default"); // Reset font
00097 
00098   if (!_welcome_rendered) {
00099     _welcome_rendered = VideoManager->RenderText(MakeUnicodeString(_welcome_text));
00100     if (!_welcome_rendered) {
00101       cerr << "BOOT ERROR: failed to render the welcome string.\n" << endl;
00102       exit(1);
00103     }
00104   }
00105 }
00106 
00107 
00108 // Hides the welcome window
00109 void WelcomeScreen::Hide()
00110 {
00111   _window.Hide();
00112   _visible = false;
00113   VideoManager->SetTextColor(Color::white); // Reset text color
00114   if (_welcome_rendered) {
00115     delete(_welcome_rendered);
00116     _welcome_rendered = NULL;
00117   }
00118 }
00119 
00120 
00121 // Returns true if the welcome window is set visible at the moment
00122 bool WelcomeScreen::IsVisible()
00123 {
00124   return _visible;
00125 }
00126 
00127 
00128 } // end hoa_boot

Generated on Fri Jul 6 23:11:11 2007 for Hero of Allacrost by  doxygen 1.5.1