level titles can now be displayed in two lines
parent
b4c046bae2
commit
729518af7f
|
@ -620,7 +620,6 @@ void View::DrawUiLevelIntro() {
|
|||
int level_number_dest_x = (screen_right - screen_left) * 0.5 - 180;
|
||||
int level_number_dest_y = (screen_bottom - screen_top) * 0.5 - 60;
|
||||
|
||||
|
||||
int level_number_start_x = level_number_dest_x;
|
||||
int level_number_start_y = (screen_top);
|
||||
|
||||
|
@ -633,7 +632,7 @@ void View::DrawUiLevelIntro() {
|
|||
);
|
||||
|
||||
int level_title_dest_x = (screen_right - screen_left) * 0.5;
|
||||
int level_title_dest_y = (screen_bottom) * 0.5 - 0;
|
||||
int level_title_dest_y = (screen_bottom) * 0.5 - 36;
|
||||
|
||||
int level_title_start_x = (screen_right - screen_left) * 0.5;
|
||||
int level_title_start_y = (screen_bottom);
|
||||
|
@ -641,18 +640,49 @@ void View::DrawUiLevelIntro() {
|
|||
int level_title_delta_x = level_title_dest_x - level_title_start_x;
|
||||
int level_title_delta_y = level_title_dest_y - level_title_start_y;
|
||||
|
||||
SelectFont("console.ttf size=46 color=#808080");
|
||||
SelectFont("console.ttf size=46 color=#505050");
|
||||
|
||||
Engine::GUI::LabelCentered (21, GetModel()->GetLevelTitle().c_str(),
|
||||
std::string level_title = GetModel()->GetLevelTitle();
|
||||
|
||||
if (level_title.size() > 24) {
|
||||
// in that case we break up the level title in two lines
|
||||
|
||||
size_t first_line_end = level_title.find_last_of (" ", 24);
|
||||
std::string first_line = level_title.substr (0, first_line_end);
|
||||
std::string second_line = level_title.substr (first_line_end + 1, level_title.size());
|
||||
|
||||
Engine::GUI::LabelCentered (21, first_line.c_str(),
|
||||
level_title_dest_x - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_x - 2,
|
||||
level_title_dest_y - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_y + 2
|
||||
);
|
||||
|
||||
Engine::GUI::LabelCentered (21, second_line.c_str(),
|
||||
level_title_dest_x - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_x - 2,
|
||||
level_title_dest_y - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_y + 2 + 40
|
||||
);
|
||||
|
||||
SelectFont("console.ttf size=46 color=#ffffff");
|
||||
Engine::GUI::LabelCentered (22, first_line.c_str(),
|
||||
level_title_dest_x - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_x,
|
||||
level_title_dest_y - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_y
|
||||
);
|
||||
|
||||
Engine::GUI::LabelCentered (22, second_line.c_str(),
|
||||
level_title_dest_x - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_x,
|
||||
level_title_dest_y - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_y + 40
|
||||
);
|
||||
} else {
|
||||
Engine::GUI::LabelCentered (21, level_title.c_str(),
|
||||
level_title_dest_x - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_x - 2,
|
||||
level_title_dest_y - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_y + 2
|
||||
);
|
||||
|
||||
SelectFont("console.ttf size=46 color=#ffffff");
|
||||
Engine::GUI::LabelCentered (22, GetModel()->GetLevelTitle().c_str(),
|
||||
Engine::GUI::LabelCentered (22, level_title.c_str(),
|
||||
level_title_dest_x - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_x,
|
||||
level_title_dest_y - Engine::GetTimer("LevelIntroLevelTitle") * level_title_delta_y
|
||||
);
|
||||
}
|
||||
|
||||
SelectFont ("console.ttf size=23");
|
||||
|
||||
|
@ -662,6 +692,17 @@ void View::DrawUiLevelIntro() {
|
|||
int level_author_dest_x = (screen_right - screen_left) * 0.5 + 80;
|
||||
int level_author_dest_y = (screen_bottom - screen_top) * 0.5 + 20;
|
||||
|
||||
if (level_title.size() > 24) {
|
||||
level_author_dest_y += 40;
|
||||
}
|
||||
|
||||
// draw a greyish backround behind the title which can improve
|
||||
// readability
|
||||
glColor4f( 1., 1., 1., 0.1);
|
||||
DrawRect2D (screen_left, level_title_dest_y - 24,
|
||||
screen_right - screen_left,
|
||||
level_author_dest_y - level_title_dest_y - 4);
|
||||
|
||||
int level_author_start_x = screen_right;
|
||||
int level_author_start_y = level_author_dest_y;
|
||||
|
||||
|
@ -762,7 +803,12 @@ void View::DrawUiPlayerDied() {
|
|||
}
|
||||
} else {
|
||||
GetModel()->ReloadLevel();
|
||||
GetModel()->SetGameState(GameStateRunning);
|
||||
GetModel()->SetGameState(GameStatePaused);
|
||||
PushViewState(ViewStateLevelIntro);
|
||||
Engine::StartTimer ("LevelIntroLevelNumber", 0.4);
|
||||
Engine::StartTimer ("LevelIntroLevelTitle", 0.6);
|
||||
Engine::StartTimer ("LevelIntroLevelAuthor", 0.8);
|
||||
Engine::StartTimer ("LevelIntroLevelStart", 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -148,6 +148,8 @@ void LabelCentered (int id, const char* caption, int x, int y) {
|
|||
assert (view);
|
||||
|
||||
view->DrawGLStringMeasure(caption, &width, &height);
|
||||
height = fabs (height);
|
||||
width = fabs (width);
|
||||
view->DrawGLString(x - 0.5 * width, y + height * 0.5, caption);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ int SoundBase::OnInit(int argc, char* argv[]) {
|
|||
int audio_rate = 22050;
|
||||
Uint16 audio_format = AUDIO_S16;
|
||||
int audio_channels = 2;
|
||||
int audio_buffers = 2048;
|
||||
int audio_buffers = 4096;
|
||||
|
||||
LogDebug("Sound Init");
|
||||
if (Mix_OpenAudio (audio_rate, audio_format, audio_channels, audio_buffers)) {
|
||||
|
|
Loading…
Reference in New Issue