#include "ui/menudef.h"




{

/////////////////////
//
//	main load/save menu
//
/////////////////////

menuDef {
   	name ingame_save
   	visible 0
   	fullscreen 0
	outOfBoundsClick			// this closes the window if it gets a click out of the rectangle
	rect 80 125 503 300
   	focusColor 1 .75 0 1
   	style 1
   	border 1

	onOpen {	uiScript loadSavegames
				setcvar ui_savegameListAutosave 0;	// hmm
				uiScript update ui_savegameListAutosave
			}


///////////// 


	itemDef {
		name window
		group ingamebox
		rect 0 2 463 300
//		background "ui/assets/testmap1.tga"
//		style WINDOW_STYLE_SHADER
		style WINDOW_STYLE_FILLED
		border 1
		bordercolor .5 .5 .5 .5
		forecolor 1 1 1 1
		backcolor 0 0 0 .25
		visible 1
		decoration
		}


	itemDef 
	{
		name window
		group ingamebox2
		rect 2 4 459 20	
		style WINDOW_STYLE_FILLED
		border 1
		bordercolor .1 .1 .1 .2
		forecolor 1 1 1 1
		backcolor .3 0.5 0.2 .25
		visible 1
		decoration
	}

//////////////// image box ///////////////////

//
// 'episode shot'
//

	itemDef {
		name window
		group ingamebox3
		rect 302 62 148 110
		ownerdraw UI_SAVEGAME_SHOT		// screenshot for savegame.  			//located in /save/images/<savegamename>.tga
//		style WINDOW_STYLE_FILLED
		border 1
		bordercolor .5 .5 .5 .5
		forecolor 1 1 1 1
		backcolor .10 .10 .10 .5
		visible 1
		decoration
		}


	itemDef 
	{
		name window2
		group grpControlbutton
		rect 2 29 298 20	
		style WINDOW_STYLE_FILLED
		border 1
		bordercolor .1 .1 .1 .2
		forecolor 1 1 1 1
		backcolor .3 0.5 0.2 .25
		visible 1
		decoration
	}

	itemDef 
	{
		name window2
		group grpControlbutton
		rect 142 29 140 222	
		style WINDOW_STYLE_FILLED
		border 1
		bordercolor .1 .1 .1 .2
		forecolor 1 1 1 1
		backcolor .3 0.4 0.2 .25
		visible 1
		decoration
	}


////////////////////////////////////////


	itemDef {
		name savegamelist
//		rect 66 150 300 230
//		rect 0 50 300 200
		rect 4 50 296 200
		type ITEM_TYPE_LISTBOX
		style WINDOW_STYLE_FILLED
		elementwidth 120
		elementheight 14
		textscale .23

//		columns 2  2 40 18  170 40 30
		columns 2  2 40 18  142 40 30

		elementtype LISTBOX_TEXT
		feeder FEEDER_SAVEGAMES
//		doubleclick { uiScript Loadgame }
		textalign 3
		textaligny 10
		forecolor .9 .9 .9 .5
		backcolor .2 .2 .2 .3
		outlinecolor .9 .9 .9 .2
		visible MENU_TRUE
		mouseEnter { fadein message_savegame ; setitemcolor savegamelist bordercolor .7 0 0 1 } 
		mouseExit { fadeout message_savegame ; setitemcolor savegamelist bordercolor .5 .5 .5 .5 } 
		}

///////////// name and date //////////////// 

	itemDef {
		name levelbar
		text "Name"
		textscale .23
		style 0	
		type ITEM_TYPE_BUTTON
		textalign ITEM_ALIGN_CENTER
		textfont UI_FONT_NORMAL
		textstyle 6
		rect 10 34 100 20 
		textalign 1	 
		textalignx 50  	
		textaligny 12        
		backcolor 0 0 0 0
		forecolor 1 1 1 1
		visible MENU_TRUE
//		decoration
		action {
			play "sound/misc/kcswish.wav";
			uiScript SavegameSort 0
			}
		}



	itemDef {
		name levelbar
		text "Date"
		textscale .23
		style 0
		textalign ITEM_ALIGN_CENTER	
		type ITEM_TYPE_BUTTON
		textfont UI_FONT_NORMAL
		textstyle 6
		rect 160 34 100 20 
		textalign 1	 
		textalignx 50  	
		textaligny 12        
		backcolor 0 0 0 0
		forecolor 1 1 1 1
		visible MENU_TRUE
//		decoration
		action {
			play "sound/misc/kcswish.wav";
			uiScript SavegameSort 1
			}
		}



	itemDef 
	{
		name window
		group ingamebox2
		text "Save"
		type 1
		textscale .23
		group grpControlbutton
		rect 200 3.5 45 20
		textalign 1
		textalignx 22
		textaligny 14
		border 1
		bordercolor .1 .1 .1 0
		forecolor 1 1 1 1
		visible 1
	}


	itemDef {
		name window
		group ingamebox4
		rect 302 62 148 168
		style WINDOW_STYLE_FILLED
		border 1
		bordercolor .5 .5 .5 .5
		forecolor 1 1 1 1
		backcolor 0 0 0 0
		visible 1
		decoration
		}


//////////////// save game info ///////////////// 

	itemDef {
		name mapname
		ownerdraw UI_SAVEGAMENAME
		rect 302 52 148 110
		backcolor 1 1 1 .25
		visible 1
		textscale .23
		textalign ITEM_ALIGN_CENTER
		textfont UI_FONT_NORMAL
		textstyle 6
		textaligny 130
		textalignx 74	
		decoration
		}
//	
//
// savegame detail info
//
	itemDef {
		name mapinfo
	textsavegame	// get text from current savegame file
		autowrapped
//		ownerdraw UI_SAVEGAMEINFO
		rect 302 180 148 50
		backcolor 1 1 1 .25
		visible 1
		textalign ITEM_ALIGN_CENTER
		textscale .23
		textfont UI_FONT_NORMAL
		textstyle 6
		textaligny 20
		textalignx 74
		decoration
		}

////////////////////////////////////////////////////// 



	itemDef {
		name savename
		group "loadsavegroup"
//		type ITEM_TYPE_EDITFIELD
		type ITEM_TYPE_VALIDFILEFIELD	// only take text that's valid for a savegame
		text "Save As:"
		cvar "ui_savegame"
		style 1
		maxchars 20			// (SA)
		maxPaintChars 20	// (SA)
		rect 10 270 242 18
		border 1
		bordercolor .5 .5 .5 .5
		textalign ITEM_ALIGN_LEFT
		textaligny 15
		textalignx 10
		textscale .25        
		outlinecolor 1 .5 .5 .5
		backcolor 0 0 0 0
		forecolor 1 1 1 1
		backcolor 0 0 0 .25
		mouseEnter { setitemcolor loadname backcolor .3 .5 .2 .25 }
		mouseExit { setitemcolor loadname backcolor 0 0 0 .25 }
		action { uiScript Savegame }
		visible 1 
	}

//

//
// save
//
	itemDef {
		name save
		text "Save"
		type ITEM_TYPE_BUTTON
   		rect 302 270 148 18
		textscale .25
		style 1
		border 1
		bordercolor .5 .5 .5 .5        
		backcolor 0 0 0 .25
		textaligny 13
		textalignx 74
		textalign ITEM_ALIGN_CENTER
		mouseEnter { setitemcolor save backcolor .3 .5 .2 .25 }
      	mouseExit { setitemcolor save backcolor 0 0 0 .25 }

		action { uiScript Savegame }
		visible 1
	}

//
// delete
//

	itemDef {
		name del
		text "Delete..."
		type ITEM_TYPE_BUTTON
   		rect 302 30 148 18
		textscale .25
		style 1
		border 1
		bordercolor .5 .5 .5 .5        
		backcolor 0 0 0 .25
		textaligny 13
		textalignx 80
		textalign ITEM_ALIGN_CENTER
		mouseEnter { setitemcolor del backcolor .3 .5 .2 .25 }
      	mouseExit { setitemcolor del backcolor 0 0 0 .25 }

		action { open save_del_sure_popmenu }
		visible 1
	}



}	// end menudef


/////////////////////
//
// Delete for sure? popup
//
/////////////////////


menuDef {
	name "save_del_sure_popmenu"
	visible 0
	fullscreen 0

	rect 220 220 200 80

	focusColor 1 .75 0 1

	backcolor .1 .15 .1 1
	border 1
	bordercolor .5 .5 .5 .5
	style WINDOW_STYLE_FILLED
	popup
	onESC {
		close save_del_sure_popmenu;
		open ingame_save
		}



	itemDef {
		name confirm
		text "Delete Selected Savegame?" 
		style 0
		textscale .25
		textstyle 3
		rect 0 0 212 60
		textalign ITEM_ALIGN_CENTER
		textalignx 106
		textaligny 20
		decoration
//		forecolor 1 1 1 1
		visible 1
		}


	itemDef {
		name sdelsure_yes
		text "YES"
		type 1
		textfont UI_FONT_NORMAL
		textalign ITEM_ALIGN_CENTER
		style WINDOW_STYLE_FILLED
		textscale .25
		rect 18 30 60 44
		textalign 1
		textalignx 30
		textaligny 22
		forecolor 1 1 1 1
		backcolor .37 .1 .1 0 
		visible 1


		// delete the selected savegame and update the list
		action
		{
			play "sound/misc/nomenu.wav"; 
			close save_del_sure_popmenu ; 
			uiScript DelSavegame;
//			uiScript loadSavegames;
			open ingame_save
		}

		mouseEnter { setitemcolor sdelsure_yes backcolor .1 .37 .1 0 } 
		mouseExit { setitemcolor sdelsure_yes backcolor .37 .1 .1 0 } 	
		}


	itemDef {
		name sdelsure_no
		text "NO"
		type 1
		textfont UI_FONT_NORMAL
		textalign ITEM_ALIGN_CENTER
		style WINDOW_STYLE_FILLED
		textscale .25
		rect 128 30 60 44
		textalign 1
		textalignx 30
		textaligny 22
		forecolor 1 1 1 1
		backcolor .37 .1 .1 0 
		visible 1

		action 
		{ 
			play "sound/misc/nomenu.wav";
			close save_del_sure_popmenu;
			open ingame_save
		}

		mouseEnter { setitemcolor sdelsure_no backcolor .1 .37 .1 0 } 
		mouseExit { setitemcolor sdelsure_no backcolor .37 .1 .1 0 } 		

		}	// end item

	}	// end menudef





menuDef {
	name save_overwrite_popmenu
	visible 0
	fullscreen 0
	rect 220 220 200 80
	focusColor 1 .75 0 1

	backcolor .1 .15 .1 1
	border 1
	bordercolor .5 .5 .5 .5
	style WINDOW_STYLE_FILLED
	popup
	onESC {
		close save_overwrite_popmenu;
		open ingame_save
		}



	itemDef {
		name confirm
		text "Overwrite existing file?"
		style 0
		textscale .24
		textstyle 3
		rect 0 0 212 60
		textalign ITEM_ALIGN_CENTER
		textalignx 100
		textaligny 20
		decoration
		forecolor 1 1 1 1
		visible 1
		}



	itemDef {
		name overwrite_ok
		text "OK"
		type 1
		textfont UI_FONT_NORMAL
		textscale .25
		rect 124 30 40 44
		textalign ITEM_ALIGN_CENTER
		textalignx 20
		textaligny 22
		forecolor 1 1 1 1
		visible 1
		action { uiScript Savegame2 }
		mouseEnter { setitemcolor overwrite_ok backcolor .1 .37 .1 0 } 
		mouseExit { setitemcolor overwrite_ok backcolor .37 .1 .1 0 } 		
		}

	itemDef {
		name overwrite_no
		text "NO"
		type 1
		textfont UI_FONT_NORMAL
		textscale .25
		rect 38 30 40 44
		textalign ITEM_ALIGN_CENTER
		textalignx 20
		textaligny 22
		forecolor 1 1 1 1
		visible 1
		action { 
			close save_overwrite_popmenu;
			open ingame_save
		}
		mouseEnter { setitemcolor overwrite_no backcolor .1 .37 .1 0 } 
		mouseExit { setitemcolor overwrite_no backcolor .37 .1 .1 0 } 		
		}


	}	// end menudef


menuDef {
	name save_name_popmenu
	visible 0
	fullscreen 0
	rect 220 220 200 80
	focusColor 1 .75 0 1

	backcolor .1 .15 .1 1
	border 1
	bordercolor .5 .5 .5 .5
	style WINDOW_STYLE_FILLED
	popup
	onESC {
		close save_name_popmenu;
		open ingame_save
		}



	itemDef {
		name confirm
		text "You must specify a filename!"
		style 0
		textscale .24
		textstyle 3
		rect 0 0 212 60
		textalign ITEM_ALIGN_CENTER
		textalignx 100
		textaligny 20
		decoration
		forecolor 1 1 1 1
		visible 1
		}




	itemDef {
		name savename_ok
		text "OK"
		type 1
		textfont UI_FONT_NORMAL
		textscale .25
		textalign ITEM_ALIGN_CENTER
		rect 80 30 40 44
		textalign 1
		textalignx 20
		textaligny 22
		forecolor 1 1 1 1
		visible 1
		action { 
			close save_name_popmenu;
			open ingame_save
		}
		mouseEnter { setitemcolor savename_ok backcolor .1 .37 .1 0 } 
		mouseExit { setitemcolor savename_ok backcolor .37 .1 .1 0 } 		
		}


	}	// end menudef

}	// end menu
