Browse Source

FIX: Selecting Quit Game opens into the Support menu #4334

pull/4367/head
Bubio 4 years ago committed by GitHub
parent
commit
9574fb30fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      Source/DiabloUI/diabloui.cpp
  2. 20
      Source/DiabloUI/ui_item.h

17
Source/DiabloUI/diabloui.cpp

@ -912,10 +912,21 @@ Uint32 dbClickTimer;
bool HandleMouseEventList(const SDL_Event &event, UiList *uiList)
{
if (event.type != SDL_MOUSEBUTTONUP || event.button.button != SDL_BUTTON_LEFT)
if (event.button.button != SDL_BUTTON_LEFT)
return false;
if (event.type != SDL_MOUSEBUTTONUP && event.type != SDL_MOUSEBUTTONDOWN)
return false;
std::size_t index = uiList->indexAt(event.button.y);
if (event.type == SDL_MOUSEBUTTONDOWN) {
uiList->Press(index);
return true;
}
if (event.type == SDL_MOUSEBUTTONUP && !uiList->IsPressed(index))
return false;
index += listOffset;
if (gfnListFocus != nullptr && SelectedItem != index) {
@ -1038,6 +1049,8 @@ bool UiItemMouseEvents(SDL_Event *event, const std::vector<UiItemBase *> &items)
for (const auto &item : items) {
if (item->IsType(UiType::Button)) {
HandleGlobalMouseUpButton(static_cast<UiButton *>(item));
} else if (item->IsType(UiType::List)) {
static_cast<UiList *>(item)->Release();
}
}
}
@ -1069,6 +1082,8 @@ bool UiItemMouseEvents(SDL_Event *event, const std::vector<std::unique_ptr<UiIte
for (const auto &item : items) {
if (item->IsType(UiType::Button)) {
HandleGlobalMouseUpButton(static_cast<UiButton *>(item.get()));
} else if (item->IsType(UiType::List)) {
static_cast<UiList *>(item.get())->Release();
}
}
}

20
Source/DiabloUI/ui_item.h

@ -381,6 +381,8 @@ public:
{
for (const auto &item : vItems)
m_vecItems.push_back(item.get());
pressed_item_index_ = -1;
}
[[nodiscard]] SDL_Rect itemRect(int i) const
@ -412,6 +414,21 @@ public:
return spacing_;
}
[[nodiscard]] bool IsPressed(size_t index) const
{
return pressed_item_index_ == index;
}
void Press(size_t index)
{
pressed_item_index_ = index;
}
void Release()
{
pressed_item_index_ = -1;
}
// private:
size_t viewportSize;
Sint16 m_x, m_y;
@ -420,5 +437,8 @@ public:
private:
int spacing_;
// State
size_t pressed_item_index_;
};
} // namespace devilution

Loading…
Cancel
Save