hide and disable buttons and labels on the main menu when not available as options
This commit is contained in:
parent
18fb61c236
commit
caa6186727
32
config.json
32
config.json
|
@ -171,35 +171,35 @@
|
|||
"resume translation": [0.0, 0.25],
|
||||
"reset text": "RESET",
|
||||
"reset translation": [0.0, -0.25],
|
||||
"level decrement translation": [-0.67, -0.6],
|
||||
"level decrement translation": [-0.67, -0.71],
|
||||
"level decrement text": "<",
|
||||
"level decrement dimensions": [40.0, 40.0],
|
||||
"level increment translation": [0.67, -0.6],
|
||||
"level increment translation": [0.67, -0.71],
|
||||
"level increment text": ">",
|
||||
"level select translation": [0.0, -0.6],
|
||||
"level select translation": [0.0, -0.71],
|
||||
"level select dimensions": [350.0, 22.0],
|
||||
"level select scale": [0.63, 0.04],
|
||||
"level select scale": [0.71, 0.04],
|
||||
"level select text": "LEVEL ",
|
||||
"profile translation": [0.0, -0.71],
|
||||
"profile translation": [0.0, -0.82],
|
||||
"profile dimensions": [320.0, 22.0],
|
||||
"profile scale": [0.63, 0.04],
|
||||
"profile text": "DIFFICULTY: ",
|
||||
"profile scale": [0.71, 0.04],
|
||||
"profile text": "",
|
||||
"profile decrement text": "<",
|
||||
"profile decrement translation": [-0.67, -0.71],
|
||||
"profile decrement translation": [-0.67, -0.82],
|
||||
"profile increment text": ">",
|
||||
"profile increment translation": [0.67, -0.71],
|
||||
"challenge text": "CHALLENGE: ",
|
||||
"challenge translation": [0.0, -0.82],
|
||||
"profile increment translation": [0.67, -0.82],
|
||||
"challenge text": "",
|
||||
"challenge translation": [0.0, -0.6],
|
||||
"challenge dimensions": [320.0, 22.0],
|
||||
"challenge scale": [0.63, 0.04],
|
||||
"challenge scale": [0.71, 0.04],
|
||||
"challenge decrement text": "<",
|
||||
"challenge decrement translation": [-0.67, -0.82],
|
||||
"challenge decrement translation": [-0.67, -0.6],
|
||||
"challenge increment text": ">",
|
||||
"challenge increment translation": [0.67, -0.82],
|
||||
"view text": "VIEW: ",
|
||||
"challenge increment translation": [0.67, -0.6],
|
||||
"view text": "",
|
||||
"view translation": [0.0, -0.925],
|
||||
"view dimensions": [320.0, 22.0],
|
||||
"view scale": [0.63, 0.04],
|
||||
"view scale": [0.71, 0.04],
|
||||
"view decrement text": "<",
|
||||
"view decrement translation": [-0.67, -0.925],
|
||||
"view increment text": ">",
|
||||
|
|
|
@ -154,7 +154,6 @@
|
|||
_main();
|
||||
}
|
||||
});
|
||||
collectData();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
2
lib/sb
2
lib/sb
|
@ -1 +1 @@
|
|||
Subproject commit a91bc4b773a0938f4f3984ce78d48d9ba70dec73
|
||||
Subproject commit 333a7b73ac7a20aa39de2241effcd3549273c9b6
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
|
||||
"levels": [
|
||||
{
|
||||
"curve": [
|
||||
|
|
|
@ -20,9 +20,12 @@ Cakefoot::Cakefoot()
|
|||
configuration().merge(levels_file_path);
|
||||
|
||||
/* Load scores */
|
||||
for (nlohmann::json score : Configuration::json_from_file(arcade_scores_file_path))
|
||||
if (fs::exists(arcade_scores_file_path))
|
||||
{
|
||||
arcade_scores.add(ArcadeScores::Score(score.at("time"), score.at("distance"), score.at("name")));
|
||||
for (nlohmann::json score : Configuration::json_from_file(arcade_scores_file_path))
|
||||
{
|
||||
arcade_scores.add(ArcadeScores::Score(score.at("time"), score.at("distance"), score.at("name")));
|
||||
}
|
||||
}
|
||||
|
||||
/* Add default progress data */
|
||||
|
@ -32,7 +35,7 @@ Cakefoot::Cakefoot()
|
|||
{"current difficulty", 0},
|
||||
{"max difficulty", 0},
|
||||
{"current challenge", 1},
|
||||
{"max challenge", 3},
|
||||
{"max challenge", 4},
|
||||
{"current view", 0},
|
||||
{"max view", 0},
|
||||
{"deaths", 0},
|
||||
|
@ -61,6 +64,7 @@ Cakefoot::Cakefoot()
|
|||
if (!progress.at("progress").contains("quest level"))
|
||||
{
|
||||
configuration()["progress"]["quest level"] = progress.at("progress").at("current level");
|
||||
configuration()["progress"]["current challenge"] = 0;
|
||||
}
|
||||
if (!progress.at("progress").contains("quest checkpoint"))
|
||||
{
|
||||
|
@ -85,6 +89,13 @@ Cakefoot::Cakefoot()
|
|||
configuration()["progress"]["current level"] = 1;
|
||||
}
|
||||
|
||||
/* Enforce max challenge to 4 */
|
||||
configuration()["progress"]["max challenge"] = 4;
|
||||
if (configuration()("progress", "current challenge") > 4)
|
||||
{
|
||||
configuration()["progress"]["current challenge"] = 4;
|
||||
}
|
||||
|
||||
/* Set the spinner values to what the player was last playing. */
|
||||
level_select_index = configuration()("progress", "current level");
|
||||
profile_index = configuration()("progress", "current difficulty");
|
||||
|
@ -577,11 +588,7 @@ void Cakefoot::set_up_buttons()
|
|||
if (!configuration()("display", "arcade only"))
|
||||
{
|
||||
if (--challenge_index < 0) challenge_index = configuration()("progress", "max challenge");
|
||||
bool skip_resume_quest = configuration()("challenge", challenge_index, "name") == "RESUME QUEST" && configuration()("progress", "quest level") == 1 &&
|
||||
configuration()("progress", "quest checkpoint") == 0.0f;
|
||||
bool skip_resume_arcade = configuration()("challenge", challenge_index, "name") == "RESUME ARCADE" && configuration()("progress", "arcade level") == 1 &&
|
||||
configuration()("progress", "arcade checkpoint") == 0.0f;
|
||||
if (skip_resume_quest || skip_resume_arcade)
|
||||
if (skip_resume_quest() || skip_resume_arcade() || skip_level_select())
|
||||
{
|
||||
button.at("challenge decrement").press();
|
||||
}
|
||||
|
@ -596,11 +603,7 @@ void Cakefoot::set_up_buttons()
|
|||
if (!configuration()("display", "arcade only"))
|
||||
{
|
||||
if (++challenge_index > configuration()("progress", "max challenge")) challenge_index = 0;
|
||||
bool skip_resume_quest = configuration()("challenge", challenge_index, "name") == "RESUME QUEST" && configuration()("progress", "quest level") == 1 &&
|
||||
configuration()("progress", "quest checkpoint") == 0.0f;
|
||||
bool skip_resume_arcade = configuration()("challenge", challenge_index, "name") == "RESUME ARCADE" && configuration()("progress", "arcade level") == 1 &&
|
||||
configuration()("progress", "arcade checkpoint") == 0.0f;
|
||||
if (skip_resume_quest || skip_resume_arcade)
|
||||
if (skip_resume_quest() || skip_resume_arcade() || skip_level_select())
|
||||
{
|
||||
button.at("challenge increment").press();
|
||||
}
|
||||
|
@ -721,6 +724,7 @@ void Cakefoot::toggle_challenge()
|
|||
}
|
||||
|
||||
configuration()["progress"]["current challenge"] = challenge_index;
|
||||
configuration()["progress"]["current level"] = level_select_index;
|
||||
write_progress();
|
||||
set_up_buttons();
|
||||
}
|
||||
|
@ -740,7 +744,7 @@ void Cakefoot::set_up_hud()
|
|||
if (static_cast<std::size_t>(level_index) == _configuration("levels").size() - 1)
|
||||
{
|
||||
label.at("clock").font(large_font);
|
||||
if (configuration()("challenge", challenge_index).contains("time limit"))
|
||||
if (arcade())
|
||||
{
|
||||
/* Arcade results size */
|
||||
clock_scale = configuration()("display", "arcade time remaining scale");
|
||||
|
@ -1292,7 +1296,7 @@ int Cakefoot::distance() const
|
|||
|
||||
float Cakefoot::limit() const
|
||||
{
|
||||
if (configuration()("challenge", challenge_index).contains("time limit"))
|
||||
if (arcade())
|
||||
{
|
||||
float limit = configuration()("challenge", challenge_index, "time limit");
|
||||
|
||||
|
@ -1338,6 +1342,11 @@ bool Cakefoot::level_select() const
|
|||
return !arcade() && configuration()("challenge", challenge_index, "name") == "LEVEL SELECT";
|
||||
}
|
||||
|
||||
bool Cakefoot::resuming() const
|
||||
{
|
||||
return configuration()("challenge", challenge_index, "name") == "RESUME QUEST" || configuration()("challenge", challenge_index, "name") == "RESUME ARCADE";
|
||||
}
|
||||
|
||||
void Cakefoot::collect_coin(bool add_to_bank)
|
||||
{
|
||||
if (!coin_collected)
|
||||
|
@ -1495,7 +1504,7 @@ void Cakefoot::respond(SDL_Event& event)
|
|||
{
|
||||
if (!configuration()("display", "arcade only") || name == "start")
|
||||
{
|
||||
if (button.at(name).collide(mouse_ndc, view, projection))
|
||||
if (button.at(name).enabled() && button.at(name).collide(mouse_ndc, view, projection))
|
||||
{
|
||||
hovering = true;
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN)
|
||||
|
@ -1533,8 +1542,7 @@ void Cakefoot::respond(SDL_Event& event)
|
|||
} } }
|
||||
|
||||
/* Collide with name entry in arcade mode on end screen */
|
||||
else if (static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1 &&
|
||||
configuration()("challenge", challenge_index).contains("time limit"))
|
||||
else if (static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1 && arcade())
|
||||
{
|
||||
for (const std::string& button_name : {std::string("name 1"), std::string("name 2"), std::string("name 3"),
|
||||
"name " + std::to_string(name_entry_index + 1) + " increment",
|
||||
|
@ -1778,8 +1786,7 @@ void Cakefoot::update(float timestamp)
|
|||
}
|
||||
|
||||
/* End run if there is a time limit and the time limit is passed. Queue end level to load after a delay. */
|
||||
bool game_over_active = configuration()("challenge", challenge_index).contains("time limit") && run_timer.elapsed() > extended_limit &&
|
||||
static_cast<std::size_t>(level_index) < configuration()("levels").size() - 1;
|
||||
bool game_over_active = arcade() && run_timer.elapsed() > extended_limit && static_cast<std::size_t>(level_index) < configuration()("levels").size() - 1;
|
||||
if (game_over_active && !game_over_animation.playing())
|
||||
{
|
||||
/* Play once with a delay to let the game over screen display temporarily before the end level is loaded. */
|
||||
|
@ -1821,8 +1828,7 @@ void Cakefoot::update(float timestamp)
|
|||
if (character.at_end(curve()))
|
||||
{
|
||||
/* On the end level, save the score and name entry. */
|
||||
if (configuration()("challenge", challenge_index).contains("time limit") &&
|
||||
static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1)
|
||||
if (arcade() && static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1)
|
||||
{
|
||||
submit_score();
|
||||
}
|
||||
|
@ -1960,6 +1966,23 @@ void Cakefoot::update(float timestamp)
|
|||
/* Draw cake */
|
||||
character.draw(curve(), uniform["mvp"], view * rotation_matrix, projection, uniform["texture enabled"]);
|
||||
|
||||
/* Check if any buttons should be disabled */
|
||||
bool profile_spinner_enabled = configuration()("progress", "max difficulty") > 0 && !resuming();
|
||||
bool profile_spinner_visible = configuration()("progress", "max difficulty") > 0;
|
||||
bool view_spinner_enabled = configuration()("progress", "max view") > 0;
|
||||
button.at("level decrement").visible(level_select());
|
||||
button.at("level decrement").enabled(level_select());
|
||||
button.at("level increment").visible(level_select());
|
||||
button.at("level increment").enabled(level_select());
|
||||
button.at("profile decrement").visible(profile_spinner_enabled);
|
||||
button.at("profile decrement").enabled(profile_spinner_enabled);
|
||||
button.at("profile increment").visible(profile_spinner_enabled);
|
||||
button.at("profile increment").enabled(profile_spinner_enabled);
|
||||
button.at("view decrement").enabled(view_spinner_enabled);
|
||||
button.at("view decrement").visible(view_spinner_enabled);
|
||||
button.at("view increment").enabled(view_spinner_enabled);
|
||||
button.at("view increment").visible(view_spinner_enabled);
|
||||
|
||||
/* Draw buttons. Don't include rotation matrix in view, so buttons will remain flat in the z-dimension. */
|
||||
glm::mat4 label_transformation {0.0f};
|
||||
if (level_index == 0)
|
||||
|
@ -1981,11 +2004,14 @@ void Cakefoot::update(float timestamp)
|
|||
/* Draw spinner labels */
|
||||
for (const std::string& name : {"level select", "profile", "challenge", "view"})
|
||||
{
|
||||
label.at(name).texture(0).bind();
|
||||
label_transformation = projection * view * label.at(name).transformation();
|
||||
glUniformMatrix4fv(uniform["mvp"], 1, GL_FALSE, &label_transformation[0][0]);
|
||||
label.at(name).enable();
|
||||
glDrawArrays(GL_TRIANGLES, 0, label.at(name).attributes("position")->count());
|
||||
if ((name != "profile" || profile_spinner_visible) && (name != "view" || view_spinner_enabled))
|
||||
{
|
||||
label.at(name).texture(0).bind();
|
||||
label_transformation = projection * view * label.at(name).transformation();
|
||||
glUniformMatrix4fv(uniform["mvp"], 1, GL_FALSE, &label_transformation[0][0]);
|
||||
label.at(name).enable();
|
||||
glDrawArrays(GL_TRIANGLES, 0, label.at(name).attributes("position")->count());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2004,8 +2030,7 @@ void Cakefoot::update(float timestamp)
|
|||
}
|
||||
|
||||
/* Draw name entry */
|
||||
if (static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1 &&
|
||||
configuration()("challenge", challenge_index).contains("time limit"))
|
||||
if (static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1 && arcade())
|
||||
{
|
||||
for (const std::string& button_name : {std::string("name 1"), std::string("name 2"), std::string("name 3"),
|
||||
"name " + std::to_string(name_entry_index + 1) + " increment",
|
||||
|
@ -2018,7 +2043,7 @@ void Cakefoot::update(float timestamp)
|
|||
|
||||
/* Draw the clock */
|
||||
float amount;
|
||||
if (configuration()("challenge", challenge_index).contains("time limit"))
|
||||
if (arcade())
|
||||
{
|
||||
if (static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1)
|
||||
{
|
||||
|
@ -2066,7 +2091,7 @@ void Cakefoot::update(float timestamp)
|
|||
}
|
||||
|
||||
/* Draw arcade results */
|
||||
if (static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1 && configuration()("challenge", challenge_index).contains("time limit"))
|
||||
if (static_cast<std::size_t>(level_index) == configuration()("levels").size() - 1 && arcade())
|
||||
{
|
||||
for (const std::string& name : {"arcade rank", "arcade distance"})
|
||||
{
|
||||
|
@ -2082,7 +2107,7 @@ void Cakefoot::update(float timestamp)
|
|||
if (level_index == 0)
|
||||
{
|
||||
/* Only draw scoreboard if arcade mode is selected */
|
||||
if (configuration()("challenge", challenge_index).contains("time limit"))
|
||||
if (arcade())
|
||||
{
|
||||
scoreboard.texture(0).bind();
|
||||
label_transformation = projection * view * scoreboard.transformation();
|
||||
|
|
|
@ -356,6 +356,28 @@ private:
|
|||
*/
|
||||
bool level_select() const;
|
||||
|
||||
/*!
|
||||
* @return True if resume quest or resume arcade is the current mode
|
||||
*/
|
||||
bool resuming() const;
|
||||
|
||||
inline bool skip_resume_quest()
|
||||
{
|
||||
return configuration()("challenge", challenge_index, "name") == "RESUME QUEST" && configuration()("progress", "quest level") == 1 &&
|
||||
configuration()("progress", "quest checkpoint") == 0.0f;
|
||||
}
|
||||
|
||||
inline bool skip_resume_arcade()
|
||||
{
|
||||
return configuration()("challenge", challenge_index, "name") == "RESUME ARCADE" && configuration()("progress", "arcade level") == 1 &&
|
||||
configuration()("progress", "arcade checkpoint") == 0.0f;
|
||||
}
|
||||
|
||||
inline bool skip_level_select()
|
||||
{
|
||||
return level_select() && configuration()("progress", "max difficulty") < 1 && configuration()("progress", "max level") <= 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Remove coin from the enemy and the level. If quest or arcade mode is active and flag is not set, add the coin to the appropriate bank.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue