mini windows GUI

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: mini windows GUI

Post by Omit »

Some Progress!!

I just finished my proof of concept for drawing a map....
this is done with labels and 4 custom graphics....
it will need logic written into it and tied into a database but mapping is possible now
Code: [show] | [select all] lua
function TESTMAP()
WindowWidth, WindowHeight = getMainWindowSize();
gfx_path = "/home/woodapple/gfx";
nwse = gfx_path.. "/nwse.png" 
ns = gfx_path.. "/ns.png" 
nesw = gfx_path.. "/swne.png" 
ew = gfx_path.. "/ew.png" 
grid = 30
WIDE = 5
HIGH = 5
RoomOffSet = 5
RoomSize = grid-(RoomOffSet*2)
x = 1
y = 1
while y <= HIGH do
while x <= WIDE do
SX = (WindowWidth-18)-(grid * WIDE)+((x-1)*grid)
SY = (y*grid)-grid
--nw
hideWindow("nw"..x.."."..y)
createLabel("nw"..x.."."..y,SX,SY,10,10,1);
setBackgroundImage("nw"..x.."."..y,nwse );
setBackgroundColor("nw"..x.."."..y, 0,0,0,0);
showWindow("nw"..x.."."..y);
--n
hideWindow("n"..x.."."..y)
createLabel("n"..x.."."..y,SX+10,SY,10,10,1);
setBackgroundImage("n"..x.."."..y,ns );
setBackgroundColor("n"..x.."."..y, 0,0,0,0);
showWindow("n"..x.."."..y);
--ne
hideWindow("ne"..x.."."..y)
createLabel("ne"..x.."."..y,SX+20,SY,10,10,1);
setBackgroundImage("ne"..x.."."..y,nesw );
setBackgroundColor("ne"..x.."."..y, 0,0,0,0);
showWindow("ne"..x.."."..y);
--w
hideWindow("w"..x.."."..y)
createLabel("w"..x.."."..y,SX,SY+10,10,10,1);
setBackgroundImage("w"..x.."."..y,ew );
setBackgroundColor("w"..x.."."..y, 0,0,0,0);
showWindow("w"..x.."."..y);
--e
hideWindow("e"..x.."."..y)
createLabel("e"..x.."."..y,SX+20,SY+10,10,10,1);
setBackgroundImage("e"..x.."."..y,ew );
setBackgroundColor("e"..x.."."..y, 0,0,0,0);
showWindow("e"..x.."."..y);
--sw
hideWindow("sw"..x.."."..y)
createLabel("sw"..x.."."..y,SX,SY+20,10,10,1);
setBackgroundImage("sw"..x.."."..y,nesw );
setBackgroundColor("sw"..x.."."..y, 0,0,0,0);
showWindow("sw"..x.."."..y);
--s
hideWindow("s"..x.."."..y)
createLabel("s"..x.."."..y,SX+10,SY+20,10,10,1);
setBackgroundImage("s"..x.."."..y,ns);
setBackgroundColor("s"..x.."."..y, 0,0,0,0);
showWindow("s"..x.."."..y);
--s
hideWindow("se"..x.."."..y)
createLabel("se"..x.."."..y,SX+20,SY+20,10,10,1);
setBackgroundImage("se"..x.."."..y,nwse);
setBackgroundColor("se"..x.."."..y, 0,0,0,0);
showWindow("se"..x.."."..y);
--Room
hideWindow("Room"..x.."."..y)
createLabel("Room"..x.."."..y,SX+RoomOffSet,SY+RoomOffSet,RoomSize,RoomSize,1);
setBackgroundColor("Room"..x.."."..y,79,121,66,255);
showWindow("Room"..x.."."..y);

x=x+1
end--while x
x=1
y=y+1
end--while y
end
...I did notice that although you can hide/change any one of the labels they cannot be moved.... once they have been drawn on the screen you cannot hide them and create them at a new location, this is not a huge deal but does mean that if you want to resize this map(change how many rooms it displays) you have to make the change, close mudlet and reopen it.
Attachments
Screenshot-Mudlet 1.1.0 March 2010.png

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: mini windows GUI

Post by tsuujin »

Actually, you can move labels and resize them after creation. You just use moveWindow(label,x,y) and resizeWindow(label,w,h)

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: mini windows GUI

