mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 20:14:54 +02:00
Platform fixes and rework ping
This commit is contained in:
@@ -21,45 +21,3 @@ MenuLabel < Label
|
||||
GameLabel < UILabel
|
||||
font: verdana-11px-antialised
|
||||
color: #bbbbbb
|
||||
|
||||
FrameCounterLabel < Label
|
||||
font: verdana-11px-rounded
|
||||
@onSetup: |
|
||||
self.updateEvent = cycleEvent(function()
|
||||
local text = 'FPS: ' .. g_app.getBackgroundPaneFps()
|
||||
self:setText(text)
|
||||
end, 1000)
|
||||
@onDestroy: self.updateEvent:cancel()
|
||||
|
||||
PingLabel < Label
|
||||
font: verdana-11px-rounded
|
||||
@onSetup: |
|
||||
self.updateEvent = cycleEvent(function()
|
||||
if g_game.isOnline() and modules.client_options.getOption('showPing') then
|
||||
local ping = -1
|
||||
if g_game.getFeature(GameClientPing) or g_game.getFeature(GameExtendedClientPing) then
|
||||
ping = g_game.getPing()
|
||||
else
|
||||
ping = g_game.getLocalPlayer():getWalkPing()
|
||||
end
|
||||
local text = 'Ping: '
|
||||
if ping < 0 then
|
||||
text = text .. "??"
|
||||
self:setColor('yellow')
|
||||
else
|
||||
text = text .. ping .. ' ms'
|
||||
if ping >= 500 then
|
||||
self:setColor('red')
|
||||
elseif ping >= 250 then
|
||||
self:setColor('yellow')
|
||||
else
|
||||
self:setColor('green')
|
||||
end
|
||||
end
|
||||
self:setText(text)
|
||||
self:show()
|
||||
else
|
||||
self:hide()
|
||||
end
|
||||
end, 1000)
|
||||
@onDestroy: self.updateEvent:cancel()
|
||||
|
@@ -46,7 +46,11 @@ TopMenuPanel < Panel
|
||||
image-repeated: true
|
||||
focusable: false
|
||||
|
||||
TopMenuFrameCounterLabel < FrameCounterLabel
|
||||
TopMenuFrameCounterLabel < Label
|
||||
font: verdana-11px-rounded
|
||||
color: white
|
||||
margin-top: 4
|
||||
margin-left: 5
|
||||
|
||||
TopMenuPingLabel < Label
|
||||
font: verdana-11px-rounded
|
||||
|
Reference in New Issue
Block a user