Adding Main Menu and Start Screen stuff Help.

Blitz3D Forums/Blitz3D Programming/Adding Main Menu and Start Screen stuff Help.

Dose anyone know a good way to add Start screens and Main Menu selections into the game engine?

Would it be VIA from an editor or hard code one as an Include and compile it when compiling the game engine code.

How do Pro engines like Quake and Doom allow you to do this in there engines ?

My trouble is there is so many ways Main menus and start screens can be made that trying to code a program to run in my editor that is flexible enough to create any type of start screen and menus seems way way to intensive almost like a Menu and Start screen Editor within it self.

Any Ideas.

My last idea was to just leave this part Blank in the engine with a default type start screen and Menu selection, then to change it just add an Include into the main code that will take over if present.
What I don't like is that this way you would need to recompile the whole engine to make it work.

I can't seem to see any other way to make it as flexible as possible.

I know Im a little vague, If you are having trouble understanding what Im referring to let me know and Ill do my best to help clear things up.


Thanks for any help at all
Stickman......

code it yourself. one way is to use an image and just create hotspots (like on a web page) by detecting where the mouse button was hit.

or...

try a 3rd party gui like alpha gui.

There was another post about this recently with helpful suggestions in it. Maybe try doing a search.

Hard coding it is by far the easiest.

What it sounds like you want to do would in most cases I think not justify the amount of effort put into it.

Just the Difference between 2D and 3D screens is a lot then to go further and mix them together.

I agree with Bradford. Creating a simple 'imagemap' system is the easiest. In fact, I'm writing a entire single surface 3D gui system based on html client side 'imagemap' files.

They're many Free ImageMap Editors that output html map files defining the hotspots. So you just load your image, draw your hotspots, and save. I've written a simple html map parser. It will only recognize RECTangle shaped hotspots, but its a simple start.

Copy the image and code and give it a try!

test.jpg


ImageMap.bb
;ImageMap by Frankie 'TechLord' Taylor 12/06/2004

Const IMAGEMAP_AREA_MAX%=256

Global imagemapCurrent.imagemap

Type imagemap
	;Purpose: Store Image and HotSpots
	Field id%
	Field name$
	Field x#
	Field y#
	Field imgsrc$
	Field image%
	Field hotspots%
	Field hotspot.hotspot[IMAGEMAP_AREA_MAX%]
	Field state%
End Type

Type hotspot
	;Purpose: Stores Coords, target, and command information
	Field id%
	Field typeid%
	Field coord[3]
	Field target$
	Field command$
	Field state%
End Type

Function imagemapLoad.imagemap(imagemapname$,imagemapfilename$,imagemapsrcname$="")
	;Purpose: Parses html client side imagemap file.
	;Parameters:
	;	imagemapname$ - name of imagemap. Can be used for reference purposes.
	;	imagemapfilename$ - html map file name, *.htm extension not required.
	;	imagemapsrcname$ - image file name. Valid map format extension required.	
	;Return:
	imagemapfile%=OpenFile(imagemapfilename+".htm") ;*.map
	If Not imagemapfile% Return Null
	While Not Eof(imagemapfile%)
		imagemapfileline$=Lower(ReadLine(imagemapfile%))
		imagemapfilelinelength%=Len(imagemapfileline$)
		
		For loop% = 1 To imagemapfilelinelength%
			imagemapchar$=Mid$(imagemapfileline$,loop%,1)
		
			Select imagemapchar$
				Case " ","<",">","=",Chr(34),Chr(39)
					;ignor whitespace and tags	
					imagemapword$=nil$			
				Default
					imagemapword$=imagemapword$+imagemapchar$
			End Select
	
			Select imagemapword$
			
				Case "name"
					this.imagemap=New imagemap
					this\imgsrc$=imagemapsrcname$					
					this\image%=LoadImage(this\imgsrc$)
					this\name$=imagemapname$
					this\state%=1

				Case "area" 
					this\hotspots%=this\hotspots%+1
					this\hotspot[this\hotspots%] = New hotspot
					hotspot.hotspot=this\hotspot[this\hotspots%]  ;testing
					
				Case "coords" ;coords define shape, rect by by limitation
					For loop% = loop%+1 To imagemapfilelinelength%
						imagemapchar$=Mid$(imagemapfileline$,loop%,1)
						Select imagemapchar$
							Case "="," "
								hotspotcoord%=0
								imagemapword$=nil$		
							Case ","
								this\hotspot[this\hotspots%]\coord[hotspotcoord%]=imagemapword$
								hotspotcoord%=hotspotcoord%+1
								imagemapword$=nil$
							Case Chr(34),Chr(39);quotes
								If hotspotcoord%>0 Or imagemapword$<>nil$
									this\hotspot[this\hotspots%]\coord[hotspotcoord%]=imagemapword$								
									Exit
								EndIf	
							Default
								imagemapword$=imagemapword$+imagemapchar$	
						End Select
					Next
					
				Case "href" ;command$
					For loop% = loop%+1 To imagemapfilelinelength%
						imagemapchar$=Mid$(imagemapfileline$,loop%,1)
						Select imagemapchar$
							Case "="," "
								imagemapword$=nil$
							Case Chr(34),Chr(39);quotes
								If imagemapword$<>nil$
									this\hotspot[this\hotspots%]\command$=imagemapword$
									Exit
								EndIf	
							Default 
								imagemapword$=imagemapword$+imagemapchar$	
						End Select
					Next
					
				Case "target" 
					For loop% = loop%+1 To imagemapfilelinelength%
						imagemapchar$=Mid$(imagemapfileline$,loop%,1)
						Select imagemapchar$
							Case "="," "
								imagemapword$=nil$
							Case Chr(34),Chr(39);quotes
								If imagemapword$<>nil$
									this\hotspot[this\hotspots%]\target$=imagemapword$
									Exit
								EndIf	
							Default 
								imagemapword$=imagemapword$+imagemapchar$	
						End Select
					Next
						
			End Select
		Next	
	Wend
	Return this
