More modules fixes

This commit is contained in:
Eduardo Bart 2012-07-26 19:13:47 -03:00
parent 5f1e58c138
commit d2b85bdba8
7 changed files with 43 additions and 38 deletions

View File

@ -18,8 +18,8 @@ currentHotkeysList = nil
hotkeyLabelSelectedOnList = nil hotkeyLabelSelectedOnList = nil
currentItemPreview = nil currentItemPreview = nil
itemWidget = nil itemWidget = nil
addHotkey = nil addHotkeyButton = nil
removeHotkey = nil removeHotkeyButton = nil
hotkeyText = nil hotkeyText = nil
hotKeyTextLabel = nil hotKeyTextLabel = nil
sendAutomatically = nil sendAutomatically = nil
@ -43,8 +43,8 @@ function init()
currentHotkeysList = hotkeysWindow:getChildById('currentHotkeys') currentHotkeysList = hotkeysWindow:getChildById('currentHotkeys')
currentItemPreview = hotkeysWindow:getChildById('itemPreview') currentItemPreview = hotkeysWindow:getChildById('itemPreview')
addHotkey = hotkeysWindow:getChildById('addHotkey') addHotkeyButton = hotkeysWindow:getChildById('addHotkeyButton')
removeHotkey = hotkeysWindow:getChildById('removeHotkey') removeHotkeyButton = hotkeysWindow:getChildById('removeHotkeyButton')
hotkeyText = hotkeysWindow:getChildById('hotkeyText') hotkeyText = hotkeysWindow:getChildById('hotkeyText')
hotKeyTextLabel = hotkeysWindow:getChildById('hotKeyTextLabel') hotKeyTextLabel = hotkeysWindow:getChildById('hotKeyTextLabel')
sendAutomatically = hotkeysWindow:getChildById('sendAutomatically') sendAutomatically = hotkeysWindow:getChildById('sendAutomatically')
@ -164,7 +164,7 @@ function onChooseItemMouseRelease(self, mousePosition, mouseButton)
hotkeyLabelSelectedOnList.itemId = item:getId() hotkeyLabelSelectedOnList.itemId = item:getId()
changeUseType(HOTKEY_MANAGER_USEONSELF) changeUseType(HOTKEY_MANAGER_USEONSELF)
checkSelectedHotkey(hotkeyLabelSelectedOnList) checkSelectedHotkey(hotkeyLabelSelectedOnList)
HotkeysManager:show() show()
end end
g_mouse.restoreCursor() g_mouse.restoreCursor()
@ -182,7 +182,7 @@ function startChooseItem()
mouseGrabberWidget:grabMouse() mouseGrabberWidget:grabMouse()
g_mouse.setTargetCursor() g_mouse.setTargetCursor()
HotkeysManager:hide() hide()
end end
function clearObject() function clearObject()
@ -314,7 +314,7 @@ function checkSelectedHotkey(focused)
hotkeyLabelSelectedOnList = focused hotkeyLabelSelectedOnList = focused
if hotkeyLabelSelectedOnList ~= nil then if hotkeyLabelSelectedOnList ~= nil then
removeHotkey:enable() removeHotkeyButton:enable()
if hotkeyLabelSelectedOnList.itemId == nil then if hotkeyLabelSelectedOnList.itemId == nil then
hotkeyText:enable() hotkeyText:enable()
@ -347,7 +347,7 @@ function checkSelectedHotkey(focused)
changeUseType(hotkeyLabelSelectedOnList.useType) changeUseType(hotkeyLabelSelectedOnList.useType)
else else
hotkeyText:clearText() hotkeyText:clearText()
removeHotkey:disable() removeHotkeyButton:disable()
hotkeyText:disable() hotkeyText:disable()
sendAutomatically:disable() sendAutomatically:disable()
sendAutomatically:setChecked(false) sendAutomatically:setChecked(false)

View File

