display puzzle title
This commit is contained in:
@ -13,7 +13,8 @@
|
||||
#include <tracy/Tracy.hpp>
|
||||
#endif
|
||||
|
||||
// TODO: Click states to display them in the board
|
||||
// TODO: Click states in the graph to display them in the board
|
||||
// TODO: Add walls (unmoveable blocks)
|
||||
|
||||
// NOTE: Tracy uses a huge amount of memory. For longer testing disable Tracy.
|
||||
|
||||
|
||||
@ -322,13 +322,26 @@ auto Renderer::DrawMenu(const std::vector<Vector3> &masses) -> void {
|
||||
|
||||
auto draw_btn = [&](int x, int y, std::string text, Color color) {
|
||||
int posx = MENU_PAD + x * (MENU_PAD + btn_width);
|
||||
int posy = MENU_PAD + y * (MENU_PAD + btn_height);
|
||||
int posy = MENU_PAD + (y + 1) * (MENU_PAD + btn_height);
|
||||
DrawRectangle(posx, posy, btn_width, btn_height, Fade(color, 0.7));
|
||||
DrawRectangleLines(posx, posy, btn_width, btn_height, color);
|
||||
DrawText(text.data(), posx + BUTTON_PAD, posy + BUTTON_PAD,
|
||||
btn_height - 2.0 * BUTTON_PAD, WHITE);
|
||||
};
|
||||
|
||||
auto draw_subtitle = [&](std::string text, Color color) {
|
||||
int posx = MENU_PAD;
|
||||
int posy = MENU_PAD;
|
||||
DrawRectangle(posx, posy,
|
||||
btn_width * MENU_COLS + MENU_PAD * (MENU_COLS - 1),
|
||||
btn_height, Fade(color, 0.7));
|
||||
DrawRectangleLines(posx, posy,
|
||||
btn_width * MENU_COLS + MENU_PAD * (MENU_COLS - 1),
|
||||
btn_height, color);
|
||||
DrawText(text.data(), posx + BUTTON_PAD, posy + BUTTON_PAD,
|
||||
btn_height = 2.0 * BUTTON_PAD, WHITE);
|
||||
};
|
||||
|
||||
// Left column
|
||||
draw_btn(0, 0,
|
||||
std::format("States: {} / Transitions: {} / Winning: {}",
|
||||
@ -336,7 +349,7 @@ auto Renderer::DrawMenu(const std::vector<Vector3> &masses) -> void {
|
||||
state.winning_states.size()),
|
||||
ORANGE);
|
||||
draw_btn(0, 1,
|
||||
std::format("Preset (M/N): {}, {} (F)", state.current_preset,
|
||||
std::format("Preset (M/N) / {} (F)",
|
||||
state.current_state.restricted ? "Restricted" : "Free"),
|
||||
ORANGE);
|
||||
draw_btn(0, 2, std::format("Pan (LMB) / Rotate (RMB) / Zoom (Wheel)"),
|
||||
@ -350,27 +363,31 @@ auto Renderer::DrawMenu(const std::vector<Vector3> &masses) -> void {
|
||||
draw_btn(1, 0, std::format("Select (LMB) / Move (W, A, S, D) / Target (T)"),
|
||||
DARKBLUE);
|
||||
draw_btn(1, 1, std::format("Add/Remove Col/Row (Arrow Keys)"), DARKBLUE);
|
||||
draw_btn(1, 2, std::format("Add/Remove Block (LMB/RMB), Set Goal (MMB)"),
|
||||
draw_btn(1, 2, std::format("Add/Remove Block (LMB/RMB) / Set Goal (MMB)"),
|
||||
DARKBLUE);
|
||||
draw_btn(1, 3, std::format("Print State (P) / Reset State (R)"), DARKBLUE);
|
||||
|
||||
// Right column
|
||||
draw_btn(2, 0, std::format("Populate Graph (G), Clear Graph (C)"),
|
||||
draw_btn(2, 0, std::format("Populate Graph (G) / Clear Graph (C)"),
|
||||
DARKPURPLE);
|
||||
draw_btn(2, 1,
|
||||
std::format("Path (U): {} / Goals (I): {} / Connect (O): {}",
|
||||
std::format("Path (U): {} / Goals (I): {} / Lines (O): {}",
|
||||
input.mark_path, input.mark_solutions,
|
||||
input.connect_solutions),
|
||||
DARKPURPLE);
|
||||
draw_btn(2, 2, std::format("Best move (Space) / Move back (Backspace)"),
|
||||
DARKPURPLE);
|
||||
draw_btn(2, 3,
|
||||
std::format("Worst (V) / Nearest target (B) / Moves remaining: {}",
|
||||
std::format("Worst (V) / Target (B) / Distance: {}",
|
||||
state.winning_path.size() > 0
|
||||
? state.winning_path.size() - 1
|
||||
: 0),
|
||||
DARKPURPLE);
|
||||
|
||||
draw_subtitle(std::format("Puzzle {}: {}", state.current_preset + 1,
|
||||
state.comments.at(state.current_preset)),
|
||||
BLACK);
|
||||
|
||||
DrawLine(0, MENU_HEIGHT - 1, GetScreenWidth(), MENU_HEIGHT - 1, BLACK);
|
||||
EndTextureMode();
|
||||
}
|
||||
|
||||
@ -20,25 +20,29 @@ auto StateManager::ParsePresetFile(const std::string &preset_file) -> void {
|
||||
}
|
||||
|
||||
std::string line;
|
||||
std::vector<std::string> lines;
|
||||
std::vector<std::string> comment_lines;
|
||||
std::vector<std::string> preset_lines;
|
||||
while (std::getline(file, line)) {
|
||||
if (line.starts_with("F") || line.starts_with("R")) {
|
||||
lines.push_back(line);
|
||||
preset_lines.push_back(line);
|
||||
} else if (line.starts_with("#")) {
|
||||
comment_lines.push_back(line);
|
||||
}
|
||||
}
|
||||
|
||||
if (lines.size() == 0) {
|
||||
if (preset_lines.size() == 0 || comment_lines.size() != preset_lines.size()) {
|
||||
std::cout << "Preset file \"" << preset_file << "\" couldn't be loaded."
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
presets.clear();
|
||||
for (const auto &preset : lines) {
|
||||
for (const auto &preset : preset_lines) {
|
||||
presets.emplace_back(preset);
|
||||
}
|
||||
comments = comment_lines;
|
||||
|
||||
std::cout << "Loaded " << lines.size() << " presets." << std::endl;
|
||||
std::cout << "Loaded " << preset_lines.size() << " presets." << std::endl;
|
||||
}
|
||||
|
||||
auto StateManager::LoadPreset(int preset) -> void {
|
||||
|
||||
Reference in New Issue
Block a user