mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
Refactor modules, closes #223
* All modules are sandboxed now * All images,sounds,fonts,translations and styles were moved to "data" folder * Reorganize image files folders * Remove unmaintained modules: client_particles, client_shaders * Implement new automatic way to load styles and fonts * Add hide/show offline option in VipList * Add invite/exclude to/from private channel in players menus * Many other minor changes
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 470 B |
Binary file not shown.
Before Width: | Height: | Size: 223 B |
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB |
@@ -1,5 +1,3 @@
|
||||
TopMenu = {}
|
||||
|
||||
-- private variables
|
||||
local topMenu
|
||||
local leftButtonsPanel
|
||||
@@ -24,17 +22,22 @@ local function addButton(id, description, icon, callback, panel, toggle, front)
|
||||
end
|
||||
button:setId(id)
|
||||
button:setTooltip(description)
|
||||
button:setIcon(resolvepath(icon, 3))
|
||||
button.onClick = callback
|
||||
button:setIcon(icon, 3)
|
||||
button.onMouseRelease = function(widget, mousePos, mouseButton)
|
||||
if widget:containsPoint(mousePos) and mouseButton ~= MouseMiddleButton then
|
||||
callback()
|
||||
return true
|
||||
end
|
||||
end
|
||||
return button
|
||||
end
|
||||
|
||||
-- public functions
|
||||
function TopMenu.init()
|
||||
connect(g_game, { onGameStart = TopMenu.showGameButtons,
|
||||
onGameEnd = TopMenu.hideGameButtons })
|
||||
function init()
|
||||
connect(g_game, { onGameStart = showGameButtons,
|
||||
onGameEnd = hideGameButtons })
|
||||
|
||||
topMenu = g_ui.displayUI('topmenu.otui')
|
||||
topMenu = g_ui.displayUI('topmenu')
|
||||
|
||||
leftButtonsPanel = topMenu:getChildById('leftButtonsPanel')
|
||||
rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')
|
||||
@@ -47,9 +50,9 @@ function TopMenu.init()
|
||||
end
|
||||
end
|
||||
|
||||
function TopMenu.terminate()
|
||||
disconnect(g_game, { onGameStart = TopMenu.showGameButtons,
|
||||
onGameEnd = TopMenu.hideGameButtons })
|
||||
function terminate()
|
||||
disconnect(g_game, { onGameStart = showGameButtons,
|
||||
onGameEnd = hideGameButtons })
|
||||
|
||||
leftButtonsPanel = nil
|
||||
rightButtonsPanel = nil
|
||||
@@ -58,54 +61,54 @@ function TopMenu.terminate()
|
||||
|
||||
topMenu:destroy()
|
||||
topMenu = nil
|
||||
|
||||
TopMenu = nil
|
||||
end
|
||||
|
||||
function TopMenu.addLeftButton(id, description, icon, callback, front)
|
||||
function addLeftButton(id, description, icon, callback, front)
|
||||
return addButton(id, description, icon, callback, leftButtonsPanel, false, front)
|
||||
end
|
||||
|
||||
function TopMenu.addLeftToggleButton(id, description, icon, callback, front)
|
||||
function addLeftToggleButton(id, description, icon, callback, front)
|
||||
return addButton(id, description, icon, callback, leftButtonsPanel, true, front)
|
||||
end
|
||||
|
||||
function TopMenu.addRightButton(id, description, icon, callback, front)
|
||||
function addRightButton(id, description, icon, callback, front)
|
||||
return addButton(id, description, icon, callback, rightButtonsPanel, false, front)
|
||||
end
|
||||
|
||||
function TopMenu.addRightToggleButton(id, description, icon, callback, front)
|
||||
function addRightToggleButton(id, description, icon, callback, front)
|
||||
return addButton(id, description, icon, callback, rightButtonsPanel, true, front)
|
||||
end
|
||||
|
||||
function TopMenu.addLeftGameButton(id, description, icon, callback, front)
|
||||
function addLeftGameButton(id, description, icon, callback, front)
|
||||
return addButton(id, description, icon, callback, leftGameButtonsPanel, false, front)
|
||||
end
|
||||
|
||||
function TopMenu.addLeftGameToggleButton(id, description, icon, callback, front)
|
||||
function addLeftGameToggleButton(id, description, icon, callback, front)
|
||||
return addButton(id, description, icon, callback, leftGameButtonsPanel, true, front)
|
||||
end
|
||||
|
||||
function TopMenu.addRightGameButton(id, description, icon, callback, front)
|
||||
function addRightGameButton(id, description, icon, callback, front)
|
||||
return addButton(id, description, icon, callback, rightGameButtonsPanel, false, front)
|
||||
end
|
||||
|
||||
function TopMenu.addRightGameToggleButton(id, description, icon, callback, front)
|
||||
function addRightGameToggleButton(id, description, icon, callback, front)
|
||||
return addButton(id, description, icon, callback, rightGameButtonsPanel, true, front)
|
||||
end
|
||||
|
||||
function TopMenu.hideGameButtons()
|
||||
function hideGameButtons()
|
||||
leftGameButtonsPanel:hide()
|
||||
rightGameButtonsPanel:hide()
|
||||
end
|
||||
|
||||
function TopMenu.showGameButtons()
|
||||
function showGameButtons()
|
||||
leftGameButtonsPanel:show()
|
||||
rightGameButtonsPanel:show()
|
||||
end
|
||||
|
||||
function TopMenu.getButton(id)
|
||||
function getButton(id)
|
||||
return topMenu:recursiveGetChildById(id)
|
||||
end
|
||||
|
||||
|
||||
function getTopMenu()
|
||||
return topMenu
|
||||
end
|
||||
|
@@ -3,10 +3,8 @@ Module
|
||||
description: Create the top menu
|
||||
author: edubart
|
||||
website: www.otclient.info
|
||||
scripts: [ topmenu ]
|
||||
sandboxed: true
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
||||
|
||||
@onLoad: |
|
||||
dofile 'topmenu'
|
||||
TopMenu.init()
|
||||
|
||||
@onUnload: |
|
||||
TopMenu.terminate()
|
||||
|
@@ -1,53 +1,3 @@
|
||||
TopButton < UIButton
|
||||
size: 26 26
|
||||
image-source: images/top_button.png
|
||||
image-clip: 0 0 26 26
|
||||
image-border: 3
|
||||
image-color: #ffffffff
|
||||
icon-color: #ffffffff
|
||||
|
||||
$hover !disabled:
|
||||
image-color: #ffffff99
|
||||
image-clip: 26 0 26 26
|
||||
|
||||
$pressed:
|
||||
image-clip: 52 0 26 26
|
||||
|
||||
$disabled:
|
||||
image-color: #ffffff44
|
||||
icon-color: #ffffff44
|
||||
|
||||
TopToggleButton < UIButton
|
||||
size: 26 26
|
||||
image-source: images/top_game_button.png
|
||||
image-clip: 26 0 26 26
|
||||
image-color: #ffffffff
|
||||
image-border: 3
|
||||
icon-color: #ffffffff
|
||||
|
||||
$on:
|
||||
image-clip: 0 0 26 26
|
||||
image-color: #ffffffff
|
||||
icon-color: #ffffffff
|
||||
|
||||
TopMenuButtonsPanel < Panel
|
||||
layout:
|
||||
type: horizontalBox
|
||||
spacing: 4
|
||||
fit-children: true
|
||||
padding: 6 4
|
||||
|
||||
TopMenuPanel < Panel
|
||||
height: 36
|
||||
image-source: images/top_panel.png
|
||||
image-repeated: true
|
||||
focusable: false
|
||||
|
||||
TopMenuFrameCounterLabel < FrameCounterLabel
|
||||
color: white
|
||||
margin-top: 4
|
||||
margin-left: 5
|
||||
|
||||
TopMenuPanel
|
||||
id: topMenu
|
||||
anchors.top: parent.top
|
||||
@@ -85,6 +35,7 @@ TopMenuPanel
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
padding-left: 0
|
||||
|
||||
TopMenuButtonsPanel
|
||||
id: rightGameButtonsPanel
|
||||
|
Reference in New Issue
Block a user