diff --git a/BUGS b/BUGS index 8ae84f93..85655f5d 100644 --- a/BUGS +++ b/BUGS @@ -11,3 +11,4 @@ some animated hits are displayed as 2 hits instead of one numpad on windows doesn't work correctly skulls is rendering outside map bounds these are some issues when skill progressbar is 0% or 100% +paste on x11 platform does not work correctly when doing ctrl+c in google chrome \ No newline at end of file diff --git a/TODO b/TODO index 52c75d7b..39d99fbe 100644 --- a/TODO +++ b/TODO @@ -65,6 +65,7 @@ Low priority TODO [bart] reapply anchor styles when adding new childs [bart] ui text selection [bart] make set of background/icon/image width alone work +[bart] check for recursive anchors to print a error and avoid crashes == Client modules [bart] make possible to reload modules diff --git a/modules/core_styles/core_styles.otmod b/modules/core_styles/core_styles.otmod index 21515d05..4ca1c408 100644 --- a/modules/core_styles/core_styles.otmod +++ b/modules/core_styles/core_styles.otmod @@ -12,6 +12,7 @@ Module importStyle 'styles/lineedits.otui' importStyle 'styles/checkboxes.otui' importStyle 'styles/progressbars.otui' + importStyle 'styles/tabbars.otui' importStyle 'styles/windows.otui' importStyle 'styles/listboxes.otui' importStyle 'styles/items.otui' diff --git a/modules/core_styles/icons/leftarrow.png b/modules/core_styles/icons/leftarrow.png new file mode 100644 index 00000000..7e065f58 Binary files /dev/null and b/modules/core_styles/icons/leftarrow.png differ diff --git a/modules/core_styles/icons/rightarrow.png b/modules/core_styles/icons/rightarrow.png new file mode 100644 index 00000000..4c51e9f2 Binary files /dev/null and b/modules/core_styles/icons/rightarrow.png differ diff --git a/modules/core_styles/icons/say.png b/modules/core_styles/icons/say.png index adfa4a65..82ffb5f8 100644 Binary files a/modules/core_styles/icons/say.png and b/modules/core_styles/icons/say.png differ diff --git a/modules/core_styles/icons/whisper.png b/modules/core_styles/icons/whisper.png index 3da8e18c..440ac166 100644 Binary files a/modules/core_styles/icons/whisper.png and b/modules/core_styles/icons/whisper.png differ diff --git a/modules/core_styles/icons/yell.png b/modules/core_styles/icons/yell.png index 0c913a78..398bc28d 100644 Binary files a/modules/core_styles/icons/yell.png and b/modules/core_styles/icons/yell.png differ diff --git a/modules/core_styles/images/consolebutton.png b/modules/core_styles/images/consolebutton.png new file mode 100644 index 00000000..2b67bbd1 Binary files /dev/null and b/modules/core_styles/images/consolebutton.png differ diff --git a/modules/core_styles/styles/buttons.otui b/modules/core_styles/styles/buttons.otui index 5add3955..d89362c4 100644 --- a/modules/core_styles/styles/buttons.otui +++ b/modules/core_styles/styles/buttons.otui @@ -18,3 +18,23 @@ Button < UIButton color: #f0ad4d88 image-color: #ffffff88 +ConsoleButton < UIButton + size: 20 20 + image-source: /core_styles/images/consolebutton.png + image-color: white + image-clip: 0 0 20 20 + image-border: 2 + icon-color: white + color: #aaaaaa + + $hover !on: + image-clip: 0 20 20 20 + color: white + + $disabled: + image-color: #ffffff66 + icon-color: #888888 + + $on: + image-clip: 0 40 20 20 + color: #80c7f8 \ No newline at end of file diff --git a/modules/core_styles/styles/tabbars.otui b/modules/core_styles/styles/tabbars.otui index ed4e10b4..61f63e25 100644 --- a/modules/core_styles/styles/tabbars.otui +++ b/modules/core_styles/styles/tabbars.otui @@ -1,5 +1,34 @@ TabBar < UITabBar -TabBarTabButton < UIButton -TabBarCloseButton < UIButton -TabBarPrevButton < UIButton -TabBarNextButton < UIButton \ No newline at end of file +TabBarPanel < Panel +TabBarButton < UIButton + size: 20 20 + image-source: /core_styles/images/consolebutton.png + image-color: white + image-clip: 0 0 20 20 + image-border: 2 + icon-color: white + color: #aaaaaa + anchors.top: parent.top + margin-left: 5 + padding: 5 + + $first: + anchors.left: parent.left + + $!first: + anchors.left: prev.right + + $hover !checked: + image-clip: 0 20 20 20 + color: white + + $disabled: + image-color: #ffffff66 + icon-color: #888888 + + $checked: + image-clip: 0 40 20 20 + color: #80c7f8 + + $on !checked: + color: #F55E5E \ No newline at end of file diff --git a/modules/core_widgets/core_widgets.otmod b/modules/core_widgets/core_widgets.otmod index 0e7021a3..12d9f79a 100644 --- a/modules/core_widgets/core_widgets.otmod +++ b/modules/core_widgets/core_widgets.otmod @@ -11,6 +11,7 @@ Module require 'uicheckbox' require 'uicombobox' require 'uiprogressbar' + require 'uitabbar' require 'uipopupmenu' require 'uiwindow' require 'tooltip/tooltip' diff --git a/modules/core_widgets/uitabbar.lua b/modules/core_widgets/uitabbar.lua index 585f6155..abfcf27a 100644 --- a/modules/core_widgets/uitabbar.lua +++ b/modules/core_widgets/uitabbar.lua @@ -1 +1,84 @@ UITabBar = extends(UIWidget) + +-- private functions +local function onTabClick(tabButton) + tabButton.tabBar:selectTab(tabButton) +end + +local function tabBlink(tabButton) + if tabButton.blinking then + tabButton:setOn(not tabButton:isOn()) + scheduleEvent(function() tabBlink(tabButton) end, 300) + end +end + +-- public functions +function UITabBar.create() + local tabbar = UITabBar.internalCreate() + tabbar.tabs = {} + return tabbar +end + +function UITabBar:setContentWidget(widget) + self.contentWidget = widget + if #self.tabs > 0 then + self.contentWidget:addChild(self.tabs[1].tabPanel) + end +end + +function UITabBar:addTab(text, panel) + if panel == nil then + panel = createWidget(self:getStyleName() .. 'Panel') + end + + local tabButton = createWidget(self:getStyleName() .. 'Button', self) + tabButton.tabPanel = panel + tabButton.tabBar = self + tabButton:setText(text) + tabButton:setWidth(tabButton:getTextSize().width + tabButton:getPaddingLeft() + tabButton:getPaddingRight()) + connect(tabButton, { onClick = onTabClick }) + + table.insert(self.tabs, tabButton) + if #self.tabs == 1 then + self:selectTab(tabButton) + end + + return tabButton +end + +function UITabBar:selectTab(tabButton) + if self.contentWidget then + local selectedWidget = self.contentWidget:getFirstChild() + if selectedWidget then + self.contentWidget:removeChild(selectedWidget) + end + self.contentWidget:addChild(tabButton.tabPanel) + 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 +end + +function UITabBar:blinkTab(tabButton) + if not tabButton:isChecked() then + tabButton:setOn(true) + tabButton.blinking = true + tabBlink(tabButton) + end +end + +function UITabBar:getTabPanel(tabButton) + return tabButton.tabPanel +end + +function UITabBar:getCurrentTabPanel() + if self.currentTabButton then + return self.currentTabButton.tabPanel + end +end diff --git a/modules/game/game.otui b/modules/game/game.otui index 84d44bb9..d9212757 100644 --- a/modules/game/game.otui +++ b/modules/game/game.otui @@ -13,7 +13,7 @@ UIGame InterfacePanel2 id: bottomPanel - height: 144 + height: 170 anchors.left: parent.left anchors.right: rightPanel.left anchors.bottom: parent.bottom diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 234f39c5..e423d681 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -20,11 +20,19 @@ local SpeakTypes = { local consolePanel local consoleBuffer +local consoleTabBar +local defaultChannelTab +local serverLogTab +local current -- public functions function Console.create() consolePanel = displayUI('console.otui', { parent = Game.gameBottomPanel } ) consoleBuffer = consolePanel:getChildById('consoleBuffer') + consoleTabBar = consolePanel:getChildById('consoleTabBar') + consoleTabBar:setContentWidget(consoleBuffer) + defaultChannelTab = consoleTabBar:addTab('Default') + serverLogTab = consoleTabBar:addTab('Server Log') end function Console.destroy() @@ -32,16 +40,25 @@ function Console.destroy() consolePanel = nil end -function Console.addText(text, color) +function Console.addText(text, color, channelTab) color = color or 'white' if Options.showTimestampsInConsole then text = os.date('%H:%M') .. ' ' .. text end - local label = createWidget('ConsoleLabel', consoleBuffer) + local label = createWidget('ConsoleLabel', consoleTabBar:getTabPanel(channelTab)) label:setText(text) label:setColor(color) + consoleTabBar:blinkTab(channelTab) +end + +function Console.addChannelMessage(text, color, channel) + if channel == 'Server Log' then + Console.addText(text, color, serverLogTab) + elseif channel == 'Default' then + Console.addText(text, color, defaultChannelTab) + end end -- hooked events @@ -57,7 +74,8 @@ local function onCreatureSpeak(name, level, speaktypedesc, message, channelId, c end end - Console.addText(message, speaktype.color) + local channelPanel = consoleTabBar:getTabPanel(defaultChannelTab) + Console.addText(message, speaktype.color, channelPanel) end connect(Game, { onLogin = Console.create, diff --git a/modules/game_console/console.otui b/modules/game_console/console.otui index 652469ad..2b622db1 100644 --- a/modules/game_console/console.otui +++ b/modules/game_console/console.otui @@ -3,48 +3,58 @@ ConsoleLabel < UILabel height: 14 color: yellow -SayModeButton < UIButton - size: 26 26 - icon: /core_styles/icons/say.png - image-source: /core_styles/images/top_button.png - image-color: white - image-clip: 0 0 26 26 - image-border: 3 - - $hover: - image-source: /core_styles/images/top_button.png - clip: 26 0 26 26 - border: 3 - - $pressed: - image-source: /core_styles/images/top_button.png - image-clip: 52 0 26 26 - image-border: 3 - - $disabled: - image-color: #ffffff66 +ConsoleTabBar < TabBar +ConsoleTabBarPanel < TabBarPanel + layout: + type: verticalBox + align-bottom: true +ConsoleTabBarButton < TabBarButton Panel id: consolePanel anchors.fill: parent + ConsoleButton + id: prevChannelButton + icon: /core_styles/icons/leftarrow.png + anchors.left: parent.left + anchors.top: parent.top + margin-left: 6 + margin-top: 6 + enabled: false + + ConsoleTabBar + id: consoleTabBar + height: 20 + anchors.left: prev.right + anchors.top: prev.top + anchors.right: next.left + margin-left: 5 + + ConsoleButton + id: nextChannelButton + icon: /core_styles/icons/rightarrow.png + anchors.right: parent.right + anchors.top: parent.top + margin-right: 5 + margin-top: 6 + enabled: false + Panel id: consoleBuffer - anchors.top: parent.top + anchors.top: prev.bottom anchors.left: parent.left anchors.right: parent.right anchors.bottom: consoleLineEdit.top margin-right: 6 margin-left: 6 - margin-bottom: 2 - margin-top: 6 - layout: - type: verticalBox - align-bottom: true + margin-bottom: 4 + margin-top: 4 focusable: false - SayModeButton + ConsoleButton id: sayModeButton + icon: /core_styles/icons/say.png size: 20 20 anchors.left: parent.left anchors.bottom: parent.bottom diff --git a/modules/game_textmessage/textmessage.lua b/modules/game_textmessage/textmessage.lua index f7567508..739213b1 100644 --- a/modules/game_textmessage/textmessage.lua +++ b/modules/game_textmessage/textmessage.lua @@ -5,16 +5,16 @@ importStyle 'textmessage.otui' -- private variables local MessageTypes = { - warning = { color = '#F55E5E', showOnConsole = true, windowLocation = 'center', consoleOption = 'showInfoMessagesInConsole' }, - eventAdvance = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' }, - eventDefault = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'bottom', consoleOption = 'showEventMessagesInConsole' }, - eventOrange = { color = '#FE6500', showOnConsole = true, windowLocation = 'bottom', consoleOption = 'showEventMessagesInConsole' }, - statusDefault = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'bottom', consoleOption = 'showStatusMessagesInConsole' }, - infoDescription = { color = '#00EB00', showOnConsole = true, windowLocation = 'center', consoleOption = 'showInfoMessagesInConsole' }, - statusSmall = { color = '#FFFFFF', showOnConsole = false, windowLocation = 'bottom' }, - consoleOrange = { color = '#FE6500', showOnConsole = true }, - consoleBlue = { color = '#9F9DFD', showOnConsole = true }, - consoleRed = { color = '#F55E5E', showOnConsole = true } + consoleRed = { color = '#F55E5E', consoleChannel = 'Server Log' }, + eventOrange = { color = '#FE6500', consoleChannel = 'Default' , windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' }, + consoleOrange = { color = '#FE6500', consoleChannel = 'Default' }, + warning = { color = '#F55E5E', consoleChannel = 'Server Log', windowLocation = 'center' }, + eventAdvance = { color = '#FFFFFF', consoleChannel = 'Server Log', windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' }, + eventDefault = { color = '#FFFFFF', consoleChannel = 'Server Log', windowLocation = 'bottom', consoleOption = 'showEventMessagesInConsole' }, + statusDefault = { color = '#FFFFFF', consoleChannel = 'Server Log', windowLocation = 'bottom', consoleOption = 'showStatusMessagesInConsole' }, + infoDescription = { color = '#00EB00', consoleChannel = 'Server Log', windowLocation = 'center', consoleOption = 'showInfoMessagesInConsole' }, + statusSmall = { color = '#FFFFFF', windowLocation = 'bottom' }, + consoleBlue = { color = '#9F9DFD', consoleChannel = 'Default' }, } local bottomLabelWidget @@ -26,9 +26,9 @@ local centerLabelHideEvent local function displayMessage(msgtype, msg, time) if not Game.isOnline() then return end - if msgtype.showOnConsole then + if msgtype.consoleChannel ~= nil then if msgtype.consoleOption == nil or Options[msgtype.consoleOption] then - Console.addText(msg, msgtype.color) + Console.addChannelMessage(msg, msgtype.color, msgtype.consoleChannel) end end diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index ce0020ca..7b0d0a6d 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -44,6 +44,7 @@ #include #include + void OTClient::registerLuaFunctions() { Application::registerLuaFunctions();