BeniS 8850528091 Updated Top Menu, Health Info, Combat Controls, Console (Channels), Game Toggle Buttons, Minimap Layout, Game Interface Prompts, and Creature Draw Info.
* Added new left and right game button panels.
* Relocated main game toggle buttons to the right side of the screen to make it easier to toggle miniwindows.
* Added table.empty(t) function to table lib.
* Renamed module game_healthbar to game_healthinfo.
* Combat controls now save per character (e.g. Fight mode, chase mode, safe fight mode)
* Last channels open now save per character.
* Fixed typo in containers.lua.
* Added logout prompting window message when you logout via the logout button.
* Added exit promting window message when you attempt to exit the client.
* Repositioned some minimap buttons.
* Fixed so when creatures health percent is < 1 it will not draw the creature information.

Known Issues:
* If you move a container widget into the map rect if you move an item onto itself it will allow this to execute still dropping the item on the ground.
* The server is calling to open channels after onGameStart is executed causing it to focus the last tab opened. Fix: Don't save channels to the settings that are opened by the server.
2012-07-13 04:45:22 +12:00

107 lines
2.9 KiB
Lua

TopMenu = {}
-- private variables
local topMenu
local leftButtonsPanel
local rightButtonsPanel
local leftGameButtonsPanel
local rightGameButtonsPanel
-- private functions
local function addButton(id, description, icon, callback, panel, toggle)
local class
if toggle then
class = 'TopToggleButton'
else
class = 'TopButton'
end
local button = g_ui.createWidget(class, panel)
button:setId(id)
button:setTooltip(description)
button:setIcon(resolvepath(icon, 3))
button.onClick = callback
return button
end
-- public functions
function TopMenu.init()
connect(g_game, { onGameStart = TopMenu.showGameButtons,
onGameEnd = TopMenu.hideGameButtons })
topMenu = g_ui.displayUI('topmenu.otui')
leftButtonsPanel = topMenu:getChildById('leftButtonsPanel')
rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')
leftGameButtonsPanel = topMenu:getChildById('leftGameButtonsPanel')
rightGameButtonsPanel = topMenu:getChildById('rightGameButtonsPanel')
if g_game.isOnline() then
leftGameButtonsPanel:show()
rightGameButtonsPanel:show()
end
end
function TopMenu.terminate()
disconnect(g_game, { onGameStart = TopMenu.showGameButtons,
onGameEnd = TopMenu.hideGameButtons })
leftButtonsPanel = nil
rightButtonsPanel = nil
leftGameButtonsPanel = nil
rightGameButtonsPanel = nil
topMenu:destroy()
topMenu = nil
TopMenu = nil
end
function TopMenu.addLeftButton(id, description, icon, callback)
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 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.addLeftGameButton(id, description, icon, callback)
return addButton(id, description, icon, callback, leftGameButtonsPanel, false)
end
function TopMenu.addLeftGameToggleButton(id, description, icon, callback, right)
return addButton(id, description, icon, callback, leftGameButtonsPanel, true)
end
function TopMenu.addRightGameButton(id, description, icon, callback)
return addButton(id, description, icon, callback, rightGameButtonsPanel, false)
end
function TopMenu.addRightGameToggleButton(id, description, icon, callback, right)
return addButton(id, description, icon, callback, rightGameButtonsPanel, true)
end
function TopMenu.hideGameButtons()
leftGameButtonsPanel:hide()
rightGameButtonsPanel:hide()
end
function TopMenu.showGameButtons()
leftGameButtonsPanel:show()
rightGameButtonsPanel:show()
end
function TopMenu.getButton(id)
return topMenu:recursiveGetChildById(id)
end