Page 3 of 3

Re: mini windows GUI

Posted: Sat Aug 14, 2010 7:36 am
by Omit
have made some progress on drawing maps... thought I would share what I have... as It could be useful.

So far... I have written 2 functions for my map window

The first creates all the labels that could be used in the map
Code: [show] | [select all] lua
function CreateMAP()
nwse = gfx_path.. "/nwse.png" 
ns = gfx_path.. "/ns.png" 
nesw = gfx_path.. "/swne.png" 
ew = gfx_path.. "/ew.png" 
local maxWIDE = 11
local maxHIGH = 11
local SX = (1)
local SY = (1)--cgrid

local x = 1
local y = 1
while y <= maxHIGH do
while x <= maxWIDE do
--nw --WATER DIRS
createLabel("Wnw"..x.."."..y,SX,SY,10,10,1);setBackgroundColor("Wnw"..x.."."..y, 100,149,237,200);
--n
createLabel("Wn"..x.."."..y,SX+10,SY,10,10,1);setBackgroundColor("Wn"..x.."."..y,100,149,237,200);
hideWindow("Wn"..x.."."..y);
--ne
createLabel("Wne"..x.."."..y,SX+20,SY,10,10,1);setBackgroundColor("Wne"..x.."."..y, 100,149,237,200);
hideWindow("ne"..x.."."..y);
--w
createLabel("Ww"..x.."."..y,SX,SY+10,10,10,1);setBackgroundColor("Ww"..x.."."..y,100,149,237,200);
hideWindow("Ww"..x.."."..y);
--e
createLabel("We"..x.."."..y,SX+20,SY+10,10,10,1);setBackgroundColor("We"..x.."."..y,100,149,237,200);
hideWindow("We"..x.."."..y);
--sw
createLabel("Wsw"..x.."."..y,SX,SY+20,10,10,1);setBackgroundColor("Wsw"..x.."."..y, 100,149,237,200);
hideWindow("Wsw"..x.."."..y);
--s
createLabel("Ws"..x.."."..y,SX+10,SY+20,10,10,1);setBackgroundColor("Ws"..x.."."..y,100,149,237,200);
hideWindow("Ws"..x.."."..y);
--s
createLabel("Wse"..x.."."..y,SX+20,SY+20,10,10,1);setBackgroundColor("Wse"..x.."."..y, 100,149,237,200);
hideWindow("Wse"..x.."."..y);

--nw -- MAIN DIRS
createLabel("nw"..x.."."..y,SX,SY,10,10,1);setBackgroundColor("nw"..x.."."..y, 0,0,0,0);setBackgroundImage("nw"..x.."."..y,nwse);
hideWindow("nw"..x.."."..y);
--n
createLabel("n"..x.."."..y,SX+10,SY,10,10,1);setBackgroundColor("n"..x.."."..y, 0,0,0,0);setBackgroundImage("n"..x.."."..y,ns );
hideWindow("n"..x.."."..y);
--ne
createLabel("ne"..x.."."..y,SX+20,SY,10,10,1);setBackgroundColor("ne"..x.."."..y, 0,0,0,0);setBackgroundImage("ne"..x.."."..y,nesw);
hideWindow("ne"..x.."."..y);
--w
createLabel("w"..x.."."..y,SX,SY+10,10,10,1);setBackgroundColor("w"..x.."."..y, 0,0,0,0);setBackgroundImage("w"..x.."."..y,ew );
hideWindow("w"..x.."."..y);
--e
createLabel("e"..x.."."..y,SX+20,SY+10,10,10,1);setBackgroundColor("e"..x.."."..y, 0,0,0,0);setBackgroundImage("e"..x.."."..y,ew );
hideWindow("e"..x.."."..y);
--sw
createLabel("sw"..x.."."..y,SX,SY+20,10,10,1);setBackgroundColor("sw"..x.."."..y, 0,0,0,0);setBackgroundImage("sw"..x.."."..y,nesw );
hideWindow("sw"..x.."."..y);
--s
createLabel("s"..x.."."..y,SX+10,SY+20,10,10,1);setBackgroundColor("s"..x.."."..y, 0,0,0,0);setBackgroundImage("s"..x.."."..y,ns);
hideWindow("s"..x.."."..y);
--s
createLabel("se"..x.."."..y,SX+20,SY+20,10,10,1);setBackgroundColor("se"..x.."."..y, 0,0,0,0);setBackgroundImage("se"..x.."."..y,nwse);
hideWindow("se"..x.."."..y);
--Room
createLabel("RoomH"..x.."."..y,SX+1,SY+1,3,3,1);
setBackgroundColor("RoomH"..x.."."..y,0,0,0,0);
hideWindow("RoomH"..x.."."..y)
createLabel("Room"..x.."."..y,SX+1,SY+1,3,3,1);
setBackgroundColor("Room"..x.."."..y, 	85,107,47,255);
hideWindow("Room"..x.."."..y)

