The level number is now displayed on the next level screen.
This commit is contained in:
parent
b5c2fc3b5f
commit
bc0912e577
11 changed files with 84 additions and 46 deletions
|
|
@ -592,8 +592,9 @@ namespace gui {
|
|||
auto config = settings::get("config");
|
||||
size_t levels_to_win = config["game_play"]["levels_to_win"];
|
||||
|
||||
if(level.index <= levels_to_win) {
|
||||
if(level.index < levels_to_win) {
|
||||
show_scene("NEXT_LEVEL");
|
||||
$cur_scene->set_text(fmt::format("ENTERING\nLEVEL\n{}", level.index+2));
|
||||
state(State::NEXT_LEVEL_SCENE);
|
||||
} else {
|
||||
show_scene("WIN");
|
||||
|
|
|
|||
|
|
@ -29,22 +29,26 @@ namespace gui {
|
|||
|
||||
auto& button_cell = $scene.button_cell();
|
||||
|
||||
$ui.position(button_cell.x, button_cell.y, button_cell.w, button_cell.h);
|
||||
$ui.layout(layout);
|
||||
$gui.position(button_cell.x, button_cell.y, button_cell.w, button_cell.h);
|
||||
$gui.layout(layout);
|
||||
|
||||
for(auto& [name, cell] : $ui.cells()) {
|
||||
auto ui_id = $ui.entity(name);
|
||||
$ui.set<guecs::Text>(ui_id, {guecs::to_wstring(name)});
|
||||
$ui.set<guecs::Rectangle>(ui_id, {});
|
||||
$ui.set<guecs::Effect>(ui_id, {});
|
||||
for(auto& [name, cell] : $gui.cells()) {
|
||||
auto ui_id = $gui.entity(name);
|
||||
$gui.set<guecs::Text>(ui_id, {guecs::to_wstring(name)});
|
||||
$gui.set<guecs::Rectangle>(ui_id, {5, guecs::THEME.DARK_MID});
|
||||
$gui.set<guecs::Effect>(ui_id, {});
|
||||
|
||||
if(actions.contains(name)) {
|
||||
auto event_id = actions[name];
|
||||
$ui.set<guecs::Clickable>(ui_id, guecs::make_action(ui_id, event_id));
|
||||
$gui.set<guecs::Clickable>(ui_id, guecs::make_action(ui_id, event_id));
|
||||
}
|
||||
}
|
||||
|
||||
$ui.init();
|
||||
$gui.init();
|
||||
}
|
||||
|
||||
void SceneUI::set_text(const std::string& text) {
|
||||
$scene.set_text(text);
|
||||
}
|
||||
|
||||
void SceneUI::render(sf::RenderTarget &target) {
|
||||
|
|
@ -52,8 +56,8 @@ namespace gui {
|
|||
target.draw($view_sprite);
|
||||
|
||||
if(has_buttons) {
|
||||
$ui.render(target);
|
||||
if(DEBUG) $ui.debug_layout(target);
|
||||
$gui.render(target);
|
||||
if(DEBUG) $gui.debug_layout(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +67,7 @@ namespace gui {
|
|||
|
||||
bool SceneUI::mouse(float x, float y, guecs::Modifiers mods) {
|
||||
$scene.mouse(x, y, mods);
|
||||
$ui.mouse(x, y, mods);
|
||||
$gui.mouse(x, y, mods);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace gui {
|
|||
AnimatedScene $scene_data{load_scene(name)};
|
||||
scene::Engine $scene{$scene_data};
|
||||
bool has_buttons = false;
|
||||
guecs::UI $ui;
|
||||
guecs::UI $gui;
|
||||
|
||||
AnimatedScene load_scene(const std::string& name);
|
||||
void create_buttons(nlohmann::json& buttons);
|
||||
|
|
@ -22,5 +22,6 @@ namespace gui {
|
|||
void render(sf::RenderTarget &target);
|
||||
void update();
|
||||
bool mouse(float x, float y, guecs::Modifiers mods);
|
||||
void set_text(const std::string& text);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,12 +32,16 @@ namespace gui {
|
|||
for(auto& [name, cell] : $gui.cells()) {
|
||||
auto gui_id = $gui.entity(name);
|
||||
|
||||
$gui.set<Text>(gui_id, {guecs::to_wstring(name)});
|
||||
|
||||
if(name.starts_with("body_")) {
|
||||
auto& cell = $gui.cell_for(name);
|
||||
$body_ui.init(cell.x, cell.y, cell.w, cell.h);
|
||||
} else {
|
||||
// don't show inventory names
|
||||
if(!name.starts_with("inv")) {
|
||||
$gui.set<Text>(gui_id, {guecs::to_wstring(name)});
|
||||
}
|
||||
|
||||
$gui.set<Rectangle>(gui_id, {});
|
||||
$gui.set<Clickable>(gui_id, {
|
||||
guecs::make_action(gui_id, game::Event::INV_SELECT, {gui_id})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue