Vyzor, UI Manager for Mudlet

Share your scripts and packages with other Mudlet users.
Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Delrayne »

for my parry buttons, I just simply used a seperate duplicated image that was red instead of blue to show which limbs were being parried and which weren't. Clicking it removed the image, or in my case border since they scale better, and then immediately added the new border to it.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Caled »

Code: [show] | [select all] lua
-------------------------------------------------
--                   Lyric					 --
--                                             --
--                 Namespace "lyr"             --
-------------------------------------------------

lyr = lyr or {}


--        Set the border frame sizes
lyr.borderframes = {}
lyr.borderframes.left = { 
	size = 0.29,
}
lyr.borderframes.right = {
	size = 0.36,
}
lyr.borderframes.top = {
	size = 0.055,
}
lyr.borderframes.bottom = {
	size = 0.11,
}
lyr.borderframes.editcol = { mode = "RGBA",		r = 50, g = 50, b = 50, a = 150,	}
lyr.borderframes.realcol = { mode = "RGBA",		r = 10, g = 10, b = 10, a = 200,	}



function lyr.borderframes:build()
	local bf = lyr.borderframes
	Vyzor.Options.Borders = {Top = bf.top.size, Bottom = bf.bottom.size, Left = bf.left.size, Right = bf.right.size }
--	Vyzor.HUD:Draw()
end
lyr.borderframes:build()

function lyr.borderframes:colour(col)
	local col = lyr.borderframes[col]
	local colour = Vyzor.Color( Vyzor.ColorMode[col.mode], col.r, col.g, col.b, col.a )
	local brush = Vyzor.Brush( colour )
	local background = Vyzor.Background( brush )

	Vyzor.HUD.Frames["VyzorBottom"]:Add( background )
	Vyzor.HUD.Frames["VyzorTop"]:Add( background )
	Vyzor.HUD.Frames["VyzorLeft"]:Add( background )
	Vyzor.HUD.Frames["VyzorRight"]:Add( background )
end

lyr.borderframes:colour("editcol")
I'm experimenting with a framework where I store the properties of my GUI in my own table, and build the GUI from that using Vyzor. I have reasons for wanting to do it this way, but I've hit a speedbump at step two of my plan (which is currently a lot longer than 2 steps hehe).

The above script sets the borders as intended (though I do need to call Vyzor.HUD:Draw() before it will update any changes I make when tweaking the sizes).

Then, it does colour each border frame a light grey colour as intended (the 'editcol' is there purely to make it easier to resize things that don't have borders yet). BUT...

After it sets the background once, I get this error:
Lua syntax error:[string "-------------------------------------------..."]:42: Vyzor: VyzorBottom
(Frame) already contains Component (Background).

It seems to be adding multiple frames, or multiple backgrounds to the one frame, as it gets darker and darker (note the transparency value of 150)

I've found hints of the answer in the wiki, but I can't figure it out; how do I:
1. Check if a background has already been set?
2. Change an existing background rather than attempting to add another over it?

Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Delrayne »

A frame can only have ONE instance of a component in it. Components are Images, Borders, Backgrounds etc... Meaning you CAN'T have two borders in a frame, but you CAN have one border, one image, and one background in a frame. To use only one frame, the frame:Remove() and frame:Add() functions are the only way to accomplish this that I know of. You could accomplish this with multiple frames using frame:Show() and frame:Hide() instead.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Caled »

Delrayne wrote:A frame can only have ONE instance of a component in it. Components are Images, Borders, Backgrounds etc... Meaning you CAN'T have two borders in a frame, but you CAN have one border, one image, and one background in a frame. To use only one frame, the frame:Remove() and frame:Add() functions are the only way to accomplish this that I know of. You could accomplish this with multiple frames using frame:Show() and frame:Hide() instead.
I only want ONE background component.
But clearly, something I am doing is causing multiple background components, perhaps by creating multiple frames.
I can't work out how to not do it. If a component already exists, I want to simply change it rather than adding a new one to a new frame and layering it over the top.

I've been trying to get frame:Remove() to work, but in my above script, how do I use it? The API wiki page says:
frame:Remove( object )

object
The object to be removed. This will be a string or a Vyzor object.

You may remove Frames by name or Components by type by passing a string. This is probably the easiest method.

Otherwise, you can pass an object (Frame, Component, or Compound) and Vyzor will remove an object by name or type. Currently, it seems I messed up somewhere and Compounds can only be removed by passing an object. Will be fixed someday.
But I don't understand how to use it. frame:Remove() isn't used in any of Oneymus's test aliases.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Caled »

Thanks to Vadi, I worked it out. The problem was me applying a component directly to the predefined border frames. The answer is to create frames the same size as each of those frames, and manipulate the newly created frames instead. :D

Thanks all

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Caled »

I have one last question before I call it a day. It's about syntax.

The API wiki talks about 'properties'. For example:
Name

Returns the Frame's name.
How do I use this to actually return a frame's name (or another property to return some more useful information). It seems that it will be really handy when searching for bugs in my scripting, to be able to access information on exactly what a frame is doing, and compare that to what I think I am telling it to do.

For example, if I could see a list of child frames with the 'frames' property, I could easily see instances where I have created a frame inside the wrong parent frame.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Oneymus »

Adding Components to the Border Frames is fine. It isn't necessary to create a new Frame over them (though you can and that's perfectly okay). To see if a Frame has a Component, you would use its Components property.

