The player now has some starting items to craft a first weapon, and it is craftable in the UI.
This commit is contained in:
parent
c8a8d2b1af
commit
bc557652ba
11 changed files with 199 additions and 155 deletions
|
@ -16,10 +16,10 @@ namespace gui {
|
|||
$gui.position(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT);
|
||||
$gui.layout(
|
||||
"[_]"
|
||||
"[inv_slot9 | inv_slot10 | inv_slot11| inv_slot12]"
|
||||
"[inv_slot13 | inv_slot14 | inv_slot15| inv_slot16]"
|
||||
"[inv_slot17 | inv_slot18 | inv_slot19| inv_slot20]"
|
||||
"[inv_slot21 | inv_slot22 | inv_slot23| inv_slot24]"
|
||||
"[inv_slot0 | inv_slot1 | inv_slot2| inv_slot3]"
|
||||
"[inv_slot4 | inv_slot5 | inv_slot6| inv_slot7]"
|
||||
"[inv_slot8 | inv_slot9 | inv_slot10| inv_slot11]"
|
||||
"[inv_slot12 | inv_slot13 | inv_slot14| inv_slot15]"
|
||||
"[*%(100,600)circle_area]"
|
||||
"[_]"
|
||||
"[_]"
|
||||
|
@ -30,38 +30,32 @@ namespace gui {
|
|||
}
|
||||
|
||||
void RitualUI::init() {
|
||||
Config config("assets/rituals.json");
|
||||
std::vector<std::string> junk_list;
|
||||
auto& blanket = $level.world->get_the<ritual::Blanket>();
|
||||
int i = 0;
|
||||
|
||||
for(auto& el : config["junk"]) {
|
||||
std::string name = el["name"];
|
||||
junk_list.push_back(name);
|
||||
};
|
||||
blanket.contents.query<ritual::JunkItem>([&](const auto, auto& item) {
|
||||
std::string slot = fmt::format("inv_slot{}", i++);
|
||||
std::string sprite_name = fmt::format("{}-64", item);
|
||||
|
||||
for(auto& [name, cell] : $gui.cells()) {
|
||||
auto button = $gui.entity(name);
|
||||
auto button = $gui.entity(slot);
|
||||
$gui.set<Sprite>(button, {sprite_name});
|
||||
$gui.set<Effect>(button, {0.4f});
|
||||
$gui.set<Sound>(button, {"ui_click"});
|
||||
$gui.set<Clickable>(button, {
|
||||
[&](auto ent, auto){ inv_slot_clicked(ent); }
|
||||
});
|
||||
});
|
||||
|
||||
if(name == "circle_area") {
|
||||
$gui.set<Effect>(button, {0.4f});
|
||||
$gui.set<Sprite>(button, {"the_ritual_circle"});
|
||||
$gui.set<Clickable>(button, {
|
||||
[&](auto ent, auto){ ritual_circle_clicked(ent); }
|
||||
});
|
||||
} else if(name.starts_with("inv_slot")) {
|
||||
$gui.set<Sprite>(button, {
|
||||
fmt::format("{}-64", junk_list[button % junk_list.size()])});
|
||||
$gui.set<Effect>(button, {0.4f});
|
||||
$gui.set<Sound>(button, {"ui_click"});
|
||||
$gui.set<Clickable>(button, {
|
||||
[&](auto ent, auto){ inv_slot_clicked(ent); }
|
||||
});
|
||||
} else if(name == "ritual_ui") {
|
||||
$gui.set<Clickable>(button, {
|
||||
[&](auto, auto){ toggle(); }
|
||||
});
|
||||
$gui.set<Sound>(button, {"pickup"});
|
||||
}
|
||||
}
|
||||
auto circle = $gui.entity("circle_area");
|
||||
$gui.set<Effect>(circle, {0.4f});
|
||||
$gui.set<Sprite>(circle, {"the_ritual_circle"});
|
||||
$gui.set<Clickable>(circle, {
|
||||
[&](auto ent, auto){ ritual_circle_clicked(ent); }
|
||||
});
|
||||
|
||||
auto open_close_toggle = $gui.entity("ritual_ui");
|
||||
$gui.set<Clickable>(open_close_toggle, {[&](auto, auto){ toggle(); }});
|
||||
$gui.set<Sound>(open_close_toggle, {"pickup"});
|
||||
|
||||
$ritual_ui = textures::get("ritual_crafting_area");
|
||||
$ritual_ui.sprite->setPosition({0,0});
|
||||
|
@ -121,7 +115,7 @@ namespace gui {
|
|||
if($blanket.is_combined()) {
|
||||
// add it to the belt
|
||||
auto ritual = $engine.finalize($blanket);
|
||||
auto& the_belt = $level.world->get<combat::RitualBelt>($level.player);
|
||||
auto& the_belt = $level.world->get_the<ritual::Belt>();
|
||||
the_belt.equip(0, ritual);
|
||||
$level.world->send<Events::GUI>(Events::GUI::NEW_RITUAL, $level.player, {});
|
||||
reset_inv_positions();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue