mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 07:26:49 +01:00
fix some keyboard issues, chat tab, fix loadScript exception
This commit is contained in:
@@ -8,10 +8,10 @@ local characterList
|
||||
-- private functions
|
||||
local function onCharactersWindowKeyPress(self, keyCode, keyText, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardNoModifier then
|
||||
if keyCode == KeyUp or keyCode == KeyTab then
|
||||
if keyCode == KeyUp then
|
||||
characterList:focusPreviousChild(ActiveFocusReason)
|
||||
return true
|
||||
elseif keyCode == KeyDown then
|
||||
elseif keyCode == KeyDown or keyCode == KeyTab then
|
||||
characterList:focusNextChild(ActiveFocusReason)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ end
|
||||
|
||||
local function determineKeyComboDesc(keyCode, keyboardModifiers)
|
||||
local keyCombo = {}
|
||||
if keyCode == KeyShift or keyCode == KeyAlt or keyCode == KeyAltGr then
|
||||
if keyCode == KeyCtrl or keyCode == KeyShift or keyCode == KeyAlt or keyCode == KeyAltGr then
|
||||
table.insert(keyCombo, keyCode)
|
||||
elseif KeyCodeDescs[keyCode] ~= nil then
|
||||
if keyboardModifiers == KeyboardCtrlModifier then
|
||||
@@ -59,6 +59,7 @@ local function determineKeyComboDesc(keyCode, keyboardModifiers)
|
||||
end
|
||||
|
||||
local function onWidgetKeyPress(widget, keyCode, keyText, keyboardModifiers)
|
||||
if keyCode == KeyUnknown then return end
|
||||
local keyComboDesc = determineKeyComboDesc(keyCode, keyboardModifiers)
|
||||
local callback = widget.boundKeyCombos[keyComboDesc]
|
||||
if callback then
|
||||
|
||||
@@ -16,7 +16,6 @@ InterfacePanel < Panel
|
||||
image-border: 4
|
||||
|
||||
InterfacePanel2 < Panel
|
||||
focusable: false
|
||||
image-source: /core_styles/images/interface_panel2.png
|
||||
image-border: 4
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ end
|
||||
-- public functions
|
||||
function UITabBar.create()
|
||||
local tabbar = UITabBar.internalCreate()
|
||||
tabbar:setFocusable(false)
|
||||
tabbar.tabs = {}
|
||||
return tabbar
|
||||
end
|
||||
@@ -46,6 +47,7 @@ function UITabBar:addTab(text, panel)
|
||||
end
|
||||
|
||||
function UITabBar:selectTab(tabButton)
|
||||
if self.currentTabButton == tabButton then return end
|
||||
if self.contentWidget then
|
||||
local selectedWidget = self.contentWidget:getFirstChild()
|
||||
if selectedWidget then
|
||||
@@ -55,13 +57,31 @@ function UITabBar:selectTab(tabButton)
|
||||
tabButton.tabPanel:fill('parent')
|
||||
end
|
||||
|
||||
tabButton:setChecked(true)
|
||||
tabButton:setOn(false)
|
||||
tabButton.blinking = false
|
||||
if self.currentTabButton then
|
||||
self.currentTabButton:setChecked(false)
|
||||
end
|
||||
self.currentTabButton = tabButton
|
||||
tabButton:setChecked(true)
|
||||
tabButton:setOn(false)
|
||||
tabButton.blinking = false
|
||||
end
|
||||
|
||||
function UITabBar:selectNextTab()
|
||||
if self.currentTabButton == nil then return end
|
||||
local index = table.find(self.tabs, self.currentTabButton)
|
||||
if index == nil then return end
|
||||
local nextTab = self.tabs[index + 1] or self.tabs[1]
|
||||
if not nextTab then return end
|
||||
self:selectTab(nextTab)
|
||||
end
|
||||
|
||||
function UITabBar:selectPrevTab()
|
||||
if self.currentTabButton == nil then return end
|
||||
local index = table.find(self.tabs, self.currentTabButton)
|
||||
if index == nil then return end
|
||||
local prevTab = self.tabs[index - 1] or self.tabs[#self.tabs]
|
||||
if not prevTab then return end
|
||||
self:selectTab(prevTab)
|
||||
end
|
||||
|
||||
function UITabBar:blinkTab(tabButton)
|
||||
|
||||
@@ -18,9 +18,9 @@ function Game.createInterface()
|
||||
CharacterList.destroyLoadBox()
|
||||
Game.gameUi = displayUI('game.otui')
|
||||
rootWidget:moveChildToIndex(Game.gameUi, 1)
|
||||
Game.gameMapPanel = Game.gameUi:getChildById('mapPanel')
|
||||
Game.gameRightPanel = Game.gameUi:getChildById('rightPanel')
|
||||
Game.gameBottomPanel = Game.gameUi:getChildById('bottomPanel')
|
||||
Game.gameMapPanel = Game.gameUi:getChildById('gameMapPanel')
|
||||
Game.gameRightPanel = Game.gameUi:getChildById('gameRightPanel')
|
||||
Game.gameBottomPanel = Game.gameUi:getChildById('gameBottomPanel')
|
||||
Game.gameUi.onKeyPress = onGameKeyPress
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ UIGame
|
||||
anchors.top: topMenu.bottom
|
||||
|
||||
InterfacePanel
|
||||
id: rightPanel
|
||||
id: gameRightPanel
|
||||
width: 200
|
||||
layout: verticalBox
|
||||
anchors.right: parent.right
|
||||
@@ -12,16 +12,17 @@ UIGame
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
InterfacePanel2
|
||||
id: bottomPanel
|
||||
id: gameBottomPanel
|
||||
height: 170
|
||||
anchors.left: parent.left
|
||||
anchors.right: rightPanel.left
|
||||
anchors.right: gameRightPanel.left
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
Map
|
||||
id: mapPanel
|
||||
id: gameMapPanel
|
||||
anchors.left: parent.left
|
||||
anchors.right: rightPanel.left
|
||||
anchors.right: gameRightPanel.left
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: bottomPanel.top
|
||||
anchors.bottom: gameBottomPanel.top
|
||||
focusable: false
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ local consoleBuffer
|
||||
local consoleTabBar
|
||||
local defaultChannelTab
|
||||
local serverLogTab
|
||||
local current
|
||||
local currentTab
|
||||
|
||||
-- public functions
|
||||
function Console.create()
|
||||
@@ -33,6 +33,9 @@ function Console.create()
|
||||
consoleTabBar:setContentWidget(consoleBuffer)
|
||||
defaultChannelTab = consoleTabBar:addTab('Default')
|
||||
serverLogTab = consoleTabBar:addTab('Server Log')
|
||||
|
||||
Hotkeys.bind('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
|
||||
Hotkeys.bind('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
|
||||
end
|
||||
|
||||
function Console.destroy()
|
||||
|
||||
@@ -69,4 +69,5 @@ Panel
|
||||
margin-right: 6
|
||||
margin-left: 6
|
||||
margin-bottom: 6
|
||||
always-active: true
|
||||
always-active: true
|
||||
focusable: false
|
||||
Reference in New Issue
Block a user