Exemple #1
0
//-------------------------------------------------------------------------
// Called from the editor... does one instance of the robot dialog box
//-------------------------------------------------------------------------
int do_robot_dialog()
{
	int i;

	// Only open 1 instance of this window...
	if ( MainWindow != NULL ) return 0;
	
	// Close other windows
	close_all_windows();
	Cur_goody_count = 0;

	// Open a window with a quit button
	MainWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
	QuitButton = ui_add_gadget_button( MainWindow, 20, 286, 40, 32, "Done", NULL );

	ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y-3, 25, 22, "<<", GoodyPrevType );
	ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y-3, 25, 22, ">>", GoodyNextType );

	ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y+21, 25, 22, "<<", GoodyPrevID );
	ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y+21, 25, 22, ">>", GoodyNextID );

	ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y+45, 25, 22, "<<", GoodyPrevCount );
	ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y+45, 25, 22, ">>", GoodyNextCount );

	InitialMode[0] = ui_add_gadget_radio( MainWindow,  6, 58, 16, 16, 0, "Hover" );
	InitialMode[1] = ui_add_gadget_radio( MainWindow, 76, 58, 16, 16, 0, "Normal" );
	InitialMode[2] = ui_add_gadget_radio( MainWindow,  6, 78, 16, 16, 0, "(hide)" );
	InitialMode[3] = ui_add_gadget_radio( MainWindow, 76, 78, 16, 16, 0, "Avoid" );
	InitialMode[4] = ui_add_gadget_radio( MainWindow,  6, 98, 16, 16, 0, "Follow" );
	InitialMode[5] = ui_add_gadget_radio( MainWindow, 76, 98, 16, 16, 0, "Station" );

	// The little box the robots will spin in.
	RobotViewBox = ui_add_gadget_userbox( MainWindow,155, 5, 150, 125 );

	// The little box the robots will spin in.
	ContainsViewBox = ui_add_gadget_userbox( MainWindow,10, 202, 100, 80 );

	// A bunch of buttons...
	i = 135;
	ui_add_gadget_button( MainWindow,190,i,53, 26, "<<Typ", 			RobotPrevType );
	ui_add_gadget_button( MainWindow,247,i,53, 26, "Typ>>", 			RobotNextType );							i += 29;		
	ui_add_gadget_button( MainWindow,190,i,110, 26, "Next in Seg", LocalObjectSelectNextinSegment );	i += 29;		

	ui_add_gadget_button( MainWindow,190,i,53, 26, "<<Obj",		 	LocalObjectSelectPrevinMine );
	ui_add_gadget_button( MainWindow,247,i,53, 26, ">>Obj",			LocalObjectSelectNextinMine ); 		i += 29;		

	ui_add_gadget_button( MainWindow,190,i,110, 26, "Delete", 		LocalObjectDelete );						i += 29;		
	ui_add_gadget_button( MainWindow,190,i,110, 26, "Create New", 	LocalObjectPlaceObject );				i += 29;		
	ui_add_gadget_button( MainWindow,190,i,110, 26, "Set Path", 	med_set_ai_path );
	
	Time = timer_get_fixed_seconds();

	old_object = -2;		// Set to some dummy value so everything works ok on the first frame.

	if ( Cur_object_index == -1 )
		LocalObjectSelectNextinMine();

	return 1;

}
Exemple #2
0
//-------------------------------------------------------------------------
// Called from the editor... does one instance of the centers dialog box
//-------------------------------------------------------------------------
int do_centers_dialog()
{
	int i;

	// Only open 1 instance of this window...
	if ( MainWindow != NULL ) return 0;

	// Close other windows.	
	close_trigger_window();
	hostage_close_window();
	close_wall_window();
	robot_close_window();

	// Open a window with a quit button
	MainWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
	QuitButton = ui_add_gadget_button( MainWindow, 20, 252, 48, 40, "Done", NULL );

	// These are the checkboxes for each door flag.
	i = 80;
	CenterFlag[0] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "NONE" ); 			i += 24;
	CenterFlag[1] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "FuelCen" );		i += 24;
	CenterFlag[2] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "RepairCen" );	i += 24;
	CenterFlag[3] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "ControlCen" );	i += 24;
	CenterFlag[4] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "RobotCen" );		i += 24;

	// These are the checkboxes for each door flag.
	for (i=0; i<N_robot_types; i++)
		RobotMatFlag[i] = ui_add_gadget_checkbox( MainWindow, 128 + (i%2)*92, 20+(i/2)*24, 16, 16, 0, Robot_names[i]);
																									  
	old_seg_num = -2;		// Set to some dummy value so everything works ok on the first frame.

	return 1;
}
Exemple #3
0
//-------------------------------------------------------------------------
// Called from the editor... does one instance of the trigger dialog box
//-------------------------------------------------------------------------
int do_trigger_dialog()
{
	int i;

	if (!Markedsegp) {
		editor_status("Trigger requires Marked Segment & Side.");
		return 0;
	}

	// Only open 1 instance of this window...
	if ( MainWindow != NULL ) return 0;

	// Close other windows.	
	robot_close_window();
	close_wall_window();
	close_centers_window();
	hostage_close_window();

	// Open a window with a quit button
	MainWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );

	// These are the checkboxes for each door flag.
	i = 44;
	TriggerFlag[0] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Door Control" );  	i+=22;
	TriggerFlag[1] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Shield damage" ); 	i+=22;
	TriggerFlag[2] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Energy drain" );		i+=22;
	TriggerFlag[3] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Exit" );					i+=22;
	TriggerFlag[4] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "One-shot" );			i+=22;
	TriggerFlag[5] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Illusion ON" );		i+=22;
	TriggerFlag[6] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Illusion OFF" );		i+=22;
	TriggerFlag[7] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Trigger ON" );			i+=22;
	TriggerFlag[8] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Matcen Trigger" ); 	i+=22;
	TriggerFlag[9] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Secret Exit" ); 		i+=22;

	QuitButton = ui_add_gadget_button( MainWindow, 20, i, 48, 40, "Done", NULL );
																				 
	// The little box the wall will appear in.
	WallViewBox = ui_add_gadget_userbox( MainWindow, 155, 5, 64, 64 );

	// A bunch of buttons...
	i = 80;
