Browse Source

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
Eduardo Bart 8 years ago
parent
commit
066ffead08

+ 16
- 0
modules/core_lib/keyboard.lua View File

@@ -134,3 +134,19 @@ function Keyboard.unbindKeyPress(keyComboDesc, widget)
134 134
     widget.boundKeyPressCombos[keyComboDesc] = nil
135 135
   end
136 136
 end
137
+
138
+function Keyboard.getModifiers()
139
+  return g_window.getKeyboardModifiers()
140
+end
141
+
142
+function Keyboard.isCtrlPressed()
143
+  return bit32.band(g_window.getKeyboardModifiers(), KeyboardCtrlModifier) ~= 0
144
+end
145
+
146
+function Keyboard.isAltPressed()
147
+  return bit32.band(g_window.getKeyboardModifiers(), KeyboardAltModifier) ~= 0
148
+end
149
+
150
+function Keyboard.isShiftPressed()
151
+  return bit32.band(g_window.getKeyboardModifiers(), KeyboardShiftModifier) ~= 0
152
+end

+ 1
- 1
modules/core_lib/widgets/uimessagebox.lua View File

@@ -19,7 +19,7 @@ function UIMessageBox.display(title, message, flags)
19 19
   messageLabel:setText(message)
20 20
   messageLabel:resizeToText()
21 21
 
22
-  messagebox:setWidth(math.max(messageLabel:getWidth() + 48, messagebox:getWidth()))
22
+  messagebox:setWidth(math.max(messageLabel:getWidth() + 48, messagebox:getTextSize().width + 20))
23 23
   messagebox:setHeight(math.max(messageLabel:getHeight() + 64, messagebox:getHeight()))
24 24
 
25 25
   -- setup messagebox first button

+ 10
- 2
modules/game/gameinterface.lua View File

@@ -52,6 +52,7 @@ function GameInterface.init()
52 52
   Keyboard.bindKeyPress('Ctrl+=', function() gameMapPanel:zoomIn() end, gameRootPanel, 250)
53 53
   Keyboard.bindKeyPress('Ctrl+-', function() gameMapPanel:zoomOut() end, gameRootPanel, 250)
54 54
   Keyboard.bindKeyDown('Ctrl+Q', GameInterface.tryLogout, gameRootPanel)
55
+  Keyboard.bindKeyDown('Ctrl+L', GameInterface.tryLogout, gameRootPanel)
55 56
 
56 57
   if g_game.isOnline() then
57 58
     GameInterface.show()
@@ -280,7 +281,7 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
280 281
 end
281 282
 
282 283
 function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
283
-  local keyboardModifiers = g_window.getKeyboardModifiers()
284
+  local keyboardModifiers = Keyboard.getModifiers()
284 285
 
285 286
   if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
286 287
     -- todo auto walk
@@ -351,8 +352,15 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
351 352
 end
352 353
 
353 354
 function GameInterface.moveStackableItem(item, toPos)
354
-  local count = item:getCount()
355
+  if Keyboard.isCtrlPressed() then
356
+    g_game.move(item, toPos, item:getCount())
357
+    return
358
+  elseif Keyboard.isShiftPressed() then
359
+    g_game.move(item, toPos, 1)
360
+    return
361
+  end
355 362
 
363
+  local count = item:getCount()
356 364
   local countWindow = createWidget('CountWindow', rootWidget)
357 365
   local spinbox = countWindow:getChildById('countSpinBox')
358 366
   local scrollbar = countWindow:getChildById('countScrollBar')

+ 1
- 2
modules/game_battle/battle.lua View File

@@ -256,8 +256,7 @@ function Battle.onMouseRelease(self, mousePosition, mouseButton)
256 256
     GameInterface.createThingMenu(mousePosition, nil, nil, self.creature)
257 257
     return true
258 258
   elseif mouseButton == MouseLeftButton then
259
-    local modifiers = g_window.getKeyboardModifiers()
260
-    if modifiers == KeyboardShiftModifier then
259
+    if Keyboard.isShiftPressed() then
261 260
       g_game.look(self.creature)
262 261
     else
263 262
       if self.isTarget then

+ 1
- 1
modules/game_bugreport/bugreport.otui View File

@@ -8,10 +8,10 @@ BugReportWindow < MainWindow
8 8
     id: bugLabel
9 9
     !text: tr('Please use this dialog to only report bugs. Do not report rule violations here!')
10 10
     text-wrap: true
11
+    text-auto-resize: true
11 12
     anchors.top: parent.top
12 13
     anchors.left: parent.left
13 14
     anchors.right: parent.right
14
-    height: 32
15 15
 
16 16
   MultilineTextEdit
17 17
     id: bugTextEdit

+ 9
- 0
modules/game_hotkeys/hotkeys_manager.lua View File

@@ -68,9 +68,18 @@ end
68 68
 function HotkeysManager.load()
69 69
   local hotkeySettings = Settings.getNode('HotkeysManager')
70 70
 
71
+  local hasCombos = false
71 72
   if hotkeySettings ~= nil then
72 73
     for i, v in pairs(hotkeySettings) do
73 74
       HotkeysManager.addKeyCombo(nil, v.keyCombo, v)
75
+      hasCombos = true
76
+    end
77
+  end
78
+
79
+  -- add default F keys combos
80
+  if not hasCombos then
81
+    for i=1,12 do
82
+      HotkeysManager.addKeyCombo(nil, 'F' .. i, nil)
74 83
     end
75 84
   end
76 85
 end

+ 1
- 0
modules/game_inventory/inventory.otui View File

@@ -95,4 +95,5 @@ MiniWindow
95 95
       anchors.left: slot10.left
96 96
       margin-top: 5
97 97
       text-align: center
98
+      text-auto-resize: true
98 99
 

Loading…
Cancel
Save