createLabel("RoomA"..x.."."..y,SX+1,SY+1,3,3,1);
setBackgroundColor("RoomA"..x.."."..y,0,0,0,0);
hideWindow("RoomA"..x.."."..y)
x=x+1
end--while x
x=1
y=y+1
end--while y
echo("created map")
end
This function draws a single room
Code: [show] | [select all] lua
function DrawLoc(Reg,Add,Wat,winx,winy,xS,yS,Gsize,Highlight)
--nw  --begin water
local x = winx
local y = winy
local OffsetR = (Gsize*.21875)
local OffsetH = OffsetR - 2
local OffsetA = OffsetR - 1

local RoomSize = Gsize -(OffsetR*2)
local RoomSizeH = Gsize -(OffsetH*2)
local RoomSizeA = Gsize -(OffsetA*2)

local AddD = nil
local t = Wat
if string.find (t, " ne ") then
moveWindow("Wne"..x.."."..y,xS+Gsize-10,yS);
showWindow("Wne"..x.."."..y);
else
hideWindow("Wne"..x.."."..y);
end -- if
if string.find (t, " n ") then
moveWindow("Wn"..x.."."..y,xS+(Gsize/2)-5,yS);
showWindow("Wn"..x.."."..y);
else
hideWindow("Wn"..x.."."..y);
end -- if
if string.find (t, " nw ") then
moveWindow("Wnw"..x.."."..y,xS,yS);
showWindow("Wnw"..x.."."..y);
else
hideWindow("Wnw"..x.."."..y);
end -- if
if string.find (t, " e ") then
moveWindow("We"..x.."."..y,xS+Gsize-10,yS+(Gsize/2)-5);
showWindow("We"..x.."."..y);
else
hideWindow("We"..x.."."..y);
end -- if
if string.find (t, " w ") then
moveWindow("Ww"..x.."."..y,xS,yS+(Gsize/2)-5);
showWindow("Ww"..x.."."..y);
else
hideWindow("Ww"..x.."."..y);
end -- if
if string.find (t, " se ") then
moveWindow("Wse"..x.."."..y,xS+Gsize-10,yS+Gsize-10);
showWindow("Wse"..x.."."..y);
else
hideWindow("Wse"..x.."."..y);
end -- if
if string.find (t, " s ") then
moveWindow("Ws"..x.."."..y,xS+(Gsize/2)-5,yS+Gsize-10);
showWindow("Ws"..x.."."..y);
else
hideWindow("Ws"..x.."."..y);
end -- if
if string.find (t, " sw ") then
moveWindow("Ws"..x.."."..y,xS+(Gsize/2)-5,yS+Gsize-10);
showWindow("Ws"..x.."."..y);
else
hideWindow("Ws"..x.."."..y);
end -- if
if string.find (t, " u ") then
AddD = 1
end -- if
if string.find (t," d ") then
AddD = 1
end -- if
local t = Reg
if string.find (t, " ne ") then
moveWindow("ne"..x.."."..y,xS+Gsize-10,yS);
showWindow("ne"..x.."."..y);
else
hideWindow("ne"..x.."."..y);
end -- if
if string.find (t, " n ") then
moveWindow("n"..x.."."..y,xS+(Gsize/2)-5,yS);
showWindow("n"..x.."."..y);
else
hideWindow("n"..x.."."..y);
end -- if
if string.find (t, " nw ") then
moveWindow("nw"..x.."."..y,xS,yS);
showWindow("nw"..x.."."..y);
else
hideWindow("nw"..x.."."..y);
end -- if
if string.find (t, " e ") then
moveWindow("e"..x.."."..y,xS+Gsize-10,yS+(Gsize/2)-5);
showWindow("e"..x.."."..y);
else
hideWindow("e"..x.."."..y);
end -- if
if string.find (t, " w ") then
moveWindow("w"..x.."."..y,xS,yS+(Gsize/2)-5);
showWindow("w"..x.."."..y);
else
hideWindow("w"..x.."."..y);
end -- if
if string.find (t, " se ") then
moveWindow("se"..x.."."..y,xS+Gsize-10,yS+Gsize-10);
showWindow("se"..x.."."..y);
else
hideWindow("se"..x.."."..y);
end -- if
if string.find (t, " s ") then
moveWindow("s"..x.."."..y,xS+(Gsize/2)-5,yS+Gsize-10);
showWindow("s"..x.."."..y);
else
hideWindow("s"..x.."."..y);
end -- if
if string.find (t, " sw ") then
moveWindow("s"..x.."."..y,xS+(Gsize/2)-5,yS+Gsize-10);
showWindow("s"..x.."."..y);
else
hideWindow("s"..x.."."..y);
end -- if
if string.find (t, " u ") then
AddD = 1
end -- if
if string.find (t," d ") then
AddD = 1
end -- if
if Highlight == 1 then
setBackgroundColor("RoomH"..x.."."..y,184,134,11,145);
resizeWindow( "RoomH"..x.."."..y  , Gsize, Gsize )
moveWindow("RoomH"..x.."."..y,xS,yS);
setBackgroundColor("RoomA"..x.."."..y,178,34,34,255);
resizeWindow( "RoomA"..x.."."..y  , RoomSizeH, RoomSizeH )
moveWindow("RoomA"..x.."."..y,xS+OffsetH,yS+OffsetH);
--setBackgroundColor("Room"..x.."."..y,0,100,0,255);
--resizeWindow( "Room"..x.."."..y  , RoomSizeA, RoomSizeA )
--moveWindow("Room"..x.."."..y,xS+OffsetA,yS+OffsetA);
else
setBackgroundColor("RoomH"..x.."."..y,184,134,11,255);
resizeWindow( "RoomH"..x.."."..y  , RoomSizeH, RoomSizeH )
moveWindow("RoomH"..x.."."..y,xS+OffsetH,yS+OffsetH);
--setBackgroundColor("RoomA"..x.."."..y,178,34,34,255);
--resizeWindow( "RoomA"..x.."."..y  , RoomSizeA, RoomSizeA )
--moveWindow("RoomA"..x.."."..y,xS+OffsetA,yS+OffsetA);
setBackgroundColor("Room"..x.."."..y,0,100,0,255);
resizeWindow( "Room"..x.."."..y  , RoomSize, RoomSize )
moveWindow("Room"..x.."."..y,xS+OffsetR,yS+OffsetR);
end
showWindow("RoomH"..x.."."..y)
showWindow("RoomA"..x.."."..y)
showWindow("Room"..x.."."..y)
echo("test")
end
function DrawLoc(Reg,Add,Wat,winx,winy,xS,yS,Gsize,Highlight)
Reg = reg dirs (n,s,e,w,nw,ne,sw,se) in a space delimited format with spaces leading and trailing(this makes parsing text very easy) Example: Reg = " n e s "
Add = this is for additional exits like up,down,in can be marked, I have commented it out for now
Wat = water exits in the same format as the reg dirs
winx,winy allow you to choose what label to use
xS,xY is the location on the main window you want to draw it
Gsize = size in pixels you want the overall size of the room drawn (looks decent from 18-30)
Highlight = 1 or 0 (1 = highlight room)

You must call the CreateMAP() function first (and I would only do it once... it takes a few seconds... least on my old machine)

Examples:
DrawLoc(" n e w sw se ",""," s e se sw ",1,1,700,400,30,0)
DrawLoc(" n e w ne nw ",""," s e se sw ",1,1,700,400,30,1)
Screenshot-Mudlet 1.1.0 March 2010.png
Screenshot-Mudlet 1.1.0 March 2010.png (4.62 KiB) Viewed 5409 times
still not a full mapper but it is getting close

Re: mini windows GUI

Posted: Sat Aug 14, 2010 11:26 am
by Vadi
very nice looking

Re: mini windows GUI

Posted: Tue Aug 24, 2010 7:23 am
by Omit
More Progress.... it Maps!!!!!
I am using an ascii map for anything on the "main grid" of the mud I play and a graphical mapper for anything "off" the grid (quests, towns, .....)

The Ascii map....
Screenshot-Mudlet 1.1.0 March 2010-maingrid.png
the Graphical Map... (I like the looks of the ascii map and am using it for a background... not sure about the colors yet)
Screenshot-Mudlet 1.1.0 March 2010-GRaphical.png
...still alot to do before it's really very useful but it does map!

Re: mini windows GUI

Posted: Tue Aug 24, 2010 12:33 pm
by Vadi
Heh that's pretty nice already

Re: mini windows GUI

Posted: Sun Dec 12, 2010 9:32 pm
by Omit
I have been playing around with the 3D mapper and converting my 2d map to work with it...
thought I would share my progress....
Screenshot.png
I have had to work around a few things to make this work but I think after the next update to the git I can rewrite it and make the 2d map generic enough to work with any 3d map file.

Re: mini windows GUI

Posted: Thu Mar 03, 2011 3:28 am
by Omit
Just thought I would share a couple screen shots of what I am working on... (map scripting still needs a few tweaks before it is posted)
Screenshot-Mudlet 2.0-rc1 January 2011.png
Color chooser to change room color (all rooms with the same short description get the same color)
Color chooser to change room color (all rooms with the same short description get the same color)