Interface edits, additions, and fixes:

* Added a new module for exiting the client (client_exit).
* Added tab spacing to the UITabBar class.
* Added tab popup menus for things like channel tabs.
* Impelemented channel tab popup menus (still need to be finished).
* Fixed UITabBar tab draging (will now change after dragged half way over the
  next tab, not 2 pixels).
* Fixes to the client_options module.
* Edited some UI settings.
* Changed game_cooldown and game_spelllist menu button icons.
* Fixed some typos.
This commit is contained in:
BeniS 2013-01-03 21:24:07 +13:00
parent 644241badb
commit fc55c6b524
16 changed files with 168 additions and 29 deletions

View File

@ -15,6 +15,7 @@ Module
- client_options - client_options
- client_terminal - client_terminal
- client_modulemanager - client_modulemanager
- client_exit
//- client_stats //- client_stats
@onLoad: | @onLoad: |

View File

@ -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

View File

@ -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()

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

View File

@ -68,7 +68,7 @@ function displayWarning(widget, warning)
if warningWindow and warningWindow:isVisible() then if warningWindow and warningWindow:isVisible() then
return return
end end
if g_game.isOfficialTibia() and widget:isChecked() then if widget:isChecked() then
local yesCallback = function() warningWindow:destroy() warningWindow=nil end local yesCallback = function() warningWindow:destroy() warningWindow=nil end
local noCallback = function() widget:setChecked(false) warningWindow:destroy() warningWindow=nil end local noCallback = function() widget:setChecked(false) warningWindow:destroy() warningWindow=nil end
@ -109,11 +109,13 @@ function Options.init()
graphicsPanel = g_ui.loadUI('graphics.otui') graphicsPanel = g_ui.loadUI('graphics.otui')
optionsTabBar:addTab(tr('Graphics'), graphicsPanel) optionsTabBar:addTab(tr('Graphics'), graphicsPanel)
if g_game.isOfficialTibia() then
local optionWalkBooster = gamePanel:getChildById('walkBooster') local optionWalkBooster = gamePanel:getChildById('walkBooster')
optionWalkBooster.onCheckChange = function(widget) optionWalkBooster.onCheckChange = function(widget)
displayWarning(widget, "This feature could be detectable by official Tibia servers. Would like to continue?") displayWarning(widget, "This feature could be detectable by official Tibia servers. Would like to continue?")
Options.setOption(widget:getId(), widget:isChecked()) Options.setOption(widget:getId(), widget:isChecked())
end end
end
setupGraphicsEngines() setupGraphicsEngines()
end end
@ -151,8 +153,13 @@ function Options.hide()
end end
function Options.toggleOption(key) function Options.toggleOption(key)
local optionWidget = optionsWindow:recursiveGetChildById(key)
if optionWidget then
optionWidget:setChecked(not Options.getOption(key))
else
Options.setOption(key, not Options.getOption(key)) Options.setOption(key, not Options.getOption(key))
end end
end
function Options.setOption(key, value) function Options.setOption(key, value)
if options[key] == value then return end if options[key] == value then return end

View File

@ -13,7 +13,6 @@ TabBarButton < UIButton
padding: 5 padding: 5
anchors.left: parent.left anchors.left: parent.left
$hover !checked: $hover !checked:
image-clip: 0 20 20 20 image-clip: 0 20 20 20
color: white color: white
@ -24,7 +23,7 @@ TabBarButton < UIButton
$checked: $checked:
image-clip: 0 40 20 20 image-clip: 0 40 20 20
color: #80c7f8 color: #D8E7F0
$on !checked: $on !checked:
color: #F55E5E color: #F55E5E

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

After

Width:  |  Height:  |  Size: 223 B

View File