Properties work here similar to C#'s Properties. Using metatables, they function as both getters and setters. To get, you would do something like...
Code: [show] | [select all] lua
some_string = Vyzor.Left.Name
some_table = Vyzor.Left.Components
To set (and this is dependent on the individual Property) you would do something like...
Code: [show] | [select all] lua
<frame>.Size.Width = 0.5
As for why you're getting the error with VyzorBottom, I'm not sure. Is that function being called multiple times? Did you first use any of the test Aliases? Vyzor doesn't preload any of the Frames with content.

As for Remove. Remove's one argument is either the name of a Frame, or the type of a Component. Says it right there in what you quoted.

I will eventually add a Replace function. For now, you have to check if a Component exists first.
Code: [show] | [select all] lua
if Vyzor.Left.Components["Background"] then
  Vyzor.Left:Remove( "Background" )
end
Vyzor.Left:Add( some_background )
And, finally, using your own table(s) to build your GUI is perfectly fine, and I might even recommend it.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Caled »

Oneymus wrote: As for why you're getting the error with VyzorBottom, I'm not sure. Is that function being called multiple times? Did you first use any of the test Aliases? Vyzor doesn't preload any of the Frames with content.
...
And, finally, using your own table(s) to build your GUI is perfectly fine, and I might even recommend it.
Thanks for the reply.
Yes, the function was being called more than once, with the intention of doing so to change the background colour. Giving it a temporary, grey, translucent background allows me to resize things while I get them all to fit. Then when happy, it can go back to being black.

When I add the component to a frame I have created, I can run that function as many times as I want. When I add it to the predefined border frame, I get the error. Your explanation about how to check for and then remove a component (I was making a syntactical error when I tried, as it turns out) would let me work directly on the border frame, but for other reasons I think I will stick with the way I'm doing it now (it might be useful as some point to be able to :Hide() my entire gui, and that would make it easier to do so).


----------
Do you know why it takes so long for the gui to resize with the map window in the mix? I'm assuming it is a Mudlet thing, but I'm just wondering. It might be nice in the future to be able to hide/rearrange the gui dynamically for different tasks while playing, such as hunting vs crafting vs duelling vs warfare.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Oneymus »

The map slowdown is a Mudlet thing. No fix for it on our end.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Caled »

I almost managed to make it through an evening of Vyzoring without a question... almost. :?

Image

On the top right, you can see me making a box compound in the grid style.
You'll also notice that of the six rectangles in the box, the bottom two are a different colour.
This is because they have been created outside of the boundary of the box itself - they should all be smaller and inside the boundary (which is width of 1 and height of 0.5, meaning it ought to take up the top 50% of the right hand border frame.)

I'm really struggling to debug this one, but I am wondering if it is the isBounding property. You can see my attempt to check this at the command line, and it does appear that isBounding is set to false but I suspect that it is actually just nil.
(lua if not lyr.skirmish.window.isBounding then echo("\nWOO") end)


Got any ideas?

Post Reply