//	ui_add_gadget_button( MainWindow,155,i,140, 26, "Add Door Control", add_trigger_control ); i += 29;
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Remove Trigger", trigger_remove ); i += 29;
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Bind Wall", bind_wall_to_trigger ); i += 29;
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Bind Matcen", bind_matcen_to_trigger ); i += 29;
	ui_add_gadget_button( MainWindow,155,i,140, 26, "All Triggers ON", trigger_turn_all_ON ); i += 29;

	old_trigger_num = -2;		// Set to some dummy value so everything works ok on the first frame.

	return 1;
}
Exemple #4
0
//-------------------------------------------------------------------------
// Called from the editor... does one instance of the hostage dialog box
//-------------------------------------------------------------------------
int do_hostage_dialog()
{
	int i;

	// Only open 1 instance of this window...
	if ( MainWindow != NULL ) return 0;
	
	// Close other windows
	close_all_windows();

	CurrentHostageIndex = 0;
	SelectClosestHostage();

	// Open a window with a quit button
	MainWindow = ui_open_window( TMAPBOX_X+10, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
	QuitButton = ui_add_gadget_button( MainWindow, 20, 222, 48, 40, "Done", NULL );

	ui_wprintf_at( MainWindow, 10, 32,"&Message:" );
	HostageText = ui_add_gadget_inputbox( MainWindow, 10, 50, HOSTAGE_MESSAGE_LEN, HOSTAGE_MESSAGE_LEN, HostageMessage );

	// The little box the hostage vclip will play in.
	HostageViewBox = ui_add_gadget_userbox( MainWindow,10, 90+10, 64, 64 );

	// A bunch of buttons...
	i = 90;
//@@	ui_add_gadget_button( MainWindow,155,i,70, 26, "<< Type", SelectPrevVclip );
//@@	ui_add_gadget_button( MainWindow,155+70,i,70, 26, "Type >>", SelectNextVclip );i += 29;		
//@@	ui_add_gadget_button( MainWindow,155,i,70, 26, "<< Sound",  find_prev_hostage_sound );
//@@	ui_add_gadget_button( MainWindow,155+70,i,70, 26, "Sound >>", find_next_hostage_sound );i += 29;		

	ui_add_gadget_button( MainWindow,155,i,70, 26, "<< Face", SelectPrevFace );
	ui_add_gadget_button( MainWindow,155+70,i,70, 26, "Face >>", SelectNextFace );i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Play sound", PlayHostageSound );i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Next Hostage", SelectNextHostage );	i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Prev Hostage", SelectPrevHostage ); i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Compress All", CompressHostages ); i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Delete", ObjectDelete );	i += 29;		
	ui_add_gadget_button( MainWindow,155,i,140, 26, "Create New", PlaceHostage );	i += 29;		
	
	Time = timer_get_fixed_seconds();

	LastHostageIndex = -2;		// Set to some dummy value so everything works ok on the first frame.
	
