Some fixes in hotkeys and other improvements
* Save last logged character and world instead of character name * Make focused label always visible in character list and hotkeys * Other fixes in hotkeys
This commit is contained in:
parent
197a379933
commit
d6e8e92a45
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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,12 +476,14 @@ function onHotkeyTextChange(id, value)
|
|||
end
|
||||
|
||||
function setSendAutomatically(value)
|
||||
if hotkeyLabelSelectedOnList ~= nil then
|
||||
hotkeyLabelSelectedOnList.autoSend = value
|
||||
if value then
|
||||
hotkeyLabelSelectedOnList:setColor(HotkeyColors.autoSend)
|
||||
else
|
||||
hotkeyLabelSelectedOnList:setColor(HotkeyColors.text)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function hotkeyCapture(widget, keyCode, keyboardModifiers)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -217,7 +217,7 @@ function refresh()
|
|||
end
|
||||
|
||||
function offline()
|
||||
expSpeedEvent:cancel()
|
||||
if expSpeedEvent then expSpeedEvent:cancel() expSpeedEvent = nil end
|
||||
end
|
||||
|
||||
function toggle()
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
bool spawnProcess(const std::string& process, const std::vector<std::string>& 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();
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include <string.h>
|
||||
#include <framework/stdext/stdext.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
void Platform::processArgs(std::vector<std::string>& args)
|
||||
{
|
||||
//nothing todo, linux args are already utf8 encoded
|
||||
|
@ -35,6 +37,10 @@ void Platform::processArgs(std::vector<std::string>& args)
|
|||
|
||||
bool Platform::spawnProcess(const std::string& process, const std::vector<std::string>& 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<std::s
|
|||
cargs[i] = (char*)args[i-1].c_str();
|
||||
cargs[args.size()+1] = 0;
|
||||
|
||||
execv(process.c_str(), cargs);
|
||||
if(execv(process.c_str(), cargs) == -1)
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -62,9 +69,9 @@ std::string Platform::getTempPath()
|
|||
return "/tmp/";
|
||||
}
|
||||
|
||||
void Platform::copyFile(std::string from, std::string to)
|
||||
bool Platform::copyFile(std::string from, std::string to)
|
||||
{
|
||||
system(stdext::format("/bin/cp '%s' '%s'", from, to).c_str());
|
||||
return system(stdext::format("/bin/cp '%s' '%s'", from, to).c_str()) == 0;
|
||||
}
|
||||
|
||||
void Platform::openUrl(std::string url)
|
||||
|
|
|
@ -68,11 +68,13 @@ std::string Platform::getTempPath()
|
|||
return stdext::utf16_to_utf8(path);
|
||||
}
|
||||
|
||||
void Platform::copyFile(std::string from, std::string to)
|
||||
bool Platform::copyFile(std::string from, std::string to)
|
||||
{
|
||||
boost::replace_all(from, "/", "\\");
|
||||
boost::replace_all(to, "/", "\\");
|
||||
CopyFileW(stdext::utf8_to_utf16(from).c_str(), stdext::utf8_to_utf16(to).c_str(), false);
|
||||
if(CopyFileW(stdext::utf8_to_utf16(from).c_str(), stdext::utf8_to_utf16(to).c_str(), FALSE) == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Platform::openUrl(std::string url)
|
||||
|
|
Loading…
Reference in New Issue