From e528fcc8f8563449cbb7adf81d8f8378b685bbd6 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Wed, 27 Feb 2013 16:24:32 -0300 Subject: [PATCH] Minor fixes and improvements --- data/images/game/minimap/cross.png | Bin 210 -> 243 bytes data/styles/30-messageboxes.otui | 3 ++- modules/client_entergame/characterlist.lua | 7 +------ modules/client_topmenu/topmenu.lua | 4 +++- modules/corelib/corelib.otmod | 1 + modules/corelib/net.lua | 16 ++++++++++++++++ modules/corelib/ui/uimovabletabbar.lua | 15 +++++++++++---- modules/corelib/ui/uiscrollbar.lua | 2 +- modules/corelib/ui/uitextedit.lua | 3 ++- modules/game_console/console.lua | 1 + modules/game_console/console.otui | 3 ++- modules/game_minimap/minimap.lua | 5 ++++- modules/game_minimap/minimap.otui | 2 +- modules/gamelib/protocollogin.lua | 7 +------ modules/gamelib/ui/uiminimap.lua | 12 ++++++++++-- src/client/protocolgame.cpp | 3 +-- src/framework/platform/platform.h | 2 +- src/framework/platform/unixplatform.cpp | 2 +- src/framework/platform/win32platform.cpp | 12 ++++++++++-- 19 files changed, 69 insertions(+), 31 deletions(-) create mode 100644 modules/corelib/net.lua diff --git a/data/images/game/minimap/cross.png b/data/images/game/minimap/cross.png index dd06cf326251b78f0d6d5a0399019a367dfd926c..d2beaabe6d93ae31d106f9da7553a7102318e601 100644 GIT binary patch delta 168 zcmcb__?dBnmf?Q}AY8C_`D6wL2F?PH$YKTtZeb8+WSBKa0w~B{;_2(kewRr~j9qQf z_gmdKI;Vst03Yo`w*UYD delta 135 zcmey&c!_a>mLUTO{B+)352QE?JR*x37`TN&n2}-D90{Nxdx@v7EBjq0Az^mTQ;|{m z6Qgy!%{*NkLo7}w|M~ylo>{e_v(d?+nE9XcM}coljt82Kp5JkZNz&lb8P*<)oHQB7 gjRzbQeApI>GwfT=p_JTV`x|7Xr>mdKI;Vst0Ezc2%>V!Z diff --git a/data/styles/30-messageboxes.otui b/data/styles/30-messageboxes.otui index a0898f7f..04fcdf6f 100644 --- a/data/styles/30-messageboxes.otui +++ b/data/styles/30-messageboxes.otui @@ -1,8 +1,9 @@ MessageBoxLabel < Label id: messageBoxLabel - text-auto-resize: true anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top + text-wrap: true + text-auto-resize: true MessageBoxButtonHolder < UIWidget id: buttonHolder diff --git a/modules/client_entergame/characterlist.lua b/modules/client_entergame/characterlist.lua index 6ca101ec..fd771d96 100644 --- a/modules/client_entergame/characterlist.lua +++ b/modules/client_entergame/characterlist.lua @@ -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 diff --git a/modules/client_topmenu/topmenu.lua b/modules/client_topmenu/topmenu.lua index a807cd20..cd53486b 100644 --- a/modules/client_topmenu/topmenu.lua +++ b/modules/client_topmenu/topmenu.lua @@ -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 diff --git a/modules/corelib/corelib.otmod b/modules/corelib/corelib.otmod index 6b61f7fc..56798e1b 100644 --- a/modules/corelib/corelib.otmod +++ b/modules/corelib/corelib.otmod @@ -17,6 +17,7 @@ Module dofile 'settings' dofile 'keyboard' dofile 'mouse' + dofile 'net' dofiles 'ui' diff --git a/modules/corelib/net.lua b/modules/corelib/net.lua new file mode 100644 index 00000000..b2d59947 --- /dev/null +++ b/modules/corelib/net.lua @@ -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 diff --git a/modules/corelib/ui/uimovabletabbar.lua b/modules/corelib/ui/uimovabletabbar.lua index dbddec70..9a108c91 100644 --- a/modules/corelib/ui/uimovabletabbar.lua +++ b/modules/corelib/ui/uimovabletabbar.lua @@ -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 diff --git a/modules/corelib/ui/uiscrollbar.lua b/modules/corelib/ui/uiscrollbar.lua index e6fce00d..f94d5591 100644 --- a/modules/corelib/ui/uiscrollbar.lua +++ b/modules/corelib/ui/uiscrollbar.lua @@ -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 diff --git a/modules/corelib/ui/uitextedit.lua b/modules/corelib/ui/uitextedit.lua index bad14028..b671c7d5 100644 --- a/modules/corelib/ui/uitextedit.lua +++ b/modules/corelib/ui/uitextedit.lua @@ -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) diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 4f5b83dd..2dc31100 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -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 diff --git a/modules/game_console/console.otui b/modules/game_console/console.otui index dc50ed0c..afbf35ef 100644 --- a/modules/game_console/console.otui +++ b/modules/game_console/console.otui @@ -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 diff --git a/modules/game_minimap/minimap.lua b/modules/game_minimap/minimap.lua index b3de05ce..ecdd7904 100644 --- a/modules/game_minimap/minimap.lua +++ b/modules/game_minimap/minimap.lua @@ -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) diff --git a/modules/game_minimap/minimap.otui b/modules/game_minimap/minimap.otui index 84c72127..437bb68e 100644 --- a/modules/game_minimap/minimap.otui +++ b/modules/game_minimap/minimap.otui @@ -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 diff --git a/modules/gamelib/protocollogin.lua b/modules/gamelib/protocollogin.lua index 8d03b615..bb19bb7f 100644 --- a/modules/gamelib/protocollogin.lua +++ b/modules/gamelib/protocollogin.lua @@ -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 \ No newline at end of file diff --git a/modules/gamelib/ui/uiminimap.lua b/modules/gamelib/ui/uiminimap.lua index 5f99797d..88686d56 100644 --- a/modules/gamelib/ui/uiminimap.lua +++ b/modules/gamelib/ui/uiminimap.lua @@ -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) diff --git a/src/client/protocolgame.cpp b/src/client/protocolgame.cpp index c6793baf..a6654d51 100644 --- a/src/client/protocolgame.cpp +++ b/src/client/protocolgame.cpp @@ -71,7 +71,6 @@ void ProtocolGame::onRecv(const InputMessagePtr& inputMessage) void ProtocolGame::onError(const boost::system::error_code& error) { - Protocol::onError(error); - g_game.processConnectionError(error); + disconnect(); } diff --git a/src/framework/platform/platform.h b/src/framework/platform/platform.h index 9332bf08..1202f759 100644 --- a/src/framework/platform/platform.h +++ b/src/framework/platform/platform.h @@ -30,7 +30,7 @@ class Platform { public: void processArgs(std::vector& args); - bool spawnProcess(const std::string& process, const std::vector& args); + bool spawnProcess(std::string process, const std::vector& args); int getProcessId(); bool isProcessRunning(const std::string& name); bool killProcess(const std::string& name); diff --git a/src/framework/platform/unixplatform.cpp b/src/framework/platform/unixplatform.cpp index 8e190184..c4d0d01b 100644 --- a/src/framework/platform/unixplatform.cpp +++ b/src/framework/platform/unixplatform.cpp @@ -35,7 +35,7 @@ void Platform::processArgs(std::vector& args) //nothing todo, linux args are already utf8 encoded } -bool Platform::spawnProcess(const std::string& process, const std::vector& args) +bool Platform::spawnProcess(std::string process, const std::vector& args) { struct stat sts; if(stat(process.c_str(), &sts) == -1 && errno == ENOENT) diff --git a/src/framework/platform/win32platform.cpp b/src/framework/platform/win32platform.cpp index 5c6a7a18..d1720ef4 100644 --- a/src/framework/platform/win32platform.cpp +++ b/src/framework/platform/win32platform.cpp @@ -42,11 +42,16 @@ void Platform::processArgs(std::vector& args) } } -bool Platform::spawnProcess(const std::string& process, const std::vector& args) +bool Platform::spawnProcess(std::string process, const std::vector& args) { std::string commandLine; for(uint i = 0; i < args.size(); ++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 wcommandLine = stdext::utf8_to_utf16(commandLine); @@ -83,9 +88,12 @@ bool Platform::killProcess(const std::string& name) std::string Platform::getTempPath() { + std::string ret; wchar_t path[MAX_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()