1 ///////////////////////////////////////////////////////////////////////////////
2 //            Copyright (C) 2004-2010 by The Allacrost Project
3 //                         All Rights Reserved
4 //
5 // This code is licensed under the GNU GPL version 2. It is free software
6 // and you may modify it and/or redistribute it under the terms of this license.
7 // See http://www.gnu.org/copyleft/gpl.html for details.
8 ///////////////////////////////////////////////////////////////////////////////
9 
10 /** ****************************************************************************
11 *** \file    boot_welcome.cpp
12 *** \author  Philip Vorsilak, gorzuate@allacrost.org
13 *** \brief   Source file for the boot welcome window
14 *** ***************************************************************************/
15 
16 #include "system.h"
17 
18 #include "boot_welcome.h"
19 
20 using namespace std;
21 
22 using namespace hoa_utils;
23 using namespace hoa_video;
24 using namespace hoa_gui;
25 using namespace hoa_script;
26 using namespace hoa_system;
27 
28 namespace hoa_boot {
29 
30 namespace private_boot {
31 
32 // *****************************************************************************
33 // ***** WelcomeWindow class methods
34 // *****************************************************************************
35 
WelcomeWindow()36 WelcomeWindow::WelcomeWindow() :
37 	_active(false)
38 {
39 	_window.Create(880.0f, 640.0f);
40 	_window.SetPosition(512.0f, 384.0f);
41 	_window.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
42 
43 	_text_header.SetStyle(TextStyle("text20"));
44 	_text_header.SetText(UTranslate("The table below lists the default game controls.\n") +
45 		UTranslate("The control mappings can be changed in the options menu on the next screen."));
46 
47 	_key_table_header.SetOwner(&_window);
48 	_key_table_header.SetPosition(50.0f, 540.0f);
49 	_key_table_header.SetDimensions(600.0f, 30.0f, 3, 1, 3, 1);
50 	_key_table_header.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
51 	_key_table_header.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
52 	_key_table_header.SetTextStyle(TextStyle("title24"));
53 	_key_table_header.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
54 
55 	_key_table_header.AddOption(UTranslate("Command"));
56 	_key_table_header.AddOption(UTranslate("Default Key"));
57 	_key_table_header.AddOption(UTranslate("General Purpose"));
58 
59 	_key_table.SetOwner(&_window);
60 	_key_table.SetPosition(50.0f, 500.0f);
61 	_key_table.SetDimensions(600.0f, 380.0f, 3, 12, 3, 12);
62 	_key_table.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
63 	_key_table.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
64 	_key_table.SetTextStyle(TextStyle("text22"));
65 	_key_table.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
66 
67 	_key_table.AddOption(UTranslate("Up"));
68 	_key_table.AddOption(UTranslate("Up Arrow"));
69 	_key_table.AddOption(UTranslate("Move position or cursor upwards"));
70 	_key_table.AddOption(UTranslate("Down"));
71 	_key_table.AddOption(UTranslate("Down Arrow"));
72 	_key_table.AddOption(UTranslate("Move position or cursor downwards"));
73 	_key_table.AddOption(UTranslate("Left"));
74 	_key_table.AddOption(UTranslate("Left Arrow"));
75 	_key_table.AddOption(UTranslate("Move position or cursor to the left"));
76 	_key_table.AddOption(UTranslate("Right"));
77 	_key_table.AddOption(UTranslate("Right Arrow"));
78 	_key_table.AddOption(UTranslate("Move position or cursor to the right"));
79 	_key_table.AddOption(UTranslate("Confirm"));
80 	_key_table.AddOption(UTranslate("F"));
81 	_key_table.AddOption(UTranslate("Confirm an action or menu command"));
82 	_key_table.AddOption(UTranslate("Cancel"));
83 	_key_table.AddOption(UTranslate("D"));
84 	_key_table.AddOption(UTranslate("Cancel an action or menu command"));
85 	_key_table.AddOption(UTranslate("Menu"));
86 	_key_table.AddOption(UTranslate("S"));
87 	_key_table.AddOption(UTranslate("Display the character menu"));
88 	_key_table.AddOption(UTranslate("Swap"));
89 	_key_table.AddOption(UTranslate("A"));
90 	_key_table.AddOption(UTranslate("Swaps active menu or character"));
91 	_key_table.AddOption(UTranslate("Left Select"));
92 	_key_table.AddOption(UTranslate("W"));
93 	_key_table.AddOption(UTranslate("Select multiple or backward page scroll"));
94 	_key_table.AddOption(UTranslate("Right Select"));
95 	_key_table.AddOption(UTranslate("E"));
96 	_key_table.AddOption(UTranslate("Select multiple or forward page scroll"));
97 	_key_table.AddOption(UTranslate("Pause"));
98 	_key_table.AddOption(UTranslate("Spacebar"));
99 	_key_table.AddOption(UTranslate("Pauses the game"));
100 	_key_table.AddOption(UTranslate("Quit"));
101 	_key_table.AddOption(UTranslate("Esc"));
102 	_key_table.AddOption(UTranslate("Quit the application"));
103 
104 	_text_additional.SetStyle(TextStyle("text20"));
105 	_text_additional.SetText(UTranslate("There are additional commands available which can be found in the MANUAL file."));
106 
107 	_text_continue.SetStyle(TextStyle("title24"));
108 	_text_continue.SetText(UTranslate("Press any key to continue."));
109 } // WelcomeWindow::WelcomeWindow()
110 
111 
112 
~WelcomeWindow()113 WelcomeWindow::~WelcomeWindow() {
114 	_window.Destroy();
115 }
116 
117 
118 
Update()119 void WelcomeWindow::Update() {
120 	if (IsActive() == false)
121 		return;
122 
123 	_window.Update();
124 	// TODO: hide window if any key is pressed
125 }
126 
127 
128 
Draw()129 void WelcomeWindow::Draw() {
130 	// Draw the background window
131 	_window.Draw();
132 
133 	// Don't draw any contents of the window until the window is fully shown
134 	if (_window.GetState() != VIDEO_MENU_STATE_SHOWN)
135 		return;
136 
137 	// Draw the window contents, starting from the top and moving downward
138 	VideoManager->PushState();
139 	VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_TOP, 0);
140 	VideoManager->Move(512.0f, 675.0f);
141 	_text_header.Draw();
142 
143 	_key_table_header.Draw();
144 	_key_table.Draw();
145 
146 	VideoManager->Move(512.0f, 150.0f);
147 	_text_additional.Draw();
148 	VideoManager->MoveRelative(0.0f, -30.0f);
149 	_text_continue.Draw();
150 	VideoManager->PopState();
151 }
152 
153 
154 
Show()155 void WelcomeWindow::Show() {
156 	_active = true;
157 	_window.Show();
158 }
159 
160 
161 
Hide()162 void WelcomeWindow::Hide() {
163 	_active = false;
164 	_window.Hide();
165 }
166 
167 } // namespace private_boot
168 
169 } // namespace hoa_boot
170