mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
restore terminal, rework console
This commit is contained in:
@@ -2,17 +2,74 @@ TopMenu = {}
|
||||
|
||||
-- private variables
|
||||
local topMenu
|
||||
local leftButtonsPanel
|
||||
local rightButtonsPanel
|
||||
|
||||
-- public functions
|
||||
function TopMenu.create()
|
||||
function TopMenu.init()
|
||||
topMenu = displayUI('topmenu.otui')
|
||||
leftButtonsPanel = topMenu:getChildById('leftButtonsPanel')
|
||||
rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')
|
||||
|
||||
TopMenu.addRightButton('logoutButton', 'Logout', '/core_styles/icons/logout.png',
|
||||
function()
|
||||
if Game.isOnline() then
|
||||
Game.logout(false)
|
||||
else
|
||||
exit()
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function TopMenu.destroy()
|
||||
function TopMenu.terminate()
|
||||
leftButtonsPanel = nil
|
||||
rightButtonsPanel = nil
|
||||
topMenu:destroy()
|
||||
topMenu = nil
|
||||
end
|
||||
|
||||
function TopMenu.getButton(id)
|
||||
return topMenu:getChildById(id)
|
||||
function TopMenu.addButton(id, description, icon, callback, right)
|
||||
local panel
|
||||
local class
|
||||
if right then
|
||||
panel = rightButtonsPanel
|
||||
class = 'TopRightButton'
|
||||
else
|
||||
panel = leftButtonsPanel
|
||||
class = 'TopLeftButton'
|
||||
end
|
||||
|
||||
local button = createWidget(class, panel)
|
||||
button:setId(id)
|
||||
button:setTooltip(description)
|
||||
button:setIcon(resolvepath(icon, 2))
|
||||
button.onClick = callback
|
||||
return button
|
||||
end
|
||||
|
||||
function TopMenu.addLeftButton(id, description, icon, callback)
|
||||
return TopMenu.addButton(id, description, icon, callback, false)
|
||||
end
|
||||
|
||||
function TopMenu.addRightButton(id, description, icon, callback)
|
||||
return TopMenu.addButton(id, description, icon, callback, true)
|
||||
end
|
||||
|
||||
function TopMenu.removeButton(param)
|
||||
local button
|
||||
if type(param) == 'string' then
|
||||
button = TopMenu.getButton(param)
|
||||
else
|
||||
button = param
|
||||
end
|
||||
button:destroy()
|
||||
end
|
||||
|
||||
function TopMenu.getButton(id)
|
||||
return topMenu:recursiveGetChildById(id)
|
||||
end
|
||||
|
||||
function TopMenu:getLogoutButton(id)
|
||||
return TopMenu.getButton('logoutButton')
|
||||
end
|
||||
|
@@ -6,7 +6,7 @@ Module
|
||||
|
||||
onLoad: |
|
||||
require 'topmenu'
|
||||
TopMenu.create()
|
||||
TopMenu.init()
|
||||
|
||||
onUnload: |
|
||||
TopMenu.destroy()
|
||||
TopMenu.terminate()
|
||||
|
@@ -1,3 +1,52 @@
|
||||
TopButton < UIButton
|
||||
background-color: white
|
||||
size: 26 26
|
||||
text-translate: 0 0
|
||||
border-image:
|
||||
source: /core_styles/images/top_button.png
|
||||
clip: 0 0 26 26
|
||||
border: 3
|
||||
|
||||
$hover:
|
||||
border-image:
|
||||
source: /core_styles/images/top_button.png
|
||||
clip: 26 0 26 26
|
||||
border: 3
|
||||
|
||||
$pressed:
|
||||
text-translate: 1 1
|
||||
border-image:
|
||||
source: /core_styles/images/top_button.png
|
||||
clip: 52 0 26 26
|
||||
border: 3
|
||||
|
||||
$disabled:
|
||||
background-color: #ffffff66
|
||||
|
||||
TopLeftButton < TopButton
|
||||
$first:
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin-top: 4
|
||||
margin-left: 6
|
||||
|
||||
$!first:
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 6
|
||||
|
||||
TopRightButton < TopButton
|
||||
$first:
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
margin-top: 4
|
||||
margin-right: 6
|
||||
|
||||
$!first:
|
||||
anchors.top: prev.top
|
||||
anchors.right: prev.left
|
||||
margin-right: 6
|
||||
|
||||
TopPanel
|
||||
id: topMenu
|
||||
anchors.top: parent.top
|
||||
@@ -5,63 +54,19 @@ TopPanel
|
||||
anchors.right: parent.right
|
||||
focusable: false
|
||||
|
||||
TopButton
|
||||
id: settingsButton
|
||||
Panel
|
||||
id: leftButtonsPanel
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
margin-top: 4
|
||||
margin-left: 6
|
||||
tooltip: Options
|
||||
icon: /core_styles/icons/settings.png
|
||||
@onClick: Options.show()
|
||||
anchors.right: next.left
|
||||
|
||||
|
||||
TopButton
|
||||
id: enterGameButton
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 6
|
||||
tooltip: Enter game with a character
|
||||
icon: /core_styles/icons/login.png
|
||||
@onClick: |
|
||||
if Game.isOnline() then
|
||||
CharacterList.show()
|
||||
elseif not CharacterList.isVisible() then
|
||||
EnterGame.show()
|
||||
end
|
||||
|
||||
TopButton
|
||||
id: motdButton
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 6
|
||||
tooltip: Message of the day
|
||||
icon: /core_styles/icons/motd.png
|
||||
visible: false
|
||||
@onClick: EnterGame.displayMotd()
|
||||
|
||||
TopButton
|
||||
Panel
|
||||
id: rightButtonsPanel
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
margin-top: 4
|
||||
margin-right: 6
|
||||
tooltip: Logout
|
||||
icon: /core_styles/icons/logout.png
|
||||
@onClick: |
|
||||
if Game.isOnline() then
|
||||
Game.logout(false)
|
||||
else
|
||||
exit()
|
||||
end
|
||||
|
||||
TopButton
|
||||
anchors.top: parent.top
|
||||
anchors.right: prev.left
|
||||
margin-top: 4
|
||||
margin-right: 6
|
||||
tooltip: About OTClient
|
||||
icon: /core_styles/icons/about.png
|
||||
@onClick: About.create()
|
||||
width: 60
|
||||
|
||||
FrameCounter
|
||||
id: frameCounter
|
||||
|
Reference in New Issue
Block a user