Hi everyone,
My MUD recently implemented MSDP so I have been fiddling around with miniwindows over the past few weeks. I have encountered some strange behavior in one of my plugins using the 'WindowResize' function. The plugin's job is basically t show spell timers counting down using the MSDP information from the MUD. The problem occurs whenever my character becomes affected by a spell or whenever the spell wears off, thus the change in window size. If I comment out the call to WindowResize, the flicker disappears. (When I say flicker, I mean the entire window disappears for about ~1 second).
If someone could take a look at the draw function and let me know if they spot any problems, it would be much appreciated!
My MUD recently implemented MSDP so I have been fiddling around with miniwindows over the past few weeks. I have encountered some strange behavior in one of my plugins using the 'WindowResize' function. The plugin's job is basically t show spell timers counting down using the MSDP information from the MUD. The problem occurs whenever my character becomes affected by a spell or whenever the spell wears off, thus the change in window size. If I comment out the call to WindowResize, the flicker disappears. (When I say flicker, I mean the entire window disappears for about ~1 second).
If someone could take a look at the draw function and let me know if they spot any problems, it would be much appreciated!
function draw_affect_timers()
if is_dragging == true then return else end
local title_width = WindowText(win,
default_font,
"[AffectTimers]",
padding,
padding,
125,
default_font_height+padding,
ColourNameToRGB("blue"),
false)
WindowAddHotspot(win,
"drag_hotspot",
padding,
padding,
title_width+padding,
default_font_height+padding,
"",
"",
"", -- mousedown
"",
"",
"",
miniwin.cursor_hand,
0)
-- add a window drag handler so the window can be moved
WindowDragHandler(win,
"drag_hotspot",
"window_move",
"window_release",
0)
WindowRectOp(win,
miniwin.rect_fill,
padding,
(default_font_height * 2),
window_width,
WindowInfo(win, 4),
ColourNameToRGB("black"))
WindowRectOp(win,
miniwin.rect_frame,
0,
0,
0,
0,
ColourNameToRGB("gray"))
local line_count = 2
for k,v in orderedPairs(affect_name) do
local timer_string = affect_timer[k]
while string.len(timer_string) < 4 do
timer_string = string.gsub(timer_string, "([%d]+)", " %1")
end
local duration = table.concat({"(", timer_string, ")"}, "")
local offset = WindowText(win,
default_font,
duration,
padding,
(default_font_height * line_count),
window_width,
(default_font_height * line_count) + default_font_height,
ColourNameToRGB("yellow"),
false)
if offset < 60 then
offset = 60
else end
local spell_name_color
local spell_name_font
if tonumber(affect_timer[k]) <= timer_warning and tonumber(affect_timer[k]) > timer_critical then
spell_name_color = "gray"
spell_name_font = warning_font
elseif tonumber(affect_timer[k]) <= timer_critical then
spell_name_color = "gray"
spell_name_font = critical_font
else
spell_name_color = "white"
spell_name_font = default_font
end
WindowText(win,
spell_name_font,
v,
offset,
(default_font_height * line_count),
window_width,
(default_font_height * line_count) + default_font_height,
ColourNameToRGB(spell_name_color),
false)
line_count = line_count + 1
end
WindowResize(win,
window_width,
tonumber((default_font_height * line_count-1) + padding),
ColourNameToRGB("black"))
WindowShow(win, true)
end -- function
--- and below is the last part of my 'OnTelnetSubnegotiation'
local msdp_affects = msdp["AFFECTS"]
if not msdp_affects then return end
update_affects(msdp_affects)
draw_affect_timers()