Big changes to use the new lel-guecs setup but now almost everything works. Only thing missing is Issue #16 in quecs.
This commit is contained in:
parent
86ddfc460f
commit
d93bc1615c
14 changed files with 51 additions and 59 deletions
Binary file not shown.
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 9.1 KiB |
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"color": {
|
"color": {
|
||||||
"transparent": [255, 255, 255, 255],
|
"transparent": [100, 100, 100, 100],
|
||||||
"BAD": [255, 0, 0]
|
"BAD": [255, 0, 0]
|
||||||
},
|
},
|
||||||
"gui/theme": {
|
"gui/theme": {
|
||||||
|
|
|
@ -14,17 +14,17 @@ namespace gui {
|
||||||
$status.position(0, 0, BOSS_VIEW_X, SCREEN_HEIGHT);
|
$status.position(0, 0, BOSS_VIEW_X, SCREEN_HEIGHT);
|
||||||
$status.layout(
|
$status.layout(
|
||||||
"[main_status]"
|
"[main_status]"
|
||||||
"[(150)status_3|(150)status_4]"
|
"[=status_3|=status_4]"
|
||||||
"[(150)status_5|(150)status_6]"
|
"[=status_5|=status_6]"
|
||||||
"[(150)status_7|(150)status_8]");
|
"[=status_7|=status_8]");
|
||||||
|
|
||||||
$overlay.position(BOSS_VIEW_X, BOSS_VIEW_Y,
|
$overlay.position(BOSS_VIEW_X, BOSS_VIEW_Y,
|
||||||
BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT);
|
BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT);
|
||||||
|
|
||||||
$overlay.layout("[overlay_1|overlay_2|overlay_4]"
|
$overlay.layout("[=overlay_1|=overlay_2|=overlay_4]"
|
||||||
"[overlay_5|overlay_6|overlay_8]"
|
"[=overlay_5|=overlay_6|=overlay_8]"
|
||||||
"[overlay_9|overlay_10|overlay_12]"
|
"[=overlay_9|=overlay_10|=overlay_12]"
|
||||||
"[overlay_13|overlay_14|overlay_16]");
|
"[=overlay_13|=overlay_14|=overlay_16]");
|
||||||
|
|
||||||
$sounds = $world->get<components::Sound>($boss_id);
|
$sounds = $world->get<components::Sound>($boss_id);
|
||||||
$combat = $world->get<components::Combat>($boss_id);
|
$combat = $world->get<components::Combat>($boss_id);
|
||||||
|
@ -73,9 +73,9 @@ namespace gui {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(name == "main_status") {
|
if(name == "main_status") {
|
||||||
$status.set<Textual>(button, {fmt::format(L"HP: {}", $combat.hp)});
|
$status.set<Text>(button, {fmt::format(L"HP: {}", $combat.hp)});
|
||||||
} else {
|
} else {
|
||||||
$status.set<Label>(button, {L"Attack"});
|
$status.set<Text>(button, {L"Attack"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$status.init();
|
$status.init();
|
||||||
|
@ -131,8 +131,8 @@ namespace gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
if($combat.hp == 0) {
|
if($combat.hp == 0) {
|
||||||
$overlay.show_label("overlay_1", L"YOU WON!");
|
$overlay.show_text("overlay_1", L"YOU WON!");
|
||||||
$overlay.show_label("overlay_4", L"CLICK TO CONTINUE...");
|
$overlay.show_text("overlay_4", L"CLICK TO CONTINUE...");
|
||||||
}
|
}
|
||||||
|
|
||||||
$status.render(window);
|
$status.render(window);
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace gui {
|
||||||
$gui.show_text("debug_text", L"STATS");
|
$gui.show_text("debug_text", L"STATS");
|
||||||
} else {
|
} else {
|
||||||
// it's off now, close it
|
// it's off now, close it
|
||||||
$gui.close<Textual>("debug_text");
|
$gui.close<Text>("debug_text");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,13 @@ namespace guecs {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrabSource::setSprite(guecs::UI& gui, guecs::Entity gui_id) {
|
void GrabSource::setSprite(guecs::UI& gui, guecs::Entity gui_id) {
|
||||||
dbc::check(gui.has<guecs::Icon>(gui_id), "GrabSource given sprite gui_id that doesn't exist");
|
if(auto sp = gui.get_if<guecs::Icon>(gui_id)) {
|
||||||
|
sprite = sp->sprite;
|
||||||
auto& sp = gui.get<guecs::Icon>(gui_id);
|
} else if(auto sp = gui.get_if<guecs::Sprite>(gui_id)) {
|
||||||
sprite = sp.sprite;
|
sprite = sp->sprite;
|
||||||
|
} else {
|
||||||
|
dbc::sentinel("GrabSource given sprite gui_id that doesn't exist");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrabSource::move(sf::Vector2f pos) {
|
void GrabSource::move(sf::Vector2f pos) {
|
||||||
|
|
|
@ -15,10 +15,10 @@ namespace gui {
|
||||||
RAY_VIEW_Y+RAY_VIEW_HEIGHT/2-200, 400, 400);
|
RAY_VIEW_Y+RAY_VIEW_HEIGHT/2-200, 400, 400);
|
||||||
|
|
||||||
$gui.layout(
|
$gui.layout(
|
||||||
"[item_0 | item_1 |item_2 | item_3 ]"
|
"[=item_0 | =item_1 |=item_2 |=item_3 ]"
|
||||||
"[item_4 | item_5 |item_6 | item_7 ]"
|
"[=item_4 | =item_5 |=item_6 |=item_7 ]"
|
||||||
"[item_8 | item_9 |item_10| item_11]"
|
"[=item_8 | =item_9 |=item_10|=item_11]"
|
||||||
"[item_12| item_13|item_14|item_15 ]"
|
"[=item_12| =item_13|=item_14|=item_15 ]"
|
||||||
"[ =take_all | =close| =destroy]");
|
"[ =take_all | =close| =destroy]");
|
||||||
|
|
||||||
$level.world->set<inventory::Model>($temp_loot, {});
|
$level.world->set<inventory::Model>($temp_loot, {});
|
||||||
|
@ -29,7 +29,7 @@ namespace gui {
|
||||||
|
|
||||||
auto button = $gui.entity(name);
|
auto button = $gui.entity(name);
|
||||||
$gui.set<guecs::Rectangle>(button, {});
|
$gui.set<guecs::Rectangle>(button, {});
|
||||||
$gui.set<guecs::Label>(button, {label});
|
$gui.set<guecs::Text>(button, {label});
|
||||||
$gui.set<guecs::Clickable>(button,
|
$gui.set<guecs::Clickable>(button,
|
||||||
guecs::make_action($level, event));
|
guecs::make_action($level, event));
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace gui {
|
||||||
|
|
||||||
$log_to = $gui.entity("log_view");
|
$log_to = $gui.entity("log_view");
|
||||||
$gui.set<Rectangle>($log_to, {10, THEME.DARK_MID, THEME.BORDER_COLOR, 10});
|
$gui.set<Rectangle>($log_to, {10, THEME.DARK_MID, THEME.BORDER_COLOR, 10});
|
||||||
$gui.set<Textual>($log_to, {L"Welcome to the Game!", 25, THEME.TEXT_COLOR, 10});
|
$gui.set<Text>($log_to, {L"Welcome to the Game!", 25, THEME.TEXT_COLOR, 10});
|
||||||
|
|
||||||
auto map_cell = lel::center(MAP_TILE_DIM * MAP_WIDTH, MAP_TILE_DIM * MAP_HEIGHT, $gui.cell_for("map_grid"));
|
auto map_cell = lel::center(MAP_TILE_DIM * MAP_WIDTH, MAP_TILE_DIM * MAP_HEIGHT, $gui.cell_for("map_grid"));
|
||||||
$map_sprite.setPosition({(float)map_cell.x, (float)map_cell.y + 30});
|
$map_sprite.setPosition({(float)map_cell.x, (float)map_cell.y + 30});
|
||||||
|
@ -59,7 +59,7 @@ namespace gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapViewUI::update() {
|
void MapViewUI::update() {
|
||||||
if(auto text = $gui.get_if<Textual>($log_to)) {
|
if(auto text = $gui.get_if<Text>($log_to)) {
|
||||||
//BUG: I'm calling this what it is, fix it
|
//BUG: I'm calling this what it is, fix it
|
||||||
wstring log_garbage;
|
wstring log_garbage;
|
||||||
for(auto msg : $messages) {
|
for(auto msg : $messages) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
namespace gui {
|
namespace gui {
|
||||||
class MiniMapUI {
|
class MiniMapUI {
|
||||||
public:
|
public:
|
||||||
guecs::Textual $map_grid;
|
guecs::Text $map_grid;
|
||||||
guecs::UI $gui;
|
guecs::UI $gui;
|
||||||
GameLevel $level;
|
GameLevel $level;
|
||||||
shared_ptr<sf::Font> $font = nullptr;
|
shared_ptr<sf::Font> $font = nullptr;
|
||||||
|
|
|
@ -10,9 +10,9 @@ namespace gui {
|
||||||
OverlayUI::OverlayUI() {
|
OverlayUI::OverlayUI() {
|
||||||
$gui.position(RAY_VIEW_X, RAY_VIEW_Y, RAY_VIEW_WIDTH, RAY_VIEW_HEIGHT);
|
$gui.position(RAY_VIEW_X, RAY_VIEW_Y, RAY_VIEW_WIDTH, RAY_VIEW_HEIGHT);
|
||||||
$gui.layout(
|
$gui.layout(
|
||||||
"[*%(100,300)left|top|>(170,170)top_right]"
|
"[*%(100,300)left|=top|>(170,170)top_right]"
|
||||||
"[_|middle|middle_right]"
|
"[_|=middle|=middle_right]"
|
||||||
"[_|bottom|bottom_right]"
|
"[_|=bottom|=bottom_right]"
|
||||||
);
|
);
|
||||||
$gui.init();
|
$gui.init();
|
||||||
}
|
}
|
||||||
|
@ -52,15 +52,7 @@ namespace gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayUI::close_text(string region) {
|
void OverlayUI::close_text(string region) {
|
||||||
$gui.close<Textual>(region);
|
$gui.close<Text>(region);
|
||||||
}
|
|
||||||
|
|
||||||
void OverlayUI::show_label(string region, wstring content) {
|
|
||||||
$gui.show_label(region, content);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OverlayUI::close_label(string region) {
|
|
||||||
$gui.close<Label>(region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayUI::update_level(GameLevel level) {
|
void OverlayUI::update_level(GameLevel level) {
|
||||||
|
|
|
@ -23,8 +23,5 @@ namespace gui {
|
||||||
void show_text(std::string region, std::wstring content);
|
void show_text(std::string region, std::wstring content);
|
||||||
void update_text(std::string region, std::wstring content);
|
void update_text(std::string region, std::wstring content);
|
||||||
void close_text(std::string region);
|
void close_text(std::string region);
|
||||||
void show_label(std::string region, std::wstring content);
|
|
||||||
void update_label(std::string region, std::wstring content);
|
|
||||||
void close_label(std::string region);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace gui {
|
||||||
"[inv_slot8 | inv_slot9 | inv_slot10| inv_slot11]"
|
"[inv_slot8 | inv_slot9 | inv_slot10| inv_slot11]"
|
||||||
"[inv_slot12 | inv_slot13 | inv_slot14| inv_slot15]"
|
"[inv_slot12 | inv_slot13 | inv_slot14| inv_slot15]"
|
||||||
"[inv_slot16 | inv_slot17 | inv_slot18| inv_slot19]"
|
"[inv_slot16 | inv_slot17 | inv_slot18| inv_slot19]"
|
||||||
"[_ |*%(200,400)result_text|_]"
|
"[_ |=*%(200,400)result_text|_]"
|
||||||
"[*%(100,200)result_image|_ |_]"
|
"[*%(100,200)result_image|_ |_]"
|
||||||
"[_|_|_]"
|
"[_|_|_]"
|
||||||
"[_|_|_]"
|
"[_|_|_]"
|
||||||
|
@ -217,7 +217,7 @@ namespace gui {
|
||||||
auto combine = $gui.entity("result_image");
|
auto combine = $gui.entity("result_image");
|
||||||
|
|
||||||
if($craft_state.is_combined()) {
|
if($craft_state.is_combined()) {
|
||||||
$gui.show_label("result_text", L"This might work...");
|
$gui.show_text("result_text", L"This might work...");
|
||||||
|
|
||||||
switch(ritual.element) {
|
switch(ritual.element) {
|
||||||
case FIRE:
|
case FIRE:
|
||||||
|
@ -234,7 +234,7 @@ namespace gui {
|
||||||
[&](auto, auto){ event(Event::COMBINE); }
|
[&](auto, auto){ event(Event::COMBINE); }
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$gui.show_label("result_text", L"That won't work.");
|
$gui.show_text("result_text", L"That won't work.");
|
||||||
$gui.show_sprite("result_image", "dubious_combination");
|
$gui.show_sprite("result_image", "dubious_combination");
|
||||||
$gui.remove<Clickable>(combine);
|
$gui.remove<Clickable>(combine);
|
||||||
return;
|
return;
|
||||||
|
@ -247,7 +247,7 @@ namespace gui {
|
||||||
|
|
||||||
void UI::clear_craft_result() {
|
void UI::clear_craft_result() {
|
||||||
$blanket.reset();
|
$blanket.reset();
|
||||||
$gui.close<Label>("result_text");
|
$gui.close<Text>("result_text");
|
||||||
$gui.close<Sprite>("result_image");
|
$gui.close<Sprite>("result_image");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,15 +17,15 @@ namespace gui {
|
||||||
$gui.position(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT);
|
$gui.position(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT);
|
||||||
$gui.layout(
|
$gui.layout(
|
||||||
"[ritual_ui]"
|
"[ritual_ui]"
|
||||||
"[earring|armor_head|amulet]"
|
"[=earring|=armor_head|=amulet]"
|
||||||
"[back|*%(200,300)character_view|_|armor_bdy]"
|
"[=back|=*%(200,300)character_view|_|=armor_bdy]"
|
||||||
"[hand_r|_|_ |hand_l]"
|
"[=hand_r|_|_ |=hand_l]"
|
||||||
"[ring_r|_|_ |ring_l]"
|
"[=ring_r|_|_ |=ring_l]"
|
||||||
"[pocket_r|armor_leg|pocket_l]");
|
"[=pocket_r|=armor_leg|=pocket_l]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusUI::init() {
|
void StatusUI::init() {
|
||||||
$gui.set<Background>($gui.MAIN, {$gui.$parser});
|
$gui.set<Background>($gui.MAIN, {$gui.$parser, });
|
||||||
|
|
||||||
for(auto& [name, cell] : $gui.cells()) {
|
for(auto& [name, cell] : $gui.cells()) {
|
||||||
auto gui_id = $gui.entity(name);
|
auto gui_id = $gui.entity(name);
|
||||||
|
@ -43,7 +43,7 @@ namespace gui {
|
||||||
});
|
});
|
||||||
$gui.set<Sound>(gui_id, {"pickup"});
|
$gui.set<Sound>(gui_id, {"pickup"});
|
||||||
} else {
|
} else {
|
||||||
$gui.set<Textual>(gui_id, {guecs::to_wstring(name)});
|
$gui.set<Text>(gui_id, {guecs::to_wstring(name)});
|
||||||
$gui.set<Clickable>(gui_id, {
|
$gui.set<Clickable>(gui_id, {
|
||||||
guecs::make_action($level, Events::GUI::INV_SELECT, {gui_id})
|
guecs::make_action($level, Events::GUI::INV_SELECT, {gui_id})
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,14 +14,14 @@ namespace arena {
|
||||||
$status.position(0, 0, BOSS_VIEW_X, SCREEN_HEIGHT);
|
$status.position(0, 0, BOSS_VIEW_X, SCREEN_HEIGHT);
|
||||||
$status.layout(
|
$status.layout(
|
||||||
"[main_status]"
|
"[main_status]"
|
||||||
"[(150)status_3|(150)status_4]"
|
"[=status_3|=status_4]"
|
||||||
"[(150)status_5|(150)status_6]"
|
"[=status_5|=status_6]"
|
||||||
"[(150)status_7|(150)status_8]");
|
"[=status_7|=status_8]");
|
||||||
|
|
||||||
$overlay.position(BOSS_VIEW_X, BOSS_VIEW_Y,
|
$overlay.position(BOSS_VIEW_X, BOSS_VIEW_Y,
|
||||||
BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT);
|
BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT);
|
||||||
|
|
||||||
$overlay.layout("[_|=(256,256)enemy|_]");
|
$overlay.layout("[_|(256,256)enemy|_]");
|
||||||
|
|
||||||
$sounds = $world->get<components::Sound>($entity_id);
|
$sounds = $world->get<components::Sound>($entity_id);
|
||||||
$combat = $world->get<components::Combat>($entity_id);
|
$combat = $world->get<components::Combat>($entity_id);
|
||||||
|
@ -74,9 +74,9 @@ namespace arena {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(name == "main_status") {
|
if(name == "main_status") {
|
||||||
$status.set<Textual>(button, {fmt::format(L"HP: {}", $combat.hp)});
|
$status.set<Text>(button, {fmt::format(L"HP: {}", $combat.hp)});
|
||||||
} else {
|
} else {
|
||||||
$status.set<Label>(button, {L"Attack"});
|
$status.set<Text>(button, {L"Attack"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$status.init();
|
$status.init();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[wrap-git]
|
[wrap-git]
|
||||||
directory=lel-guecs-0.4.1
|
directory=lel-guecs-0.5.0
|
||||||
url=https://git.learnjsthehardway.com/learn-code-the-hard-way/lel-guecs.git
|
url=https://git.learnjsthehardway.com/learn-code-the-hard-way/lel-guecs.git
|
||||||
revision=HEAD
|
revision=HEAD
|
||||||
depth=1
|
depth=1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue