a lot of changes in modules

This commit is contained in:
Eduardo Bart
2012-02-06 17:19:47 -02:00
parent add8505a5b
commit 88301c329a
50 changed files with 488 additions and 322 deletions

View File

@@ -54,25 +54,40 @@ function ModuleManager.refreshModules()
end
function ModuleManager.listModules()
if not moduleManagerWindow then return end
moduleList:destroyChildren()
local modules = g_modules.getModules()
for i,module in ipairs(modules) do
local label = createWidget('ModuleListLabel', moduleList)
label:setText(module:getName())
label:setOn(module:isLoaded())
end
moduleList:focusChild(moduleList:getFirstChild(), ActiveFocusReason)
end
function ModuleManager.refreshLoadedModules()
if not moduleManagerWindow then return end
for i,child in ipairs(moduleList:getChildren()) do
local module = g_modules.getModule(child:getText())
child:setOn(module:isLoaded())
end
end
function ModuleManager.updateModuleInfo(moduleName)
if not moduleManagerWindow then return end
local name = ''
local description = ''
local autoLoad = ''
local author = ''
local website = ''
local version = ''
local canLoad = false
local loaded = false
local canReload = false
local canUnload = false
local module = g_modules.getModule(moduleName)
@@ -82,8 +97,9 @@ function ModuleManager.updateModuleInfo(moduleName)
author = module:getAuthor()
website = module:getWebsite()
version = module:getVersion()
canUnload = module:isLoaded()
canLoad = not canUnload
loaded = module:isLoaded()
canUnload = module:canUnload()
canReload = not loaded or canUnload
end
moduleManagerWindow:recursiveGetChildById('moduleName'):setText(name)
@@ -93,17 +109,26 @@ function ModuleManager.updateModuleInfo(moduleName)
moduleManagerWindow:recursiveGetChildById('moduleWebsite'):setText(website)
moduleManagerWindow:recursiveGetChildById('moduleVersion'):setText(version)
moduleManagerWindow:recursiveGetChildById('moduleLoadButton'):setEnabled(canLoad)
moduleManagerWindow:recursiveGetChildById('moduleUnloadButton'):setEnabled(canUnload)
local reloadButton = moduleManagerWindow:recursiveGetChildById('moduleReloadButton')
reloadButton:setEnabled(canReload)
reloadButton:setVisible(true)
if loaded then reloadButton:setText('Reload')
else reloadButton:setText('Load') end
local unloadButton = moduleManagerWindow:recursiveGetChildById('moduleUnloadButton')
unloadButton:setVisible(true)
unloadButton:setEnabled(canUnload)
end
function ModuleManager.loadCurrentModule()
function ModuleManager.reloadCurrentModule()
local focusedChild = moduleList:getFocusedChild()
if focusedChild then
local module = g_modules.getModule(focusedChild:getText())
if module then
module:load()
module:reload()
ModuleManager.updateModuleInfo(module:getName())
ModuleManager.refreshLoadedModules()
ModuleManager.show()
end
end
end
@@ -115,7 +140,14 @@ function ModuleManager.unloadCurrentModule()
if module then
module:unload()
ModuleManager.updateModuleInfo(module:getName())
ModuleManager.refreshLoadedModules()
end
end
end
function ModuleManager.reloadAllModules()
g_modules.reloadModules()
ModuleManager.refreshLoadedModules()
ModuleManager.show()
end