asking now whether online highscore mode should be used
parent
55b7c383af
commit
980f55955d
|
@ -21,6 +21,8 @@ static Model* ModelInstance = NULL;
|
|||
Engine::Variable Model::HighscoreServerName ("highscore_server_name", "asteroids.fysx.org");
|
||||
Engine::Variable Model::HighscoreServerPath ("highscore_server_path", "/highscore/highscore.php?format=raw");
|
||||
Engine::Variable Model::UseServerHighscore ("use_server_highscore", "false");
|
||||
// makes sure we have asked whether the player wants to submit the highscore data
|
||||
Engine::Variable Model::UseServerHighscoreAsked ("use_server_highscore_asked", "false");
|
||||
|
||||
/*
|
||||
* Inherited Module functions
|
||||
|
@ -83,6 +85,7 @@ int Model::OnInit (int argc, char* argv[]) {
|
|||
mLevelTitle = "";
|
||||
mLevelName = "";
|
||||
mLevelParTimeSeconds = -1.f;
|
||||
mPoints = 0;
|
||||
|
||||
// initialize SDL_net to be able to retrieve highscore from the internet
|
||||
if (SDLNet_Init() == -1) {
|
||||
|
|
|
@ -975,7 +975,65 @@ void View::DrawHighscoreEntry (float x, float y, float entry_width, const std::s
|
|||
Engine::DrawGLString ( x + entry_width - points_value_width, y, points_value_stream.str().c_str());
|
||||
}
|
||||
|
||||
bool View::DrawUiAskOnlineHighscore() {
|
||||
// DrawPageTitle but centered:
|
||||
SelectFont("console.ttf size=46 color=#808080");
|
||||
|
||||
float xpos = (screen_right) * 0.5;
|
||||
float ypos = 180;
|
||||
|
||||
Engine::GUI::LabelCentered (0, "Use online highscores?", xpos, ypos);
|
||||
|
||||
|
||||
xpos = screen_right * 0.5;
|
||||
ypos = screen_bottom * 0.5 - 40;
|
||||
|
||||
SelectFont("console.ttf size=23 color=#ffffff");
|
||||
|
||||
Engine::GUI::LabelCentered (0, "Submit your score to the global", xpos, ypos);
|
||||
ypos += 20;
|
||||
Engine::GUI::LabelCentered (0, "highscore list and compete against", xpos, ypos);
|
||||
ypos += 20;
|
||||
Engine::GUI::LabelCentered (0, "the best fysxasteroids players?", xpos, ypos);
|
||||
ypos += 30;
|
||||
Engine::GUI::LabelCentered (0, "You can change your decision later", xpos, ypos);
|
||||
ypos += 20;
|
||||
Engine::GUI::LabelCentered (0, "in the options menu. ", xpos, ypos);
|
||||
|
||||
ypos += 48;
|
||||
|
||||
if (Engine::GUI::Button (1, "Yes", screen_right * 0.5 - 60 - button_width, ypos, button_width, button_height)
|
||||
|| Engine::GUI::CheckKeyPressed(SDLK_ESCAPE) ) {
|
||||
// Remove the ViewStateGameRunning
|
||||
Engine::SetVariableValue (std::string("use_server_highscore"), std::string("yes"));
|
||||
Engine::SetVariableValue ("use_server_highscore_asked", "yes");
|
||||
|
||||
// submit the highscore if there are any points
|
||||
if (GetModel()->GetPoints() > 0)
|
||||
GetModel()->SubmitHighscoreEntry(GetModel()->GetPlayerName(), GetModel()->GetPoints());
|
||||
|
||||
GetModel()->LoadHighscoreList();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Engine::GUI::Button (2, "No", screen_right * 0.5 + 60, ypos, button_width, button_height)
|
||||
|| Engine::GUI::CheckKeyPressed(SDLK_ESCAPE) ) {
|
||||
// Remove the ViewStateGameRunning
|
||||
Engine::SetVariableValue (std::string("use_server_highscore"), std::string("no"));
|
||||
Engine::SetVariableValue ("use_server_highscore_asked", "yes");
|
||||
GetModel()->LoadHighscoreList();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void View::DrawUiHighscore() {
|
||||
if (!Engine::GetVariableBool("use_server_highscore_asked")) {
|
||||
DrawUiAskOnlineHighscore();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// DrawPageTitle but centered:
|
||||
SelectFont("console.ttf size=46 color=#808080");
|
||||
|
||||
|
@ -986,7 +1044,7 @@ void View::DrawUiHighscore() {
|
|||
float ypos = 180;
|
||||
DrawGLString (xpos, ypos, "Highscores");
|
||||
SelectFont("console.ttf size=46 color=#ffffff");
|
||||
DrawGLString (xpos, ypos, "Highscores");
|
||||
DrawGLString (xpos + 2, ypos - 2, "Highscores");
|
||||
|
||||
if (GetModel()->GetHighscoreIsOnline()) {
|
||||
SelectFont("console.ttf size=23 color=#887500");
|
||||
|
@ -1226,7 +1284,7 @@ EOF\r\
|
|||
}
|
||||
|
||||
void View::DrawUiEnterPlayername() {
|
||||
DrawPageTitle ("Asteroids");
|
||||
DrawPageTitle ("New Game");
|
||||
SelectFont ("console.ttf size=23");
|
||||
|
||||
// Enter your name
|
||||
|
|
|
@ -96,6 +96,7 @@ class View : public Engine::ViewBase {
|
|||
void DrawUiPlayerDied();
|
||||
void DrawHighscoreEntry(float x, float y, float entry_width,
|
||||
const std::string &name, unsigned int points);
|
||||
bool DrawUiAskOnlineHighscore();
|
||||
void DrawUiHighscore();
|
||||
void DrawUiOptions();
|
||||
void DrawUiEnterPlayername();
|
||||
|
|
|
@ -150,7 +150,7 @@ int main (int argc, char* argv[]) {
|
|||
else
|
||||
SDL_WM_SetIcon(image,NULL);
|
||||
|
||||
SDL_WM_SetCaption("fysxasteroids -RC 1-","fysxasteroids -RC 1-");
|
||||
SDL_WM_SetCaption("fysxasteroids -RC2-","fysxasteroids -RC2-");
|
||||
|
||||
engine.GetView()->SetGridSize (8,8);
|
||||
|
||||
|
@ -179,6 +179,8 @@ int main (int argc, char* argv[]) {
|
|||
config_file << "set effects_volume " << Engine::GetEffectsVolume() << std::endl;
|
||||
config_file << "set music_volume " << Engine::GetMusicVolume() << std::endl;
|
||||
config_file << "set use_server_highscore " << Engine::GetVariableString("use_server_highscore") << std::endl;
|
||||
config_file << "set use_server_highscore_asked " << Engine::GetVariableString ("use_server_highscore_asked") << std::endl;
|
||||
|
||||
if (Engine::GetVariableBool("cheat_mode"))
|
||||
config_file << "set cheat_mode " << true << std::endl;
|
||||
config_file.close();
|
||||
|
|
|
@ -126,7 +126,7 @@ Variable* GetVariable (const std::string &name) {
|
|||
return VariablesInstance->GetVariable (name);
|
||||
}
|
||||
|
||||
bool SetVariableValue (const std::string &name, const std::string value) {
|
||||
bool SetVariableValue (const std::string &name, const std::string &value) {
|
||||
if (! VariablesInstance ) {
|
||||
LogError ("Unable to set Variable '%s': Variables System not initialized!", name.c_str());
|
||||
return false;
|
||||
|
@ -138,6 +138,7 @@ bool SetVariableValue (const std::string &name, const std::string value) {
|
|||
}
|
||||
|
||||
var->SetStringValue (value);
|
||||
var->SetBoolValueFromString (value);
|
||||
var->SetFloatValue (atof (value.c_str()));
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue