Minor fixes and improvements

This commit is contained in:
Eduardo Bart
2013-02-27 16:24:32 -03:00
parent 46aa0c005f
commit e528fcc8f8
19 changed files with 69 additions and 31 deletions

View File

@@ -111,12 +111,7 @@ end
function onGameConnectionError(message, code)
CharacterList.destroyLoadBox()
local text
if g_game.getProtocolGame() and g_game.getProtocolGame():isConnecting() then
text = tr('Unable to establish a connection. (err: %d)%s', code)
else
text = tr('Your connection has been lost. (err: %d)', code)
end
local text = translateNetworkError(code, g_game.getProtocolGame() and g_game.getProtocolGame():isConnecting(), message)
errorBox = displayErrorBox(tr("Connection Error"), text)
errorBox.onOk = function()
errorBox = nil

View File

@@ -68,8 +68,10 @@ end
function online()
showGameButtons()
if modules.client_options.getOption('showFps') and (g_game.getFeature(GameClientPing) or g_game.getFeature(GameExtendedClientPing)) then
if g_settings.getBoolean('showPing') and (g_game.getFeature(GameClientPing) or g_game.getFeature(GameExtendedClientPing)) then
pingLabel:show()
else
pingLabel:hide()
end
end

View File

@@ -17,6 +17,7 @@ Module
dofile 'settings'
dofile 'keyboard'
dofile 'mouse'
dofile 'net'
dofiles 'ui'

16
modules/corelib/net.lua Normal file
View File

@@ -0,0 +1,16 @@
function translateNetworkError(errcode, connecting, errdesc)
local text
if errcode == 111 then
text = tr('Connection refused, the server might be offline or restarting.\nPlease try again later.')
elseif errcode == 110 then
text = tr('Connection timed out. Either your network is failing or the server is offline.')
elseif errcode == 1 then
text = tr('Connection failed, the server address does not exist.')
elseif connecting then
text = tr('Connection failed.')
else
text = tr('Your connection has been lost.\nEither your network or the server went down.')
end
text = text .. ' ' .. tr('(ERROR %d)', errcode)
return text
end

View File

@@ -83,10 +83,17 @@ local function onTabDragMove(tab, mousePos, mouseMoved)
end
end
local function tabBlink(tab)
if not tab.blinking then return end
local function tabBlink(tab, step)
step = step or 0
tab:setOn(not tab:isOn())
tab.blinkEvent = scheduleEvent(function() tabBlink(tab) end, 500)
removeEvent(tab.blinkEvent)
if step < 4 then
tab.blinkEvent = scheduleEvent(function() tabBlink(tab, step+1) end, 500)
else
tab:setOn(true)
tab.blinkEvent = nil
end
end
-- public functions
@@ -240,7 +247,7 @@ function UIMoveableTabBar:selectPrevTab()
end
function UIMoveableTabBar:blinkTab(tab)
if tab:isChecked() or tab.blinking then return end
if tab:isChecked() then return end
tab.blinking = true
tabBlink(tab)
end

View File

@@ -237,7 +237,7 @@ function UIScrollBar:onMouseWheel(mousePos, mouseWheel)
if not self.mouseScroll then
return false
end
if mouseWheel == MouseWheelDown then
if mouseWheel == MouseWheelUp then
if self.orientation == 'vertical' then
self:decrement()
else

View File

@@ -19,14 +19,15 @@ function UITextEdit:onMouseWheel(mousePos, mouseWheel)
else
self.verticalScrollBar:increment()
end
return true
elseif self.horizontalScrollBar then
if mouseWheel == MouseWheelUp then
self.horizontalScrollBar:increment()
else
self.horizontalScrollBar:decrement()
end
return true
end
return true
end
function UITextEdit:onTextAreaUpdate(virtualOffset, virtualSize, totalSize)

View File