@ -14,7 +14,7 @@ local function updateMargins(tabBar)
if i == 1 then if i == 1 then
tabBar.tabs[i]:setMarginLeft(0) tabBar.tabs[i]:setMarginLeft(0)
else else
tabBar.tabs[i]:setMarginLeft(5 * (i - 1) + currentMargin) tabBar.tabs[i]:setMarginLeft(tabBar.tabSpacing * (i - 1) + currentMargin)
end end
currentMargin = currentMargin + tabBar.tabs[i]:getWidth() currentMargin = currentMargin + tabBar.tabs[i]:getWidth()
end end
@ -23,16 +23,18 @@ end
local function onTabMousePress(tab, mousePos, mouseButton) local function onTabMousePress(tab, mousePos, mouseButton)
if mouseButton == MouseLeftButton and tab.tabBar.tabsMoveable then if mouseButton == MouseLeftButton and tab.tabBar.tabsMoveable then
tab.tabBar.selected = tab tab.tabBar.selected = tab
elseif mouseButton == MouseRightButton then
if tab.menuCallback then tab.menuCallback(tab, mousePos, mouseButton) end
end end
end end
local function onTabMouseRelease(tab, mousePos, mouseButton) local function onTabMouseRelease(tab, mousePos, mouseButton)
local tabs = tab.tabBar.tabs local tabs = tab.tabBar.tabs
if tab.tabBar.selected then if tab.tabBar.selected then
local lastMargin = -5 local lastMargin = -tab.tabBar.tabSpacing
for i = 1, #tabs do 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() 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() >= lastMargin and tab:getMarginLeft() < nextMargin then if (tab:getMarginLeft()+(tabs[i]:getWidth()/2)) >= lastMargin and (tab:getMarginLeft()+(tabs[i]:getWidth()/2)) < nextMargin then
if tabs[i] ~= tab then if tabs[i] ~= tab then
local newIndex = table.find(tab.tabBar.tabs, tab.tabBar.tabs[i]) local newIndex = table.find(tab.tabBar.tabs, tab.tabBar.tabs[i])
table.remove(tab.tabBar.tabs, table.find(tab.tabBar.tabs, tab)) table.remove(tab.tabBar.tabs, table.find(tab.tabBar.tabs, tab))
@ -44,7 +46,7 @@ local function onTabMouseRelease(tab, mousePos, mouseButton)
break break
end end
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
end end
@ -54,7 +56,7 @@ end
local function onTabMouseMove(tab, mousePos, mouseMoved) local function onTabMouseMove(tab, mousePos, mouseMoved)
if tab == tab.tabBar.selected then if tab == tab.tabBar.selected then
local newMargin = tab:getMarginLeft() + mouseMoved.x 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) tab:setMarginLeft(newMargin)
end end
end end
@ -72,6 +74,7 @@ function UITabBar.create()
tabbar:setFocusable(false) tabbar:setFocusable(false)
tabbar.tabs = {} tabbar.tabs = {}
tabbar.selected = nil -- dragged tab tabbar.selected = nil -- dragged tab
tabbar.tabSpacing = 5
tabsMoveable = false tabsMoveable = false
return tabbar return tabbar
end end
@ -83,7 +86,12 @@ function UITabBar:setContentWidget(widget)
end end
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 if panel == nil then
panel = g_ui.createWidget(self:getStyleName() .. 'Panel') panel = g_ui.createWidget(self:getStyleName() .. 'Panel')
panel:setId('tabPanel') panel:setId('tabPanel')
@ -96,6 +104,7 @@ function UITabBar:addTab(text, panel)
tab:setId('tab') tab:setId('tab')
tab:setText(text) tab:setText(text)
tab:setWidth(tab:getTextSize().width + tab:getPaddingLeft() + tab:getPaddingRight()) tab:setWidth(tab:getTextSize().width + tab:getPaddingLeft() + tab:getPaddingRight())
tab.menuCallback = menuCallback or nil
tab.onClick = onTabClick tab.onClick = onTabClick
tab.onMousePress = onTabMousePress tab.onMousePress = onTabMousePress
tab.onMouseRelease = onTabMouseRelease tab.onMouseRelease = onTabMouseRelease
@ -107,7 +116,7 @@ function UITabBar:addTab(text, panel)
self:selectTab(tab) self:selectTab(tab)
tab:setMarginLeft(0) tab:setMarginLeft(0)
else else
local newMargin = 5 * (#self.tabs - 1) local newMargin = self.tabSpacing * (#self.tabs - 1)
for i = 1, #self.tabs - 1 do for i = 1, #self.tabs - 1 do
newMargin = newMargin + self.tabs[i]:getWidth() newMargin = newMargin + self.tabs[i]:getWidth()
end end

View File

@ -77,6 +77,7 @@ function init()
consoleContentPanel = consolePanel:getChildById('consoleContentPanel') consoleContentPanel = consolePanel:getChildById('consoleContentPanel')
consoleTabBar = consolePanel:getChildById('consoleTabBar') consoleTabBar = consolePanel:getChildById('consoleTabBar')
consoleTabBar:setContentWidget(consoleContentPanel) consoleTabBar:setContentWidget(consoleContentPanel)
consoleTabBar:setTabSpacing(0)
channels = {} channels = {}
defaultTab = addTab(tr('Default'), true) defaultTab = addTab(tr('Default'), true)
@ -182,6 +183,11 @@ function clear()
end end
end end
function clearChannel(consoleTabBar)
consoleTabBar:getCurrentTab().tabPanel:getChildById('consoleBuffer'):destroyChildren()
consoleTabBar:getCurrentTab().tabPanel:getChildById('consoleBufferHighlight'):destroyChildren()
end
function setTextEditText(text) function setTextEditText(text)
consoleTextEdit:setText(text) consoleTextEdit:setText(text)
end end
@ -195,7 +201,7 @@ function addTab(name, focus)
if tab then -- is channel already open if tab then -- is channel already open
if not focus then focus = true end if not focus then focus = true end
else else
tab = consoleTabBar:addTab(name) tab = consoleTabBar:addTab(name, nil, processChannelTabMenu)
end end
if focus then if focus then
consoleTabBar:selectTab(tab) consoleTabBar:selectTab(tab)
@ -205,6 +211,23 @@ function addTab(name, focus)
return tab return tab
end 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() function removeCurrentTab()
local tab = consoleTabBar:getCurrentTab() local tab = consoleTabBar:getCurrentTab()
if tab == defaultTab or tab == serverTab then return end if tab == defaultTab or tab == serverTab then return end
@ -371,7 +394,7 @@ function addTabText(text, speaktype, tab, creatureName)
labelHighlight:setText("") labelHighlight:setText("")
end 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 if consoleBuffer:getChildCount() > MAX_LINES then
consoleBuffer:getFirstChild():destroy() consoleBuffer:getFirstChild():destroy()
@ -382,7 +405,22 @@ function addTabText(text, speaktype, tab, creatureName)
end end
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 if mouseButton == MouseRightButton then
local menu = g_ui.createWidget('PopupMenu') local menu = g_ui.createWidget('PopupMenu')
if creatureName then if creatureName then

View File

@ -6,8 +6,8 @@ ConsoleLabel < UILabel
text-wrap: true text-wrap: true
text-auto-resize: true text-auto-resize: true
ConsoleTabBar < TabBarRounded ConsoleTabBar < TabBar
ConsoleTabBarPanel < TabBarRoundedPanel ConsoleTabBarPanel < TabBarPanel
id: consoleTab id: consoleTab
ScrollablePanel ScrollablePanel
@ -57,7 +57,9 @@ ConsoleTabBarPanel < TabBarRoundedPanel
step: 14 step: 14
pixels-scroll: true pixels-scroll: true
ConsoleTabBarButton < TabBarRoundedButton ConsoleTabBarButton < TabBarButton
height: 28
padding: 15
Panel Panel
id: consolePanel id: consolePanel
@ -73,11 +75,12 @@ Panel
ConsoleTabBar ConsoleTabBar
id: consoleTabBar id: consoleTabBar
height: 20 height: 28
anchors.left: prev.right anchors.left: prev.right
anchors.top: prev.top anchors.top: parent.top
anchors.right: next.left anchors.right: next.left
margin-left: 5 margin-left: 5
margin-top: 3
moveable: true moveable: true
TabButton TabButton
@ -109,8 +112,7 @@ Panel
margin-top: 6 margin-top: 6
@onClick: | @onClick: |
local consoleTabBar = self:getParent():getChildById('consoleTabBar') local consoleTabBar = self:getParent():getChildById('consoleTabBar')
consoleTabBar:getCurrentTab().tabPanel:getChildById('consoleBuffer'):destroyChildren() clearChannel(consoleTabBar)
consoleTabBar:getCurrentTab().tabPanel:getChildById('consoleBufferHighlight'):destroyChildren()
TabButton TabButton
id: channelsButton id: channelsButton

Binary file not shown.

Before

Width:  |  Height:  |  Size: 675 B

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 860 B

After

Width:  |  Height:  |  Size: 706 B

View File

@ -1,3 +1,5 @@
local textWindow = nil
function init() function init()
g_ui.importStyle('textwindow.otui') g_ui.importStyle('textwindow.otui')

View File

@ -348,7 +348,7 @@ namespace Otc
}; };
enum PathFindResult { enum PathFindResult {
PathFineResultOk = 0, PathFindResultOk = 0,
PathFindResultSamePosition, PathFindResultSamePosition,
PathFindResultImpossible, PathFindResultImpossible,
PathFindResultTooFar, PathFindResultTooFar,

View File

@ -507,6 +507,12 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
const TilePtr& tile = getTile(neighborPos); const TilePtr& tile = getTile(neighborPos);
if(neighborPos != goalPos) { 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) if(!(flags & Otc::PathFindAllowNullTiles) && !tile)
continue; continue;
if(tile) { if(tile) {
@ -568,7 +574,7 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
} }
dirs.pop_back(); dirs.pop_back();
std::reverse(dirs.begin(), dirs.end()); std::reverse(dirs.begin(), dirs.end());
result = Otc::PathFineResultOk; result = Otc::PathFindResultOk;
} }
for(auto it : nodes) for(auto it : nodes)