diff --git a/modules/client/client.otmod b/modules/client/client.otmod index 41fa3a57..ee107b4e 100644 --- a/modules/client/client.otmod +++ b/modules/client/client.otmod @@ -15,6 +15,7 @@ Module - client_options - client_terminal - client_modulemanager + - client_exit //- client_stats @onLoad: | diff --git a/modules/client_exit/exit.lua b/modules/client_exit/exit.lua new file mode 100644 index 00000000..0208038b --- /dev/null +++ b/modules/client_exit/exit.lua @@ -0,0 +1,59 @@ +Exit = {} + +local exitWindow +local exitButton + +function Exit.init() + exitButton = TopMenu.addRightButton('exitButton', tr('Exit Client'), 'exit.png', Exit.tryExit) + + connect(g_game, { + onGameStart = Exit.hide, + onGameEnd = Exit.show + }) +end + +function Exit.terminate() + disconnect(g_game, { + onGameStart = Exit.hide, + onGameEnd = Exit.show + }) + + if exitWindow then + exitWindow:destroy() + exitWindow = nil + end + + if exitButton then + exitButton:destroy() + exitButton = nil + end + + Exit = nil +end + +function Exit.hide() + if exitWindow then + exitWindow:destroy() + end + exitButton:hide() +end + +function Exit.show() + exitButton:show() +end + +function Exit.tryExit() + if exitWindow then + return true + end + + local yesFunc = function() scheduleEvent(exit, 10) end + local noFunc = function() exitWindow:destroy() exitWindow = nil end + + exitWindow = displayGeneralBox('Exit', tr("Do you really want to exit?"), + { { text='Yes', callback=yesFunc }, + { text='No', callback=noFunc }, + anchor=AnchorHorizontalCenter }, yesFunc, noFunc) + + return true +end diff --git a/modules/client_exit/exit.otmod b/modules/client_exit/exit.otmod new file mode 100644 index 00000000..80afc3b8 --- /dev/null +++ b/modules/client_exit/exit.otmod @@ -0,0 +1,16 @@ +Module + name: client_exit + description: Handles the exit exit of the client (for cases of fullscreen) + author: BeniS + website: www.otclient.info + + dependencies: + - client_topmenu + - client_entergame + + @onLoad: | + dofile 'exit' + Exit.init() + + @onUnload: | + Exit.terminate() diff --git a/modules/client_exit/exit.otui b/modules/client_exit/exit.otui new file mode 100644 index 00000000..e69de29b diff --git a/modules/client_exit/exit.png b/modules/client_exit/exit.png new file mode 100644 index 00000000..1512fab2 Binary files /dev/null and b/modules/client_exit/exit.png differ diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index b38a6d6d..99836cd5 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -68,7 +68,7 @@ function displayWarning(widget, warning) if warningWindow and warningWindow:isVisible() then return end - if g_game.isOfficialTibia() and widget:isChecked() then + if widget:isChecked() then local yesCallback = function() warningWindow:destroy() warningWindow=nil end local noCallback = function() widget:setChecked(false) warningWindow:destroy() warningWindow=nil end @@ -109,10 +109,12 @@ function Options.init() graphicsPanel = g_ui.loadUI('graphics.otui') optionsTabBar:addTab(tr('Graphics'), graphicsPanel) - local optionWalkBooster = gamePanel:getChildById('walkBooster') - optionWalkBooster.onCheckChange = function(widget) - displayWarning(widget, "This feature could be detectable by official Tibia servers. Would like to continue?") - Options.setOption(widget:getId(), widget:isChecked()) + if g_game.isOfficialTibia() then + local optionWalkBooster = gamePanel:getChildById('walkBooster') + optionWalkBooster.onCheckChange = function(widget) + displayWarning(widget, "This feature could be detectable by official Tibia servers. Would like to continue?") + Options.setOption(widget:getId(), widget:isChecked()) + end end setupGraphicsEngines() @@ -151,7 +153,12 @@ function Options.hide() end function Options.toggleOption(key) - Options.setOption(key, not Options.getOption(key)) + local optionWidget = optionsWindow:recursiveGetChildById(key) + if optionWidget then + optionWidget:setChecked(not Options.getOption(key)) + else + Options.setOption(key, not Options.getOption(key)) + end end function Options.setOption(key, value) diff --git a/modules/client_skins/skins/default/styles/tabbars.otui b/modules/client_skins/skins/default/styles/tabbars.otui index e0abd3ec..b937f412 100644 --- a/modules/client_skins/skins/default/styles/tabbars.otui +++ b/modules/client_skins/skins/default/styles/tabbars.otui @@ -13,7 +13,6 @@ TabBarButton < UIButton padding: 5 anchors.left: parent.left - $hover !checked: image-clip: 0 20 20 20 color: white @@ -24,7 +23,7 @@ TabBarButton < UIButton $checked: image-clip: 0 40 20 20 - color: #80c7f8 + color: #D8E7F0 $on !checked: color: #F55E5E diff --git a/modules/client_topmenu/images/top_game_button.png b/modules/client_topmenu/images/top_game_button.png index 7820d506..c6f115f6 100644 Binary files a/modules/client_topmenu/images/top_game_button.png and b/modules/client_topmenu/images/top_game_button.png differ diff --git a/modules/corelib/ui/uitabbar.lua b/modules/corelib/ui/uitabbar.lua index 1350e4f9..1dbe1367 100644 --- a/modules/corelib/ui/uitabbar.lua +++ b/modules/corelib/ui/uitabbar.lua @@ -14,7 +14,7 @@ local function updateMargins(tabBar) if i == 1 then tabBar.tabs[i]:setMarginLeft(0) else - tabBar.tabs[i]:setMarginLeft(5 * (i - 1) + currentMargin) + tabBar.tabs[i]:setMarginLeft(tabBar.tabSpacing * (i - 1) + currentMargin) end currentMargin = currentMargin + tabBar.tabs[i]:getWidth() end @@ -23,16 +23,18 @@ end local function onTabMousePress(tab, mousePos, mouseButton) if mouseButton == MouseLeftButton and tab.tabBar.tabsMoveable then tab.tabBar.selected = tab + elseif mouseButton == MouseRightButton then + if tab.menuCallback then tab.menuCallback(tab, mousePos, mouseButton) end end end local function onTabMouseRelease(tab, mousePos, mouseButton) local tabs = tab.tabBar.tabs if tab.tabBar.selected then - local lastMargin = -5 + local lastMargin = -tab.tabBar.tabSpacing for i = 1, #tabs do - local nextMargin = tabs[i + 1] and (tabs[i + 1] == tab and (tabs[i]:getMarginLeft() + tabs[i]:getWidth() + 5) or tabs[i + 1]:getMarginLeft()) or tab.tabBar:getWidth() - if tab:getMarginLeft() >= lastMargin and tab:getMarginLeft() < nextMargin then + local nextMargin = tabs[i + 1] and (tabs[i + 1] == tab and (tabs[i]:getMarginLeft() + tabs[i]:getWidth() + tab.tabBar.tabSpacing) or tabs[i + 1]:getMarginLeft()) or tab.tabBar:getWidth() + if (tab:getMarginLeft()+(tabs[i]:getWidth()/2)) >= lastMargin and (tab:getMarginLeft()+(tabs[i]:getWidth()/2)) < nextMargin then if tabs[i] ~= tab then local newIndex = table.find(tab.tabBar.tabs, tab.tabBar.tabs[i]) table.remove(tab.tabBar.tabs, table.find(tab.tabBar.tabs, tab)) @@ -44,7 +46,7 @@ local function onTabMouseRelease(tab, mousePos, mouseButton) break end end - lastMargin = tab.tabBar.tabs[i]:getMarginLeft() == 0 and -5 or tab.tabBar.tabs[i]:getMarginLeft() + lastMargin = tab.tabBar.tabs[i]:getMarginLeft() == 0 and -tab.tabBar.tabSpacing or tab.tabBar.tabs[i]:getMarginLeft() end end @@ -54,7 +56,7 @@ end local function onTabMouseMove(tab, mousePos, mouseMoved) if tab == tab.tabBar.selected then local newMargin = tab:getMarginLeft() + mouseMoved.x - if newMargin >= -5 and newMargin < tab.tabBar:getWidth() - tab:getWidth() then + if newMargin >= -tab.tabBar.tabSpacing and newMargin < tab.tabBar:getWidth() - tab:getWidth() then tab:setMarginLeft(newMargin) end end @@ -72,6 +74,7 @@ function UITabBar.create() tabbar:setFocusable(false) tabbar.tabs = {} tabbar.selected = nil -- dragged tab + tabbar.tabSpacing = 5 tabsMoveable = false return tabbar end @@ -83,7 +86,12 @@ function UITabBar:setContentWidget(widget) end end -function UITabBar:addTab(text, panel) +function UITabBar:setTabSpacing(tabSpacing) + self.tabSpacing = tabSpacing + updateMargins(self) +end + +function UITabBar:addTab(text, panel, menuCallback) if panel == nil then panel = g_ui.createWidget(self:getStyleName() .. 'Panel') panel:setId('tabPanel') @@ -96,6 +104,7 @@ function UITabBar:addTab(text, panel) tab:setId('tab') tab:setText(text) tab:setWidth(tab:getTextSize().width + tab:getPaddingLeft() + tab:getPaddingRight()) + tab.menuCallback = menuCallback or nil tab.onClick = onTabClick tab.onMousePress = onTabMousePress tab.onMouseRelease = onTabMouseRelease @@ -107,7 +116,7 @@ function UITabBar:addTab(text, panel) self:selectTab(tab) tab:setMarginLeft(0) else - local newMargin = 5 * (#self.tabs - 1) + local newMargin = self.tabSpacing * (#self.tabs - 1) for i = 1, #self.tabs - 1 do newMargin = newMargin + self.tabs[i]:getWidth() end @@ -221,4 +230,4 @@ end function UITabBar:getCurrentTab() return self.currentTab -end \ No newline at end of file +end diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 26687a5e..43163c13 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -77,6 +77,7 @@ function init() consoleContentPanel = consolePanel:getChildById('consoleContentPanel') consoleTabBar = consolePanel:getChildById('consoleTabBar') consoleTabBar:setContentWidget(consoleContentPanel) + consoleTabBar:setTabSpacing(0) channels = {} defaultTab = addTab(tr('Default'), true) @@ -182,6 +183,11 @@ function clear() end end +function clearChannel(consoleTabBar) + consoleTabBar:getCurrentTab().tabPanel:getChildById('consoleBuffer'):destroyChildren() + consoleTabBar:getCurrentTab().tabPanel:getChildById('consoleBufferHighlight'):destroyChildren() +end + function setTextEditText(text) consoleTextEdit:setText(text) end @@ -195,7 +201,7 @@ function addTab(name, focus) if tab then -- is channel already open if not focus then focus = true end else - tab = consoleTabBar:addTab(name) + tab = consoleTabBar:addTab(name, nil, processChannelTabMenu) end if focus then consoleTabBar:selectTab(tab) @@ -205,6 +211,23 @@ function addTab(name, focus) return tab end +function removeTab(name) + local tab = consoleTabBar:getTab(name) + if tab == defaultTab or tab == serverTab then return end + + -- notificate the server that we are leaving the channel + if tab.channelId then + for k, v in pairs(channels) do + if (k == tab.channelId) then channels[k] = nil end + end + g_game.leaveChannel(tab.channelId) + elseif tab:getText() == "NPCs" then + g_game.closeNpcChannel() + end + + consoleTabBar:removeTab(tab) +end + function removeCurrentTab() local tab = consoleTabBar:getCurrentTab() if tab == defaultTab or tab == serverTab then return end @@ -371,7 +394,7 @@ function addTabText(text, speaktype, tab, creatureName) labelHighlight:setText("") end - label.onMouseRelease = function (self, mousePos, mouseButton) popupMenu(mousePos, mouseButton, creatureName, text) end + label.onMouseRelease = function (self, mousePos, mouseButton) processMessageMenu(mousePos, mouseButton, creatureName, text) end if consoleBuffer:getChildCount() > MAX_LINES then consoleBuffer:getFirstChild():destroy() @@ -382,7 +405,22 @@ function addTabText(text, speaktype, tab, creatureName) end end -function popupMenu(mousePos, mouseButton, creatureName, text) +function processChannelTabMenu(tab, mousePos, mouseButton) + local menu = g_ui.createWidget('PopupMenu') + + channelName = tab:getText() + if tab ~= defaultTab and tab ~= serverTab then + menu:addOption(tr('Close'), function() removeTab(channelName) end) + --menu:addOption(tr('Show Server Messages'), function() --[[TODO]] end) + menu:addSeparator() + end + menu:addOption(tr('Clear Messages'), function() clearChannel(consoleTabBar) end) + --menu:addOption(tr('Save Messages'), function() --[[TODO]] end) + + menu:display(mousePos) +end + +function processMessageMenu(mousePos, mouseButton, creatureName, text) if mouseButton == MouseRightButton then local menu = g_ui.createWidget('PopupMenu') if creatureName then diff --git a/modules/game_console/console.otui b/modules/game_console/console.otui index 86cc7fcf..59b5acd5 100644 --- a/modules/game_console/console.otui +++ b/modules/game_console/console.otui @@ -6,8 +6,8 @@ ConsoleLabel < UILabel text-wrap: true text-auto-resize: true -ConsoleTabBar < TabBarRounded -ConsoleTabBarPanel < TabBarRoundedPanel +ConsoleTabBar < TabBar +ConsoleTabBarPanel < TabBarPanel id: consoleTab ScrollablePanel @@ -57,7 +57,9 @@ ConsoleTabBarPanel < TabBarRoundedPanel step: 14 pixels-scroll: true -ConsoleTabBarButton < TabBarRoundedButton +ConsoleTabBarButton < TabBarButton + height: 28 + padding: 15 Panel id: consolePanel @@ -73,11 +75,12 @@ Panel ConsoleTabBar id: consoleTabBar - height: 20 + height: 28 anchors.left: prev.right - anchors.top: prev.top + anchors.top: parent.top anchors.right: next.left margin-left: 5 + margin-top: 3 moveable: true TabButton @@ -109,8 +112,7 @@ Panel margin-top: 6 @onClick: | local consoleTabBar = self:getParent():getChildById('consoleTabBar') - consoleTabBar:getCurrentTab().tabPanel:getChildById('consoleBuffer'):destroyChildren() - consoleTabBar:getCurrentTab().tabPanel:getChildById('consoleBufferHighlight'):destroyChildren() + clearChannel(consoleTabBar) TabButton id: channelsButton diff --git a/modules/game_cooldown/cooldown.png b/modules/game_cooldown/cooldown.png index 802aaf37..0e66ccf1 100644 Binary files a/modules/game_cooldown/cooldown.png and b/modules/game_cooldown/cooldown.png differ diff --git a/modules/game_spelllist/spelllist.png b/modules/game_spelllist/spelllist.png index ae2adacf..e1c01ccc 100644 Binary files a/modules/game_spelllist/spelllist.png and b/modules/game_spelllist/spelllist.png differ diff --git a/modules/game_textwindow/textwindow.lua b/modules/game_textwindow/textwindow.lua index 081527f8..3258da8f 100644 --- a/modules/game_textwindow/textwindow.lua +++ b/modules/game_textwindow/textwindow.lua @@ -1,3 +1,5 @@ +local textWindow = nil + function init() g_ui.importStyle('textwindow.otui') diff --git a/src/otclient/const.h b/src/otclient/const.h index 5034fd32..a77d9c48 100644 --- a/src/otclient/const.h +++ b/src/otclient/const.h @@ -348,7 +348,7 @@ namespace Otc }; enum PathFindResult { - PathFineResultOk = 0, + PathFindResultOk = 0, PathFindResultSamePosition, PathFindResultImpossible, PathFindResultTooFar, diff --git a/src/otclient/map.cpp b/src/otclient/map.cpp index 00beb579..a2dc1de8 100644 --- a/src/otclient/map.cpp +++ b/src/otclient/map.cpp @@ -507,6 +507,12 @@ std::tuple, Otc::PathFindResult> Map::findPath(const const TilePtr& tile = getTile(neighborPos); if(neighborPos != goalPos) { + /* + Known Issue with Otc::PathFindAllowNullTiles flag: + If you are above ground floor this will attempt to path over null + tiles, need to rework this for "fly servers" and blank map click, + but it is breaking normal path finding. + */ if(!(flags & Otc::PathFindAllowNullTiles) && !tile) continue; if(tile) { @@ -568,7 +574,7 @@ std::tuple, Otc::PathFindResult> Map::findPath(const } dirs.pop_back(); std::reverse(dirs.begin(), dirs.end()); - result = Otc::PathFineResultOk; + result = Otc::PathFindResultOk; } for(auto it : nodes)