parent
69e762385e
commit
b804dd6959
@ -0,0 +1,8 @@
|
||||
Font
|
||||
name: terminus-10px
|
||||
texture: terminus-10px
|
||||
height: 12
|
||||
y-offset: 0
|
||||
glyph-size: 16 16
|
||||
fixed-glyph-width: 6
|
||||
space-width: 6
|
After Width: | Height: | Size: 3.1 KiB |
@ -1,99 +1,71 @@
|
||||
function dumpWidgets(widget, level)
|
||||
widget = widget or rootWidget
|
||||
level = level or 0
|
||||
for i=1,widget:getChildCount() do
|
||||
local child = widget:getChildByIndex(i)
|
||||
if child:isVisible() then
|
||||
local name = child:getId()
|
||||
if name:match('widget%d+') == nil then
|
||||
print(string.rep(' ', level) .. name)
|
||||
end
|
||||
if child:getId() ~= 'terminalBuffer' then
|
||||
dumpWidgets(child, level+1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function drawDebugBoxes(enable)
|
||||
function draw_debug_boxes(enable)
|
||||
if enable == nil then enable = true end
|
||||
g_ui.setDebugBoxesDrawing(enable)
|
||||
end
|
||||
|
||||
function hideMap()
|
||||
local map = rootWidget:recursiveGetChildById('gameMapPanel')
|
||||
if map then map:hide() end
|
||||
function hide_map()
|
||||
modules.game_interface.getMapPanel():hide()
|
||||
end
|
||||
|
||||
function showMap()
|
||||
local map = rootWidget:recursiveGetChildById('gameMapPanel')
|
||||
if map then map:show() end
|
||||
function show_map()
|
||||
modules.game_interface.getMapPanel():show()
|
||||
end
|
||||
|
||||
function debugContainersItems()
|
||||
function UIItem:onHoverChange(hovered)
|
||||
if hovered then
|
||||
local item = self:getItem()
|
||||
if item then
|
||||
local text = "id: " ..item:getId() ..
|
||||
"\n stackable: " ..tostring(item:isStackable()) ..
|
||||
"\n marketable: " ..tostring(item:isMarketable()) ..
|
||||
"\n vocation: "..(item:getMarketData() and item:getMarketData().restrictVocation or 'none') ..
|
||||
"\n cloth slot: " ..item:getClothSlot()
|
||||
g_tooltip.display(text)
|
||||
end
|
||||
else
|
||||
g_tooltip.hide()
|
||||
end
|
||||
function auto_reload_module(name)
|
||||
local function reloadEvent()
|
||||
reloadModule(name)
|
||||
scheduleEvent(reloadEvent, 1000)
|
||||
end
|
||||
reloadEvent()
|
||||
end
|
||||
|
||||
function debugPosition(enable)
|
||||
if enable == nil then enable = true end
|
||||
local label = rootWidget:getChildById('debugPositionLabel')
|
||||
if not label then
|
||||
label = g_ui.createWidget('GameLabel', rootWidget)
|
||||
label:setColor('pink')
|
||||
label:setFont('terminus-14px-bold')
|
||||
label:setId('debugPositionLabel')
|
||||
label:setPosition({x= 10, y = 40 })
|
||||
label:setPhantom(true)
|
||||
label:setTextAutoResize(true)
|
||||
end
|
||||
if enable then
|
||||
label.event = cycleEvent(function()
|
||||
local player = g_game.getLocalPlayer()
|
||||
if player then
|
||||
local pos = g_game.getLocalPlayer():getPosition()
|
||||
label:show()
|
||||
label:setText('x: ' .. pos.x .. '\ny: ' .. pos.y .. '\nz: ' .. pos.z)
|
||||
else
|
||||
label:hide()
|
||||
end
|
||||
end, 100)
|
||||
local function pingBack(ping) print(g_game.getWorldName() .. ' => ' .. ping .. ' ms') end
|
||||
local pinging = false
|
||||
function ping()
|
||||
if pinging then
|
||||
pdebug('Ping stopped.')
|
||||
g_game.setPingDelay(1000)
|
||||
disconnect(g_game, 'onPingBack', pingBack)
|
||||
else
|
||||
removeEvent(label.event)
|
||||
label.event = nil
|
||||
label:hide()
|
||||
if not (g_game.getFeature(GameClientPing) or g_game.getFeature(GameExtendedClientPing)) then
|
||||
perror('this server does not support ping')
|
||||
return
|
||||
elseif not g_game.isOnline() then
|
||||
perror('ping command is only allowed when online')
|
||||
return
|
||||
end
|
||||
|
||||
pdebug('Starting ping...')
|
||||
g_game.setPingDelay(0)
|
||||
connect(g_game, 'onPingBack', pingBack)
|
||||
end
|
||||
pinging = not pinging
|
||||
end
|
||||
|
||||
function autoReloadModule(name)
|
||||
local function reloadEvent()
|
||||
reloadModule(name)
|
||||
scheduleEvent(reloadEvent, 1000)
|
||||
function clear()
|
||||
modules.client_terminal.clear()
|
||||
end
|
||||
|
||||
function ls(path)
|
||||
path = path or '/'
|
||||
local files = g_resources.listDirectoryFiles(path)
|
||||
for k,v in pairs(files) do
|
||||
if g_resources.directoryExists(path .. v) then
|
||||
modules.client_terminal.addLine(path .. v, 'blue')
|
||||
else
|
||||
pinfo(path .. v)
|
||||
end
|
||||
end
|
||||
reloadEvent()
|
||||
end
|
||||
|
||||
function createDebugUIItem(id)
|
||||
local uiitem = g_ui.createWidget('Item', rootWidget)
|
||||
uiitem:setPosition({x= 200, y = 200 })
|
||||
uiitem:setItemId(id)
|
||||
uiitem:show()
|
||||
function about_version()
|
||||
pinfo(g_app.getName() .. ' ' .. g_app.getVersion() .. '\n' ..
|
||||
'Rev ' .. g_app.getBuildRevision() .. ' ('.. g_app.getBuildCommit() .. ')\n' ..
|
||||
'Built on ' .. g_app.getBuildDate())
|
||||
end
|
||||
|
||||
function debugPings()
|
||||
g_game.setPingDelay(0)
|
||||
connect(g_game, { onPingBack = function(ping) print(g_game.getWorldName() .. ' => ' .. ping .. ' ms') end })
|
||||
function about_graphics()
|
||||
pinfo('Vendor ' .. g_graphics.getVendor() )
|
||||
pinfo('Renderer' .. g_graphics.getRenderer())
|
||||
pinfo('Version' .. g_graphics.getVersion())
|
||||
end
|
||||
|
Loading…
Reference in new issue