//	if ( CurrentHostageIndex == -1 )
//		SelectNextHostage();

	return 1;

}
Exemple #5
0
//-------------------------------------------------------------------------
// Called from the editor... does one instance of the object dialog box
//-------------------------------------------------------------------------
int do_object_dialog()
{
	char	Xmessage[MATT_LEN], Ymessage[MATT_LEN], Zmessage[MATT_LEN];
	object *obj=&Objects[Cur_object_index];

	if (obj->type == OBJ_ROBOT)		//don't do this for robots
		return 0;

	// Only open 1 instance of this window...
	if ( MattWindow != NULL )
		return 0;
	
	Cur_goody_count = 0;

	// Open a window with a quit button
	MattWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
	QuitButton = ui_add_gadget_button( MattWindow, 20, 286, 40, 32, "Done", NULL );

	QuitButton->hotkey = KEY_ENTER;

	// These are the radio buttons for each mode
	InitialMode[0] = ui_add_gadget_radio( MattWindow, 10, 50, 16, 16, 0, "None" );
	InitialMode[1] = ui_add_gadget_radio( MattWindow, 80, 50, 16, 16, 0, "Spinning" );

	InitialMode[obj->movement_type == MT_SPINNING?1:0]->flag = 1;

	sprintf(Xmessage,"%.2f",f2fl(obj->mtype.spin_rate.x));
	sprintf(Ymessage,"%.2f",f2fl(obj->mtype.spin_rate.y));
	sprintf(Zmessage,"%.2f",f2fl(obj->mtype.spin_rate.z));

	ui_wprintf_at( MattWindow, 10, 132,"&X:" );
	Xtext = ui_add_gadget_inputbox( MattWindow, 30, 132, MATT_LEN, MATT_LEN, Xmessage );

	ui_wprintf_at( MattWindow, 10, 162,"&Y:" );
	Ytext = ui_add_gadget_inputbox( MattWindow, 30, 162, MATT_LEN, MATT_LEN, Ymessage );

	ui_wprintf_at( MattWindow, 10, 192,"&Z:" );
	Ztext = ui_add_gadget_inputbox( MattWindow, 30, 192, MATT_LEN, MATT_LEN, Zmessage );

	ui_gadget_calc_keys(MattWindow);

	MattWindow->keyboard_focus_gadget = (UI_GADGET *) InitialMode[0];

	mprintf((0, "X = %08x, Y = %08x, Z = %08x\n", atoi(Xmessage), atoi(Ymessage), atoi(Zmessage)));

	return 1;

}
Exemple #6
0
//-------------------------------------------------------------------------
// Called from the editor... does one instance of the wall dialog box
//-------------------------------------------------------------------------
int do_wall_dialog()
{
	int i;

	// Only open 1 instance of this window...
	if ( MainWindow != NULL ) return 0;

	// Close other windows.	
	close_all_windows();

	// Open a window with a quit button
	MainWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
	QuitButton = ui_add_gadget_button( MainWindow, 20, 252, 48, 40, "Done", NULL );

	// These are the checkboxes for each door flag.
	i = 80;
	DoorFlag[0] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Locked" ); i += 24;
	DoorFlag[1] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Auto" ); i += 24;
	DoorFlag[2] = ui_add_gadget_checkbox( MainWindow, 22, i, 16, 16, 0, "Illusion OFF" ); i += 24;

	KeyFlag[0] = ui_add_gadget_radio( MainWindow, 22, i, 16, 16, 0, "NONE" ); i += 24;
	KeyFlag[1] = ui_add_gadget_radio( MainWindow, 22, i, 16, 16, 0, "Blue" ); i += 24;
	KeyFlag[2] = ui_add_gadget_radio( MainWindow, 22, i, 16, 16, 0, "Red" );  i += 24;
	KeyFlag[3] = ui_add_gadget_radio( MainWindow, 22, i, 16, 16, 0, "Yellow" ); i += 24;

	// The little box the wall will appear in.
	WallViewBox = ui_add_gadget_userbox( MainWindow, 155, 5, 64, 64 );

	// A bunch of buttons...
	i = 80;
	ui_add_gadget_button( MainWindow,155,i,70, 22, "<< Clip", PrevWall );
	ui_add_gadget_button( MainWindow,155+70,i,70, 22, "Clip >>", NextWall );i += 25;		
	ui_add_gadget_button( MainWindow,155,i,140, 22, "Add Blastable", wall_add_blastable ); i += 25;
	ui_add_gadget_button( MainWindow,155,i,140, 22, "Add Door", wall_add_door  );	i += 25;
	ui_add_gadget_button( MainWindow,155,i,140, 22, "Add Illusory", wall_add_illusion);	i += 25;
	ui_add_gadget_button( MainWindow,155,i,140, 22, "Add Closed Wall", wall_add_closed_wall ); i+=25;
//	ui_add_gadget_button( MainWindow,155,i,140, 22, "Restore All Walls", wall_restore_all );	i += 25;
	ui_add_gadget_button( MainWindow,155,i,70, 22, "<< Prev", GotoPrevWall );
	ui_add_gadget_button( MainWindow,155+70,i,70, 22, "Next >>", GotoNextWall );i += 25;
	ui_add_gadget_button( MainWindow,155,i,140, 22, "Remove Wall", wall_remove ); i += 25;
	ui_add_gadget_button( MainWindow,155,i,140, 22, "Bind to Trigger", bind_wall_to_trigger ); i += 25;
	ui_add_gadget_button( MainWindow,155,i,140, 22, "Bind to Control", bind_wall_to_control_center ); i+=25;
	
	old_wall_num = -2;		// Set to some dummy value so everything works ok on the first frame.

	return 1;
}
Exemple #7
0
int GetKeyCode(char * text)
{
	UI_WINDOW * wnd;
	UI_GADGET_BUTTON * DoneButton;
	char temp_text[100];

	text = text;

	wnd = ui_open_window( 200, 200, 400, 200, WIN_DIALOG );

	DoneButton = ui_add_gadget_button( wnd, 170, 165, 60, 25, "Ok", NULL );

	ui_gadget_calc_keys(wnd);

	//key_flush();

	wnd->keyboard_focus_gadget = (UI_GADGET *)DoneButton;

	while(1)
	{
		ui_mega_process();
		ui_window_do_gadgets(wnd);

		if (last_keypress > 0)
		{
			GetKeyDescription( temp_text, last_keypress );
			ui_wprintf_at( wnd, 10, 100, "%s     ", temp_text  );
		}

		if (DoneButton->pressed)
			break;
	}

	ui_close_window(wnd);

	return 0;
}
Exemple #8
0
//setup the editors windows, canvases, gadgets, etc.
//called whenever the editor screen is selected
void init_editor_screen()
{
//	grsBitmap * bmp;

	if (editor_screen_open) return;

	grdCurScreen->scCanvas.cvFont = editor_font;

	//create canvas for game on the editor screen
	initializing = 1;
	GrSetCurrentCanvas(Canv_editor);
	Canv_editor->cvFont = editor_font;
	GrInitSubCanvas(Canv_editor_game,Canv_editor,GAMEVIEW_X,GAMEVIEW_Y,GAMEVIEW_W,GAMEVIEW_H);

	//Editor renders into full (320x200) game screen 

	init_info = 1;

	//do other editor screen setup

	// Since the palette might have changed, find some good colors...
	CBLACK = GrFindClosestColor( 1, 1, 1 );
	CGREY = GrFindClosestColor( 28, 28, 28 );
	CWHITE = GrFindClosestColor( 38, 38, 38 );
	CBRIGHT = GrFindClosestColor( 60, 60, 60 );
	CRED = GrFindClosestColor( 63, 0, 0 );

	GrSetCurFont(editor_font);
	GrSetFontColor( CBLACK, CWHITE );

	EditorWindow = ui_open_window( 0 , 0, ED_SCREEN_W, ED_SCREEN_H, WIN_FILLED );

	LargeViewBox	= ui_add_gadget_userbox( EditorWindow,LVIEW_X,LVIEW_Y,LVIEW_W,LVIEW_H);
#if ORTHO_VIEWS
	TopViewBox		= ui_add_gadget_userbox( EditorWindow,TVIEW_X,TVIEW_Y,TVIEW_W,TVIEW_H);
 	FrontViewBox	= ui_add_gadget_userbox( EditorWindow,FVIEW_X,FVIEW_Y,FVIEW_W,FVIEW_H);
	RightViewBox	= ui_add_gadget_userbox( EditorWindow,RVIEW_X,RVIEW_Y,RVIEW_W,RVIEW_H);
#endif
	ui_gadget_calc_keys(EditorWindow);	//make tab work for all windows

	GameViewBox	= ui_add_gadget_userbox( EditorWindow, GAMEVIEW_X, GAMEVIEW_Y, GAMEVIEW_W, GAMEVIEW_H );
//	GroupViewBox	= ui_add_gadget_userbox( EditorWindow,GVIEW_X,GVIEW_Y,GVIEW_W,GVIEW_H);

//	GameViewBox->when_tab = GameViewBox->when_btab = (UI_GADGET *) LargeViewBox;
//	LargeViewBox->when_tab = LargeViewBox->when_btab = (UI_GADGET *) GameViewBox;

//	ui_gadget_calc_keys(EditorWindow);	//make tab work for all windows

	ViewIcon	= ui_add_gadget_icon( EditorWindow, "Lock\nview",	455,25+530, 	40, 22,	KEY_V+KEY_CTRLED, ToggleLockViewToCursegp );
	AllIcon	= ui_add_gadget_icon( EditorWindow, "Draw\nall",	500,25+530,  	40, 22,	KEY_A+KEY_CTRLED, ToggleDrawAllSegments );
	AxesIcon	= ui_add_gadget_icon( EditorWindow, "Coord\naxes",545,25+530,		40, 22,	KEY_D+KEY_CTRLED, ToggleCoordAxes );
//-NOLIGHTICON-	LightIcon	= ui_add_gadget_icon( EditorWindow, "Light\ning",	590,25+530, 	40, 22,	KEY_L+KEY_SHIFTED,ToggleLighting );
	ChaseIcon	= ui_add_gadget_icon( EditorWindow, "Chase\nmode",635,25+530,		40, 22,	-1,				ToggleChaseMode );
	OutlineIcon = ui_add_gadget_icon( EditorWindow, "Out\nline", 	680,25+530,  	40, 22,	KEY_O,			ToggleOutlineMode );
	LockIcon	= ui_add_gadget_icon( EditorWindow, "Lock\nstep", 725,25+530, 	40, 22,	KEY_L,			ToggleLockstep );

	meddraw_initViews(LargeViewBox->canvas);

	//ui_add_gadget_button( EditorWindow, 460, 510, 50, 25, "Quit", ExitEditor );
	//ui_add_gadget_button( EditorWindow, 520, 510, 50, 25, "Lisp", CallLisp );
	//ui_add_gadget_button( EditorWindow, 580, 510, 50, 25, "Mine", MineMenu );
	//ui_add_gadget_button( EditorWindow, 640, 510, 50, 25, "Help", DoHelp );
	//ui_add_gadget_button( EditorWindow, 460, 540, 50, 25, "Macro", MacroMenu );
	//ui_add_gadget_button( EditorWindow, 520, 540, 50, 25, "About", ShowAbout );
	//ui_add_gadget_button( EditorWindow, 640, 540, 50, 25, "Shell", DosShell );

	ui_pad_activate( EditorWindow, PAD_X, PAD_Y );
	Pad_text_canvas = GrCreateSubCanvas(Canv_editor, PAD_X + 250, PAD_Y + 8, 180, 160);
	ui_add_gadget_button( EditorWindow, PAD_X+6, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "<<",  med_keypad_goto_prev );
	ui_add_gadget_button( EditorWindow, PAD_X+PAD_WIDTH1+6, PAD_Y+(30*5)+22, PAD_WIDTH, 20, ">>",  med_keypad_goto_next );

	{	int	i;
		i = 0;	ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "SR",  med_keypad_goto_0 );
		i++;		ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "SS",  med_keypad_goto_1 );
		i++;		ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "CF",  med_keypad_goto_2 );
		i++;		ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "TM",  med_keypad_goto_3 );
		i++;		ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "OP",  med_keypad_goto_4 );
		i++;		ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "OR",  med_keypad_goto_5 );
		i++;		ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "GE",  med_keypad_goto_6 );
		i++;		ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "LI",  med_keypad_goto_7 );
		i++;		ui_add_gadget_button( EditorWindow, PAD_X+16+(i+2)*PAD_WIDTH1, PAD_Y+(30*5)+22, PAD_WIDTH, 20, "TT",  med_keypad_goto_8 );
	}

	GrSetCurFont(editor_font);
	menubar_show();

	// INIT TEXTURE STUFF
	texpage_init( EditorWindow );
	objpage_init( EditorWindow );

	EditorWindow->keyboard_focus_gadget = (UI_GADGET *)LargeViewBox;

	canv_offscreen->cvFont = grdCurScreen->scCanvas.cvFont;
