Alright guys here is some of my code, uhm I got it to work but I still don't know how to dock the window.
chat_buffer = {}
chat_max_lines = 200 -- how many lines to keep
chat_line_height = 14 -- pixel height per line
chat_scroll = 0 -- 0 = bottom, positive = scroll up
function wheel_move(flags, hotspot_id)
-- wheel down (towards you)
if bit.band(flags, 0x100) ~= 0 then
chat_scroll = chat_scroll - 1
else
-- wheel up (away from you)
chat_scroll = chat_scroll + 1
end
if chat_scroll < 0 then chat_scroll = 0 end
if chat_scroll > #chat_buffer - 1 then
chat_scroll = #chat_buffer - 1
end
chat_redraw()
return 0
end
function init()
local width = GetInfo(281) -- main window width
local height = GetInfo(280) -- main window height
WindowCreate(
"chatwin",
0, 0, width, 150, -- left, top, width, height=150px
2,
0,
0x000000
)
-- Draw a border so you can SEE it
WindowRectOp("chatwin", miniwin.rect_frame, 0, 0, 0, 0, 0x777777)
-- Force a repaint
WindowShow("chatwin", true)
WindowAddHotspot(
"chatwin",
"hs1",
0, 0, width, 150, -- FULL WINDOW
"", -- mouse over script to call
"", -- cancel mouse over
"", -- mouse down
"", -- cancel mouse down
"", -- mouse up
"Hovering Over", -- Tooltip text
0,
0
)
WindowScrollwheelHandler("chatwin", "hs1", "wheel_move")
end
function chat_redraw()
if #chat_buffer == 0 then
WindowShow("chatwin", true)
return
end
local width = GetInfo(281)
local height = 150
WindowResize("chatwin", width, height, 0x000000)
WindowRectOp("chatwin", miniwin.rect_fill, 0, 0, width, height, ColourNameToRGB("black"))
local fi = WindowFontInfo("chatwin", "chatfont", 1)
if not fi then
WindowFont("chatwin", "chatfont", "Consolas", 9)
end
local start_index = math.max(1, #chat_buffer - chat_scroll)
local y = height - chat_line_height
for i = start_index, 1, -1 do
WindowText("chatwin", "chatfont", chat_buffer, 5, y, 0, 0, 0xFFFFFF)
y = y - chat_line_height
if y < 0 then break end
end
WindowShow("chatwin", true)
end
function chat_add(text)
table.insert(chat_buffer, text)
-- trim buffer
if #chat_buffer > chat_max_lines then
table.remove(chat_buffer, 1)
end
chat_redraw()
end
function hide_chat()
WindowShow("chatwin", false)
end
|