@ -149,9 +149,9 @@ namespace guecs {
} ) ;
}
bool UI : : mouse ( float x , float y , bool hover ) {
bool UI : : mouse ( float x , float y , Modifiers mods ) {
int action_count = 0 ;
// BUG: Is Parser::hit useful?
bool hover = mods . test ( size_t ( ModBit : : hover ) ) ;
query < lel : : Cell > ( [ & ] ( auto ent , auto & cell ) {
if ( ( x > = cell . x & & x < = cell . x + cell . w ) & &
@ -169,11 +169,11 @@ namespace guecs {
if ( hover ) return ;
click_on ( ent ) ;
click_on ( ent , mods ) ;
action_count + + ;
} else {
do_if < Effect > ( ent , [ hover ] ( auto & effect ) {
do_if < Effect > ( ent , [ ] ( auto & effect ) {
effect . stop ( ) ;
} ) ;
@ -220,25 +220,10 @@ namespace guecs {
}
}
void UI : : click_on ( const string & name , bool required ) {
auto ent = entity ( name ) ;
if ( required ) {
assert ( has < Clickable > ( ent ) & &
" click_on required '{}' to exist but it doesn't " ) ;
}
click_on ( ent ) ;
}
void UI : : click_on ( 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 : : click_on ( Entity gui_id , Modifiers mods ) {
if ( auto to_click = get_if < Clickable > ( gui_id ) ) {
to_click - > action ( mods ) ;
} ;
}
wstring to_wstring ( const string & str ) {