@ -13,8 +13,8 @@ MainWindow
!text: tr('Hotkeys') !text: tr('Hotkeys')
size: 340 460 size: 340 460
@onEnter: hide() @onEnter: modules.game_hotkeys.hide()
@onEscape: hide() @onEscape: modules.game_hotkeys.hide()
Label Label
id: currentHotkeysLabel id: currentHotkeysLabel
@ -50,23 +50,23 @@ MainWindow
margin-top: 10 margin-top: 10
Button Button
id: addHotkey id: addHotkeyButton
!text: tr('Add') !text: tr('Add')
width: 64 width: 64
anchors.left: parent.left anchors.left: parent.left
anchors.top: prev.bottom anchors.top: prev.bottom
margin-top: 2 margin-top: 2
@onClick: addHotkey() @onClick: modules.game_hotkeys.addHotkey()
Button Button
id: removeHotkey id: removeHotkeyButton
!text: tr('Remove') !text: tr('Remove')
width: 64 width: 64
enabled: false enabled: false
anchors.left: prev.right anchors.left: prev.right
anchors.top: prev.top anchors.top: prev.top
margin-left: 10 margin-left: 10
@onClick: removeHotkey() @onClick: modules.game_hotkeys.removeHotkey()
Label Label
id: hotKeyTextLabel id: hotKeyTextLabel
@ -84,7 +84,7 @@ MainWindow
anchors.right: parent.right anchors.right: parent.right
anchors.top: prev.bottom anchors.top: prev.bottom
margin-bottom: 2 margin-bottom: 2
@onTextChange: onHotkeyTextChange(self:getId(), self:getText()) @onTextChange: modules.game_hotkeys.onHotkeyTextChange(self:getId(), self:getText())
CheckBox CheckBox
id: sendAutomatically id: sendAutomatically
@ -94,7 +94,7 @@ MainWindow
anchors.top: prev.bottom anchors.top: prev.bottom
enabled:false enabled:false
margin-top: 10 margin-top: 10
@onCheckChange: setSendAutomatically(self:isChecked()) @onCheckChange: modules.game_hotkeys.setSendAutomatically(self:isChecked())
Item Item
id: itemPreview id: itemPreview
@ -111,7 +111,7 @@ MainWindow
anchors.left: prev.right anchors.left: prev.right
anchors.top: prev.top anchors.top: prev.top
margin-left: 10 margin-left: 10
@onClick: startChooseItem() @onClick: modules.game_hotkeys.startChooseItem()
Button Button
id: clearObjectButton id: clearObjectButton
@ -122,7 +122,7 @@ MainWindow
anchors.right: prev.right anchors.right: prev.right
anchors.top: prev.bottom anchors.top: prev.bottom
margin-top: 2 margin-top: 2
@onClick: clearObject() @onClick: modules.game_hotkeys.clearObject()
ButtonBox ButtonBox
id: useOnSelf id: useOnSelf
@ -134,7 +134,7 @@ MainWindow
anchors.top: selectObjectButton.top anchors.top: selectObjectButton.top
checked: false checked: false
margin-left: 10 margin-left: 10
@onCheckChange: changeUseType(HOTKEY_MANAGER_USEONSELF, self:isChecked()) @onCheckChange: modules.game_hotkeys.changeUseType(HOTKEY_MANAGER_USEONSELF, self:isChecked())
ButtonBox ButtonBox
id: useOnTarget id: useOnTarget
@ -146,7 +146,7 @@ MainWindow
anchors.top: prev.bottom anchors.top: prev.bottom
checked: false checked: false
margin-top: 2 margin-top: 2
@onCheckChange: changeUseType(HOTKEY_MANAGER_USEONTARGET, self:isChecked()) @onCheckChange: modules.game_hotkeys.changeUseType(HOTKEY_MANAGER_USEONTARGET, self:isChecked())
ButtonBox ButtonBox
id: useWith id: useWith
@ -158,11 +158,11 @@ MainWindow
anchors.top: prev.bottom anchors.top: prev.bottom
checked: false checked: false
margin-top: 2 margin-top: 2
@onCheckChange: changeUseType(HOTKEY_MANAGER_USEWITH, self:isChecked()) @onCheckChange: modules.game_hotkeys.changeUseType(HOTKEY_MANAGER_USEWITH, self:isChecked())
Button Button
!text: tr('Close') !text: tr('Close')
width: 64 width: 64
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
@onClick: hide() @onClick: modules.game_hotkeys.hide()

View File

