From 481f4db4b4c8b0e02452ad96fea02bd7aa8825b2 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Mon, 30 Oct 2017 17:37:59 +0100 Subject: [PATCH] Use a method for fixing the decor shifting It will be used for supporting the smooth scrolling. --- src/decor.cxx | 42 ++++++++++++++++++++++++------------------ src/decor.h | 1 + 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/decor.cxx b/src/decor.cxx index 8b41db7..f4e65c0 100644 --- a/src/decor.cxx +++ b/src/decor.cxx @@ -449,6 +449,29 @@ CDecor::SetFire (Point cel, bool bFire) return true; } +void +CDecor::FixShifting (Sint32 & nbx, Sint32 & nby, Point & iCel, Point & iPos) +{ + if (m_shiftOffset.x < 0) // décalage à droite ? + nbx += 2; + if (m_shiftOffset.y < 0) // décalage en bas ? + nby += 2; + if (m_shiftOffset.x > 0) // décalage à gauche ? + { + nbx += 2; + iCel.x--; + iCel.y++; + iPos = ConvCelToPos (iCel); + } + if (m_shiftOffset.y > 0) // décalage en haut ? + { + nby += 2; + iCel.x--; + iCel.y--; + iPos = ConvCelToPos (iCel); + } +} + // Modifie l'offset pour le shift. void @@ -1435,24 +1458,7 @@ CDecor::Build (Rect clip, Point posMouse) if (!m_bFog) goto term; - if (m_shiftOffset.x < 0) // décalage à droite ? - nbx += 2; - if (m_shiftOffset.y < 0) // décalage en bas ? - nby += 2; - if (m_shiftOffset.x > 0) // décalage à gauche ? - { - nbx += 2; - iCel.x--; - iCel.y++; - iPos = ConvCelToPos (iCel); - } - if (m_shiftOffset.y > 0) // décalage en haut ? - { - nby += 2; - iCel.x--; - iCel.y--; - iPos = ConvCelToPos (iCel); - } + this->FixShifting (nbx, nby, iCel, iPos); mCel = iCel; mPos = iPos; diff --git a/src/decor.h b/src/decor.h index 01e4ec4..c53610a 100644 --- a/src/decor.h +++ b/src/decor.h @@ -381,6 +381,7 @@ public: bool IsCheminFree (Sint32 rank, Point dest, Sint32 button); // Decor.cpp + void FixShifting (Sint32 & nbx, Sint32 & nby, Point & iCel, Point & iPos); void SetShiftOffset (Point offset); Point ConvCelToPos (Point cel); Point ConvPosToCel (Point pos, bool bMap = false);