1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Fix the mouse movements with scaling != of 1x

This commit is contained in:
Mathieu Schroeter 2017-03-01 18:10:20 +01:00
parent ae6d01a519
commit ace9791ab0
3 changed files with 10 additions and 5 deletions

View File

@ -3556,7 +3556,7 @@ bool CEvent::PlayUp (POINT pos)
{
m_menuCel = m_pDecor->ConvPosToCel (pos);
m_menuPos = pos;
m_menu.Create (m_pPixmap, m_pSound,
m_menu.Create (m_pPixmap, m_pSound, this,
pos, m_menuNb, m_menuButtons, m_menuErrors,
m_menuTexts, m_menuPerso);
m_bMenu = true;

View File

@ -131,6 +131,7 @@ CMenu::CMenu()
m_pPixmap = nullptr;
m_pDecor = nullptr;
m_pSound = nullptr;
m_pEvent = nullptr;
}
// Destructeur.
@ -142,7 +143,7 @@ CMenu::~CMenu()
// Crée un nouveau bouton.
bool CMenu::Create (CPixmap *pPixmap, CSound *pSound,
bool CMenu::Create (CPixmap *pPixmap, CSound *pSound, CEvent *pEvent,
POINT pos, Sint32 nb, Sint32 *pButtons, Sint32 *pErrors,
std::unordered_map<Sint32, const char *> &texts,
Sint32 perso)
@ -152,6 +153,7 @@ bool CMenu::Create (CPixmap *pPixmap, CSound *pSound,
m_pPixmap = pPixmap;
m_pSound = pSound;
m_pEvent = pEvent;
m_nbButtons = nb;
m_pos = pos;
m_perso = perso;
@ -173,7 +175,9 @@ bool CMenu::Create (CPixmap *pPixmap, CSound *pSound,
pos = m_pos;
pos.x += DIMBUTTONX / 2;
pos.y += DIMBUTTONY / 2;
SDL_WarpMouseInWindow (g_window, pos.x, pos.y);
SDL_WarpMouseInWindow (g_window,
pos.x * m_pEvent->GetWindowScale (),
pos.y * m_pEvent->GetWindowScale ());
}
m_selRank = Detect (pos);

View File

@ -4,7 +4,7 @@
#include <unordered_map>
#include "def.h"
/////////////////////////////////////////////////////////////////////////////
class CEvent;
class CMenu
{
@ -12,7 +12,7 @@ public:
CMenu();
~CMenu();
bool Create (CPixmap *pPixmap, CSound *pSound,
bool Create (CPixmap *pPixmap, CSound *pSound, CEvent *pEvent,
POINT pos, Sint32 nb, Sint32 *pButtons, Sint32 *pErrors,
std::unordered_map<Sint32, const char *> &texts,
Sint32 perso);
@ -38,6 +38,7 @@ protected:
CPixmap *m_pPixmap;
CDecor *m_pDecor;
CSound *m_pSound;
CEvent *m_pEvent;
POINT m_pos; // coin sup/gauche
POINT m_dim; // dimensions
Sint32 m_nbButtons;