Post by Heiko »

You can hide/show, move and resize labels, but you cannot destroy and recreate them under the same name.
What I'd suggest in your case is to make use of tranparency, layering and setting the room color of the top layer via css when your map changes.

If your use case is too complex then I'll add a few drawing functions to the next release.

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: mini windows GUI

Post by Omit »

Thanks... I looked into that (yeah! I can move it if the window resizes!)....

I think the labels will work fine... the only problem I see is using custom graphics... it means that others are not able to reuse my code without changing it (they need to enter the path to their graphic folder) Are there any functions like.... GetCurrentPlatform, getCurrentSystemUsername? with these functions we should be able to write a script to get graphics from a default location(where ever that should be.)

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: mini windows GUI

Post by Heiko »

There are functions that open a file dialog and let the user pick a folder or file of his choice and return the chosen file path. This makes it easy to let the user pick the path to your custom graphics folder on first use via an install script.
To get the directory that the respective profile is stored in check getMudletHomeDir(). That can also be used to determine the platform as it returns the platform specific correct path.
The upcoming new release also ships Lua file system libraries to allow for better install scripts.

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: mini windows GUI

Post by Omit »

Ok... I am making progress (MUDlet really is a joy to write in) however....
I can't figure out how to label my buttons...(In screenshot left is a custom graphic right is in css style)
If I use a custom graphic I can't seem to write my text over it and still see my graphic (is there a way to make that text transparent?)

or...

I kind of like the css styles but have no experience with them and have not been able to figure out how to insert my variable into the [[]] tags. (can I insert variable text into a css style sheet? how about a border? have tried both and failed)

Any advice anyone can give would be appreciated.

Thanks,
Omit

(Oh... I really do love MUDlet and the more I use it the more I love it. I was able to recreate the navagation miniwindow in a fraction of the time It took in mush... it captures exits, draws them on the screen, everything clickable, and assigns the corresponding commands to the keypad keys.... I will post a copy once I work out the last couple of issues with it.)
Attachments
Screenshot-Mudlet 1.1.0 March 2010-1.png

User avatar
Vadi
Posts: 5050
Joined: Sat Mar 14, 2009 3:13 pm

Re: mini windows GUI

Post by Vadi »

You can put labels on top of labels and give them transparency, and you can embed variable info in block tags with:
Code: [show] | [select all] lua
string = [[hello, ]] .. name .. ..[[!]]
or:
Code: [show] | [select all] lua
string = string.format([[hello, %s!]], name)

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: mini windows GUI

Post by Omit »

OK, my navigation window has been recreated and has all the functionality of my old one :)

There is just one more thing I want to add... the ability to move it by clicking and dragging it with the mouse.

I am trying to do this the following way....
created a label in the upper right hand corner(the little red dot in the screenshot) when clicked it raises a sysWindowMousePressEvent than using the sysWindowMouseReleaseEvent assign a new starting position for the "navigation window"

the problem I am having is that I cannot seem to raise any of the main window click events (with the raise event function or without)...
Code: [show] | [select all] lua
function onClickHandler( event, button, x, y )
        echo("CLICK event:"..event.." button="..button.." x="..x.." y="..y.."\n")
end
...and this doesn't seem to work either :(

(thank you vadi... I now have buttons that look acceptable to me :) )
Attachments
Screenshot-Mudlet 1.1.0 March 2010-2.png
Screenshot-Mudlet 1.1.0 March 2010-2.png (62.58 KiB) Viewed 8132 times

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: mini windows GUI

Post by Heiko »

To handle mouse press and release events you need to add 2 script items that explicitly handle these 2 events as Mudlet will try to call these 2 scripts if such a sys event happens. If you have no event handler scripts, nothing will happen.

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: mini windows GUI

Post by Omit »

I'm not sure how to do that.... one of the reasons I have written a mapper for the mud I play is to learn a bit more programming than I do(which is limited, I develop databases using filemaker pro) ...
I have looked though the manual and the examples posted but have not been unable to figure this out (somehow the resize event seems fine, but I had an example for that one...although it looks like something changed and the way it's done is no longer preferred?)

Could you point me in the right direction?

Post Reply