code for credits is finished
This commit is contained in:
@@ -31,6 +31,7 @@ BEGIN_ENUM(ViewState)
|
||||
DECL_ENUM_ELEMENT(ViewStateEnterPlayername),
|
||||
DECL_ENUM_ELEMENT(ViewStateEditor),
|
||||
DECL_ENUM_ELEMENT(ViewStateOptions),
|
||||
DECL_ENUM_ELEMENT(ViewStateCredits),
|
||||
DECL_ENUM_ELEMENT(ViewStateGameOver),
|
||||
DECL_ENUM_LAST(ViewState)
|
||||
}
|
||||
|
||||
+120
-1
@@ -83,6 +83,8 @@ int View::OnInit (int argc, char* argv[]) {
|
||||
|
||||
PushViewState (ViewStateMainMenu);
|
||||
|
||||
mCreditsPageIndex = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -446,6 +448,9 @@ void View::DrawUi () {
|
||||
case ViewStateEditor:
|
||||
DrawUiEditor();
|
||||
break;
|
||||
case ViewStateCredits:
|
||||
DrawUiCredits();
|
||||
break;
|
||||
default:
|
||||
Engine::LogWarning ("Trying to draw unknown ViewState: %s (%d)",
|
||||
GetStringViewState (game_state), game_state);
|
||||
@@ -494,6 +499,11 @@ void View::DrawUiMainMenu() {
|
||||
PushViewState(ViewStateShowHighscore);
|
||||
}
|
||||
|
||||
if (Engine::GUI::Button (4, "Credits", screen_right * 0.5 - 100, 350, button_width, button_height)) {
|
||||
mCreditsPageIndex = 0;
|
||||
PushViewState(ViewStateCredits);
|
||||
}
|
||||
|
||||
/*
|
||||
if (Engine::GUI::Button (6, "E", screen_right - 48, 20, 32, button_height)) {
|
||||
PushViewState(ViewStateEditor);
|
||||
@@ -501,7 +511,7 @@ void View::DrawUiMainMenu() {
|
||||
}
|
||||
*/
|
||||
|
||||
if (Engine::GUI::Button (4, "Quit", screen_right * 0.5 - 100, 380, button_width, button_height)) {
|
||||
if (Engine::GUI::Button (5, "Quit", screen_right * 0.5 - 100, 430, button_width, button_height)) {
|
||||
Engine::RunCommand("quit");
|
||||
}
|
||||
}
|
||||
@@ -747,6 +757,115 @@ void View::DrawUiOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
void View::DrawUiCredits() {
|
||||
// DrawPageTitle ("Credits");
|
||||
SelectFont ("console.ttf size=23");
|
||||
|
||||
static std::string credits_content (
|
||||
"_Programming,\r\
|
||||
_ Design, and Graphics\r\
|
||||
Martin Felis\r\
|
||||
\r\
|
||||
_Level Design\r\
|
||||
Martin Felis\r\
|
||||
\r\
|
||||
_Music\r\
|
||||
DJad - Space Exploration\r\
|
||||
\r\
|
||||
_Sounds\r\
|
||||
Marcus Zetterquist\r\
|
||||
\r\
|
||||
_Libraries\r\
|
||||
libSDL\r\
|
||||
SDL_mixer\r\
|
||||
OGLFT\r\
|
||||
freetype2\r\
|
||||
boost\r\
|
||||
libpng\r\
|
||||
\r\
|
||||
_Tools\r\
|
||||
GIMP\r\
|
||||
Blender\r\
|
||||
CMake\r\
|
||||
\r\
|
||||
_Special Thanks\r\
|
||||
to my wonderful wife Katrina\r\
|
||||
\r\
|
||||
\r\
|
||||
\r\
|
||||
\r\
|
||||
\r\
|
||||
\r\
|
||||
_http://www.fysx.org\r\
|
||||
\r\
|
||||
\r\
|
||||
\r\
|
||||
\r\
|
||||
\r\
|
||||
\r\
|
||||
\r\
|
||||
:created with vim.\r\
|
||||
::wq\r\
|
||||
\r\
|
||||
EOF\r\
|
||||
");
|
||||
static float page_duration = 4.;
|
||||
static float page_draw_duration = page_duration;
|
||||
|
||||
if (page_draw_duration < 0.) {
|
||||
mCreditsPageIndex ++;
|
||||
page_draw_duration = page_duration;
|
||||
}
|
||||
|
||||
stringstream credits_stream (credits_content);
|
||||
std::string line;
|
||||
|
||||
float xpos = 270, ypos = 200.f;
|
||||
float dy = 20.f;
|
||||
|
||||
unsigned int index = 0;
|
||||
bool first_content_line = false;
|
||||
while (getline (credits_stream, line, '\r')) {
|
||||
if (line.size() == 0) {
|
||||
index ++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (index == mCreditsPageIndex) {
|
||||
if (line[0] == '_') {
|
||||
SelectFont ("console.ttf size=23 color=#e8d500");
|
||||
line = line.substr (1, line.size());
|
||||
first_content_line = true;
|
||||
} else if (line[0] == ':') {
|
||||
SelectFont ("console.ttf size=23 color=#ffffff");
|
||||
line = line.substr (1, line.size());
|
||||
} else {
|
||||
if (first_content_line) {
|
||||
ypos += 20;
|
||||
first_content_line = false;
|
||||
}
|
||||
SelectFont ("console.ttf size=23 color=#ffffff");
|
||||
}
|
||||
|
||||
DrawGLString (xpos, ypos, line.c_str());
|
||||
ypos += dy;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (index == mCreditsPageIndex && line == std::string("EOF")) {
|
||||
PopViewState();
|
||||
}
|
||||
}
|
||||
|
||||
page_draw_duration -= Engine::GetFrameDuration();
|
||||
|
||||
if (Engine::GUI::CheckKeyPressed(SDLK_ESCAPE)
|
||||
|| Engine::GUI::CheckKeyPressed(SDLK_SPACE) ) {
|
||||
PopViewState();
|
||||
}
|
||||
}
|
||||
|
||||
void View::DrawUiEnterPlayername() {
|
||||
DrawPageTitle ("Asteroids");
|
||||
SelectFont ("console.ttf size=23");
|
||||
|
||||
+7
-2
@@ -56,7 +56,8 @@ class View : public Engine::ViewBase {
|
||||
if (mViewStateStack.size() > 0)
|
||||
current_name = GetStringViewState(mViewStateStack.top());
|
||||
|
||||
Engine::LogDebug("Popped ViewState: %s current %s remaining: %u", popped_name.c_str(), current_name.c_str(), mViewStateStack.size());
|
||||
Engine::LogDebug("Popped ViewState: %s current %s remaining: %u",
|
||||
popped_name.c_str(), current_name.c_str(), mViewStateStack.size());
|
||||
|
||||
if (mViewStateStack.size() == 0) {
|
||||
Engine::LogDebug ("No ViewState on the stack! Quitting.");
|
||||
@@ -88,10 +89,12 @@ class View : public Engine::ViewBase {
|
||||
void DrawUiLevelComplete();
|
||||
void DrawUiGamePaused();
|
||||
void DrawUiPlayerDied();
|
||||
void DrawHighscoreEntry(float x, float y, float entry_width, const std::string &name, unsigned int points);
|
||||
void DrawHighscoreEntry(float x, float y, float entry_width,
|
||||
const std::string &name, unsigned int points);
|
||||
void DrawUiHighscore();
|
||||
void DrawUiOptions();
|
||||
void DrawUiEnterPlayername();
|
||||
void DrawUiCredits();
|
||||
|
||||
void DrawUiEditor();
|
||||
|
||||
@@ -154,6 +157,8 @@ class View : public Engine::ViewBase {
|
||||
EditorState mEditorState;
|
||||
unsigned int mEditorEntityId;
|
||||
|
||||
unsigned int mCreditsPageIndex;
|
||||
|
||||
/// \brief can be used to perform some fading, etc.
|
||||
float mFadeTimerSecValue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user