fix zero length text bug, fix scoreboard text rendering on wasm build
This commit is contained in:
parent
ae0ce70b3d
commit
db7e41e470
|
@ -48,6 +48,7 @@
|
|||
"scoreboard scale": [1.4, 0.15],
|
||||
"scoreboard translation": [-0.45, 0.865],
|
||||
"scoreboard scale": [1.35, 0.14],
|
||||
"scoreboard wrap": 3000,
|
||||
"qr texture": "resource/qr.png",
|
||||
"qr translation": [1.49, -0.7],
|
||||
"qr scale": [0.205, 0.225],
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
{
|
||||
"render driver": "opengles2",
|
||||
"fluid resize": false,
|
||||
"use play button": true
|
||||
"use play button": true,
|
||||
"scoreboard wrap": 3200
|
||||
},
|
||||
|
||||
"recording":
|
||||
|
|
2
lib/sb
2
lib/sb
|
@ -1 +1 @@
|
|||
Subproject commit c7fb948e3970eeaccb143225ab10bc84689bd09f
|
||||
Subproject commit 464e69be56299a890ee73b0ee937f2e0c3dce3b0
|
|
@ -150,7 +150,9 @@ Cakefoot::Cakefoot()
|
|||
|
||||
/* Set to default values in case these get displayed erroneously */
|
||||
label.at("arcade rank").content("999th");
|
||||
label.at("arcade rank").refresh();
|
||||
label.at("arcade distance").content("10000m");
|
||||
label.at("arcade distance").refresh();
|
||||
|
||||
/* Initialize scoreboard content */
|
||||
refresh_scoreboard();
|
||||
|
@ -333,6 +335,7 @@ void Cakefoot::set_up_buttons()
|
|||
text.background(configuration()("button", "text background").get<glm::vec4>());
|
||||
text.content(configuration()("button", name + " text"));
|
||||
text.dimensions(dimensions);
|
||||
text.refresh();
|
||||
button.at(name) = sb::Pad<>{text, configuration()("button", name + " translation"), scale, dimensions.y / dimensions.x};
|
||||
}
|
||||
|
||||
|
@ -486,6 +489,7 @@ void Cakefoot::set_up_buttons()
|
|||
label.at(name).translate(configuration()("button", name + " translation"));
|
||||
label.at(name).scale(configuration()("button", name + " scale"));
|
||||
label.at(name).dimensions(dimensions);
|
||||
label.at(name).refresh();
|
||||
}
|
||||
button.at("profile decrement").on_state_change([&](bool state){
|
||||
/* Disable in arcade-only mode and resume game modes */
|
||||
|
@ -639,6 +643,7 @@ void Cakefoot::set_up_buttons()
|
|||
sb::Text character {fonts.at("large"), "", configuration()("display", "clock hud foreground").get<glm::vec4>(),
|
||||
configuration()("display", "clock hud background").get<glm::vec4>(), character_dimensions};
|
||||
character.content(name_entry[std::stoi(character_index) - 1]);
|
||||
character.refresh();
|
||||
button.at("name " + character_index) = sb::Pad<>{
|
||||
character, {configuration()("button", "name", "character " + character_index + " x"), configuration()("button", "name", "character y")},
|
||||
configuration()("button", "name", "character scale")[1], character_dimensions.y / character_dimensions.x};
|
||||
|
@ -785,6 +790,7 @@ void Cakefoot::set_up_hud()
|
|||
label.at("game over").untransform();
|
||||
label.at("game over").translate(configuration()("display", "game over translation"));
|
||||
label.at("game over").scale(configuration()("display", "game over scale"));
|
||||
label.at("game over").refresh();
|
||||
|
||||
/* Style arcade results */
|
||||
for (const std::string& name : {"arcade rank", "arcade distance"})
|
||||
|
@ -795,11 +801,14 @@ void Cakefoot::set_up_hud()
|
|||
label.at(name).translate(configuration()("display", name + " translation"));
|
||||
label.at(name).scale(configuration()("display", name + " scale"));
|
||||
label.at(name).dimensions(configuration()("display", name + " dimensions"));
|
||||
label.at(name).refresh();
|
||||
}
|
||||
|
||||
/* Style the scoreboard */
|
||||
scoreboard.wrap(configuration()("display", "scoreboard wrap"));
|
||||
scoreboard.foreground(configuration()("display", "scoreboard foreground").get<glm::vec4>());
|
||||
scoreboard.background(configuration()("display", "scoreboard background").get<glm::vec4>());
|
||||
scoreboard.refresh();
|
||||
scoreboard.untransform();
|
||||
scoreboard.translate(configuration()("display", "scoreboard translation"));
|
||||
scoreboard.scale(configuration()("display", "scoreboard scale"));
|
||||
|
@ -820,6 +829,7 @@ void Cakefoot::set_up_hud()
|
|||
{
|
||||
label.at("quest best").content(configuration()("display", "quest best text").get<std::string>() +
|
||||
format_clock(configuration()("progress", "quest best")));
|
||||
label.at("quest best").refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1071,6 +1081,7 @@ void Cakefoot::load_level(int index)
|
|||
{
|
||||
sb::Text message {fonts.at("glyph large"), configuration()("ending", "end text"), configuration()("ending", "messages foreground").get<glm::vec4>()};
|
||||
message.dimensions(configuration()("ending", "messages dimensions"));
|
||||
message.refresh();
|
||||
ending_messages.push_back(message);
|
||||
}
|
||||
|
||||
|
@ -1082,6 +1093,7 @@ void Cakefoot::load_level(int index)
|
|||
configuration()["progress"]["max view"] = 1;
|
||||
sb::Text message {fonts.at("glyph"), configuration()("ending", "unlock mirror"), configuration()("ending", "messages foreground").get<glm::vec4>()};
|
||||
message.dimensions(configuration()("ending", "messages dimensions"));
|
||||
message.refresh();
|
||||
ending_messages.push_back(message);
|
||||
}
|
||||
if (configuration()("progress", "max view").get<int>() < 2 && profile_index >= 1)
|
||||
|
@ -1089,6 +1101,7 @@ void Cakefoot::load_level(int index)
|
|||
configuration()["progress"]["max view"] = 2;
|
||||
sb::Text message {fonts.at("glyph"), configuration()("ending", "unlock warped"), configuration()("ending", "messages foreground").get<glm::vec4>()};
|
||||
message.dimensions(configuration()("ending", "messages dimensions"));
|
||||
message.refresh();
|
||||
ending_messages.push_back(message);
|
||||
}
|
||||
if (configuration()("progress", "jackpot") != 777 && profile_index == 2)
|
||||
|
@ -1097,6 +1110,7 @@ void Cakefoot::load_level(int index)
|
|||
character.profile(configuration()("character", "profile", profile_index, "name"));
|
||||
sb::Text message {fonts.at("glyph"), configuration()("ending", "unlock jackpot"), configuration()("ending", "messages foreground").get<glm::vec4>()};
|
||||
message.dimensions(configuration()("ending", "messages dimensions"));
|
||||
message.refresh();
|
||||
ending_messages.push_back(message);
|
||||
}
|
||||
}
|
||||
|
@ -1137,6 +1151,7 @@ void Cakefoot::load_level(int index)
|
|||
message.foreground(configuration()("ending", "messages foreground").get<glm::vec4>());
|
||||
profile_index == 1 ? message.content(configuration()("ending", "unlock beef")) : message.content(configuration()("ending", "unlock buffalo"));
|
||||
message.dimensions(configuration()("ending", "messages dimensions"));
|
||||
message.refresh();
|
||||
ending_messages.push_back(message);
|
||||
}
|
||||
|
||||
|
@ -1150,8 +1165,10 @@ void Cakefoot::load_level(int index)
|
|||
{
|
||||
configuration()["progress"]["quest best"] = run_timer.elapsed();
|
||||
label.at("quest best").content(configuration()("display", "quest best text").get<std::string>() + " " + format_clock(run_timer.elapsed()));
|
||||
label.at("quest best").refresh();
|
||||
sb::Text message {fonts.at("glyph"), configuration()("ending", "new best"), configuration()("ending", "messages foreground").get<glm::vec4>()};
|
||||
message.dimensions(configuration()("ending", "messages dimensions"));
|
||||
message.refresh();
|
||||
ending_messages.push_back(message);
|
||||
}
|
||||
}
|
||||
|
@ -1535,8 +1552,10 @@ void Cakefoot::set_arcade_score(float extended_limit, int maximum_distance)
|
|||
rank_str << "th";
|
||||
}
|
||||
label.at("arcade rank").content(rank_str.str());
|
||||
label.at("arcade rank").refresh();
|
||||
distance_str << arcade_score.distance << "m";
|
||||
label.at("arcade distance").content(distance_str.str());
|
||||
label.at("arcade distance").refresh();
|
||||
}
|
||||
|
||||
void Cakefoot::shift_hue()
|
||||
|
@ -1557,6 +1576,7 @@ void Cakefoot::refresh_scoreboard()
|
|||
{
|
||||
std::string text {arcade_scores.formatted(4, 4)};
|
||||
scoreboard.content(text);
|
||||
scoreboard.refresh();
|
||||
}
|
||||
|
||||
void Cakefoot::respond(SDL_Event& event)
|
||||
|
@ -2272,6 +2292,7 @@ void Cakefoot::update(float timestamp)
|
|||
amount = run_timer.elapsed();
|
||||
}
|
||||
label.at("clock").content(format_clock(amount));
|
||||
label.at("clock").refresh();
|
||||
sb::Plane::position->bind("vertex_position", shader_program);
|
||||
glUniform1i(uniform["texture enabled"], true);
|
||||
label.at("clock").texture(0).bind();
|
||||
|
@ -2286,6 +2307,7 @@ void Cakefoot::update(float timestamp)
|
|||
std::stringstream level_indicator;
|
||||
level_indicator << std::setw(2) << std::setfill('0') << level_index << "/" << std::setw(2) << _configuration("levels").size() - 2;
|
||||
label.at("level").content(level_indicator.str());
|
||||
label.at("level").refresh();
|
||||
label.at("level").texture(0).bind();
|
||||
label_transformation = projection * view * label.at("level").transformation();
|
||||
glUniformMatrix4fv(uniform["mvp"], 1, GL_FALSE, &label_transformation[0][0]);
|
||||
|
@ -2370,6 +2392,7 @@ void Cakefoot::update(float timestamp)
|
|||
{
|
||||
std::string padded = sb::pad(current_frames_per_second, 2);
|
||||
label.at("fps").content(padded);
|
||||
label.at("fps").refresh();
|
||||
previous_frames_per_second = current_frames_per_second;
|
||||
}
|
||||
if (label.at("fps").texture(0).generated())
|
||||
|
|
Loading…
Reference in New Issue