fix some keyboard issues, chat tab, fix loadScript exception
This commit is contained in:
parent
f57d46de0e
commit
aae784468b
|
@ -8,10 +8,10 @@ local characterList
|
||||||
-- private functions
|
-- private functions
|
||||||
local function onCharactersWindowKeyPress(self, keyCode, keyText, keyboardModifiers)
|
local function onCharactersWindowKeyPress(self, keyCode, keyText, keyboardModifiers)
|
||||||
if keyboardModifiers == KeyboardNoModifier then
|
if keyboardModifiers == KeyboardNoModifier then
|
||||||
if keyCode == KeyUp or keyCode == KeyTab then
|
if keyCode == KeyUp then
|
||||||
characterList:focusPreviousChild(ActiveFocusReason)
|
characterList:focusPreviousChild(ActiveFocusReason)
|
||||||
return true
|
return true
|
||||||
elseif keyCode == KeyDown then
|
elseif keyCode == KeyDown or keyCode == KeyTab then
|
||||||
characterList:focusNextChild(ActiveFocusReason)
|
characterList:focusNextChild(ActiveFocusReason)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ end
|
||||||
|
|
||||||
local function determineKeyComboDesc(keyCode, keyboardModifiers)
|
local function determineKeyComboDesc(keyCode, keyboardModifiers)
|
||||||
local keyCombo = {}
|
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)
|
table.insert(keyCombo, keyCode)
|
||||||
elseif KeyCodeDescs[keyCode] ~= nil then
|
elseif KeyCodeDescs[keyCode] ~= nil then
|
||||||
if keyboardModifiers == KeyboardCtrlModifier then
|
if keyboardModifiers == KeyboardCtrlModifier then
|
||||||
|
@ -59,6 +59,7 @@ local function determineKeyComboDesc(keyCode, keyboardModifiers)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onWidgetKeyPress(widget, keyCode, keyText, keyboardModifiers)
|
local function onWidgetKeyPress(widget, keyCode, keyText, keyboardModifiers)
|
||||||
|
if keyCode == KeyUnknown then return end
|
||||||
local keyComboDesc = determineKeyComboDesc(keyCode, keyboardModifiers)
|
local keyComboDesc = determineKeyComboDesc(keyCode, keyboardModifiers)
|
||||||
local callback = widget.boundKeyCombos[keyComboDesc]
|
local callback = widget.boundKeyCombos[keyComboDesc]
|
||||||
if callback then
|
if callback then
|
||||||
|
|
|
@ -16,7 +16,6 @@ InterfacePanel < Panel
|
||||||
image-border: 4
|
image-border: 4
|
||||||
|
|
||||||
InterfacePanel2 < Panel
|
InterfacePanel2 < Panel
|
||||||
focusable: false
|
|
||||||
image-source: /core_styles/images/interface_panel2.png
|
image-source: /core_styles/images/interface_panel2.png
|
||||||
image-border: 4
|
image-border: 4
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ end
|
||||||
-- public functions
|
-- public functions
|
||||||
function UITabBar.create()
|
function UITabBar.create()
|
||||||
local tabbar = UITabBar.internalCreate()
|
local tabbar = UITabBar.internalCreate()
|
||||||
|
tabbar:setFocusable(false)
|
||||||
tabbar.tabs = {}
|
tabbar.tabs = {}
|
||||||
return tabbar
|
return tabbar
|
||||||
end
|
end
|
||||||
|
@ -46,6 +47,7 @@ function UITabBar:addTab(text, panel)
|
||||||
end
|
end
|
||||||
|
|
||||||
function UITabBar:selectTab(tabButton)
|
function UITabBar:selectTab(tabButton)
|
||||||
|
if self.currentTabButton == tabButton then return end
|
||||||
if self.contentWidget then
|
if self.contentWidget then
|
||||||
local selectedWidget = self.contentWidget:getFirstChild()
|
local selectedWidget = self.contentWidget:getFirstChild()
|
||||||
if selectedWidget then
|
if selectedWidget then
|
||||||
|
@ -55,13 +57,31 @@ function UITabBar:selectTab(tabButton)
|
||||||
tabButton.tabPanel:fill('parent')
|
tabButton.tabPanel:fill('parent')
|
||||||
end
|
end
|
||||||
|
|
||||||
tabButton:setChecked(true)
|
|
||||||
tabButton:setOn(false)
|
|
||||||
tabButton.blinking = false
|
|
||||||
if self.currentTabButton then
|
if self.currentTabButton then
|
||||||
self.currentTabButton:setChecked(false)
|
self.currentTabButton:setChecked(false)
|
||||||
end
|
end
|
||||||
self.currentTabButton = tabButton
|
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
|
end
|
||||||
|
|
||||||
function UITabBar:blinkTab(tabButton)
|
function UITabBar:blinkTab(tabButton)
|
||||||
|
|
|
@ -18,9 +18,9 @@ function Game.createInterface()
|
||||||
CharacterList.destroyLoadBox()
|
CharacterList.destroyLoadBox()
|
||||||
Game.gameUi = displayUI('game.otui')
|
Game.gameUi = displayUI('game.otui')
|
||||||
rootWidget:moveChildToIndex(Game.gameUi, 1)
|
rootWidget:moveChildToIndex(Game.gameUi, 1)
|
||||||
Game.gameMapPanel = Game.gameUi:getChildById('mapPanel')
|
Game.gameMapPanel = Game.gameUi:getChildById('gameMapPanel')
|
||||||
Game.gameRightPanel = Game.gameUi:getChildById('rightPanel')
|
Game.gameRightPanel = Game.gameUi:getChildById('gameRightPanel')
|
||||||
Game.gameBottomPanel = Game.gameUi:getChildById('bottomPanel')
|
Game.gameBottomPanel = Game.gameUi:getChildById('gameBottomPanel')
|
||||||
Game.gameUi.onKeyPress = onGameKeyPress
|
Game.gameUi.onKeyPress = onGameKeyPress
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ UIGame
|
||||||
anchors.top: topMenu.bottom
|
anchors.top: topMenu.bottom
|
||||||
|
|
||||||
InterfacePanel
|
InterfacePanel
|
||||||
id: rightPanel
|
id: gameRightPanel
|
||||||
width: 200
|
width: 200
|
||||||
layout: verticalBox
|
layout: verticalBox
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
@ -12,16 +12,17 @@ UIGame
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
InterfacePanel2
|
InterfacePanel2
|
||||||
id: bottomPanel
|
id: gameBottomPanel
|
||||||
height: 170
|
height: 170
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: rightPanel.left
|
anchors.right: gameRightPanel.left
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
Map
|
Map
|
||||||
id: mapPanel
|
id: gameMapPanel
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: rightPanel.left
|
anchors.right: gameRightPanel.left
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: bottomPanel.top
|
anchors.bottom: gameBottomPanel.top
|
||||||
|
focusable: false
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ local consoleBuffer
|
||||||
local consoleTabBar
|
local consoleTabBar
|
||||||
local defaultChannelTab
|
local defaultChannelTab
|
||||||
local serverLogTab
|
local serverLogTab
|
||||||
local current
|
local currentTab
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
function Console.create()
|
function Console.create()
|
||||||
|
@ -33,6 +33,9 @@ function Console.create()
|
||||||
consoleTabBar:setContentWidget(consoleBuffer)
|
consoleTabBar:setContentWidget(consoleBuffer)
|
||||||
defaultChannelTab = consoleTabBar:addTab('Default')
|
defaultChannelTab = consoleTabBar:addTab('Default')
|
||||||
serverLogTab = consoleTabBar:addTab('Server Log')
|
serverLogTab = consoleTabBar:addTab('Server Log')
|
||||||
|
|
||||||
|
Hotkeys.bind('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
|
||||||
|
Hotkeys.bind('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Console.destroy()
|
function Console.destroy()
|
||||||
|
|
|
@ -70,3 +70,4 @@ Panel
|
||||||
margin-left: 6
|
margin-left: 6
|
||||||
margin-bottom: 6
|
margin-bottom: 6
|
||||||
always-active: true
|
always-active: true
|
||||||
|
focusable: false
|
|
@ -297,9 +297,13 @@ void LuaInterface::loadScript(const std::string& fileName)
|
||||||
if(!boost::starts_with(fileName, "/"))
|
if(!boost::starts_with(fileName, "/"))
|
||||||
filePath = getCurrentSourcePath() + "/" + filePath;
|
filePath = getCurrentSourcePath() + "/" + filePath;
|
||||||
|
|
||||||
|
try {
|
||||||
std::string buffer = g_resources.loadFile(filePath);
|
std::string buffer = g_resources.loadFile(filePath);
|
||||||
std::string source = "@" + filePath;
|
std::string source = "@" + filePath;
|
||||||
loadBuffer(buffer, source);
|
loadBuffer(buffer, source);
|
||||||
|
} catch(Exception& e) {
|
||||||
|
throw LuaException(e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaInterface::loadFunction(const std::string& buffer, const std::string& source)
|
void LuaInterface::loadFunction(const std::string& buffer, const std::string& source)
|
||||||
|
|
|
@ -77,8 +77,8 @@ X11Window::X11Window()
|
||||||
m_keyMap[XK_Control_R] = Fw::KeyCtrl;
|
m_keyMap[XK_Control_R] = Fw::KeyCtrl;
|
||||||
m_keyMap[XK_Shift_R] = Fw::KeyShift;
|
m_keyMap[XK_Shift_R] = Fw::KeyShift;
|
||||||
m_keyMap[XK_Shift_L] = Fw::KeyShift;
|
m_keyMap[XK_Shift_L] = Fw::KeyShift;
|
||||||
m_keyMap[XK_Alt_R] = Fw::KeyAlt;
|
m_keyMap[XK_Alt_R] = Fw::KeyAltGr;
|
||||||
m_keyMap[XK_Alt_L] = Fw::KeyAltGr;
|
m_keyMap[XK_Alt_L] = Fw::KeyAlt;
|
||||||
m_keyMap[XK_Meta_L] = Fw::KeyMeta;
|
m_keyMap[XK_Meta_L] = Fw::KeyMeta;
|
||||||
m_keyMap[XK_Meta_R] = Fw::KeyMeta;
|
m_keyMap[XK_Meta_R] = Fw::KeyMeta;
|
||||||
m_keyMap[XK_Menu] = Fw::KeyMenu;
|
m_keyMap[XK_Menu] = Fw::KeyMenu;
|
||||||
|
@ -642,13 +642,14 @@ void X11Window::poll()
|
||||||
//logDebug("char: ", buf[0], " code: ", (uint)buf[0]);
|
//logDebug("char: ", buf[0], " code: ", (uint)buf[0]);
|
||||||
m_inputEvent.keyText = buf;
|
m_inputEvent.keyText = buf;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
len = XLookupString(&event.xkey, buf, sizeof(buf), &keysym, 0);
|
|
||||||
|
|
||||||
if(len > 0)
|
|
||||||
m_inputEvent.keyText = buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XKeyEvent xkey = event.xkey;
|
||||||
|
xkey.state = xkey.state & ~(ShiftMask);
|
||||||
|
len = XLookupString(&xkey, buf, sizeof(buf), &keysym, 0);
|
||||||
|
if(len > 0 && m_inputEvent.keyText.length() == 0)
|
||||||
|
m_inputEvent.keyText = buf;
|
||||||
|
|
||||||
if(m_keyMap.find(keysym) != m_keyMap.end())
|
if(m_keyMap.find(keysym) != m_keyMap.end())
|
||||||
m_inputEvent.keyCode = m_keyMap[keysym];
|
m_inputEvent.keyCode = m_keyMap[keysym];
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
|
|
||||||
bool UIGame::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifiers)
|
bool UIGame::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifiers)
|
||||||
{
|
{
|
||||||
|
if(UIWidget::onKeyPress(keyCode, keyText, keyboardModifiers))
|
||||||
|
return true;
|
||||||
|
|
||||||
UILineEditPtr chatLineEdit = std::dynamic_pointer_cast<UILineEdit>(getParent()->recursiveGetChildById("consoleLineEdit"));
|
UILineEditPtr chatLineEdit = std::dynamic_pointer_cast<UILineEdit>(getParent()->recursiveGetChildById("consoleLineEdit"));
|
||||||
|
|
||||||
if(keyboardModifiers == Fw::KeyboardNoModifier) {
|
if(keyboardModifiers == Fw::KeyboardNoModifier) {
|
||||||
|
@ -108,5 +111,5 @@ bool UIGame::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifier
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return UIWidget::onKeyPress(keyCode, keyText, keyboardModifiers);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue