addon to show walk ping
This commit is contained in:
parent
81e378cc22
commit
b00076bcb9
2
TODO
2
TODO
|
@ -101,3 +101,5 @@ attack while walking cancels the walk
|
|||
if a spell is used while pressing arrows keys the walk is canceled and it doesnt starts walking again
|
||||
game map text message boxes is not displayed like tibia
|
||||
name/shields doesnt follow the creature when walking on parcels
|
||||
hotkeys wont work with caps lock
|
||||
hotkeys works while windows are locked, it shouldnt
|
|
@ -0,0 +1,27 @@
|
|||
PingBar = {}
|
||||
|
||||
local pingLabel
|
||||
|
||||
-- public functions
|
||||
function PingBar.init()
|
||||
pingLabel = createWidget('UILabel', rootWidget:recursiveGetChildById('leftButtonsPanel'))
|
||||
pingLabel:applyStyle({ ['anchors.left'] = 'prev.right',
|
||||
['anchors.top'] = 'parent.top',
|
||||
['margin-top'] = 12,
|
||||
['margin-left'] = 10,
|
||||
font = 'verdana-11px-rounded',
|
||||
color = '#FE6500',
|
||||
width = 120,
|
||||
height = 16})
|
||||
end
|
||||
|
||||
function PingBar.terminate()
|
||||
pingLabel:destroy()
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
local function onGamePingUpdate(ping)
|
||||
pingLabel:setText('Walk Ping: ' .. ping .. ' ms')
|
||||
end
|
||||
|
||||
connect(Game, { onWalkPingUpdate = onGamePingUpdate })
|
|
@ -0,0 +1,15 @@
|
|||
Module
|
||||
name: pingbar
|
||||
description: Show ping in game
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
|
||||
autoLoad: true
|
||||
autoLoadPriority: 1000
|
||||
|
||||
onLoad: |
|
||||
require 'pingbar'
|
||||
PingBar.init()
|
||||
|
||||
onUnload: |
|
||||
PingBar.terminate()
|
|
@ -5,7 +5,7 @@ Module
|
|||
website: https://github.com/edubart/otclient
|
||||
|
||||
autoLoad: true
|
||||
autoLoadPriority: 1000
|
||||
autoLoadPriority: 200
|
||||
|
||||
onLoad: |
|
||||
require 'terminal'
|
||||
|
|
|
@ -66,11 +66,11 @@ TopPanel
|
|||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
width: 60
|
||||
width: 70
|
||||
|
||||
FrameCounter
|
||||
id: frameCounter
|
||||
anchors.top: parent.top
|
||||
anchors.right: prev.left
|
||||
margin-top: 8
|
||||
margin-right: 12
|
||||
margin-right: 5
|
|
@ -12,7 +12,7 @@ local SpeakTypes = {
|
|||
channelWhite = { color = '#FFFFFF' },
|
||||
channelRed = { color = '#F55E5E' },
|
||||
channelOrange = { color = '#FE6500' },
|
||||
private = { color = '#FFFF00' },
|
||||
private = { color = '#5FF7F7' },
|
||||
playerToNpc = { color = '#9F9DFD' },
|
||||
broadcast = { color = '#F55E5E' },
|
||||
privateRed = { color = '#F55E5E' }
|
||||
|
|
|
@ -37,8 +37,7 @@ void Game::loginWorld(const std::string& account, const std::string& password, c
|
|||
m_online = false;
|
||||
m_dead = false;
|
||||
m_walkFeedback = true;
|
||||
m_ping = 0;
|
||||
m_pingTimer.restart();
|
||||
m_walkPing = 0;
|
||||
m_protocolGame = ProtocolGamePtr(new ProtocolGame);
|
||||
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName);
|
||||
}
|
||||
|
@ -77,7 +76,6 @@ void Game::processConnectionError(const boost::system::error_code& error)
|
|||
|
||||
void Game::processLogin(const LocalPlayerPtr& localPlayer, int serverBeat)
|
||||
{
|
||||
updatePing();
|
||||
m_localPlayer = localPlayer;
|
||||
m_online = true;
|
||||
m_serverBeat = serverBeat;
|
||||
|
@ -148,7 +146,7 @@ void Game::processCreatureMove(const CreaturePtr& creature, const Position& oldP
|
|||
creature->cancelWalk();
|
||||
}
|
||||
*/
|
||||
if(!m_walkFeedback) {
|
||||
if(!m_walkFeedback && creature == m_localPlayer) {
|
||||
updatePing();
|
||||
m_walkFeedback = true;
|
||||
}
|
||||
|
@ -183,7 +181,7 @@ void Game::walk(Otc::Direction direction)
|
|||
m_localPlayer->clientWalk(direction);
|
||||
|
||||
// ping calculation restarts when the local players try to walk one tile
|
||||
m_pingTimer.restart();
|
||||
m_walkPingTimer.restart();
|
||||
|
||||
switch(direction) {
|
||||
case Otc::North:
|
||||
|
@ -388,6 +386,6 @@ bool Game::checkBotProtection()
|
|||
|
||||
void Game::updatePing()
|
||||
{
|
||||
m_ping = m_pingTimer.ticksElapsed();
|
||||
g_lua.callGlobalField("Game", "onPingUpdate", m_ping);
|
||||
m_walkPing = m_walkPingTimer.ticksElapsed();
|
||||
g_lua.callGlobalField("Game", "onWalkPingUpdate", m_walkPing);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
LocalPlayerPtr getLocalPlayer() { return m_localPlayer; }
|
||||
ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
|
||||
int getProtocolVersion() { return PROTOCOL; }
|
||||
int getPing() { return m_ping; }
|
||||
int getWalkPing() { return m_walkPing; }
|
||||
|
||||
private:
|
||||
void updatePing();
|
||||
|
@ -93,8 +93,8 @@ private:
|
|||
bool m_online;
|
||||
bool m_dead;
|
||||
bool m_walkFeedback;
|
||||
Timer m_pingTimer;
|
||||
int m_ping;
|
||||
Timer m_walkPingTimer;
|
||||
int m_walkPing;
|
||||
int m_serverBeat;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue