Multiple miniwindows in a plugin-issue.

Posted by Mr.lundmark on Fri 29 Jul 2011 03:23 PM — 11 posts, 35,270 views.

#0
Hi Nick (and the rest of you).

First off, thanks for coding a great mud-client.

As always, each time anyone has anything positive to say - they also want something from you ;)

When I run a Debug("summary") and look into my miniwindows, I get the following printout:
Window: 'KillCommands', at (0,0,187,64), shown: yes
width: 187, height: 64, position: 4, hotspots: 1, fonts: 1, images: 0
Window: 'Killers', at (0,0,109,16), shown: yes
width: 109, height: 16, position: 4, hotspots: 1, fonts: 1, images: 0
Window: 'StepInfo', at (0,0,70,48), shown: yes
width: 70, height: 48, position: 4, hotspots: 1, fonts: 1, images: 0


They are all from the same plugin.

As you can see, the heights of the windows are 64, 16 and 48. Still, they are all drawn as if they were 64 pixels high.

What is it that I'm doing wrong? I've tried with WindowDelete/windowCreate every time I rescale them, but it doesn't seem to help. I could provide with more information such as code or screenshots. Just let me know.

Edit: I'm running version 4.75.

Cheers,
Simon.
Amended on Fri 29 Jul 2011 06:00 PM by Mr.lundmark
#1
Add:

Since my windows are stacked top-right and I'm offsetting them towards the center, it seems as if my right-most window scales accordingly, but when I try to scale the mid or left one to a size smaller than a window that is more to the right, it fails.

Red squared means that the button is minimized. Blue that it's maximized.

This is when it works correctly:
http://i53.tinypic.com/33ath5z.jpg

This is when it works incorrectly:
http://i51.tinypic.com/169jhv9.jpg
Amended on Fri 29 Jul 2011 10:27 PM by Mr.lundmark
Australia Forum Administrator #2
The code please? Can't help debug code without seeing it.

Quote:

... but when I try to scale the mid or left one to a size smaller than a window that is more to the right, it fails.


Fails, as in makes a bigger window than you expect?
#3
The code of importance is:

for i, name in ipairs(data.windows) do
	WindowDelete(name)
	WindowCreate(name, offset_x, 0, data.x_size[i] + offset_x, data.y_size[i], 4, 0, ColourNameToRGB("black"))
	WindowFont(name, font, "Sylfaen", 8, false, false, false, false, 1, 0)
	WindowAddHotspot(name, name, offset_x, 0, data.x_size[i] + offset_x, 16, 
			"mouseOver",
			"cancelMouseOver",
			"mouseDown",
			"cancelMouseDown",
			"mouseUp",
			"Minimize/Maximize",
			1, 0)
	WindowShow(name, true)
	offset_x = offset_x + data.x_size[i]
end


Where X/Y sizes vary. As the applied "failed" screenshot describe (http://i51.tinypic.com/169jhv9.jpg), the mid-window (named "Killers") should be only 17 pixels in Y (which is what I set it to) and yet it is being displayed as much bigger.

So the answer to your question is Yes, the mid-window becomes larger than expected. So does the left one if it is attempted to be smaller (in height) than the mid/right ones.

Does that explain my issue?

[EDIT] Edited by Nick to "escape" square brackets.
Amended on Sat 30 Jul 2011 12:12 AM by Nick Gammon
Australia Forum Administrator #4
Mr lundmark said:

... the mid-window (named "Killers") should be only 17 pixels in Y (which is what I set it to) and yet it is being displayed as much bigger.


I don't actually see that number 17. I only see data.y_size[i], whatever that might be.

You need to show each value being passed to WindowCreate, but I am guessing that data.y_size[i] isn't what you think it is.
#5
Nick Gammon said:

Mr lundmark said:

... the mid-window (named "Killers") should be only 17 pixels in Y (which is what I set it to) and yet it is being displayed as much bigger.


I don't actually see that number 17. I only see data.y_size[i], whatever that might be.

You need to show each value being passed to WindowCreate, but I am guessing that data.y_size[i] isn't what you think it is.


Mr lundmark said:

When I run a Debug("summary") and look into my miniwindows, I get the following printout:
Window: 'KillCommands', at (0,0,187,64), shown: yes
width: 187, height: 64, position: 4, hotspots: 1, fonts: 1, images: 0
Window: 'Killers', at (0,0,109,16), shown: yes
width: 109, height: 16, position: 4, hotspots: 1, fonts: 1, images: 0
Window: 'StepInfo', at (0,0,70,48), shown: yes
width: 70, height: 48, position: 4, hotspots: 1, fonts: 1, images: 0


According to your Debug("summary"), it's "16". Look at the middle window called "Killers". It says that it's 16 (I changed that to 17 later). When I debug-write the value every time I draw the window, I get that number (the code added to the for loop is a simple "print("Window " .. name .. " height: " .. data.y_size[ i ])"), and the output is:
Window StepInfo height: 48
Window Killers height: 17
Window KillCommands height: 64

The middle window is set to 17.
Amended on Sat 30 Jul 2011 12:08 PM by Mr.lundmark
#6
I made a new plugin (much simpler than the old one) to demonstrate the issue.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on söndag, oktober 10, 2010, 8:15  -->
<!-- MuClient version 4.63 -->

<!-- Plugin "StatusMonitor" generated by Plugin Wizard -->

<muclient>
<plugin
   name="DebugDrawing"
   author="Simon Lundmark"
   id="aaa419bdde4edec0668f7aaa"
   language="Lua"
   date_written="2010-10-10 08:14:31"
   requires="4.63"
   version="1.0"
   >

</plugin>

<!--  Get our standard constants -->

<script>
<![CDATA[

local data = {
	windows = {
		"StepInfo",
		"Killers",
		"KillCommands",
	},
	y_size = {
		100,
		15,
		100,
	},
	
	x_size = {
		100,
		50,
		100,
	},
}

function clearWindow()
	local offset_x = 0
	for i, name in ipairs(data.windows) do
		WindowDelete(name)
		WindowCreate(name, offset_x, 0, data.x_size[i] + offset_x, data.y_size[i], 4, 0, ColourNameToRGB("red"))
		WindowShow(name, true)
		offset_x = offset_x + data.x_size[i]
	end
end
	
function OnPluginEnable()
	clearWindow()
end

function OnPluginInstall() 
	clearWindow()
end
	
function OnPluginClose() 
	for i, name in ipairs(data.windows) do
		WindowDelete(name)
	end
end

function OnPluginTick()
	clearWindow()
end
	
]]>
</script>


</muclient>



NOTE: This is definetly not any way that anyone should update their miniwindow, this is not at all performance-friendly.

Edit: Changed to escape bracket-sequences.
Amended on Sat 30 Jul 2011 12:09 PM by Mr.lundmark
USA Global Moderator #7
data.x_size and data.y_size are tables. WindowCreate expects numbers. Perhaps you meant data.x_size[i] or something?
Amended on Sat 30 Jul 2011 12:34 PM by Fiendish
#8
Actually I'm accessing them by using array/table indexing in lua, but the forum seems to parse them away.


Edit: Fixxed that by adding escape-sequence to the brackets.
Amended on Sat 30 Jul 2011 12:11 PM by Mr.lundmark
USA Global Moderator #9
Ok, I see two problems.

First, WindowCreate's 4th and 5th parameters are width/height not right-x, bottom-y, so use

data.x_size[i]

instead of

data.x_size[i] + offset_x


And second, you're not using the flag to specify that you want exact positioning. The 7th parameter should be 2 instead of 0.
#10
That fixxed my problems!

Thanks a bunch!