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:
@@ -1,60 +1,61 @@
|
||||
ModuleManager = {}
|
||||
|
||||
local moduleManagerWindow
|
||||
local moduleManagerButton
|
||||
local moduleList
|
||||
|
||||
function ModuleManager.init()
|
||||
moduleManagerWindow = g_ui.displayUI('modulemanager.otui')
|
||||
function init()
|
||||
moduleManagerWindow = g_ui.displayUI('modulemanager')
|
||||
moduleManagerWindow:hide()
|
||||
moduleList = moduleManagerWindow:getChildById('moduleList')
|
||||
connect(moduleList, { onChildFocusChange = function(self, focusedChild)
|
||||
if focusedChild == nil then return end
|
||||
ModuleManager.updateModuleInfo(focusedChild:getText())
|
||||
updateModuleInfo(focusedChild:getText())
|
||||
end })
|
||||
|
||||
g_keyboard.bindKeyPress('Up', function() moduleList:focusPreviousChild(KeyboardFocusReason) end, moduleManagerWindow)
|
||||
g_keyboard.bindKeyPress('Down', function() moduleList:focusNextChild(KeyboardFocusReason) end, moduleManagerWindow)
|
||||
|
||||
moduleManagerButton = TopMenu.addLeftButton('moduleManagerButton', tr('Module Manager'), 'modulemanager.png', ModuleManager.toggle)
|
||||
moduleManagerButton = modules.client_topmenu.addLeftButton('moduleManagerButton', tr('Module Manager'), '/images/topbuttons/modulemanager', toggle)
|
||||
|
||||
-- refresh modules only after all modules are loaded
|
||||
addEvent(ModuleManager.listModules)
|
||||
addEvent(listModules)
|
||||
end
|
||||
|
||||
function ModuleManager.terminate()
|
||||
function hideButton()
|
||||
moduleManagerButton:hide()
|
||||
end
|
||||
|
||||
function terminate()
|
||||
moduleManagerWindow:destroy()
|
||||
moduleManagerWindow = nil
|
||||
moduleManagerButton:destroy()
|
||||
moduleManagerButton = nil
|
||||
moduleList = nil
|
||||
ModuleManager = nil
|
||||
end
|
||||
|
||||
function ModuleManager.hide()
|
||||
function hide()
|
||||
moduleManagerWindow:hide()
|
||||
end
|
||||
|
||||
function ModuleManager.show()
|
||||
function show()
|
||||
moduleManagerWindow:show()
|
||||
moduleManagerWindow:raise()
|
||||
moduleManagerWindow:focus()
|
||||
end
|
||||
|
||||
function ModuleManager.toggle()
|
||||
function toggle()
|
||||
if moduleManagerWindow:isVisible() then
|
||||
ModuleManager.hide()
|
||||
hide()
|
||||
else
|
||||
ModuleManager.show()
|
||||
show()
|
||||
end
|
||||
end
|
||||
|
||||
function ModuleManager.refreshModules()
|
||||
function refreshModules()
|
||||
g_modules.discoverModules()
|
||||
ModuleManager.listModules()
|
||||
listModules()
|
||||
end
|
||||
|
||||
function ModuleManager.listModules()
|
||||
function listModules()
|
||||
if not moduleManagerWindow then return end
|
||||
|
||||
moduleList:destroyChildren()
|
||||
@@ -69,7 +70,7 @@ function ModuleManager.listModules()
|
||||
moduleList:focusChild(moduleList:getFirstChild(), ActiveFocusReason)
|
||||
end
|
||||
|
||||
function ModuleManager.refreshLoadedModules()
|
||||
function refreshLoadedModules()
|
||||
if not moduleManagerWindow then return end
|
||||
|
||||
for i,child in ipairs(moduleList:getChildren()) do
|
||||
@@ -78,7 +79,7 @@ function ModuleManager.refreshLoadedModules()
|
||||
end
|
||||
end
|
||||
|
||||
function ModuleManager.updateModuleInfo(moduleName)
|
||||
function updateModuleInfo(moduleName)
|
||||
if not moduleManagerWindow then return end
|
||||
|
||||
local name = ''
|
||||
@@ -118,36 +119,36 @@ function ModuleManager.updateModuleInfo(moduleName)
|
||||
unloadButton:setEnabled(canUnload)
|
||||
end
|
||||
|
||||
function ModuleManager.reloadCurrentModule()
|
||||
function reloadCurrentModule()
|
||||
local focusedChild = moduleList:getFocusedChild()
|
||||
if focusedChild then
|
||||
local module = g_modules.getModule(focusedChild:getText())
|
||||
if module then
|
||||
module:reload()
|
||||
if ModuleManager == nil then return end
|
||||
ModuleManager.updateModuleInfo(module:getName())
|
||||
ModuleManager.refreshLoadedModules()
|
||||
ModuleManager.show()
|
||||
if modules.client_modulemanager == nil then return end
|
||||
updateModuleInfo(module:getName())
|
||||
refreshLoadedModules()
|
||||
show()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ModuleManager.unloadCurrentModule()
|
||||
function unloadCurrentModule()
|
||||
local focusedChild = moduleList:getFocusedChild()
|
||||
if focusedChild then
|
||||
local module = g_modules.getModule(focusedChild:getText())
|
||||
if module then
|
||||
module:unload()
|
||||
if ModuleManager == nil then return end
|
||||
ModuleManager.updateModuleInfo(module:getName())
|
||||
ModuleManager.refreshLoadedModules()
|
||||
updateModuleInfo(module:getName())
|
||||
refreshLoadedModules()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ModuleManager.reloadAllModules()
|
||||
function reloadAllModules()
|
||||
g_modules.reloadModules()
|
||||
ModuleManager.refreshLoadedModules()
|
||||
ModuleManager.show()
|
||||
refreshLoadedModules()
|
||||
show()
|
||||
end
|
||||
|
||||
|
@@ -3,13 +3,8 @@ Module
|
||||
description: Manage other modules
|
||||
author: edubart
|
||||
website: www.otclient.info
|
||||
|
||||
dependencies:
|
||||
- client_topmenu
|
||||
|
||||
@onLoad: |
|
||||
dofile 'modulemanager'
|
||||
ModuleManager.init()
|
||||
|
||||
@onUnload: |
|
||||
ModuleManager.terminate()
|
||||
sandboxed: true
|
||||
scripts: [ modulemanager ]
|
||||
dependencies: [ client_topmenu ]
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
||||
|
@@ -35,7 +35,7 @@ MainWindow
|
||||
size: 450 450
|
||||
!text: tr('Module Manager')
|
||||
|
||||
@onEscape: ModuleManager.hide()
|
||||
@onEscape: modules.client_modulemanager.hide()
|
||||
|
||||
TextList
|
||||
id: moduleList
|
||||
@@ -63,7 +63,7 @@ MainWindow
|
||||
margin-top: 8
|
||||
!text: tr('Refresh')
|
||||
text-auto-resize: true
|
||||
@onClick: ModuleManager.refreshModules()
|
||||
@onClick: modules.client_modulemanager.refreshModules()
|
||||
|
||||
Button
|
||||
id: reloadAllModulesButton
|
||||
@@ -72,7 +72,7 @@ MainWindow
|
||||
margin-top: 8
|
||||
!text: tr('Reload All')
|
||||
text-auto-resize: true
|
||||
@onClick: ModuleManager.reloadAllModules()
|
||||
@onClick: modules.client_modulemanager.reloadAllModules()
|
||||
|
||||
Panel
|
||||
id: moduleInfo
|
||||
@@ -131,7 +131,7 @@ MainWindow
|
||||
!text: tr('Load')
|
||||
enabled: false
|
||||
width: 90
|
||||
@onClick: ModuleManager.reloadCurrentModule()
|
||||
@onClick: modules.client_modulemanager.reloadCurrentModule()
|
||||
|
||||
Button
|
||||
id: moduleUnloadButton
|
||||
@@ -142,7 +142,7 @@ MainWindow
|
||||
!text: tr('Unload')
|
||||
enabled: false
|
||||
width: 90
|
||||
@onClick: ModuleManager.unloadCurrentModule()
|
||||
@onClick: modules.client_modulemanager.unloadCurrentModule()
|
||||
|
||||
Button
|
||||
id: closeButton
|
||||
@@ -150,5 +150,5 @@ MainWindow
|
||||
anchors.right: parent.right
|
||||
!text: tr('Close')
|
||||
width: 90
|
||||
@onClick: ModuleManager.hide()
|
||||
@onClick: modules.client_modulemanager.hide()
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 952 B |
Reference in New Issue
Block a user