|
|
|
@ -259,7 +259,7 @@ namespace guecs { |
|
|
|
|
bool UI::mouse(float x, float y, bool hover) { |
|
|
|
|
int action_count = 0; |
|
|
|
|
|
|
|
|
|
$world.query<lel::Cell, Clickable>([&](auto ent, auto& cell, auto &clicked) { |
|
|
|
|
$world.query<lel::Cell>([&](auto ent, auto& cell) { |
|
|
|
|
if((x >= cell.x && x <= cell.x + cell.w) && |
|
|
|
|
(y >= cell.y && y <= cell.y + cell.h)) |
|
|
|
|
{ |
|
|
|
@ -275,11 +275,7 @@ namespace guecs { |
|
|
|
|
|
|
|
|
|
if(hover) return; |
|
|
|
|
|
|
|
|
|
if(auto action_data = get_if<ActionData>(ent)) { |
|
|
|
|
clicked.action(ent, action_data->data); |
|
|
|
|
} else { |
|
|
|
|
clicked.action(ent, {}); |
|
|
|
|
} |
|
|
|
|
click_on(ent); |
|
|
|
|
|
|
|
|
|
action_count++; |
|
|
|
|
} else { |
|
|
|
@ -317,6 +313,27 @@ namespace guecs { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UI::click_on(const std::string& name, bool required) { |
|
|
|
|
auto ent = entity(name); |
|
|
|
|
|
|
|
|
|
if(required) { |
|
|
|
|
dbc::check(has<Clickable>(ent), |
|
|
|
|
fmt::format("click_on required '{}' to exist but it doesn't", name)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
click_on(ent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UI::click_on(DinkyECS::Entity ent) { |
|
|
|
|
if(auto clicked = get_if<Clickable>(ent)) { |
|
|
|
|
if(auto action_data = get_if<ActionData>(ent)) { |
|
|
|
|
clicked->action(ent, action_data->data); |
|
|
|
|
} else { |
|
|
|
|
clicked->action(ent, {}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UI::show_label(string region, wstring content) { |
|
|
|
|
auto ent = entity(region); |
|
|
|
|
|
|
|
|
|