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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

After

Width:  |  Height:  |  Size: 243 B

View File

@ -1,8 +1,9 @@
MessageBoxLabel < Label MessageBoxLabel < Label
id: messageBoxLabel id: messageBoxLabel
text-auto-resize: true
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top anchors.top: parent.top
text-wrap: true
text-auto-resize: true
MessageBoxButtonHolder < UIWidget MessageBoxButtonHolder < UIWidget
id: buttonHolder id: buttonHolder

View File

@ -111,12 +111,7 @@ end
function onGameConnectionError(message, code) function onGameConnectionError(message, code)
CharacterList.destroyLoadBox() CharacterList.destroyLoadBox()
local text local text = translateNetworkError(code, g_game.getProtocolGame() and g_game.getProtocolGame():isConnecting(), message)
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
errorBox = displayErrorBox(tr("Connection Error"), text) errorBox = displayErrorBox(tr("Connection Error"), text)
errorBox.onOk = function() errorBox.onOk = function()
errorBox = nil errorBox = nil

View File

@ -68,8 +68,10 @@ end
function online() function online()
showGameButtons() 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() pingLabel:show()
else
pingLabel:hide()
end end
end end

View File

@ -17,6 +17,7 @@ Module
dofile 'settings' dofile 'settings'
dofile 'keyboard' dofile 'keyboard'
dofile 'mouse' dofile 'mouse'
dofile 'net'
dofiles 'ui' 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
end end
local function tabBlink(tab) local function tabBlink(tab, step)
if not tab.blinking then return end step = step or 0
tab:setOn(not tab:isOn()) 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 end
-- public functions -- public functions
@ -240,7 +247,7 @@ function UIMoveableTabBar:selectPrevTab()
end end
function UIMoveableTabBar:blinkTab(tab) function UIMoveableTabBar:blinkTab(tab)
if tab:isChecked() or tab.blinking then return end if tab:isChecked() then return end
tab.blinking = true tab.blinking = true
tabBlink(tab) tabBlink(tab)
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@ MiniWindow
text: ? text: ?
text-align: center text-align: center
phantom: false 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.top: minimizeButton.top
anchors.right: minimizeButton.left anchors.right: minimizeButton.left
margin-right: 3 margin-right: 3

View File

@ -157,11 +157,6 @@ function ProtocolLogin:parseOpcode(opcode, msg)
end end
function ProtocolLogin:onError(msg, code) function ProtocolLogin:onError(msg, code)
local text local text = translateNetworkError(code, self:isConnecting(), msg)
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
signalcall(self.onLoginError, self, text) signalcall(self.onLoginError, self, text)
end end

View File

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

View File

@ -71,7 +71,6 @@ void ProtocolGame::onRecv(const InputMessagePtr& inputMessage)
void ProtocolGame::onError(const boost::system::error_code& error) void ProtocolGame::onError(const boost::system::error_code& error)
{ {
Protocol::onError(error);
g_game.processConnectionError(error); g_game.processConnectionError(error);
disconnect();
} }

View File

@ -30,7 +30,7 @@ class Platform
{ {
public: public:
void processArgs(std::vector<std::string>& args); void processArgs(std::vector<std::string>& args);
bool spawnProcess(const std::string& process, const std::vector<std::string>& args); bool spawnProcess(std::string process, const std::vector<std::string>& args);
int getProcessId(); int getProcessId();
bool isProcessRunning(const std::string& name); bool isProcessRunning(const std::string& name);
bool killProcess(const std::string& name); bool killProcess(const std::string& name);

View File

@ -35,7 +35,7 @@ void Platform::processArgs(std::vector<std::string>& args)
//nothing todo, linux args are already utf8 encoded //nothing todo, linux args are already utf8 encoded
} }
bool Platform::spawnProcess(const std::string& process, const std::vector<std::string>& args) bool Platform::spawnProcess(std::string process, const std::vector<std::string>& args)
{ {
struct stat sts; struct stat sts;
if(stat(process.c_str(), &sts) == -1 && errno == ENOENT) if(stat(process.c_str(), &sts) == -1 && errno == ENOENT)

View File

@ -42,11 +42,16 @@ void Platform::processArgs(std::vector<std::string>& args)
} }
} }
bool Platform::spawnProcess(const std::string& process, const std::vector<std::string>& args) bool Platform::spawnProcess(std::string process, const std::vector<std::string>& args)
{ {
std::string commandLine; std::string commandLine;
for(uint i = 0; i < args.size(); ++i) for(uint i = 0; i < args.size(); ++i)
commandLine += stdext::format(" \"%s\"", args[i]); commandLine += stdext::format(" \"%s\"", args[i]);
boost::replace_all(process, "/", "\\");
if(!boost::ends_with(process, ".exe"))
process += ".exe";
std::wstring wfile = stdext::utf8_to_utf16(process); std::wstring wfile = stdext::utf8_to_utf16(process);
std::wstring wcommandLine = stdext::utf8_to_utf16(commandLine); std::wstring wcommandLine = stdext::utf8_to_utf16(commandLine);
@ -83,9 +88,12 @@ bool Platform::killProcess(const std::string& name)
std::string Platform::getTempPath() std::string Platform::getTempPath()
{ {
std::string ret;
wchar_t path[MAX_PATH]; wchar_t path[MAX_PATH];
GetTempPathW(MAX_PATH, path); GetTempPathW(MAX_PATH, path);
return stdext::utf16_to_utf8(path); ret = stdext::utf16_to_utf8(path);
boost::replace_all(ret, "\\", "/");
return ret;
} }
std::string Platform::getCurrentDir() std::string Platform::getCurrentDir()