mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 20:43:26 +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:
@@ -10,9 +10,9 @@ function init()
|
||||
|
||||
g_keyboard.bindKeyDown('Ctrl+P', toggle)
|
||||
|
||||
vipButton = TopMenu.addRightGameToggleButton('vipListButton', tr('VIP list') .. ' (Ctrl+P)', 'viplist.png', toggle)
|
||||
vipButton = modules.client_topmenu.addRightGameToggleButton('vipListButton', tr('VIP list') .. ' (Ctrl+P)', '/images/topbuttons/viplist', toggle)
|
||||
vipButton:setOn(true)
|
||||
vipWindow = g_ui.loadUI('viplist.otui', modules.game_interface.getRightPanel())
|
||||
vipWindow = g_ui.loadUI('viplist', modules.game_interface.getRightPanel())
|
||||
|
||||
refresh()
|
||||
vipWindow:setup()
|
||||
@@ -58,7 +58,7 @@ function onMiniWindowClose()
|
||||
end
|
||||
|
||||
function createAddWindow()
|
||||
addVipWindow = g_ui.displayUI('addvip.otui')
|
||||
addVipWindow = g_ui.displayUI('addvip')
|
||||
end
|
||||
|
||||
function destroyAddWindow()
|
||||
@@ -71,6 +71,22 @@ function addVip()
|
||||
destroyAddWindow()
|
||||
end
|
||||
|
||||
function hideOffline(state)
|
||||
settings = {}
|
||||
settings['hideOffline'] = state
|
||||
g_settings.mergeNode('VipList', settings)
|
||||
|
||||
refresh()
|
||||
end
|
||||
|
||||
function isHiddingOffline()
|
||||
local settings = g_settings.getNode('VipList')
|
||||
if not settings then
|
||||
return false
|
||||
end
|
||||
return settings['hideOffline']
|
||||
end
|
||||
|
||||
function onAddVip(id, name, state)
|
||||
local vipList = vipWindow:getChildById('contentsPanel')
|
||||
|
||||
@@ -92,6 +108,10 @@ function onAddVip(id, name, state)
|
||||
label:setPhantom(false)
|
||||
connect(label, { onDoubleClick = function () g_game.openPrivateChannel(label:getText()) return true end } )
|
||||
|
||||
if state == VipState.Offline and isHiddingOffline() then
|
||||
label:setVisible(false)
|
||||
end
|
||||
|
||||
local nameLower = name:lower()
|
||||
local childrenCount = vipList:getChildCount()
|
||||
|
||||
@@ -140,6 +160,13 @@ function onVipListMousePress(widget, mousePos, mouseButton)
|
||||
|
||||
local menu = g_ui.createWidget('PopupMenu')
|
||||
menu:addOption(tr('Add new VIP'), function() createAddWindow() end)
|
||||
|
||||
if not isHiddingOffline() then
|
||||
menu:addOption(tr('Hide Offline'), function() hideOffline(true) end)
|
||||
else
|
||||
menu:addOption(tr('Show Offline'), function() hideOffline(false) end)
|
||||
end
|
||||
|
||||
menu:display(mousePos)
|
||||
|
||||
return true
|
||||
@@ -155,7 +182,16 @@ function onVipListLabelMousePress(widget, mousePos, mouseButton)
|
||||
menu:addOption(tr('Add new VIP'), function() createAddWindow() end)
|
||||
menu:addOption(tr('Remove %s', widget:getText()), function() if widget then g_game.removeVip(widget:getId():sub(4)) vipList:removeChild(widget) end end)
|
||||
menu:addSeparator()
|
||||
menu:addOption(tr('Copy Name'), function() g_window.setClipboardText(widget:getText()) end)
|
||||
menu:addOption(tr('Copy Name'), function() g_window.setClipboardText(widget:getText()) end) if modules.game_console.getOwnPrivateTab() then
|
||||
menu:addSeparator()
|
||||
menu:addOption(tr('Invite to private chat'), function() g_game.inviteToOwnChannel(creatureName) end)
|
||||
menu:addOption(tr('Exclude from private chat'), function() g_game.excludeFromOwnChannel(creatureName) end)
|
||||
end
|
||||
if not isHiddingOffline() then
|
||||
menu:addOption(tr('Hide Offline'), function() hideOffline(true) end)
|
||||
else
|
||||
menu:addOption(tr('Show Offline'), function() hideOffline(false) end)
|
||||
end
|
||||
menu:display(mousePos)
|
||||
|
||||
return true
|
||||
|
@@ -4,6 +4,6 @@ Module
|
||||
author: baxnie, edubart
|
||||
website: www.otclient.info
|
||||
sandboxed: true
|
||||
scripts: [ viplist.lua ]
|
||||
scripts: [ viplist ]
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
||||
|
@@ -10,7 +10,7 @@ MiniWindow
|
||||
id: vipWindow
|
||||
!text: tr('VIP List')
|
||||
height: 100
|
||||
icon: viplist.png
|
||||
icon: /images/topbuttons/viplist
|
||||
@onClose: modules.game_viplist.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 945 B |
Reference in New Issue
Block a user