more fixes
* add default key combos to Hotkeys * impement moving countable items holding Ctrl or Shift * fix messagebox incorrent size * implement API in Keyboard to get modifiers key states * minor UI layout fixes * add Ctrl+L logout hotkey
This commit is contained in:
parent
486837a61d
commit
066ffead08
|
@ -134,3 +134,19 @@ function Keyboard.unbindKeyPress(keyComboDesc, widget)
|
|||
widget.boundKeyPressCombos[keyComboDesc] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function Keyboard.getModifiers()
|
||||
return g_window.getKeyboardModifiers()
|
||||
end
|
||||
|
||||
function Keyboard.isCtrlPressed()
|
||||
return bit32.band(g_window.getKeyboardModifiers(), KeyboardCtrlModifier) ~= 0
|
||||
end
|
||||
|
||||
function Keyboard.isAltPressed()
|
||||
return bit32.band(g_window.getKeyboardModifiers(), KeyboardAltModifier) ~= 0
|
||||
end
|
||||
|
||||
function Keyboard.isShiftPressed()
|
||||
return bit32.band(g_window.getKeyboardModifiers(), KeyboardShiftModifier) ~= 0
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ function UIMessageBox.display(title, message, flags)
|
|||
messageLabel:setText(message)
|
||||
messageLabel:resizeToText()
|
||||
|
||||
messagebox:setWidth(math.max(messageLabel:getWidth() + 48, messagebox:getWidth()))
|
||||
messagebox:setWidth(math.max(messageLabel:getWidth() + 48, messagebox:getTextSize().width + 20))
|
||||
messagebox:setHeight(math.max(messageLabel:getHeight() + 64, messagebox:getHeight()))
|
||||
|
||||
-- setup messagebox first button
|
||||
|
|
|
@ -52,6 +52,7 @@ function GameInterface.init()
|
|||
Keyboard.bindKeyPress('Ctrl+=', function() gameMapPanel:zoomIn() end, gameRootPanel, 250)
|
||||
Keyboard.bindKeyPress('Ctrl+-', function() gameMapPanel:zoomOut() end, gameRootPanel, 250)
|
||||
Keyboard.bindKeyDown('Ctrl+Q', GameInterface.tryLogout, gameRootPanel)
|
||||
Keyboard.bindKeyDown('Ctrl+L', GameInterface.tryLogout, gameRootPanel)
|
||||
|
||||
if g_game.isOnline() then
|
||||
GameInterface.show()
|
||||
|
@ -280,7 +281,7 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
|
|||
end
|
||||
|
||||
function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
|
||||
local keyboardModifiers = g_window.getKeyboardModifiers()
|
||||
local keyboardModifiers = Keyboard.getModifiers()
|
||||
|
||||
if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
|
||||
-- todo auto walk
|
||||
|
@ -351,8 +352,15 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
|
|||
end
|
||||
|
||||
function GameInterface.moveStackableItem(item, toPos)
|
||||
local count = item:getCount()
|
||||
if Keyboard.isCtrlPressed() then
|
||||
g_game.move(item, toPos, item:getCount())
|
||||
return
|
||||
elseif Keyboard.isShiftPressed() then
|
||||
g_game.move(item, toPos, 1)
|
||||
return
|
||||
end
|
||||
|
||||
local count = item:getCount()
|
||||
local countWindow = createWidget('CountWindow', rootWidget)
|
||||
local spinbox = countWindow:getChildById('countSpinBox')
|
||||
local scrollbar = countWindow:getChildById('countScrollBar')
|
||||
|
|
|
@ -256,8 +256,7 @@ function Battle.onMouseRelease(self, mousePosition, mouseButton)
|
|||
GameInterface.createThingMenu(mousePosition, nil, nil, self.creature)
|
||||
return true
|
||||
elseif mouseButton == MouseLeftButton then
|
||||
local modifiers = g_window.getKeyboardModifiers()
|
||||
if modifiers == KeyboardShiftModifier then
|
||||
if Keyboard.isShiftPressed() then
|
||||
g_game.look(self.creature)
|
||||
else
|
||||
if self.isTarget then
|
||||
|
|
|
@ -8,10 +8,10 @@ BugReportWindow < MainWindow
|
|||
id: bugLabel
|
||||
!text: tr('Please use this dialog to only report bugs. Do not report rule violations here!')
|
||||
text-wrap: true
|
||||
text-auto-resize: true
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 32
|
||||
|
||||
MultilineTextEdit
|
||||
id: bugTextEdit
|
||||
|
|
|
@ -68,9 +68,18 @@ end
|
|||
function HotkeysManager.load()
|
||||
local hotkeySettings = Settings.getNode('HotkeysManager')
|
||||
|
||||
local hasCombos = false
|
||||
if hotkeySettings ~= nil then
|
||||
for i, v in pairs(hotkeySettings) do
|
||||
HotkeysManager.addKeyCombo(nil, v.keyCombo, v)
|
||||
hasCombos = true
|
||||
end
|
||||
end
|
||||
|
||||
-- add default F keys combos
|
||||
if not hasCombos then
|
||||
for i=1,12 do
|
||||
HotkeysManager.addKeyCombo(nil, 'F' .. i, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -95,4 +95,5 @@ MiniWindow
|
|||
anchors.left: slot10.left
|
||||
margin-top: 5
|
||||
text-align: center
|
||||
text-auto-resize: true
|
||||
|
||||
|
|
Loading…
Reference in New Issue