Esempio n. 1
0
void WeatherInfo::Update()
{
    // There will be a 66% the weather density decreases. If Sunny, use as currentDensity as countdown
    if (m_currentEffect == 0 || RandomUInt(100) < 66)
    {
        m_currentDensity -= WEATHER_DENSITY_UPDATE;
        if (m_currentDensity < 0.30f)  //0.20 is considered fog, lower values are annoying
        {
            m_currentDensity = 0.0f;
            m_currentEffect = 0;
            sEventMgr.RemoveEvents(this, EVENT_WEATHER_UPDATE);
            _GenerateWeather();
            return;
        }
    }
    else
    {
        m_currentDensity += WEATHER_DENSITY_UPDATE;
        if (m_currentDensity >= m_maxDensity)
        {
            m_currentDensity = m_maxDensity;
            return;
        }
    }
    SendUpdate();
    //    LOG_DEBUG("Weather Updated,zoneId:%d type:%d density:%f", m_zoneId, m_currentEffect, m_currentDensity);
}
Esempio n. 2
0
bool Group::AddMember(ObjectGuid guid, const char* name)
{
    if (!_addMember(guid, name))
        return false;

    SendUpdate();

    if (Player* player = sObjectMgr.GetPlayer(guid))
    {
        if (!IsLeader(player->GetObjectGuid()) && !isBGGroup())
        {
            // reset the new member's instances, unless he is currently in one of them
            // including raid instances that they are not permanently bound to!
            player->ResetInstances(INSTANCE_RESET_GROUP_JOIN);
        }
        player->SetGroupUpdateFlag(GROUP_UPDATE_FULL);
        UpdatePlayerOutOfRange(player);

        // quest related GO state dependent from raid membership
        if (isRaidGroup())
            player->UpdateForQuestWorldObjects();
    }

    return true;
}
Esempio n. 3
0
void WeatherInfo::_GenerateWeather()
{
    m_currentTime = 0;
    m_currentDensity = 0;
    m_currentEffect = 0;

    uint32 rv = sRand.randInt(100);

    std::map<uint32, uint32>::iterator itr;

    for(itr = m_effectValues.begin(); itr != m_effectValues.end(); itr++)
    {
        if (rv <= itr->second)
        {
            m_currentEffect = itr->first;
            break;
        }
        else
        {
            rv -= itr->second;
        }
    }

    m_maxDensity = sRand.rand(2); //0 - 2
    m_totalTime = (sRand.randInt(11) + 5)*1000*60;
    m_increase = true;

    SendUpdate();

    sEventMgr.AddEvent(this, &WeatherInfo::Update, EVENT_WEATHER_UPDATE, 
        (uint32)(m_totalTime/ceil(m_maxDensity/WEATHER_DENSITY_UPDATE)*2), 0);
}
Esempio n. 4
0
void WeatherInfo::_GenerateWeather()
{
    m_currentTime = 0;
    m_currentEffect = 0;
    m_currentDensity = 0.30f;//Starting Offset (don't go below, it's annoying fog)
    float fd = RandomFloat();
    m_maxDensity = fd + 1; //1 - 2
    m_totalTime = (RandomUInt(11) + 5) * 1000 * 120; //update approx. every 1-2 minutes

    uint32 rv = RandomUInt(100);

    std::map<uint32, uint32>::iterator itr;

    if (rv <= m_effectValues[4])  // %chance on changing weather from sunny to m_effectValues[5]
    {
        m_currentEffect = m_effectValues[5];
    }
    else if (rv <= m_effectValues[2])  // %chance on changing weather from sunny to m_effectValues[3]
    {
        m_currentEffect = m_effectValues[3];
    }
    else if (rv <= m_effectValues[0])  // %chance on changing weather from sunny to m_effectValues[1]
    {
        m_currentEffect = m_effectValues[1];
    }

    SendUpdate();

    sEventMgr.AddEvent(this, &WeatherInfo::BuildUp, EVENT_WEATHER_UPDATE, (uint32)(m_totalTime / ceil(m_maxDensity / WEATHER_DENSITY_UPDATE) * 2), 0, 0);
    Log.Debug("WeatherMgr", "Forecast for zone:%d new type:%d new interval:%d ms", m_zoneId, m_currentEffect, (uint32)(m_totalTime / ceil(m_maxDensity / WEATHER_DENSITY_UPDATE) * 2));
}
Esempio n. 5
0
void WeatherInfo::Update()
{
    if (m_increase)
    {
        m_currentDensity += WEATHER_DENSITY_UPDATE;
        if (m_currentDensity >= m_maxDensity)
        {
            m_currentDensity = m_maxDensity;
            m_increase = false;
        }
    }
    else
    {
        m_currentDensity -= WEATHER_DENSITY_UPDATE;
        if (m_currentDensity <= 0)
        {
            m_currentDensity = 0;
            sEventMgr.RemoveEvents(this, EVENT_WEATHER_UPDATE);
            _GenerateWeather();
            return;
        }
    }

    SendUpdate();
}
Esempio n. 6
0
void Group::ChangeLeader(const uint64 &guid)
{
    uint32 i;
    WorldPacket data;

    Player *player;

    for( i = 0; i < m_count; i++ )
    {
        if( m_members[i].guid == guid )
            break;
    }

    ASSERT( i < MAXGROUPSIZE );

    m_leaderGuid=guid;
    data.Initialize( SMSG_GROUP_SET_LEADER );
    data << m_members[i].name;

    for( i = 0; i < m_count; i++ )
    {
#ifndef ENABLE_GRID_SYSTEM
        player = objmgr.GetObject<Player>( m_members[i].guid );
#else
    player = ObjectAccessor::Instance().FindPlayer( m_members[i].guid );
#endif
        ASSERT( player );

        player->SetLeader(guid );
        player->GetSession()->SendPacket( &data );
    }

    SendUpdate();
}
Esempio n. 7
0
void BaseResource::UpdateCollector () {

	/* avoid updating the collector too often, except on the 
	first update */
	if ( !_firstCollectorUpdate ) {
		int delay = ( _lastCollectorUpdate + 
			_collectorUpdateInterval ) - time ( NULL );
		if ( delay > 0 ) {
			daemonCore->Reset_Timer ( _updateCollectorTimerId, delay );
			return;
		}
	} else {
		_firstCollectorUpdate = false;
	}

	/* Update the the Collector as to this resource's state */
    if ( !SendUpdate () && !daemonCore->getCollectorList()->IsEmpty() ) {
		dprintf (
			D_FULLDEBUG,
			"BaseResource::UpdateCollector: Updating Collector(s) "
			"failed.\n" );
	}

	/* reset the timer to fire again at the defined interval */
	daemonCore->Reset_Timer ( 
		_updateCollectorTimerId, 
		_collectorUpdateInterval );
	_lastCollectorUpdate = time ( NULL );
}
Esempio n. 8
0
bool Group::AddMember(ObjectGuid guid, const char* name)
{
    if (!_addMember(guid, name))
        return false;

    SendUpdate();

    if (Player* player = sObjectMgr.GetPlayer(guid))
    {
        if (!IsLeader(player->GetObjectGuid()) && !isBGGroup())
        {
            // reset the new member's instances, unless he is currently in one of them
            // including raid/heroic instances that they are not permanently bound to!
            player->ResetInstances(INSTANCE_RESET_GROUP_JOIN);

            if (player->getLevel() >= LEVELREQUIREMENT_HEROIC && player->GetDifficulty() != GetDifficulty())
            {
                player->SetDifficulty(GetDifficulty());
                player->SendDungeonDifficulty(true);
            }
        }
        player->SetGroupUpdateFlag(GROUP_UPDATE_FULL);
        UpdatePlayerOutOfRange(player);

        // used by eluna
        GlobalEluna(OnAddMember(this, player->GetObjectGuid()));

        // quest related GO state dependent from raid membership
        if (isRaidGroup())
            player->UpdateForQuestWorldObjects();
    }

    return true;
}
Esempio n. 9
0
void HuffyServer::ServerWaitForClientToRequestUpdate()
{
	//Todo, should be multi-threaded to avoid hanging while waiting for client.
	std::string Request = "";
	std::cout <<"\nWaiting for client to request update\n";
	while (Request != UPDATE_REQUEST)
	{

		try
		{
			*m_ConectionSocket >> Request;
		}
		catch (SocketException& e)
		{
			std::cout << "Socket exception was caught:" << e.description();

			Request = UPDATE_REQUEST;
		}

	}
	std::cout << "\nMessage recieved from client:" + Request;
	std::cout << "\nnote: U is the value for UPDATE_REQUEST defined in the Comunication codes header";
		std::cout <<"\nClient requested update\n";
	std::cout <<"\nUpdate is:" << (UPDATE_RESPONSE + m_Update) << ".\n";
	SendUpdate(UPDATE_RESPONSE + m_Update);
}
Esempio n. 10
0
uint32 Group::RemoveMember(ObjectGuid guid, uint8 method)
{
    //Playerbot mod - if master leaves group, all bots leave group
    {
        Player* const player = sObjectMgr.GetPlayer(guid);
        if (player && player->GetPlayerbotMgr())
            player->GetPlayerbotMgr()->RemoveAllBotsFromGroup();
    }
    //END Playerbot mod

    // remove member and change leader (if need) only if strong more 2 members _before_ member remove
    if (GetMembersCount() > uint32(isBGGroup() ? 1 : 2))    // in BG group case allow 1 members group
    {
        bool leaderChanged = _removeMember(guid);

        if (Player* player = sObjectMgr.GetPlayer(guid))
        {
            // quest related GO state dependent from raid membership
            if (isRaidGroup())
                player->UpdateForQuestWorldObjects();

            WorldPacket data;

            if (method == 1)
            {
                data.Initialize(SMSG_GROUP_UNINVITE, 0);
                player->GetSession()->SendPacket(&data);
            }

            // we already removed player from group and in player->GetGroup() is his original group!
            if (Group* group = player->GetGroup())
            {
                group->SendUpdate();
            }
            else
            {
                data.Initialize(SMSG_GROUP_LIST, 24);
                data << uint64(0) << uint64(0) << uint64(0);
                player->GetSession()->SendPacket(&data);
            }

            _homebindIfInstance(player);
        }

        if (leaderChanged)
        {
            WorldPacket data(SMSG_GROUP_SET_LEADER, (m_memberSlots.front().name.size() + 1));
            data << m_memberSlots.front().name;
            BroadcastPacket(&data, true);
        }

        SendUpdate();
    }
    // if group before remove <= 2 disband it
    else
        Disband(true);

    return m_memberSlots.size();
}
Esempio n. 11
0
bool Group::AddMember(const uint64 &guid, const char* name)
{
    if(!_addMember(guid, name))
        return false;
    SendUpdate();

    return true;
}
Esempio n. 12
0
void Group::ChangeLeader(const uint64 &guid)
{
    _setLeader(guid);

    WorldPacket data(SMSG_GROUP_SET_LEADER, (m_members[_getMemberIndex(guid)].name.size()+1));
    data << m_members[_getMemberIndex(guid)].name;
    BroadcastPacket(&data);
    SendUpdate();
}
Esempio n. 13
0
void tcNumberWidget<T>::OnLButtonUp(wxMouseEvent& event)
{
    // implement change for simple click on release of mouse
    if (!autoChange)
    {
        val += changeIncrement;
        SendUpdate();
    }

    if (autoChange)
    {
        SendUpdate();
    }
    autoChange = false;
    changeIncrement = 0;
    leftButtonDown = false;

    SendRedraw();
}
Esempio n. 14
0
void MainWindow::AskForExit ( ) {
	int ans=wxMessageBox("Hay cambios sin aplicar al pseudocódigo.\n¿Aplicar los cambios antes de cerrar el editor?",main_window->GetTitle(),wxYES_NO|wxCANCEL|wxICON_QUESTION,this);
	if (ans==wxYES) {
		Save(); SendUpdate(MO_SAVE); Salir(true);
	} else if (ans==wxNO) {
		Salir(true);
	} else {
		return;
	}
}
Esempio n. 15
0
void
ImageBridgeChild::EndTransaction()
{
  MOZ_ASSERT(!mTxn->Finished(), "forgot BeginTransaction?");

  AutoEndTransaction _(mTxn);

  if (mTxn->IsEmpty()) {
    return;
  }

  AutoInfallibleTArray<CompositableOperation, 10> cset;
  cset.SetCapacity(mTxn->mOperations.size());
  if (!mTxn->mOperations.empty()) {
    cset.AppendElements(&mTxn->mOperations.front(), mTxn->mOperations.size());
  }
  ShadowLayerForwarder::PlatformSyncBeforeUpdate();

  AutoInfallibleTArray<EditReply, 10> replies;

  if (mTxn->mSwapRequired) {
    if (!SendUpdate(cset, &replies)) {
      NS_WARNING("could not send async texture transaction");
      return;
    }
  } else {
    // If we don't require a swap we can call SendUpdateNoSwap which
    // assumes that aReplies is empty (DEBUG assertion)
    if (!SendUpdateNoSwap(cset)) {
      NS_WARNING("could not send async texture transaction (no swap)");
      return;
    }
  }
  for (nsTArray<EditReply>::size_type i = 0; i < replies.Length(); ++i) {
    const EditReply& reply = replies[i];
    switch (reply.type()) {
    case EditReply::TOpTextureSwap: {
      const OpTextureSwap& ots = reply.get_OpTextureSwap();

      CompositableChild* compositableChild =
          static_cast<CompositableChild*>(ots.compositableChild());

      MOZ_ASSERT(compositableChild);

      compositableChild->GetCompositableClient()
        ->SetDescriptorFromReply(ots.textureId(), ots.image());
      break;
    }
    default:
      NS_RUNTIMEABORT("not reached");
    }
  }
}
Esempio n. 16
0
void Group::ChangeLeader(ObjectGuid guid)
{
    member_citerator slot = _getMemberCSlot(guid);
    if (slot == m_memberSlots.end())
        return;

    _setLeader(guid);

    WorldPacket data(SMSG_GROUP_SET_LEADER, slot->name.size() + 1);
    data << slot->name;
    BroadcastPacket(&data, true);
    SendUpdate();
}
Esempio n. 17
0
void WeatherInfo::BuildUp()
{
	// Increase until 0.5, start random counter when reached
	if (m_currentDensity >= 0.50f)
	{
		sEventMgr.RemoveEvents(this, EVENT_WEATHER_UPDATE);
		sEventMgr.AddEvent(this, &WeatherInfo::Update, EVENT_WEATHER_UPDATE, (uint32)(m_totalTime/ceil(m_maxDensity/WEATHER_DENSITY_UPDATE)*4), 0,0);
	}
	else
	{
		m_currentDensity += WEATHER_DENSITY_UPDATE;
		SendUpdate();
	}
}
Esempio n. 18
0
void tcNumberWidget<T>::OnMouseWheel(wxMouseEvent& event)
{
    bool mouseWheelUp = (event.GetWheelRotation() > 0);

    if (mouseWheelUp)
    {
        val += 1;
    }
    else
    {
        val -= 1;
    }
    SendUpdate();
}
Esempio n. 19
0
void Group::ConvertToRaid()
{
    m_groupType = GROUPTYPE_RAID;

    _initRaidSubGroupsCounter();

    if (!isBGGroup())
        CharacterDatabase.PExecute("UPDATE groups SET isRaid = 1 WHERE groupId='%u'", m_Id);
    SendUpdate();

    // update quest related GO states (quest activity dependent from raid membership)
    for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
        if (Player* player = sObjectMgr.GetPlayer(citr->guid))
            player->UpdateForQuestWorldObjects();
}
Esempio n. 20
0
void CMainMenuSection::UpdateState(long inSectionID,const CState_UpdateRequest& update)
{
//	CRenderSection_SetCamera render(CVector(0,0,0), CVector(0,0,1),,CVector(0,1,0), 1,0,100);
//	CTCommandSender<CRenderSection_SetCamera>::SendCommand( m_RenderSectionID, render);
    if (m_Command == UNDEFINED)
    {
        // do something
    }
    else

    {
        CTCommandSender<CHamster_HideMainMenuRequest>::SendCommand(inSectionID, CHamster_HideMainMenuRequest());
    }
    SendUpdate();
}
Esempio n. 21
0
void WeatherInfo::BuildUp()
{
    // Increase until 0.5, start random counter when reached
    if (m_currentDensity >= 0.50f)
    {
        sEventMgr.RemoveEvents(this, EVENT_WEATHER_UPDATE);
        sEventMgr.AddEvent(this, &WeatherInfo::Update, EVENT_WEATHER_UPDATE, (uint32)(m_totalTime / ceil(m_maxDensity / WEATHER_DENSITY_UPDATE) * 4), 0, 0);
        //        LOG_DEBUG("Weather starting random for zone:%d type:%d new interval:%d ms",m_zoneId,m_currentEffect,(uint32)(m_totalTime/ceil(m_maxDensity/WEATHER_DENSITY_UPDATE)*4));
    }
    else
    {
        m_currentDensity += WEATHER_DENSITY_UPDATE;
        //        LOG_DEBUG("Weather increased for zone:%d type:%d density:%f",m_zoneId,m_currentEffect,m_currentDensity);
        SendUpdate();
    }
}
Esempio n. 22
0
void Group::UpdatePlayerOnlineStatus(Player* player, bool online /*= true*/)
{
    if (!player)
        return;
    const ObjectGuid guid = player->GetObjectGuid();
    if (!IsMember(guid))
        return;

    SendUpdate();
    if (online)
    {
        player->SetGroupUpdateFlag(GROUP_UPDATE_FULL);
        UpdatePlayerOutOfRange(player);
    }
    else if (IsLeader(guid))
        m_leaderLastOnline = time(nullptr);
}
Esempio n. 23
0
void NetClient::SendUpdates( void )
{
	// Reduce update rate temporarily in high-ping situations.
	double temp_netrate = NetRate;
	temp_netrate /= ((int) LatestPing() / 100) + 1;
	
	// Send an update if it's time to do so.
	if( Connected && Raptor::Game->PlayerID && (NetClock.ElapsedSeconds() >= (1.0 / temp_netrate)) )
	{
		NetClock.Reset();
		
		if( PingClock.ElapsedSeconds() >= (1.0 / PingRate) )
		{
			PingClock.Reset();
			SendPing();
		}
		
		SendUpdate();
	}
}
Esempio n. 24
0
bool HuffyServer::Initalise()
{
	bool SetupResult = false;

	try
	{
		// Create the socket
		//Todo, this value should be configurable, in HuffyConstants.h?
		//Fix in next iteraltion
		m_ServerSocket = new ServerSocket(30000);
		std::cout << "\nSetting up Server, waiting on client\n";
		while (!SetupResult)
		{
			m_ServerSocket->accept(new_sock);
			m_ConectionSocket = &new_sock;
			try
			{
				while (!SetupResult)
				{
					std::string data;
					*m_ConectionSocket >> data;
					if (data == CLIENT_REQUEST)
					{
						SetupResult = true;
					}
					SendUpdate(SERVER_RESPONSE);
				}
			}
			catch (SocketException&) {}

		}
	}
	catch (SocketException& e)
	{
		std::cout << "Socket exception was caught:" << e.description();
	}
	std::cout << "\nClient has connected\n";
	return SetupResult;
}
Esempio n. 25
0
void CGameSection:: Reaction(long src , const CRenderSection_RenderObject_Response& in)
{
	assert(m_pShadowCreator);
	assert(1==in.m_pShadows.size());
	m_pShadowCreator->ReclaimShadow( in.m_pShadows[0] );


	CObject * next = m_pField->NextObject();
	if (!next)
	{
		SendUpdate();
	}
	else
	{
		CShadow* pShadow = m_pShadowCreator->CreateShadow(next);
		CTCommandSender< CRenderSection_RenderObject_Request >::SendCommand(
			m_RenderSectionID,
			CRenderSection_RenderObject_Request(pShadow)
		);

	}
}
Esempio n. 26
0
// allows setting subgroup for offline members
void Group::ChangeMembersGroup(ObjectGuid guid, uint8 group)
{
    if (!isRaidGroup())
        return;

    Player* player = sObjectMgr.GetPlayer(guid);

    if (!player)
    {
        uint8 prevSubGroup = GetMemberGroup(guid);
        if (prevSubGroup == group)
            return;

        if (_setMembersGroup(guid, group))
        {
            SubGroupCounterDecrease(prevSubGroup);
            SendUpdate();
        }
    }
    else
        // This methods handles itself groupcounter decrease
        ChangeMembersGroup(player, group);
}
Esempio n. 27
0
void LfgGroup::KilledCreature(Creature *creature)
{
    if ((creature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) &&
        m_instanceStatus == INSTANCE_NOT_SAVED)
    {
        m_instanceStatus = INSTANCE_SAVED;
    }
    
    if (!m_awarded && creature->GetEntry() == sLfgMgr.GetDungeonInfo(m_dungeonInfo->ID)->lastBossId)
    {
        //Last boss
        m_instanceStatus = INSTANCE_COMPLETED;
        //Reward here
        for (GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
        {
            Player *plr = itr->getSource();
            if (!plr || !plr->IsInWorld())
                continue;
            WorldPacket data(SMSG_LFG_PLAYER_REWARD);
            data << uint32(GetDungeonInfo((IsRandom() || IsFromRnd(plr->GetGUID())))->Entry());
            data << uint32(m_dungeonInfo->Entry());

            uint32 ID = GetDungeonInfo((IsRandom() || IsFromRnd(plr->GetGUID())))->ID;
            sLfgMgr.BuildRewardBlock(&data, ID, plr);
            plr->GetSession()->SendPacket(&data);
            LfgReward *reward = sLfgMgr.GetDungeonReward(ID, plr->m_lookingForGroup.DoneDungeon(ID, plr), plr->getLevel());
            if (!reward)
                continue;
            plr->CompleteQuest(reward->questInfo->GetQuestId());
            if (IsRandom())
                plr->RemoveAurasDueToSpell(LFG_RANDOM_COOLDOWN);
        }
        m_awarded = true;
    }  
    SendUpdate();
}
Esempio n. 28
0
// only for online members
void Group::ChangeMembersGroup(Player* player, uint8 group)
{
    if (!player || !isRaidGroup())
        return;

    uint8 prevSubGroup = player->GetSubGroup();
    if (prevSubGroup == group)
        return;

    if (_setMembersGroup(player->GetObjectGuid(), group))
    {
        if (player->GetGroup() == this)
            player->GetGroupRef().setSubGroup(group);
        // if player is in BG raid, it is possible that he is also in normal raid - and that normal raid is stored in m_originalGroup reference
        else
        {
            prevSubGroup = player->GetOriginalSubGroup();
            player->GetOriginalGroupRef().setSubGroup(group);
        }
        SubGroupCounterDecrease(prevSubGroup);

        SendUpdate();
    }
}
Esempio n. 29
0
uint32 Group::RemoveMember(const uint64 &guid, const uint8 &method)
{
    if(m_members.size() > 1)
    {
        bool leaderChanged = _removeMember(guid);

        Player *player = objmgr.GetPlayer( guid );
        if (player)
        {
            WorldPacket data;

            if(method == 1)
            {
                data.Initialize( SMSG_GROUP_UNINVITE, 0 );
                player->GetSession()->SendPacket( &data );
            }

            data.Initialize(SMSG_GROUP_LIST, 14);
            data<<(uint16)0<<(uint32)0<<(uint64)0;
            player->GetSession()->SendPacket(&data);
        }

        if(leaderChanged)
        {
            WorldPacket data(SMSG_GROUP_SET_LEADER, (m_members[0].name.size()+1));
            data << m_members[0].name;
            BroadcastPacket(&data);
        }

        SendUpdate();
    }
    else
        Disband(true);

    return m_members.size();
}
Esempio n. 30
0
void LWSlider::OnMouseEvent(wxMouseEvent & event)
{
   if (event.Entering()) {
      #if wxUSE_TOOLTIPS // Not available in wxX11
      // Display the tooltip in the status bar
      if (mParent->GetToolTip()) 
      {
         wxString tip = mParent->GetToolTip()->GetTip();
         GetActiveProject()->TP_DisplayStatusMessage(tip);
         Refresh();
      }
      #endif
   }
   else if (event.Leaving())
   {
      GetActiveProject()->TP_DisplayStatusMessage(wxT(""));
      Refresh();
   }

   // Events other than mouse-overs are ignored when we are disabled
   if (!mEnabled)
      return;

   float prevValue = mCurrentValue;

   // Figure out the thumb position
   wxRect r;
   if (mOrientation == wxHORIZONTAL)
   {
      r.x = mLeft + ValueToPosition(mCurrentValue);
      r.y = mTop + (mCenterY - (mThumbHeight / 2));
   }
   else 
   {
      r.x = mLeft + (mCenterX - (mThumbWidth / 2));
      r.y = mTop + ValueToPosition(mCurrentValue);
   }
   r.width = mThumbWidth;
   r.height = mThumbHeight;

   wxRect tolerantThumbRect = r;
   tolerantThumbRect.Inflate(3, 3);

   // Should probably use a right click instead/also
   if( event.ButtonDClick() && mPopup )
   {
      //On a double-click, we should pop up a dialog.
      DoShowDialog(mParent->ClientToScreen(wxPoint(event.m_x,event.m_y)));
   }
   else if( event.ButtonDown() )
   {
      if( mDefaultShortcut && event.CmdDown() )
      {
         mCurrentValue = mDefaultValue;
      }

      if( event.RightDown() ) {
         mParent->SetFocus();
      }

      // Thumb clicked?
      //
      // Do not change position until first drag.  This helps
      // with unintended value changes.
      if( tolerantThumbRect.Contains( event.GetPosition() ) )
      {
         // Remember mouse position and current value
         mClickPos = (mOrientation == wxHORIZONTAL) ? event.m_x : event.m_y;
         mClickValue = mCurrentValue;

         mIsDragging = true;
      }
      // Clicked to set location?
      else
      {
         mCurrentValue = 
            ClickPositionToValue(
               (mOrientation == wxHORIZONTAL) ? event.m_x : event.m_y, 
               event.ShiftDown());
      }

      mParent->CaptureMouse();
      // wxSetCursor(wxCURSOR_BLANK);
      ((TipPanel*)LWSlider::sharedTipPanel)->SetTargetParent(mParent);
      FormatPopWin();
      SetPopWinPosition();
      LWSlider::sharedTipPanel->Show();
      //hide mouseover tooltip
      wxToolTip::Enable(false);
   }
   else if( event.ButtonUp() )
   {
      mIsDragging = false;
      if (mParent->HasCapture())
         mParent->ReleaseMouse();
      LWSlider::sharedTipPanel->Hide();
      //restore normal tooltip behavor for mouseovers
      wxToolTip::Enable(true);
      // wxSetCursor(wxNullCursor);
   }
   else if (event.Dragging() && mIsDragging)
   {
      if (mOrientation == wxHORIZONTAL)
      {
         if (event.m_y < (r.y - 2 * r.height) ||
             event.m_y > (r.y + 3 * r.height)) {
            // If the mouse y coordinate is relatively far from the slider,
            // snap back to the original position
            mCurrentValue = mClickValue;
         }
         else {
            // Otherwise, move the slider to the right position based
            // on the mouse position
            mCurrentValue = DragPositionToValue(event.m_x, event.ShiftDown());
         }
      }
      else // (mOrientation == wxVERTICAL)
      {
         if (event.m_x < (r.x - 2 * r.width) ||
             event.m_x > (r.x + 3 * r.width)) {
            // If the mouse x coordinate is relatively far from the slider,
            // snap back to the original position
            mCurrentValue = mClickValue;
         }
         else {
            // Otherwise, move the slider to the right position based
            // on the mouse position
            mCurrentValue = DragPositionToValue(event.m_y, event.ShiftDown());
         }
      }
   }
   else if( event.m_wheelRotation != 0 )
   {
      //Calculate the number of steps in a given direction this event
      //represents (allows for two or more clicks on a single event.)
      double steps =  event.m_wheelRotation /
         (event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);

      if( steps < 0.0 )
      {
         Decrease( (float)-steps );
      }
      else
      {
         Increase( (float)steps );
      }
      SendUpdate( mCurrentValue );
   }

   if( prevValue != mCurrentValue )
      SendUpdate( mCurrentValue );
}