//----------------------------------------------------------------------------------------------------------------------------------- Vector2 GameMouse::GetInGamePosition() { return ScreenManager::GetCamera().ScreenToGameCoords(GetLocalPosition()); }
bool GuiElement::CheckEvent(GuiElement* hover, GuiElement* focus) { bool inside = (hover == this); bool focused = (focus == this); if (inside != mouseIn) { if (listener) { if (inside) listener->OnEvent(this, EVENT_MOUSE_ENTER); else listener->OnEvent(this, EVENT_MOUSE_EXIT); } mouseIn = inside; } if (inside) { if (listener) { if (App->input->GetMouseButtonDown(SDL_BUTTON_LEFT) == KEY_DOWN) listener->OnEvent(this, EVENT_MOUSE_LEFTCLICK_DOWN); if (App->input->GetMouseButtonDown(SDL_BUTTON_LEFT) == KEY_UP) listener->OnEvent(this, EVENT_MOUSE_LEFTCLICK_UP); if (App->input->GetMouseButtonDown(SDL_BUTTON_RIGHT) == KEY_DOWN) listener->OnEvent(this, EVENT_MOUSE_RIGHTCLICK_DOWN); if (App->input->GetMouseButtonDown(SDL_BUTTON_RIGHT) == KEY_UP) listener->OnEvent(this, EVENT_MOUSE_RIGHTCLICK_UP); } if (draggable && App->input->GetMouseButtonDown(SDL_BUTTON_LEFT) == KEY_REPEAT) { iPoint p = GetLocalPosition(); iPoint m = App->input->GetMouseMotion(); SetLocalPosition(p + m); } } if (focusIn != focused) { if (listener) { if (focused) listener->OnEvent(this, EVENT_FOCUS_DOWN); else listener->OnEvent(this, EVENT_FOCUS_UP); } focusIn = focused; } if (focused) { if (listener) { if(App->input->GetKey(SDL_SCANCODE_RETURN) == KEY_DOWN) listener->OnEvent(this, EVENT_MOUSE_LEFTCLICK_DOWN); if (App->input->GetKey(SDL_SCANCODE_RETURN) == KEY_UP) listener->OnEvent(this, EVENT_MOUSE_LEFTCLICK_UP); } } return true; }