diff --git a/modules/client_entergame/characterlist.lua b/modules/client_entergame/characterlist.lua index ffbeb9bf..29bda7b7 100644 --- a/modules/client_entergame/characterlist.lua +++ b/modules/client_entergame/characterlist.lua @@ -38,7 +38,8 @@ local function tryLogin(charInfo, tries) end }) -- save last used character - g_settings.set('lastUsedCharacter', charInfo.characterName) + g_settings.set('last-used-character', charInfo.characterName) + g_settings.set('last-used-world', charInfo.worldName) end local function updateWait(timeStart, timeEnd) @@ -224,12 +225,15 @@ function CharacterList.create(characters, account, otui) connect(widget, { onDoubleClick = function () CharacterList.doLogin() return true end } ) - if i == 1 or g_settings.get('lastUsedCharacter') == widget.characterName then + if i == 1 or (g_settings.get('last-used-character') == widget.characterName and g_settings.get('last-used-world') == widget.worldName) then focusLabel = widget end end - characterList:focusChild(focusLabel, ActiveFocusReason) + if focusLabel then + characterList:focusChild(focusLabel, KeyboardFocusReason) + addEvent(function() characterList:ensureChildVisible(focusLabel) end) + end -- account if account.premDays > 0 and account.premDays < 65535 then diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index 98f02396..4378284a 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -62,10 +62,13 @@ local function onUpdateNeeded(protocol, signature) loadBox:destroy() loadBox = nil - if updateFunc then + if EnterGame.updateFunc then local continueFunc = EnterGame.show local cancelFunc = EnterGame.show - updateFunc(signature, continueFunc, cancelFunc) + EnterGame.updateFunc(signature, continueFunc, cancelFunc) + else + local errorBox = displayErrorBox(tr('Update needed'), tr('Your client needs update, try redownloading it.')) + connect(errorBox, { onOk = EnterGame.show }) end end diff --git a/modules/corelib/ui/uiscrollarea.lua b/modules/corelib/ui/uiscrollarea.lua index e709f98e..4df15145 100644 --- a/modules/corelib/ui/uiscrollarea.lua +++ b/modules/corelib/ui/uiscrollarea.lua @@ -116,26 +116,26 @@ function UIScrollArea:onMouseWheel(mousePos, mouseWheel) return true end -function UIScrollArea:onChildFocusChange(focusedChild, oldFocused, reason) - if focusedChild and (reason == MouseFocusReason or reason == KeyboardFocusReason) then +function UIScrollArea:ensureChildVisible(child) + if child then local paddingRect = self:getPaddingRect() if self.verticalScrollBar then - local deltaY = paddingRect.y - focusedChild:getY() + local deltaY = paddingRect.y - child:getY() if deltaY > 0 then self.verticalScrollBar:decrement(deltaY) end - deltaY = (focusedChild:getY() + focusedChild:getHeight()) - (paddingRect.y + paddingRect.height) + deltaY = (child:getY() + child:getHeight()) - (paddingRect.y + paddingRect.height) if deltaY > 0 then self.verticalScrollBar:increment(deltaY) end else - local deltaX = paddingRect.x - focusedChild:getX() + local deltaX = paddingRect.x - child:getX() if deltaX > 0 then self.horizontalScrollBar:decrement(deltaX) end - deltaX = (focusedChild:getX() + focusedChild:getWidth()) - (paddingRect.x + paddingRect.width) + deltaX = (child:getX() + child:getWidth()) - (paddingRect.x + paddingRect.width) if deltaX > 0 then self.horizontalScrollBar:increment(deltaX) end @@ -143,6 +143,12 @@ function UIScrollArea:onChildFocusChange(focusedChild, oldFocused, reason) end end +function UIScrollArea:onChildFocusChange(focusedChild, oldFocused, reason) + if focusedChild and (reason == MouseFocusReason or reason == KeyboardFocusReason) then + self:ensureChildVisible(focusedChild) + end +end + function UIScrollArea:onScrollWidthChange() if self.alwaysScrollMaximum and self.horizontalScrollBar then self.horizontalScrollBar:setValue(self.horizontalScrollBar:getMaximum()) diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index dc98a0b2..0b71e5a7 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -213,7 +213,7 @@ function onChooseItemMouseRelease(self, mousePosition, mouseButton) end end - if item then + if item and hotkeyLabelSelectedOnList then currentItemPreview:setItemId(item:getId()) hotkeyLabelSelectedOnList.itemId = item:getId() changeUseType(HOTKEY_MANAGER_USEONSELF) @@ -235,7 +235,7 @@ function startChooseItem() connect(mouseGrabberWidget, { onMouseRelease = onChooseItemMouseRelease }) mouseGrabberWidget:grabMouse() - g_mouse.pushCursor('target-cursor') + g_mouse.pushCursor('target') hide() end @@ -260,10 +260,11 @@ function addHotkey() connect(assignWindow, { onKeyDown = hotkeyCapture }, true) end -function addKeyCombo(messageBox, keyCombo, keySettings) - local label = nil - if currentHotkeysList:getChildById(keyCombo) == nil then - local label = g_ui.createWidget('HotkeyListLabel') +function addKeyCombo(messageBox, keyCombo, keySettings, focus) + if not keyCombo then return end + local label = currentHotkeysList:getChildById(keyCombo) + if not label then + label = g_ui.createWidget('HotkeyListLabel') label:setId(keyCombo) label:setColor(HotkeyColors.text) label:setText(keyCombo .. ': ') @@ -289,10 +290,9 @@ function addKeyCombo(messageBox, keyCombo, keySettings) if keySettings then hotkeyLabelSelectedOnList = label label.keyCombo = keyCombo - setSendAutomatically(keySettings.autoSend) + label.autoSend = keySettings.autoSend label.itemId = keySettings.itemId - currentItemPreview:setItemId(keySettings.itemId) - changeUseType(tonumber(keySettings.useType)) + label.useType = tonumber(keySettings.useType) label.value = keySettings.value else label.keyCombo = keyCombo @@ -308,6 +308,11 @@ function addKeyCombo(messageBox, keyCombo, keySettings) g_keyboard.bindKeyPress(keyCombo, function () call(keyCombo) end, nil, 350) end + if focus then + currentHotkeysList:focusChild(label) + currentHotkeysList:ensureChildVisible(label) + end + if messageBox then messageBox:destroy() messageBox = nil @@ -340,7 +345,6 @@ function call(keyCombo) end function checkSelectedHotkey(focused) - if not focused then return end if hotkeysManagerLoaded then hotkeyLabelSelectedOnList = focused @@ -352,6 +356,7 @@ function checkSelectedHotkey(focused) hotkeyText:focus() hotKeyTextLabel:enable() hotkeyText:setText(hotkeyLabelSelectedOnList.value) + hotkeyText:setCursorPos(-1) if hotkeyLabelSelectedOnList.value ~= '' then sendAutomatically:setChecked(hotkeyLabelSelectedOnList.autoSend) @@ -452,6 +457,7 @@ function removeHotkey() hotkeyList[hotkeyLabelSelectedOnList.keyCombo] = nil g_keyboard.unbindKeyPress(hotkeyLabelSelectedOnList.keyCombo) hotkeyLabelSelectedOnList:destroy() + hotkeyLabelSelectedOnList = nil end end @@ -470,11 +476,13 @@ function onHotkeyTextChange(id, value) end function setSendAutomatically(value) - hotkeyLabelSelectedOnList.autoSend = value - if value then - hotkeyLabelSelectedOnList:setColor(HotkeyColors.autoSend) - else - hotkeyLabelSelectedOnList:setColor(HotkeyColors.text) + if hotkeyLabelSelectedOnList ~= nil then + hotkeyLabelSelectedOnList.autoSend = value + if value then + hotkeyLabelSelectedOnList:setColor(HotkeyColors.autoSend) + else + hotkeyLabelSelectedOnList:setColor(HotkeyColors.text) + end end end diff --git a/modules/game_hotkeys/hotkeys_manager.otui b/modules/game_hotkeys/hotkeys_manager.otui index b349dfb1..6e345b9f 100644 --- a/modules/game_hotkeys/hotkeys_manager.otui +++ b/modules/game_hotkeys/hotkeys_manager.otui @@ -215,7 +215,7 @@ HotkeyAssignWindow < MainWindow width: 64 anchors.right: next.left anchors.bottom: parent.bottom - @onClick: modules.game_hotkeys.addKeyCombo(self:getParent(), self:getParent():getChildById('comboPreview').keyCombo) + @onClick: modules.game_hotkeys.addKeyCombo(self:getParent(), self:getParent():getChildById('comboPreview').keyCombo, nil, true) margin-right: 10 Button diff --git a/modules/game_skills/skills.lua b/modules/game_skills/skills.lua index 7811efe8..8f1d8368 100644 --- a/modules/game_skills/skills.lua +++ b/modules/game_skills/skills.lua @@ -217,7 +217,7 @@ function refresh() end function offline() - expSpeedEvent:cancel() + if expSpeedEvent then expSpeedEvent:cancel() expSpeedEvent = nil end end function toggle() diff --git a/src/framework/platform/platform.h b/src/framework/platform/platform.h index b733f2e1..2c862cfe 100644 --- a/src/framework/platform/platform.h +++ b/src/framework/platform/platform.h @@ -33,7 +33,7 @@ public: bool spawnProcess(const std::string& process, const std::vector& args); int getProcessId(); std::string getTempPath(); - void copyFile(std::string from, std::string to); + bool copyFile(std::string from, std::string to); void openUrl(std::string url); std::string getCPUName(); double getTotalSystemMemory(); diff --git a/src/framework/platform/unixplatform.cpp b/src/framework/platform/unixplatform.cpp index 2486052f..b422fb6b 100644 --- a/src/framework/platform/unixplatform.cpp +++ b/src/framework/platform/unixplatform.cpp @@ -28,6 +28,8 @@ #include #include +#include + void Platform::processArgs(std::vector& args) { //nothing todo, linux args are already utf8 encoded @@ -35,6 +37,10 @@ void Platform::processArgs(std::vector& args) bool Platform::spawnProcess(const std::string& process, const std::vector& args) { + struct stat sts; + if(stat(process.c_str(), &sts) == -1 && errno == ENOENT) + return false; + pid_t pid = fork(); if(pid == -1) return false; @@ -46,7 +52,8 @@ bool Platform::spawnProcess(const std::string& process, const std::vector