Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
Nimetu 6 years ago
commit f979597830

@ -222,6 +222,7 @@ inline double isValidDouble (double v)
* \param str a string to transform to lower case * \param str a string to transform to lower case
*/ */
std::string toLower ( const char *str );
std::string toLower ( const std::string &str ); std::string toLower ( const std::string &str );
void toLower ( char *str ); void toLower ( char *str );
char toLower ( const char ch ); // convert only one character char toLower ( const char ch ); // convert only one character

@ -1443,12 +1443,11 @@ namespace NLGUI
if (_FontName == name) if (_FontName == name)
return; return;
if (_FontName.length() > 0) if (_Index != 0xFFFFFFFF)
{ CViewRenderer::getTextContext(_FontName)->erase (_Index);
if (_Index != 0xFFFFFFFF) clearLines();
CViewRenderer::getTextContext(_FontName)->erase (_Index);
clearLines(); resetTextIndex();
}
_FontName = name; _FontName = name;
computeFontSize (); computeFontSize ();

@ -591,6 +591,22 @@ NLMISC_CATEGORISED_COMMAND(nel,stohr, "Convert a second number into an human rea
return true; return true;
} }
std::string toLower(const char *str)
{
if (!str) return "";
uint len = strlen(str);
string res;
res.reserve(len);
for(uint i = 0; i < len; i++)
{
if( (str[i] >= 'A') && (str[i] <= 'Z') )
res += str[i] - 'A' + 'a';
else
res += str[i];
}
return res;
}
std::string toLower(const std::string &str) std::string toLower(const std::string &str)
{ {

@ -84,9 +84,6 @@ bool InitMouseWithCursor (bool hardware)
MouseHardware = hardware; MouseHardware = hardware;
CViewPointer::setHWMouse( hardware ); CViewPointer::setHWMouse( hardware );
// Update mouse information
UpdateMouse ();
if (InitMouseFirstTime) if (InitMouseFirstTime)
{ {
InitMouseFirstTime = false; InitMouseFirstTime = false;
@ -129,16 +126,6 @@ bool IsMouseCursorHardware ()
return MouseHardware; return MouseHardware;
} }
// *********************************************************************************
// Set the mouse mode. Call this method once per frame to update window size
void UpdateMouse ()
{
if (!Driver->isSystemCursorCaptured())
{
DownMouseButtons = 0;
}
}
// ********************************************************************************* // *********************************************************************************
// Use this method to toggle the mouse (freelook <- cursor) // Use this method to toggle the mouse (freelook <- cursor)
void SetMouseFreeLook () void SetMouseFreeLook ()
@ -160,7 +147,6 @@ void SetMouseFreeLook ()
pointer->show (false); pointer->show (false);
} }
} }
UpdateMouse ();
} }
} }
@ -202,7 +188,6 @@ void SetMouseCursor (bool updatePos)
} }
MouseFreeLook = false; MouseFreeLook = false;
UpdateMouse ();
// Integer coordinates // Integer coordinates
sint ix = (sint)(x*(float)width+0.5f); sint ix = (sint)(x*(float)width+0.5f);
@ -253,7 +238,6 @@ void SetMouseCursor (bool updatePos)
void SetMouseSpeed (float speed) void SetMouseSpeed (float speed)
{ {
MouseCursorSpeed = speed; MouseCursorSpeed = speed;
UpdateMouse ();
} }
// ********************************************************************************* // *********************************************************************************
@ -261,12 +245,27 @@ void SetMouseSpeed (float speed)
void SetMouseAcceleration (uint accel) void SetMouseAcceleration (uint accel)
{ {
MouseCursorAcceleration = accel; MouseCursorAcceleration = accel;
UpdateMouse ();
} }
// ********************************************************************************* // *********************************************************************************
void HandleSystemCursorCapture(const CEvent &event) void HandleSystemCursorCapture(const CEvent &event)
{ {
static bool mouseCaptured = false;
// capture on first move event after button is held down or free look is activated
if (event == EventMouseMoveId && !mouseCaptured && (MouseFreeLook || DownMouseButtons != 0))
{
mouseCaptured = true;
Driver->setCapture(true);
}
// release when button is released and not in free look
if (mouseCaptured && !MouseFreeLook && DownMouseButtons == 0)
{
mouseCaptured = false;
Driver->setCapture(false);
}
if (event == EventMouseDownId) if (event == EventMouseDownId)
{ {
CEventMouseDown &em = (CEventMouseDown &) event; CEventMouseDown &em = (CEventMouseDown &) event;
@ -279,8 +278,6 @@ void HandleSystemCursorCapture(const CEvent &event)
cursor->setPointerMiddleDown(em.Button == middleButton); cursor->setPointerMiddleDown(em.Button == middleButton);
cursor->setPointerRightDown(em.Button == rightButton); cursor->setPointerRightDown(em.Button == rightButton);
} }
Driver->setCapture(true);
} }
if (event == EventMouseUpId) if (event == EventMouseUpId)
@ -297,7 +294,6 @@ void HandleSystemCursorCapture(const CEvent &event)
cursor->setPointerMiddleDown(false); cursor->setPointerMiddleDown(false);
cursor->setPointerRightDown(false); cursor->setPointerRightDown(false);
} }
Driver->setCapture(false);
} }
} }

