From 830ebdbea98462e9891f4d0f132f946bea168983 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Thu, 12 Jan 2012 21:47:31 -0200 Subject: [PATCH] implement some chat functionality, but not complete yet --- BUGS | 1 + TODO | 1 + modules/core_styles/core_styles.otmod | 1 + modules/core_styles/icons/leftarrow.png | Bin 0 -> 271 bytes modules/core_styles/icons/rightarrow.png | Bin 0 -> 285 bytes modules/core_styles/icons/say.png | Bin 284 -> 255 bytes modules/core_styles/icons/whisper.png | Bin 286 -> 255 bytes modules/core_styles/icons/yell.png | Bin 419 -> 266 bytes modules/core_styles/images/consolebutton.png | Bin 0 -> 415 bytes modules/core_styles/styles/buttons.otui | 20 +++++ modules/core_styles/styles/tabbars.otui | 37 ++++++++- modules/core_widgets/core_widgets.otmod | 1 + modules/core_widgets/uitabbar.lua | 83 +++++++++++++++++++ modules/game/game.otui | 2 +- modules/game_console/console.lua | 24 +++++- modules/game_console/console.otui | 64 ++++++++------ modules/game_textmessage/textmessage.lua | 24 +++--- src/otclient/luafunctions.cpp | 1 + 18 files changed, 212 insertions(+), 47 deletions(-) create mode 100644 modules/core_styles/icons/leftarrow.png create mode 100644 modules/core_styles/icons/rightarrow.png create mode 100644 modules/core_styles/images/consolebutton.png 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 0000000000000000000000000000000000000000..7e065f58a3a19c3c26367481ef0ccecb40f5747c GIT binary patch literal 271 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6U4S$Y z{B+)352QE?JR*x37`TN&n2}-D90{Nxdx@v7EBhTr9uaoNzu$csfkLvGArU3c`MJ5N zc_lzD1A}u>YGO%hib8p2Nrr;Er*A-tUMf3KJk8U^F~s8Z)kz0A8w>xNPaWr+0)lEHUi8Xg2?3L!;!422l>vXR&9b~_Y@$RDT)ZKd5B0)~^boFyt=akR{ E0Ojvj?EnA( literal 0 HcmV?d00001 diff --git a/modules/core_styles/icons/rightarrow.png b/modules/core_styles/icons/rightarrow.png new file mode 100644 index 0000000000000000000000000000000000000000..4c51e9f212db32f4a6876004b0ee6f0f006df7b7 GIT binary patch literal 285 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6U4S$Y z{B+)352QE?JR*x37`TN&n2}-D90{Nxdx@v7EBhTr9uYT9;TGqd zrN8?F@(LRk>0NkyTDN1%((CitKTi|b=OAQJdt~_{DTle26_s>?uDb1A?U`#F!4h+I z`L7`PqbGO@L^m5Hk}oQWAa*zzizZ4-S#}iFfvoj(^>bP0l+XkK;6F4d delta 169 zcmV;a09OD10h|JmHwh{LF#tITo{M#nKp+SS7X=#!JD8G@Xe@toNklt2L)joIpcg~~L*l@)&`CCr*kqHt(LF2uT7Uz3z|{hJU;#oEBu)^3wHT6& z-vT4B0YhHb7(07Ov!qVa5#5=9q{+u(f7N6Gij@O)NmFzZzm);=i0{4e$spB7`4gR% X5rUd)jU`3^000R9NkvXXu0mjfWnM#v diff --git a/modules/core_styles/icons/whisper.png b/modules/core_styles/icons/whisper.png index 3da8e18cea711b43578fa5492891b97cadf9cc01..440ac1664ae8e7215833a95e13bfd4d32cb85ed1 100644 GIT binary patch delta 139 zcmbQo^q+BpIVS@M{B+)3KhZ&fgGX4MG1sPEZDNK_c9^G&V~EA+y^{}eF(`02FaPp? z{~kZbz^&=WMc%qGW|S?kznEvewhp&t;ucLK6V3Of((< delta 171 zcmV;c0960~0iFVoHwpg${{a7>y{D6rKp+SS7X|^*bTTWEXe@tqNklB$zkl84 z@rhQ=)98R6NIt||d$Zzt^}svuAY_&t09R9Be!c)};0U||UslOHjZFpm^BOn__*g3O zAvOsTuoIAyya|8lpz^C882J{|3uzBHAL6eEUFkM303X1M1+`pO1q1LY-I=~vD{d?$ zI0Mhpv+0Y~$vQIdEq*B31-KUxtPiTp zFx&W2!6HEFh%euRzu|W~dN`CleofThV%ey-N_~c-#-8E^d7eFg=6huCWz$KFTgo7P zKJTRWTh-FtZJ8DktP`fsI=}Ec)8`;#UUof>KP(~v4vhcVL+T$_%w2MinOlI>-{G=} zL~>KcIm;=A$L`r*NpXGH+MCN=kmVI7^5yqlaf^7Jiu#F%#en+G@77GdEwsGO_or-x zQbKMI=OvNnF-sYiowm5rA0N7H)!RQGJ5}PVJdfvbe^|>fspjPMcZa!sPFw# 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();