1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

add sound; possibility to click outside to close

This commit is contained in:
Michael 2023-08-20 13:05:25 +02:00 committed by GitHub
parent 8635c24166
commit 52ed824100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#include "../CGameInfo.h"
#include "../CServerHandler.h"
#include "../CMusicHandler.h"
#include "../gui/CGuiHandler.h"
#include "../gui/Shortcut.h"
#include "../gui/WindowHandler.h"
@ -470,6 +471,7 @@ void OptionsTab::SelectionWindow::apply()
if(GH.windows().isTopWindow(this))
{
GH.input().hapticFeedback();
CCS->soundh->playSound(soundBase::button);
close();
@ -732,8 +734,19 @@ void OptionsTab::SelectionWindow::setElement(int elem, bool doApply)
apply();
}
bool OptionsTab::SelectionWindow::receiveEvent(const Point & position, int eventType) const
{
return true; // capture click also outside of window
}
void OptionsTab::SelectionWindow::clickReleased(const Point & cursorPosition)
{
if(!pos.isInside(cursorPosition))
{
close();
return;
}
int elem = getElement(cursorPosition);
setElement(elem, true);
@ -741,6 +754,9 @@ void OptionsTab::SelectionWindow::clickReleased(const Point & cursorPosition)
void OptionsTab::SelectionWindow::showPopupWindow(const Point & cursorPosition)
{
if(!pos.isInside(cursorPosition))
return;
int elem = getElement(cursorPosition);
setElement(elem, false);
@ -939,4 +955,4 @@ void OptionsTab::PlayerOptionsEntry::hideUnavailableButtons()
buttonBonusLeft->enable();
buttonBonusRight->enable();
}
}
}

View File

@ -140,6 +140,7 @@ public:
int getElement(const Point & cursorPosition);
void setElement(int element, bool doApply);
bool receiveEvent(const Point & position, int eventType) const override;
void clickReleased(const Point & cursorPosition) override;
void showPopupWindow(const Point & cursorPosition) override;