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_terminal
- client_modulemanager
- client_exit
//- client_stats
@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
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,11 +109,13 @@ function Options.init()
graphicsPanel = g_ui.loadUI('graphics.otui')
optionsTabBar:addTab(tr('Graphics'), graphicsPanel)
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()
end
@ -151,8 +153,13 @@ function Options.hide()
end
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))
end
end
function Options.setOption(key, value)
if options[key] == value then return end

View File

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

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

View File

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

View File

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

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()
g_ui.importStyle('textwindow.otui')

View File

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

View File

@ -507,6 +507,12 @@ std::tuple<std::vector<Otc::Direction>, 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<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
}
dirs.pop_back();
std::reverse(dirs.begin(), dirs.end());
result = Otc::PathFineResultOk;
result = Otc::PathFindResultOk;
}
for(auto it : nodes)