@ -44,9 +44,6 @@ bool InitMouseWithCursor (bool hardware);
// Is mouse cursor hardware ? // Is mouse cursor hardware ?
bool IsMouseCursorHardware (); bool IsMouseCursorHardware ();
// Set the mouse mode. Call this method once per frame to update window size
void UpdateMouse ();
// Use this method to toggle the mouse (freelook <- cursor) // Use this method to toggle the mouse (freelook <- cursor)
void SetMouseFreeLook (); void SetMouseFreeLook ();

@ -163,6 +163,7 @@ CUserEntity::CUserEntity()
// Your are not on a mount at the beginning. // Your are not on a mount at the beginning.
_OnMount = false; _OnMount = false;
_HiddenMount = CLFECOMMON::INVALID_SLOT;
_AnimAttackOn = false; _AnimAttackOn = false;
@ -3188,6 +3189,8 @@ void CUserEntity::viewMode(CUserEntity::TView viewMode, bool changeView)
CEntityCL *mount = EntitiesMngr.entity(_Mount); CEntityCL *mount = EntitiesMngr.entity(_Mount);
if(mount) if(mount)
mount->displayable(false); mount->displayable(false);
_HiddenMount = _Mount;
} }
// Change Controls. // Change Controls.
if( isRiding() ) if( isRiding() )
@ -3205,11 +3208,14 @@ void CUserEntity::viewMode(CUserEntity::TView viewMode, bool changeView)
case ThirdPV: case ThirdPV:
if(changeView) if(changeView)
ClientCfg.FPV = false; ClientCfg.FPV = false;
if(_Mount != CLFECOMMON::INVALID_SLOT)
if(_HiddenMount != CLFECOMMON::INVALID_SLOT)
{ {
CEntityCL *mount = EntitiesMngr.entity(_Mount); CEntityCL *mount = EntitiesMngr.entity(_HiddenMount);
if(mount) if(mount)
mount->displayable(true); mount->displayable(true);
_HiddenMount == CLFECOMMON::INVALID_SLOT;
} }
// Change Controls. // Change Controls.
UserControls.mode(CUserControls::ThirdMode); UserControls.mode(CUserControls::ThirdMode);
@ -3393,9 +3399,24 @@ void CUserEntity::updateVisualDisplay()
if(UserControls.isInternalView() || View.forceFirstPersonView()) if(UserControls.isInternalView() || View.forceFirstPersonView())
{ {
// Hide the mount // Hide the mount
CCharacterCL *mount = dynamic_cast<CCharacterCL *>(EntitiesMngr.entity(_Mount)); if (_Mount != CLFECOMMON::INVALID_SLOT)
if(mount) {
mount->displayable(false); CCharacterCL *mount = dynamic_cast<CCharacterCL *>(EntitiesMngr.entity(_Mount));
if(mount)
mount->displayable(false);
_HiddenMount = _Mount;
}
else if (_HiddenMount != CLFECOMMON::INVALID_SLOT)
{
// not on mount anymore, but still in FPV
CCharacterCL *mount = dynamic_cast<CCharacterCL *>(EntitiesMngr.entity(_HiddenMount));
if(mount)
mount->displayable(true);
_HiddenMount = CLFECOMMON::INVALID_SLOT;
}
// Hide all user body parts. // Hide all user body parts.
for(uint i=0; i<_Instances.size(); ++i) for(uint i=0; i<_Instances.size(); ++i)
if(!_Instances[i].Current.empty()) if(!_Instances[i].Current.empty())

@ -701,6 +701,8 @@ protected:
private: private:
/// TO know if the user is on a mount at the moment. /// TO know if the user is on a mount at the moment.
bool _OnMount; bool _OnMount;
/// Keep track of last hidden mount when switching to FPV mode
CLFECOMMON::TCLEntityId _HiddenMount;
/// Is the attack animation is currently playing. /// Is the attack animation is currently playing.
bool _AnimAttackOn; bool _AnimAttackOn;
/// Current View Mode (First/Third Person View). /// Current View Mode (First/Third Person View).

Loading…
Cancel
Save