mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
BEAWARE all game functionality is disabled with this commit for a while
* rework client modules * hide main window when loading * remake top menu functions * rework modules autoload * improve path resolving for otml and lua * move core_widgets to core_lib * fix tooltip issues * split some styles * add bit32 lua library * fix assert issues * fix compilation on linux 32 systems * rework gcc compile options * renable and fix some warnings * remove unused constants * speedup sprite cache * move UIGame to lua (not funcional yet) * fix a lot of issues in x11 window * fix crash handler * add some warnings do uiwidget and much more...
This commit is contained in:
BIN
modules/client_topmenu/images/top_button.png
Normal file
BIN
modules/client_topmenu/images/top_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 470 B |
BIN
modules/client_topmenu/images/top_game_button.png
Normal file
BIN
modules/client_topmenu/images/top_game_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 426 B |
BIN
modules/client_topmenu/images/top_panel.png
Normal file
BIN
modules/client_topmenu/images/top_panel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
@@ -7,12 +7,25 @@ local rightButtonsPanel
|
||||
local gameButtonsPanel
|
||||
|
||||
-- private functions
|
||||
local function onLogout()
|
||||
if g_game.isOnline() then
|
||||
g_game.safeLogout()
|
||||
local function addButton(id, description, icon, callback, panel, toggle)
|
||||
local class
|
||||
if toggle then
|
||||
class = 'TopToggleButton'
|
||||
else
|
||||
exit()
|
||||
class = 'TopButton'
|
||||
end
|
||||
|
||||
local button = createWidget(class, panel)
|
||||
button:setId(id)
|
||||
button:setTooltip(description)
|
||||
button:setIcon(resolvepath(icon, 3))
|
||||
|
||||
if toggle then
|
||||
button.onCheckChange = callback
|
||||
else
|
||||
button.onClick = callback
|
||||
end
|
||||
return button
|
||||
end
|
||||
|
||||
-- public functions
|
||||
@@ -22,15 +35,11 @@ function TopMenu.init()
|
||||
rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')
|
||||
gameButtonsPanel = topMenu:getChildById('gameButtonsPanel')
|
||||
|
||||
TopMenu.addRightButton('logoutButton', 'Logout (Ctrl+Q)', '/core_styles/icons/logout.png', onLogout)
|
||||
Keyboard.bindKeyDown('Ctrl+Q', onLogout)
|
||||
|
||||
connect(g_game, { onGameStart = TopMenu.showGameButtons,
|
||||
onGameEnd = TopMenu.hideGameButtons })
|
||||
onGameEnd = TopMenu.hideGameButtons })
|
||||
end
|
||||
|
||||
function TopMenu.terminate()
|
||||
Keyboard.unbindKeyDown('Ctrl+Q')
|
||||
leftButtonsPanel = nil
|
||||
rightButtonsPanel = nil
|
||||
gameButtonsPanel = nil
|
||||
@@ -38,45 +47,33 @@ function TopMenu.terminate()
|
||||
topMenu = nil
|
||||
|
||||
disconnect(g_game, { onGameStart = TopMenu.showGameButtons,
|
||||
onGameEnd = TopMenu.hideGameButtons })
|
||||
onGameEnd = TopMenu.hideGameButtons })
|
||||
|
||||
TopMenu = nil
|
||||
end
|
||||
|
||||
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.addGameButton(id, description, icon, callback)
|
||||
local button = createWidget('GameTopButton', gameButtonsPanel)
|
||||
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, resolvepath(icon, 2), callback, false)
|
||||
return addButton(id, description, icon, callback, leftButtonsPanel, false)
|
||||
end
|
||||
|
||||
function TopMenu.addLeftToggleButton(id, description, icon, callback, right)
|
||||
return addButton(id, description, icon, callback, leftButtonsPanel, true)
|
||||
end
|
||||
|
||||
function TopMenu.addRightButton(id, description, icon, callback)
|
||||
return TopMenu.addButton(id, description, resolvepath(icon, 2), callback, true)
|
||||
return addButton(id, description, icon, callback, rightButtonsPanel, false)
|
||||
end
|
||||
|
||||
function TopMenu.addRightToggleButton(id, description, icon, callback, right)
|
||||
return addButton(id, description, icon, callback, rightButtonsPanel, true)
|
||||
end
|
||||
|
||||
function TopMenu.addGameButton(id, description, icon, callback)
|
||||
return addButton(id, description, icon, callback, gameButtonsPanel, false)
|
||||
end
|
||||
|
||||
function TopMenu.addGameToggleButton(id, description, icon, callback, right)
|
||||
return addButton(id, description, icon, callback, gameButtonsPanel, true)
|
||||
end
|
||||
|
||||
function TopMenu.hideGameButtons()
|
||||
@@ -90,3 +87,5 @@ end
|
||||
function TopMenu.getButton(id)
|
||||
return topMenu:recursiveGetChildById(id)
|
||||
end
|
||||
|
||||
|
||||
|
@@ -3,12 +3,11 @@ Module
|
||||
description: Create the top menu
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
autoload: true
|
||||
autoload-antecedence: 120
|
||||
reloadable: true
|
||||
|
||||
onLoad: |
|
||||
@onLoad: |
|
||||
dofile 'topmenu'
|
||||
TopMenu.init()
|
||||
|
||||
onUnload: |
|
||||
@onUnload: |
|
||||
TopMenu.terminate()
|
||||
|
@@ -1,6 +1,6 @@
|
||||
TopButton < UIButton
|
||||
size: 26 26
|
||||
image-source: /core_styles/images/top_button.png
|
||||
image-source: images/top_button.png
|
||||
image-clip: 0 0 26 26
|
||||
image-border: 3
|
||||
image-color: #ffffffff
|
||||
@@ -17,66 +17,61 @@ TopButton < UIButton
|
||||
image-color: #ffffff44
|
||||
icon-color: #ffffff44
|
||||
|
||||
GameTopButton < UIButton
|
||||
TopToggleButton < UICheckBox
|
||||
size: 26 26
|
||||
image-source: /core_styles/images/top_button2.png
|
||||
image-source: images/top_game_button.png
|
||||
image-clip: 26 0 26 26
|
||||
image-color: #ffffff22
|
||||
icon-color: #ffffffff
|
||||
image-border: 3
|
||||
icon-color: #ffffffff
|
||||
|
||||
$on:
|
||||
$checked:
|
||||
image-clip: 0 0 26 26
|
||||
image-color: #ffffffff
|
||||
icon-color: #ffffffff
|
||||
|
||||
TopLeftButton < TopButton
|
||||
TopRightButton < TopButton
|
||||
TopMenuButtonsPanel < Panel
|
||||
layout:
|
||||
type: horizontalBox
|
||||
spacing: 4
|
||||
fit-children: true
|
||||
padding: 6 4
|
||||
|
||||
TopPanel < Panel
|
||||
height: 36
|
||||
image-source: images/top_panel.png
|
||||
image-repeated: true
|
||||
focusable: false
|
||||
|
||||
|
||||
TopPanel
|
||||
id: topMenu
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
focusable: false
|
||||
|
||||
Panel
|
||||
TopMenuButtonsPanel
|
||||
id: leftButtonsPanel
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
layout:
|
||||
type: horizontalBox
|
||||
spacing: 4
|
||||
fit-children: true
|
||||
padding: 6 4
|
||||
|
||||
Panel
|
||||
TopMenuButtonsPanel
|
||||
id: gameButtonsPanel
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: prev.right
|
||||
anchors.right: next.left
|
||||
layout:
|
||||
type: horizontalBox
|
||||
spacing: 4
|
||||
padding: 6 4
|
||||
visible: false
|
||||
|
||||
Panel
|
||||
TopMenuButtonsPanel
|
||||
id: rightButtonsPanel
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
layout:
|
||||
type: horizontalBox
|
||||
spacing: 4
|
||||
fit-children: true
|
||||
padding: 6 4
|
||||
|
||||
FrameCounter
|
||||
id: frameCounter
|
||||
anchors.top: parent.top
|
||||
anchors.right: prev.left
|
||||
margin-top: 8
|
||||
margin-right: 5
|
||||
margin-right: 5
|
||||
|
Reference in New Issue
Block a user