//	BigCanvas[0]->cvFont = grdCurScreen->scCanvas.cvFont; 
//	BigCanvas[1]->cvFont = grdCurScreen->scCanvas.cvFont; 
//	BigCanvasFirstTime = 1;

	// Draw status box
	GrSetCurrentCanvas( NULL );
	GrSetColor( CGREY );
	GrRect(STATUS_X,STATUS_Y,STATUS_X+STATUS_W-1,STATUS_Y+STATUS_H-1);			//0, 582, 799, 599 );

	// Draw icon box
	// GrSetCurrentCanvas( NULL );
	//  GrSetColor( CBRIGHT );
	//  GrRect( 528, 2, 798, 22);
	//  GrSetColor( CGREY);
	//  GrRect( 530, 2, 799, 20);

	UpdateFlags = UF_ALL;
	initializing = 0;
	editor_screen_open = 1;
}
Exemple #9
0
int PopupMenu( int NumButtons, char * text[] )
{
	UI_WINDOW * wnd;
	UI_GADGET_BUTTON * ButtonG[10];

	short SavedMouseX, SavedMouseY;
	char * Button[10];

	int button_width, button_height, width, height;

	short i, x, y;
	short w, h;

	int choice;

	ui_mouse_flip_buttons();

	//ui_mouse_process();

	if ( B1_RELEASED )
	{
		ui_mouse_flip_buttons();
		return -1;
	}

	if ((NumButtons < 1) || (NumButtons>10))
	{
		ui_mouse_flip_buttons();
		return -1;
	}

	SavedMouseX = Mouse.x; SavedMouseY = Mouse.y;

	button_width = button_height = 0;

	gr_set_current_canvas( &grd_curscreen->sc_canvas );

	for (i=0; i<NumButtons; i++ )
	{
		Button[i] = text[i];

		ui_get_button_size( Button[i], &width, &height );

		if ( width > button_width ) button_width = width;
		if ( height > button_height ) button_height = height;
	}

	width = button_width + 2*(MENU_BORDER+3);

	height = (button_height*NumButtons) + (MENU_VERT_SPACING*(NumButtons-1)) ;
	height += (MENU_BORDER+3) * 2;

	x = Mouse.x - width/2;
	y = Mouse.y - (MENU_BORDER+3) - button_height/2;

	w = grd_curscreen->sc_w;
	h = grd_curscreen->sc_h;

	if (x < 0 ) {
		x = 0;
		Mouse.x = x + width / 2;
	}

	if ( (x+width-1) >= w ) {
		x = w - width;
		Mouse.x = x + width / 2;
	}

	if (y < 0 ) {
		y = 0;
		Mouse.y = y + (MENU_BORDER+3) + button_height/2;
	}

	if ( (y+height-1) >= h ) {
		y = h - height;
		Mouse.y = y + (MENU_BORDER+3) + button_height/2;
	}

	wnd = ui_open_window( x, y, width, height, WIN_DIALOG );

	mouse_set_pos( Mouse.x, Mouse.y );

	x = MENU_BORDER+3;
	y = MENU_BORDER+3;

	for (i=0; i<NumButtons; i++ )
	{
		ButtonG[i] = ui_add_gadget_button( wnd, x, y, button_width, button_height, Button[i], NULL );
		y += button_height+MENU_VERT_SPACING;
	}

	choice = 0;

	while(choice==0)
	{
		ui_mega_process();
		ui_window_do_gadgets(wnd);

		for (i=0; i<NumButtons; i++ )
		{
			if (ButtonG[i]->pressed)   {
				choice = i+1;
				break;
			}
		}

		if ( (choice==0) && B1_JUST_RELEASED )  {
			choice = -1;
			break;
		}

	}

	ui_close_window(wnd);

	ui_mouse_flip_buttons();

	return choice;

}
Exemple #10
0
Fichier : menu.c Projet : btb/d1x
int MenuX( int x, int y, int NumButtons, char * text[] )
{
	UI_WINDOW * wnd;
	UI_GADGET_BUTTON ** ButtonG;
	char ** Button;

	int button_width, button_height, width, height;

	int i;
	int w, h;

	int choice;

	ButtonG = (UI_GADGET_BUTTON **)malloc( sizeof(UI_GADGET_BUTTON *)*NumButtons );
	Button = (char **)malloc( sizeof(char *)*NumButtons );

	button_width = button_height = 0;

	for (i=0; i<NumButtons; i++ )
	{
		Button[i] = text[i];

		ui_get_button_size( Button[i], &width, &height );

		if ( width > button_width ) button_width = width;
		if ( height > button_height ) button_height = height;
	}

	width = button_width + 2*(MENU_BORDER+3);

	height = (button_height*NumButtons) + (MENU_VERT_SPACING*(NumButtons-1)) ;
	height += (MENU_BORDER+3) * 2;

	w = grd_curscreen->sc_w;
	h = grd_curscreen->sc_h;

	if ( x == -1 ) x = Mouse.x - width/2;
	if ( y == -1 ) y = Mouse.y;

	if (x < 0 ) {
		x = 0;
	}

	if ( (x+width-1) >= w ) {
		x = w - width;
	}

	if (y < 0 ) {
		y = 0;
	}

	if ( (y+height-1) >= h ) {
		y = h - height;
	}

	wnd = ui_open_window( x, y, width, height, WIN_FILLED | WIN_SAVE_BG );

	x = MENU_BORDER+3;
	y = MENU_BORDER+3;

	for (i=0; i<NumButtons; i++ )
	{
		ButtonG[i] = ui_add_gadget_button( wnd, x, y, button_width, button_height, Button[i], NULL );
		y += button_height+MENU_VERT_SPACING;
	}

	choice = 0;

	while(choice==0)
	{
		ui_mega_process();
		ui_window_do_gadgets(wnd);

		for (i=0; i<NumButtons; i++ )
		{
			if (ButtonG[i]->pressed)   {
				choice = i+1;
				break;
			}
		}

		if ( (choice==0) && B1_JUST_RELEASED )  {
			choice = -1;
			break;
		}

	}

	ui_close_window(wnd);
	free(Button);
	free(ButtonG);

	return choice;

}
Exemple #11
0
Fichier : file.c Projet : btb/d2x
int ui_get_filename( char * filename, char * Filespec, char * message  )
{
	char		ViewDir[PATH_MAX];
	char		InputText[PATH_MAX];
	char		*p;
	PHYSFS_file	*TempFile;
	int			NumFiles, NumDirs,i;
	char		**filename_list;
	char		**directory_list;
	char		Spaces[35];
	UI_WINDOW			*wnd;
	UI_GADGET_BUTTON	*Button1, *Button2, *HelpButton;
	UI_GADGET_LISTBOX	*ListBox1;
	UI_GADGET_LISTBOX	*ListBox2;
	UI_GADGET_INPUTBOX	*UserFile;
	int 				new_listboxes;

	if ((p = strrchr(filename, '/')))
	{
		*p++ = 0;
		strcpy(ViewDir, filename);
		strcpy(InputText, p);
	}
	else
	{
		strcpy(ViewDir, "");
		strcpy(InputText, filename);
	}

	filename_list = file_getfilelist(&NumFiles, Filespec, ViewDir);
	directory_list = file_getdirlist(&NumDirs, ViewDir);

	// Running out of memory may become likely in the future
	if (!filename_list && !directory_list)
		return 0;

	if (!filename_list)
	{
		PHYSFS_freeList(directory_list);
		return 0;
	}

	if (!directory_list)
	{
		PHYSFS_freeList(filename_list);
		return 0;
	}

	//ui_messagebox( -2,-2, 1,"DEBUG:0", "Ok" );
	for (i=0; i<35; i++)
		Spaces[i] = ' ';
	Spaces[34] = 0;

	wnd = ui_open_window( 200, 100, 400, 370, WIN_DIALOG );

	ui_wprintf_at( wnd, 10, 5, message );

	ui_wprintf_at( wnd, 20, 32,"N&ame" );
	UserFile  = ui_add_gadget_inputbox( wnd, 60, 30, PATH_MAX, 40, InputText );

	ui_wprintf_at( wnd, 20, 86,"&Files" );
	ui_wprintf_at( wnd, 210, 86,"&Dirs" );

	ListBox1 = ui_add_gadget_listbox(wnd,  20, 110, 125, 200, NumFiles, filename_list);
	ListBox2 = ui_add_gadget_listbox(wnd, 210, 110, 100, 200, NumDirs, directory_list);

	Button1 = ui_add_gadget_button( wnd,     20, 330, 60, 25, "Ok", NULL );
	Button2 = ui_add_gadget_button( wnd,    100, 330, 60, 25, "Cancel", NULL );
	HelpButton = ui_add_gadget_button( wnd, 180, 330, 60, 25, "Help", NULL );

	wnd->keyboard_focus_gadget = (UI_GADGET *)UserFile;

	Button1->hotkey = KEY_CTRLED + KEY_ENTER;
	Button2->hotkey = KEY_ESC;
	HelpButton->hotkey = KEY_F1;
	ListBox1->hotkey = KEY_ALTED + KEY_F;
	ListBox2->hotkey = KEY_ALTED + KEY_D;
	UserFile->hotkey = KEY_ALTED + KEY_A;

	ui_gadget_calc_keys(wnd);

	ui_wprintf_at( wnd, 20, 60, "%s", Spaces );
	ui_wprintf_at( wnd, 20, 60, "%s", ViewDir );

	new_listboxes = 0;

	while( 1 )
	{
		ui_mega_process();
		ui_window_do_gadgets(wnd);

		if ( Button2->pressed )
		{
			PHYSFS_freeList(filename_list);
			PHYSFS_freeList(directory_list);
			ui_close_window(wnd);
			return 0;
		}

		if ( HelpButton->pressed )
			ui_messagebox( -1, -1, 1, "Sorry, no help is available!", "Ok" );

		if (ListBox1->moved || new_listboxes)
		{
			if (ListBox1->current_item >= 0 )
				ui_inputbox_set_text(UserFile, filename_list[ListBox1->current_item]);
		}

		if (ListBox2->moved || new_listboxes)
		{
			if (ListBox2->current_item >= 0 )
				ui_inputbox_set_text(UserFile, directory_list[ListBox2->current_item]);
		}
		new_listboxes = 0;

		if (Button1->pressed || UserFile->pressed || (ListBox1->selected_item > -1 ) || (ListBox2->selected_item > -1 ))
		{
			ui_mouse_hide();

			if (ListBox2->selected_item > -1 )
				strcpy(UserFile->text, directory_list[ListBox2->selected_item]);

			strncpy(filename, ViewDir, PATH_MAX);

			p = UserFile->text;
			while (!strncmp(p, "..", 2))	// shorten the path manually
			{
				char *sep = strrchr(filename, '/');
				if (sep)
					*sep = 0;
				else
					*filename = 0;	// look directly in search paths

				p += 2;
				if (*p == '/')
					p++;
			}

			if (*filename && *p)
				strncat(filename, "/", PATH_MAX - strlen(filename));
			strncat(filename, p, PATH_MAX - strlen(filename));

			if (!PHYSFS_isDirectory(filename))
			{
				TempFile = PHYSFS_openRead(filename);
				if (TempFile)
				{
					// Looks like a valid filename that already exists!
					PHYSFS_close(TempFile);
					break;
				}
	
				// File doesn't exist, but can we create it?
				TempFile = PHYSFS_openWrite(filename);
				if (TempFile)
				{
					// Looks like a valid filename!
					PHYSFS_close(TempFile);
					PHYSFS_delete(filename);
					break;
				}
			}
			else
			{
				if (filename[strlen(filename) - 1] == '/')	// user typed a separator on the end
					filename[strlen(filename) - 1] = 0;
	
				strcpy(ViewDir, filename);
	
				//mprintf( 0, "----------------------------\n" );
				//mprintf( 0, "Full dir: '%s'\n", ViewDir );
	
				PHYSFS_freeList(filename_list);
				filename_list = file_getfilelist(&NumFiles, Filespec, ViewDir);
				if (!filename_list)
				{
					PHYSFS_freeList(directory_list);
					return 0;
				}

				ui_inputbox_set_text(UserFile, Filespec);

				PHYSFS_freeList(directory_list);
				directory_list = file_getdirlist(&NumDirs, ViewDir);
				if (!directory_list)
				{
					PHYSFS_freeList(filename_list);
					return 0;
				}

				ui_listbox_change(wnd, ListBox1, NumFiles, filename_list);
				ui_listbox_change(wnd, ListBox2, NumDirs, directory_list);
				new_listboxes = 0;

				ui_wprintf_at( wnd, 20, 60, "%s", Spaces );
				ui_wprintf_at( wnd, 20, 60, "%s", ViewDir );

				//i = TICKER;
				//while ( TICKER < i+2 );

			}

			ui_mouse_show();

		}

		vid_update();
	}

	//key_flush();

	ui_close_window(wnd);
	if (filename_list)
		PHYSFS_freeList(filename_list);
	if (directory_list)
		PHYSFS_freeList(directory_list);

	return 1;
}
Exemple #12
0
double ui_input_number( short xc, short yc, char * text, double OrgNumber )
{
	UI_WINDOW * wnd;
	UI_GADGET_INPUTBOX * InputBox;

	int text_width, text_height, avg;
	short box_width, box_height, width, height, x, y;
	short w, h;
	char string[100];

	sprintf( string, "%f", OrgNumber );

	box_width = box_height = 0;

	gr_set_current_canvas( &grd_curscreen->sc_canvas );

	box_width = 8*20;
	box_height = 20;

	gr_get_string_size(text, &text_width, &text_height, &avg );

	width = box_width + 50;

	text_width += avg*6;
	text_width += 10;

	if (text_width > width )
		width = text_width;

	height = text_height;
	height += box_height;
	height += 4*5;

	// Center X and Y
	w = grd_curscreen->sc_w;
	h = grd_curscreen->sc_h;

	if ( xc == -1 ) xc = Mouse.x;
	if ( yc == -1 ) yc = Mouse.y - box_height/2;
	if ( xc == -2 ) xc = w/2;
	if ( yc == -2 ) yc = h/2;

	x = xc - width/2;
	y = yc - height/2;

	// Make sure that we're onscreen
	if (x < 0 ) x = 0;
	if ( (x+width-1) >= w ) x = w - width;
	if (y < 0 ) y = 0;
	if ( (y+height-1) >= h ) y = h - height;


	wnd = ui_open_window( x, y, width, height, WIN_DIALOG );

	y = TEXT_EXTRA_HEIGHT + text_height/2 - 1;

	ui_string_centered( width/2, y, text );

	y = 2*TEXT_EXTRA_HEIGHT + text_height;

	y = height - TEXT_EXTRA_HEIGHT - box_height-10;

	InputBox = ui_add_gadget_inputbox( wnd, 10, y, 20, 20, string );

	ui_gadget_calc_keys(wnd);

	//key_flush();

	wnd->keyboard_focus_gadget = (UI_GADGET *)InputBox;

	while(1)
	{
		ui_mega_process();
		ui_window_do_gadgets(wnd);

		if (InputBox->pressed) break;
	}

	ui_close_window(wnd);

	OrgNumber = atof(InputBox->text);

	return OrgNumber;

}