End Function

Function imagemapDestroy(this.imagemap)
	;Purpose: Removes imagemap, hotspots, and image from memory
	;Parameters: imagemap object
	;Return: none
	If this<>Null
		For loop = 1 To hotspots%
			If this\hotspot[loop%]<>Null
				Delete this\hotspot[loop%] 
			EndIf
		Next
		If this\image% FreeImage(this\image)
		Delete this
	EndIf
End Function

Function imagemapUpdate()
	;Purpose: Checks for mouse and hotspot events. called in main loop
	;Parameters: none
	;Return: none
	this.imagemap=imagemapCurrent
	If imagemapCurrent\state%
		
		If this\image DrawBlock(this\image%,this\x,this\y)
		
		;check mouse and hotspot events
		For loop% = 1 To this\hotspots%
			
			If MouseX()>=this\hotspot[loop%]\coord%[0] And MouseX()<this\hotspot[loop%]\coord%[2] 
				If MouseY()>=this\hotspot[loop%]\coord%[1] And MouseY()<this\hotspot[loop%]\coord%[3] 
					
					Color 0,255,0
					
					If MouseDown(1)
						
						Color 255,0,0 ; do something
						 								
					EndIf
					
					Rect this\hotspot[loop%]\coord%[0],this\hotspot[loop%]\coord%[1],this\hotspot[loop%]\coord%[2]-this\hotspot[loop%]\coord%[0],this\hotspot[loop%]\coord%[3]-this\hotspot[loop%]\coord%[1],0
					
				EndIf
			EndIf	
		Next
	EndIf
End Function


;DEMO ==========================================================================================
.MAIN
Graphics 512,256,16,2
SetBuffer(BackBuffer())

;load a imagemap
imagemapCurrent=imagemapLoad("test","test","test.jpg")

While Not KeyDown(1)
	imagemapUpdate()
	Flip()
Wend

imagemapDestroy(imagemapCurrent)

End


test.htm
<BODY>
<MAP NAME="">
<!-- #$-:Image Map file created by Map THIS! -->
<!-- #$-:Map THIS! free image map editor by Todd C. Wilson -->
<!-- #$-:Please do not edit lines starting with "#$" -->
<!-- #$VERSION:1.30 -->
<!-- #$DATE:Mon Dec 06 04:34:48 2004 -->
<!-- #$PATH:C:\Program Files\Blitz3D\myprojects\ppf2k4.5\game\fps\client\ui\ -->
<!-- #$GIF:test.jpg -->
<AREA SHAPE=RECT COORDS="281,86,484,109" HREF="#" TARGET="none">
<AREA SHAPE=RECT COORDS="318,122,486,145" HREF="#" TARGET="none">
<AREA SHAPE=RECT COORDS="335,156,486,179" HREF="#" TARGET="none">
<AREA SHAPE=RECT COORDS="362,190,487,213" HREF="#" TARGET="none">
</MAP></BODY>


Html Map file generated with Map This! 1.3

I was going to say(something like) that!

Check out Chroma's system... I use it, although it's now heavily modified. You can find the link to Chroma's original stuff (I'm hosting it) from this thread:

http://www.blitzbasic.com/Community/posts.php?topic=24972

You will most likely want more than just hotspots. You may desire to flip images on mouseevents, play sound, use scroll bars, fades, etc. HTML Image Maps can meet the need. I started with Image Map Code above, and I'm developing a more advanced GUI System based on it and JimB's ImagePacker & SpriteMasterPro.

GUI Editing was the factor for me. If you dont want to use the traditional Windows-style controls and available GUI Libs (which usually feature an Editor), you will find yourself drawing the menus and organizing buttons manually. There are plenty of FREE Editors to draw images and organize ImageMap hotspots.