@@ -288,6 +288,7 @@ function openPlayerReportRuleViolationWindow()
g_game.talkChannel(MessageModes.RVRChannel, 0, text)
violationReportTab = addTab(tr('Report Rule') .. '...', true)
addTabText(tr('Please wait patiently for a gamemaster to reply') .. '.', SpeakTypesSettings.privateRed, violationReportTab)
addTabText(applyMessagePrefixies(g_game.getCharacterName(), 0, text), SpeakTypesSettings.say, violationReportTab, g_game.getCharacterName())
violationReportTab.locked = true
violationWindow:destroy()
violationWindow = nil

View File

@@ -21,6 +21,8 @@ ConsolePhantomLabel < UILabel
selection-background-color: #999999
ConsoleTabBar < MoveableTabBar
height: 28
ConsoleTabBarPanel < MoveableTabBarPanel
id: consoleTab
@@ -64,7 +66,6 @@ Panel
ConsoleTabBar
id: consoleTabBar
height: 28
anchors.left: prev.right
anchors.top: parent.top
anchors.right: next.left

View File

@@ -87,6 +87,7 @@ end
function online()
loadMap(not preloaded)
updateCameraPosition()
end
function offline()
@@ -128,6 +129,9 @@ end
function updateCameraPosition()
local player = g_game.getLocalPlayer()
if not player then return end
local pos = player:getPosition()
if not pos then return end
if not minimapWidget:isDragging() then
if not fullmapView then
minimapWidget:setCameraPosition(player:getPosition())
@@ -153,7 +157,6 @@ function toggleFullMap()
local zoom = oldZoom or 0
local pos = oldPos or minimapWidget:getCameraPosition()
pos.z = 7
oldZoom = minimapWidget:getZoom()
oldPos = minimapWidget:getCameraPosition()
minimapWidget:setZoom(zoom)

View File

@@ -10,7 +10,7 @@ MiniWindow
text: ?
text-align: center
phantom: false
!tooltip: tr('Hold left mouse button to navigate\nScroll mouse middle button to zoom\nRight mouse button to create map marks')
!tooltip: tr('Hold left mouse button to navigate\nScroll mouse middle button to zoom\nRight mouse button to create map marks\nPress Ctrl+Shift+M to view the entire game map')')
anchors.top: minimizeButton.top
anchors.right: minimizeButton.left
margin-right: 3

View File

@@ -157,11 +157,6 @@ function ProtocolLogin:parseOpcode(opcode, msg)
end
function ProtocolLogin:onError(msg, code)
local text
if self:isConnecting() then
text = tr('Unable to establish a connection. (err: %d)', code)
else
text = tr('Your connection has been lost. (err: %d)', code)
end
local text = translateNetworkError(code, self:isConnecting(), msg)
signalcall(self.onLoginError, self, text)
end

View File

@@ -34,6 +34,12 @@ function UIMinimap:onVisibilityChange()
end
end
function UIMinimap:onCameraPositionChange(cameraPos)
if self.cross then
self:setCrossPosition(self.cross.pos)
end
end
function UIMinimap:hideFloor()
self.floorUpWidget:hide()
self.floorDownWidget:hide()
@@ -91,6 +97,7 @@ function UIMinimap:setCrossPosition(pos)
self.cross = cross
end
pos.z = self:getCameraPosition().z
cross.pos = pos
if pos then
self:centerInPosition(cross, pos)
@@ -106,7 +113,8 @@ function UIMinimap:addFlag(pos, icon, description)
return
end
flag = g_ui.createWidget('MinimapFlag', self)
flag = g_ui.createWidget('MinimapFlag')
self:insertChild(1, flag)
flag.pos = pos
flag.description = description
flag.icon = icon
@@ -130,7 +138,7 @@ function UIMinimap:setAlternativeWidgetsVisible(show)
layout:disableUpdates()
for _,widget in pairs(self.alternatives) do
if show then
self:addChild(widget)
self:insertChild(1, widget)
self:centerInPosition(widget, widget.pos)
else
self:removeChild(widget)