MUSHclient version: 4.40
Script provided
Screenies provided
(You might notice that the gridline loops in DrawGrid are hard-set to loop to 23. That's not really my problem per se; if I fixed that, the real bug would just be hidden one way but not another. It's key to the explanation below)
I have an odd bug here involving miniwindow sizes and drawing. A little backstory might help: I'm writing a plugin that parses the output of a MAP command into a miniwindow. The MAP output can come in multiple sizes (it shows more or less area around you depending on its set radius). The miniwindow should resize itself based on that MAP RADIUS value so it doesn't have a bunch of blank space within the borders.
This plugin is still being worked on, so I'm starting the plugin off at the maximum size, a 5-radius map. Here's an image, with gridlines: http://img17.imageshack.us/img17/1313/bug1rsr.png
That looks right, doesn't it? But then I set MAP RADIUS 4, and the script responds with a call to SizeWindow (see below). I expect the entire drawing region I reserved before to be cleared and deallocated, just like the backbuffer. Oddly enough, that's not so. Here's another screenshot of the miniwindow when I do that: http://img17.imageshack.us/img17/4637/bug2v.png
The grid lines go beyond the area I've newly reserved. And if I change the gridline code to deliberately go past even the radius 5 area, they won't do that. They really do stop right there, way past where they should. And if I deliberately expand the map beyond the original radius 5 window, it gets cut off there. It's as though the first (well, second if you count the dummy window for font loading) size I set determines the drawing area from then on, whether I resize the miniwindow or not.
If I'm wrong somehow please let me know, because this has me stumped. I really want to be able to resize my miniwindow without worrying that the drawing area won't resize with it.
EDIT: Also, just to see what would happen, I added WindowDelete() into SizeWindow. Quite apart from the loss of my loaded font (which I might've been able to put up with), this problem is still there...
Script provided
Screenies provided
(You might notice that the gridline loops in DrawGrid are hard-set to loop to 23. That's not really my problem per se; if I fixed that, the real bug would just be hidden one way but not another. It's key to the explanation below)
I have an odd bug here involving miniwindow sizes and drawing. A little backstory might help: I'm writing a plugin that parses the output of a MAP command into a miniwindow. The MAP output can come in multiple sizes (it shows more or less area around you depending on its set radius). The miniwindow should resize itself based on that MAP RADIUS value so it doesn't have a bunch of blank space within the borders.
This plugin is still being worked on, so I'm starting the plugin off at the maximum size, a 5-radius map. Here's an image, with gridlines: http://img17.imageshack.us/img17/1313/bug1rsr.png
That looks right, doesn't it? But then I set MAP RADIUS 4, and the script responds with a call to SizeWindow (see below). I expect the entire drawing region I reserved before to be cleared and deallocated, just like the backbuffer. Oddly enough, that's not so. Here's another screenshot of the miniwindow when I do that: http://img17.imageshack.us/img17/4637/bug2v.png
The grid lines go beyond the area I've newly reserved. And if I change the gridline code to deliberately go past even the radius 5 area, they won't do that. They really do stop right there, way past where they should. And if I deliberately expand the map beyond the original radius 5 window, it gets cut off there. It's as though the first (well, second if you count the dummy window for font loading) size I set determines the drawing area from then on, whether I resize the miniwindow or not.
If I'm wrong somehow please let me know, because this has me stumped. I really want to be able to resize my miniwindow without worrying that the drawing area won't resize with it.
EDIT: Also, just to see what would happen, I added WindowDelete() into SizeWindow. Quite apart from the loss of my loaded font (which I might've been able to put up with), this problem is still there...
Window = {
new = function(name, x, y)
local o = {}
setmetatable(o, Window)
Window.__index = Window
o.name = name
o.x = x
o.y = y
-- Dummy window to load font
WindowCreate(o.name, 1, 1, 1, 1, 6, 2, 0x000000)
WindowFont(o.name, "f", "Lucida Console", 11, false, false, false, false, 1, 0)
o.textwidth = WindowTextWidth(o.name, "f", "#")
o.textheight = WindowFontInfo(o.name, "f", 1)
-- a grid of 23 cells, with room to make up for the borders
o.width = o.textwidth*23 + 3
o.height = o.textheight*23 + 2
-- set up the miniwindow dimensions here
o:SizeWindow(o.width, o.height)
return o
end,
SizeWindow = function(self, width, height)
self.width = width
self.height = height
WindowCreate(self.name, self.x, self.y, width, height, 6, 2, 0x000000)
WindowShow(self.name, true)
end,
DrawGrid = function(self, grid)
-- blanks the miniwindow
self:ClearGrid()
-- Draws gridlines
for i = 1, 23 do
WindowLine(self.name, 0, i*self.textheight, self.width, i*self.textheight, 0x666666, 0, 1)
end
for i = 1, 23 do
WindowLine(self.name, 3+i*self.textwidth, 0, 3+i*self.textwidth, self.height, 0x666666, 0, 1)
end
-- write each line of the map
for i = 1, 23 do
self:DrawLine(grid or {}, i-1)
end
end,
}