@ -12,8 +12,8 @@ MessageSettings = {
} }
MessageTypes = { MessageTypes = {
[MessageModes.MonsterSay] = MessageSettings.orange, [MessageModes.MonsterSay] = MessageSettings.consoleOrange,
[MessageModes.MonsterYell] = MessageSettings.orange, [MessageModes.MonsterYell] = MessageSettings.consoleOrange,
[MessageModes.Failure] = MessageSettings.statusSmall, [MessageModes.Failure] = MessageSettings.statusSmall,
[MessageModes.Login] = MessageSettings.bottomWhite, [MessageModes.Login] = MessageSettings.bottomWhite,
[MessageModes.Game] = MessageSettings.centerWhite, [MessageModes.Game] = MessageSettings.centerWhite,
@ -31,7 +31,6 @@ messagesPanel = nil
function init() function init()
connect(g_game, 'onTextMessage', displayMessage) connect(g_game, 'onTextMessage', displayMessage)
connect(g_game, 'onPrivateTalk', onPrivateTalk)
connect(g_game, 'onGameEnd', clearMessages) connect(g_game, 'onGameEnd', clearMessages)
messagesPanel = g_ui.loadUI('textmessage.otui', modules.game_interface.getRootPanel()) messagesPanel = g_ui.loadUI('textmessage.otui', modules.game_interface.getRootPanel())
end end

View File

@ -1,8 +1,8 @@
MainWindow MainWindow
size: 256 128 size: 256 128
!text: tr('Add to VIP list') !text: tr('Add to VIP list')
@onEnter: addVip() @onEnter: modules.game_viplist.addVip()
@onEscape: destroyAddWindow() @onEscape: modules.game_viplist.destroyAddWindow()
Label Label
!text: tr('Please enter a character name:') !text: tr('Please enter a character name:')
@ -29,11 +29,11 @@ MainWindow
anchors.right: next.left anchors.right: next.left
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin-right: 10 margin-right: 10
@onClick: addVip() @onClick: modules.game_viplist.addVip()
Button Button
!text: tr('Cancel') !text: tr('Cancel')
width: 64 width: 64
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
@onClick: destroyAddWindow() @onClick: modules.game_viplist.destroyAddWindow()

View File

@ -11,6 +11,7 @@ function init()
g_keyboard.bindKeyDown('Ctrl+P', toggle) g_keyboard.bindKeyDown('Ctrl+P', toggle)
vipWindow = g_ui.loadUI('viplist.otui', modules.game_interface.getRightPanel()) vipWindow = g_ui.loadUI('viplist.otui', modules.game_interface.getRightPanel())
vipWindow.onClose = onMiniWindowClose
vipButton = TopMenu.addRightGameToggleButton('vipListButton', tr('VIP list') .. ' (Ctrl+P)', 'viplist.png', toggle) vipButton = TopMenu.addRightGameToggleButton('vipListButton', tr('VIP list') .. ' (Ctrl+P)', 'viplist.png', toggle)
vipButton:setOn(true) vipButton:setOn(true)
@ -71,6 +72,7 @@ function onAddVip(id, name, online)
local vipList = vipWindow:getChildById('contentsPanel') local vipList = vipWindow:getChildById('contentsPanel')
local label = g_ui.createWidget('VipListLabel') local label = g_ui.createWidget('VipListLabel')
label.onMousePress = onVipListLabelMousePress
label:setId('vip' .. id) label:setId('vip' .. id)
label:setText(name) label:setText(name)

View File

@ -1,17 +1,15 @@
VipListLabel < GameLabel VipListLabel < GameLabel
font: verdana-11px-monochrome font: verdana-11px-monochrome
phantom: false phantom: false
&onMousePress: onVipListLabelMousePress
MiniWindow MiniWindow
id: vipWindow id: vipWindow
!text: tr('VIP List') !text: tr('VIP List')
height: 100 height: 100
icon: viplist.png icon: viplist.png
@onClose: onMiniWindowClose()
&save: true &save: true
MiniWindowContents MiniWindowContents
layout: verticalBox layout: verticalBox
anchors.fill: parent anchors.fill: parent
&onMousePress: onVipListMousePress @onMousePress: onVipListMousePress()

View File

@ -39,6 +39,12 @@ bool Module::load()
return true; return true;
try { try {
// add to package.loaded
g_lua.getGlobalField("package", "loaded");
g_lua.getRef(m_sandboxEnv);
g_lua.setField(m_name);
g_lua.pop();
for(const std::string& depName : m_dependencies) { for(const std::string& depName : m_dependencies) {
ModulePtr dep = g_modules.getModule(depName); ModulePtr dep = g_modules.getModule(depName);
if(!dep) if(!dep)
@ -70,15 +76,15 @@ bool Module::load()
if(m_sandboxed) if(m_sandboxed)
g_lua.resetGlobalEnvironment(); g_lua.resetGlobalEnvironment();
// add to package.loaded
g_lua.getGlobalField("package", "loaded");
g_lua.getRef(m_sandboxEnv);
g_lua.setField(m_name);
g_lua.pop();
m_loaded = true; m_loaded = true;
g_logger.debug(stdext::format("Loaded module '%s'", m_name)); g_logger.debug(stdext::format("Loaded module '%s'", m_name));
} catch(stdext::exception& e) { } catch(stdext::exception& e) {
// remove from package.loaded
g_lua.getGlobalField("package", "loaded");
g_lua.pushNil();
g_lua.setField(m_name);
g_lua.pop();
if(m_sandboxed) if(m_sandboxed)
g_lua.resetGlobalEnvironment(); g_lua.resetGlobalEnvironment();
g_logger.error(stdext::format("Unable to load module '%s': %s", m_name, e.what())); g_logger.error(stdext::format("Unable to load module '%s': %s", m_name, e.what()));