Exemplo n.º 1
0
Arquivo: medrobot.c Projeto: btb/d2x
//-------------------------------------------------------------------------
// 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;

}
Exemplo n.º 2
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;

}
Exemplo n.º 3
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;
}
Exemplo n.º 4
0
void do_robot_window()
{
	int	i;
	fix	DeltaTime, Temp;
	int	first_object_index;

	if ( MainWindow == NULL ) return;

	first_object_index = Cur_object_index;
	while (!is_legal_type_for_this_window(Cur_object_index)) {
		LocalObjectSelectNextinMine();
		if (first_object_index == Cur_object_index) {
			break;
		}
	}

	//------------------------------------------------------------
	// Call the ui code..
	//------------------------------------------------------------
	ui_button_any_drawn = 0;
	ui_window_do_gadgets(MainWindow);

	//------------------------------------------------------------
	// If we change objects, we need to reset the ui code for all
	// of the radio buttons that control the ai mode.  Also makes
	// the current AI mode button be flagged as pressed down.
	//------------------------------------------------------------
	if (old_object != Cur_object_index )	{
		for (	i=0; i < NUM_BOXES; i++ )	{
			InitialMode[i]->flag = 0;		// Tells ui that this button isn't checked
			InitialMode[i]->status = 1;	// Tells ui to redraw button
		}
		if ( Cur_object_index > -1 ) {
			int	behavior = Objects[Cur_object_index].ctype.ai_info.behavior;
			if ( !((behavior >= MIN_BEHAVIOR) && (behavior <= MAX_BEHAVIOR))) {
				Objects[Cur_object_index].ctype.ai_info.behavior = AIB_NORMAL;
				behavior = AIB_NORMAL;
			}
			InitialMode[behavior - MIN_BEHAVIOR]->flag = 1;	// Mark this button as checked
		}
	}

	//------------------------------------------------------------
	// If any of the radio buttons that control the mode are set, then
	// update the cooresponding AI state.
	//------------------------------------------------------------
	for (	i=0; i < NUM_BOXES; i++ )	{
		if ( InitialMode[i]->flag == 1 )	
			if (Objects[Cur_object_index].ctype.ai_info.behavior != MIN_BEHAVIOR+i) {
				Objects[Cur_object_index].ctype.ai_info.behavior = MIN_BEHAVIOR+i;		// Set the ai_state to the cooresponding radio button
				call_init_ai_object(&Objects[Cur_object_index], MIN_BEHAVIOR+i);
			}
	}

	//------------------------------------------------------------
	// A simple frame time counter for spinning the objects...
	//------------------------------------------------------------
	Temp = timer_get_fixed_seconds();
	DeltaTime = Temp - Time;
	Time = Temp;

	//------------------------------------------------------------
	// Redraw the object in the little 64x64 box
	//------------------------------------------------------------
	if (Cur_object_index > -1 )	{
		int id;
		gr_set_current_canvas( RobotViewBox->canvas );
		id = get_object_id(&Objects[Cur_object_index]);
		if ( id > -1 )	
			draw_robot_picture(id, &angles, -1 );
		else
			gr_clear_canvas( CGREY );
		angles.h += fixmul(0x1000, DeltaTime );
	} else {
		// no object, so just blank out
		gr_set_current_canvas( RobotViewBox->canvas );
		gr_clear_canvas( CGREY );

//		LocalObjectSelectNextInMine();
	}

	//------------------------------------------------------------
	// Redraw the contained object in the other little box
	//------------------------------------------------------------
	if ((Cur_object_index > -1 ) && (Cur_goody_count > 0))	{
		int id;

		gr_set_current_canvas( ContainsViewBox->canvas );
		id = Cur_goody_id;
		if ( id > -1 )	 {
                        int ol_type=0;
			if (Cur_goody_type == OBJ_ROBOT)
				ol_type = OL_ROBOT;
			else if (Cur_goody_type == OBJ_POWERUP)
				ol_type = OL_POWERUP;
			else
				Int3();	//	Error?  Unknown goody type!

			draw_robot_picture(id, &goody_angles, ol_type );
		} else
			gr_clear_canvas( CGREY );
		goody_angles.h += fixmul(0x1000, DeltaTime );
	} else {
		// no object, so just blank out
		gr_set_current_canvas( ContainsViewBox->canvas );
		gr_clear_canvas( CGREY );

//		LocalObjectSelectNextInMine();
	}

	//------------------------------------------------------------
	// If anything changes in the ui system, redraw all the text that
	// identifies this robot.
	//------------------------------------------------------------

	if (ui_button_any_drawn || (old_object != Cur_object_index) )	{
		int	i;
		char	type_text[STRING_LENGTH+1],id_text[STRING_LENGTH+1];

		if (Cur_object_index != -1) {
			Cur_goody_type = Objects[Cur_object_index].contains_type;
			Cur_goody_id = Objects[Cur_object_index].contains_id;
			if (Objects[Cur_object_index].contains_count < 0)
				Objects[Cur_object_index].contains_count = 0;
			Cur_goody_count = Objects[Cur_object_index].contains_count;
		}

		ui_wprintf_at( MainWindow, GOODY_X, GOODY_Y,    " Type:");
		ui_wprintf_at( MainWindow, GOODY_X, GOODY_Y+24, "   ID:");
		ui_wprintf_at( MainWindow, GOODY_X, GOODY_Y+48, "Count:");

		for (i=0; i<STRING_LENGTH; i++)
			id_text[i] = ' ';
		id_text[i] = 0;

		switch (Cur_goody_type) {
			case OBJ_ROBOT:
				strcpy(type_text, "Robot  ");
				strncpy(id_text, Robot_names[Cur_goody_id], strlen(Robot_names[Cur_goody_id]));
				break;
			case OBJ_POWERUP:
				strcpy(type_text, "Powerup");
				strncpy(id_text, Powerup_names[Cur_goody_id], strlen(Powerup_names[Cur_goody_id]));
				break;
			default:
				editor_status("Illegal contained object type (%i), changing to powerup.", Cur_goody_type);
				Cur_goody_type = OBJ_POWERUP;
				Cur_goody_id = 0;
				strcpy(type_text, "Powerup");
				strncpy(id_text, Powerup_names[Cur_goody_id], strlen(Powerup_names[Cur_goody_id]));
				break;
		}

		ui_wprintf_at( MainWindow, GOODY_X+108, GOODY_Y, type_text);
		ui_wprintf_at( MainWindow, GOODY_X+108, GOODY_Y+24, id_text);
		ui_wprintf_at( MainWindow, GOODY_X+108, GOODY_Y+48, "%i", Cur_goody_count);

		if ( Cur_object_index > -1 )	{
			int	id = Objects[Cur_object_index].id;
			char	id_text[12];
			int	i;

			for (i=0; i<STRING_LENGTH; i++)
				id_text[i] = ' ';
			id_text[i] = 0;

			strncpy(id_text, Robot_names[id], strlen(Robot_names[id]));

			ui_wprintf_at( MainWindow, 12,  6, "Robot: %3d ", Cur_object_index );
			ui_wprintf_at( MainWindow, 12, 22, "   Id: %3d", id);
			ui_wprintf_at( MainWindow, 12, 38, " Name: %8s", id_text);

		}	else {
			ui_wprintf_at( MainWindow, 12,  6, "Robot: none" );
			ui_wprintf_at( MainWindow, 12, 22, " Type: ?  "  );
			ui_wprintf_at( MainWindow, 12, 38, " Name: ________" );
		}
		Update_flags |= UF_WORLD_CHANGED;
	}

	if ( QuitButton->pressed || (last_keypress==KEY_ESC))	{
		robot_close_window();
		return;
	}		

	old_object = Cur_object_index;
}
Exemplo n.º 5
0
void do_hostage_window()
{
	fix DeltaTime, Temp;

	if ( MainWindow == NULL ) return;

	SelectClosestHostage();

	//------------------------------------------------------------
	// Call the ui code..
	//------------------------------------------------------------
	ui_button_any_drawn = 0;
	ui_window_do_gadgets(MainWindow);

	//------------------------------------------------------------
	// If we change objects, we need to reset the ui code for all
	// of the radio buttons that control the ai mode.  Also makes
	// the current AI mode button be flagged as pressed down.
	//------------------------------------------------------------
	if (LastHostageIndex != CurrentHostageIndex )	{

		if ( CurrentHostageIndex > -1 )	
			strcpy( HostageText->text, Hostages[CurrentHostageIndex].text );
		else
			strcpy(HostageText->text, " " );

		HostageText->position = strlen(HostageText->text);
		HostageText->oldposition = HostageText->position;
		HostageText->status=1;
		HostageText->first_time = 1;

	}

	//------------------------------------------------------------
	// If any of the radio buttons that control the mode are set, then
	// update the cooresponding AI state.
	//------------------------------------------------------------
	if ( CurrentHostageIndex > -1 )	
		strcpy( Hostages[CurrentHostageIndex].text, HostageText->text );

	//------------------------------------------------------------
	// A simple frame time counter for spinning the objects...
	//------------------------------------------------------------
	Temp = timer_get_fixed_seconds();
	DeltaTime = Temp - Time;
	Time = Temp;

	//------------------------------------------------------------
	// Redraw the object in the little 64x64 box
	//------------------------------------------------------------
	if (CurrentHostageIndex > -1 )	{
		int vclip_num;
		
		vclip_num = Hostages[CurrentHostageIndex].vclip_num;

		Assert(vclip_num != -1);

		gr_set_current_canvas( HostageViewBox->canvas );

		if ( vclip_num > -1 )	{
			vclip_play( &Hostage_face_clip[vclip_num], DeltaTime );	
		} else {
			gr_clear_canvas( CGREY );
		}
	} else {
		// no hostage, so just blank out
		gr_set_current_canvas( HostageViewBox->canvas );
		gr_clear_canvas( CGREY );
	}

	//------------------------------------------------------------
	// If anything changes in the ui system, redraw all the text that
	// identifies this robot.
	//------------------------------------------------------------
	if (ui_button_any_drawn || (LastHostageIndex != CurrentHostageIndex) )	{
		if ( CurrentHostageIndex > -1 )	{
			ui_wprintf_at( MainWindow, 10, 15, "Hostage: %d   Object: %d", CurrentHostageIndex, Hostages[CurrentHostageIndex].objnum );
			//@@ui_wprintf_at( MainWindow, 10, 73, "Type: %d   Sound: %d   ", Hostages[CurrentHostageIndex].type, Hostages[CurrentHostageIndex].sound_num );
			ui_wprintf_at( MainWindow, 10, 73, "Face: %d   ", Hostages[CurrentHostageIndex].vclip_num);
		}	else {
			ui_wprintf_at( MainWindow, 10, 15, "Hostage: none " );
			//@@ui_wprintf_at( MainWindow, 10, 73, "Type:    Sound:       " );
			ui_wprintf_at( MainWindow, 10, 73, "Face:         " );
		}
		Update_flags |= UF_WORLD_CHANGED;
	}

	if ( QuitButton->pressed || (last_keypress==KEY_ESC))	{
		hostage_close_window();
		return;
	}		

	LastHostageIndex = CurrentHostageIndex;
}
Exemplo n.º 6
0
void do_wall_window()
{
	int i;
	sbyte type;
	fix DeltaTime, Temp;

	if ( MainWindow == NULL ) return;

	//------------------------------------------------------------
	// Call the ui code..
	//------------------------------------------------------------
	ui_button_any_drawn = 0;
	ui_window_do_gadgets(MainWindow);

	//------------------------------------------------------------
	// If we change walls, we need to reset the ui code for all
	// of the checkboxes that control the wall flags.  
	//------------------------------------------------------------
	if (old_wall_num != Cursegp->sides[Curside].wall_num) {
		for (	i=0; i < 3; i++ )	{
			DoorFlag[i]->flag = 0;		// Tells ui that this button isn't checked
			DoorFlag[i]->status = 1;	// Tells ui to redraw button
		}
		for (	i=0; i < 4; i++ )	{
			KeyFlag[i]->flag = 0;		// Tells ui that this button isn't checked
			KeyFlag[i]->status = 1;		// Tells ui to redraw button
		}

		if ( Cursegp->sides[Curside].wall_num != -1) {
			if (Walls[Cursegp->sides[Curside].wall_num].flags & WALL_DOOR_LOCKED)			
				DoorFlag[0]->flag = 1;	// Mark this button as checked
			if (Walls[Cursegp->sides[Curside].wall_num].flags & WALL_DOOR_AUTO)
				DoorFlag[1]->flag = 1;	// Mark this button as checked
			if (Walls[Cursegp->sides[Curside].wall_num].flags & WALL_ILLUSION_OFF)
				DoorFlag[2]->flag = 1;	// Mark this button as checked

			if (Walls[Cursegp->sides[Curside].wall_num].keys & KEY_NONE)
				KeyFlag[0]->flag = 1;
			if (Walls[Cursegp->sides[Curside].wall_num].keys & KEY_BLUE)
				KeyFlag[1]->flag = 1;
			if (Walls[Cursegp->sides[Curside].wall_num].keys & KEY_RED)
				KeyFlag[2]->flag = 1;
			if (Walls[Cursegp->sides[Curside].wall_num].keys & KEY_GOLD)
				KeyFlag[3]->flag = 1;
		}
	}
	
	//------------------------------------------------------------
	// If any of the checkboxes that control the wallflags are set, then
	// update the corresponding wall flag.
	//------------------------------------------------------------

	if (Walls[Cursegp->sides[Curside].wall_num].type == WALL_DOOR) {
		if ( DoorFlag[0]->flag == 1 )	
			Walls[Cursegp->sides[Curside].wall_num].flags |= WALL_DOOR_LOCKED;
		else
			Walls[Cursegp->sides[Curside].wall_num].flags &= ~WALL_DOOR_LOCKED;
		if ( DoorFlag[1]->flag == 1 )	
			Walls[Cursegp->sides[Curside].wall_num].flags |= WALL_DOOR_AUTO;
		else
			Walls[Cursegp->sides[Curside].wall_num].flags &= ~WALL_DOOR_AUTO;

		//------------------------------------------------------------
		// If any of the radio buttons that control the mode are set, then
		// update the corresponding key.
		//------------------------------------------------------------
		for (	i=0; i < 4; i++ )	{
			if ( KeyFlag[i]->flag == 1 ) {
				Walls[Cursegp->sides[Curside].wall_num].keys = 1<<i;		// Set the ai_state to the cooresponding radio button
			}
		}
	} else {
		for (	i=0; i < 2; i++ )	
			if (DoorFlag[i]->flag == 1) { 
				DoorFlag[i]->flag = 0;		// Tells ui that this button isn't checked
				DoorFlag[i]->status = 1;	// Tells ui to redraw button
			}
		for (	i=0; i < 4; i++ )	{
			if ( KeyFlag[i]->flag == 1 ) {
				KeyFlag[i]->flag = 0;		
				KeyFlag[i]->status = 1;		
			}
		}
	}

	if (Walls[Cursegp->sides[Curside].wall_num].type == WALL_ILLUSION) {
		if ( DoorFlag[2]->flag == 1 )	
			Walls[Cursegp->sides[Curside].wall_num].flags |= WALL_ILLUSION_OFF;
		else
			Walls[Cursegp->sides[Curside].wall_num].flags &= ~WALL_ILLUSION_OFF;
	} else 
		for (	i=2; i < 3; i++ )	
			if (DoorFlag[i]->flag == 1) { 
				DoorFlag[i]->flag = 0;		// Tells ui that this button isn't checked
				DoorFlag[i]->status = 1;	// Tells ui to redraw button
			}

	//------------------------------------------------------------
	// A simple frame time counter for animating the walls...
	//------------------------------------------------------------
	Temp = timer_get_fixed_seconds();
	DeltaTime = Temp - Time;

	//------------------------------------------------------------
	// Draw the wall in the little 64x64 box
	//------------------------------------------------------------
  	gr_set_current_canvas( WallViewBox->canvas );
	if (Cursegp->sides[Curside].wall_num != -1) {
		type = Walls[Cursegp->sides[Curside].wall_num].type;
		if ((type == WALL_DOOR) || (type == WALL_BLASTABLE)) {
			if (DeltaTime > ((F1_0*200)/1000)) {
				framenum++;
				Time = Temp;
			}
			if (framenum >= WallAnims[Walls[Cursegp->sides[Curside].wall_num].clip_num].num_frames)
				framenum=0;
			PIGGY_PAGE_IN(Textures[WallAnims[Walls[Cursegp->sides[Curside].wall_num].clip_num].frames[framenum]]);
			gr_ubitmap(0,0, &GameBitmaps[Textures[WallAnims[Walls[Cursegp->sides[Curside].wall_num].clip_num].frames[framenum]].index]);
		} else {
			if (type == WALL_OPEN)
				gr_clear_canvas( CBLACK );
			else {
				if (Cursegp->sides[Curside].tmap_num2 > 0)
					gr_ubitmap(0,0, texmerge_get_cached_bitmap( Cursegp->sides[Curside].tmap_num, Cursegp->sides[Curside].tmap_num2));
				else	{
					PIGGY_PAGE_IN(Textures[Cursegp->sides[Curside].tmap_num]);
					gr_ubitmap(0,0, &GameBitmaps[Textures[Cursegp->sides[Curside].tmap_num].index]);
				}
			}
		}
	} else
		gr_clear_canvas( CGREY );

	//------------------------------------------------------------
	// If anything changes in the ui system, redraw all the text that
	// identifies this wall.
	//------------------------------------------------------------
	if (ui_button_any_drawn || (old_wall_num != Cursegp->sides[Curside].wall_num) )	{
		if ( Cursegp->sides[Curside].wall_num > -1 )	{
			ui_wprintf_at( MainWindow, 12, 6, "Wall: %d    ", Cursegp->sides[Curside].wall_num);
			switch (Walls[Cursegp->sides[Curside].wall_num].type) {
				case WALL_NORMAL:
					ui_wprintf_at( MainWindow, 12, 23, " Type: Normal   " );
					break;
				case WALL_BLASTABLE:
					ui_wprintf_at( MainWindow, 12, 23, " Type: Blastable" );
					break;
				case WALL_DOOR:
					ui_wprintf_at( MainWindow, 12, 23, " Type: Door     " );
					ui_wprintf_at( MainWindow, 223, 6, "%s", WallAnims[Walls[Cursegp->sides[Curside].wall_num].clip_num].filename);
					break;
				case WALL_ILLUSION:
					ui_wprintf_at( MainWindow, 12, 23, " Type: Illusion " );
					break;
				case WALL_OPEN:
					ui_wprintf_at( MainWindow, 12, 23, " Type: Open     " );
					break;
				case WALL_CLOSED:
					ui_wprintf_at( MainWindow, 12, 23, " Type: Closed   " );
					break;
				default:
					ui_wprintf_at( MainWindow, 12, 23, " Type: Unknown  " );
					break;
			}			
			if (Walls[Cursegp->sides[Curside].wall_num].type != WALL_DOOR)
					ui_wprintf_at( MainWindow, 223, 6, "            " );

			ui_wprintf_at( MainWindow, 12, 40, " Clip: %d   ", Walls[Cursegp->sides[Curside].wall_num].clip_num );
			ui_wprintf_at( MainWindow, 12, 57, " Trigger: %d  ", Walls[Cursegp->sides[Curside].wall_num].trigger );
		}	else {
			ui_wprintf_at( MainWindow, 12, 6, "Wall: none ");
			ui_wprintf_at( MainWindow, 12, 23, " Type: none ");
			ui_wprintf_at( MainWindow, 12, 40, " Clip: none   ");
			ui_wprintf_at( MainWindow, 12, 57, " Trigger: none  ");
		}
		Update_flags |= UF_WORLD_CHANGED;
	}
	if ( QuitButton->pressed || (last_keypress==KEY_ESC) )	{
		close_wall_window();
		return;
	}		

	old_wall_num = Cursegp->sides[Curside].wall_num;
}
Exemplo n.º 7
0
void do_centers_window()
{
	int i;
//	int robot_flags;
	int redraw_window;

	if ( MainWindow == NULL ) return;

	//------------------------------------------------------------
	// Call the ui code..
	//------------------------------------------------------------
	ui_button_any_drawn = 0;
	ui_window_do_gadgets(MainWindow);

	//------------------------------------------------------------
	// If we change walls, we need to reset the ui code for all
	// of the checkboxes that control the wall flags.  
	//------------------------------------------------------------
	if (old_seg_num != Cursegp-Segments) {
		for (	i=0; i < MAX_CENTER_TYPES; i++ ) {
			CenterFlag[i]->flag = 0;		// Tells ui that this button isn't checked
			CenterFlag[i]->status = 1;		// Tells ui to redraw button
		}

		Assert(Cursegp->special < MAX_CENTER_TYPES);
		CenterFlag[Cursegp->special]->flag = 1;

		mprintf((0, "Cursegp->matcen_num = %i\n", Cursegp->matcen_num));

		//	Read materialization center robot bit flags
		for (	i=0; i < N_robot_types; i++ ) {
			RobotMatFlag[i]->status = 1;		// Tells ui to redraw button
			if (RobotCenters[Cursegp->matcen_num].robot_flags & (1 << i))
				RobotMatFlag[i]->flag = 1;		// Tells ui that this button is checked
			else
				RobotMatFlag[i]->flag = 0;		// Tells ui that this button is not checked
		}

	}

	//------------------------------------------------------------
	// If any of the radio buttons that control the mode are set, then
	// update the corresponding center.
	//------------------------------------------------------------

	redraw_window=0;
	for (	i=0; i < MAX_CENTER_TYPES; i++ )	{
		if ( CenterFlag[i]->flag == 1 )
			if ( i == 0)
				fuelcen_delete(Cursegp);
			else if ( Cursegp->special != i ) {
				fuelcen_delete(Cursegp);
				redraw_window = 1;
				fuelcen_activate( Cursegp, i );
			}
	}

	for (	i=0; i < N_robot_types; i++ )	{
		if ( RobotMatFlag[i]->flag == 1 ) {
			if (!(RobotCenters[Cursegp->matcen_num].robot_flags & (1<<i) )) {
				RobotCenters[Cursegp->matcen_num].robot_flags |= (1<<i);
				mprintf((0,"Segment %i, matcen = %i, Robot_flags %d\n", Cursegp-Segments, Cursegp->matcen_num, RobotCenters[Cursegp->matcen_num].robot_flags));
			} 
		} else if (RobotCenters[Cursegp->matcen_num].robot_flags & 1<<i) {
			RobotCenters[Cursegp->matcen_num].robot_flags &= ~(1<<i);
			mprintf((0,"Segment %i, matcen = %i, Robot_flags %d\n", Cursegp-Segments, Cursegp->matcen_num, RobotCenters[Cursegp->matcen_num].robot_flags));
		}
	}
	
	//------------------------------------------------------------
	// If anything changes in the ui system, redraw all the text that
	// identifies this wall.
	//------------------------------------------------------------
	if (redraw_window || (old_seg_num != Cursegp-Segments ) ) {
//		int	i;
//		char	temp_text[CENTER_STRING_LENGTH];
	
		ui_wprintf_at( MainWindow, 12, 6, "Seg: %3d", Cursegp-Segments );

//		for (i=0; i<CENTER_STRING_LENGTH; i++)
//			temp_text[i] = ' ';
//		temp_text[i] = 0;

//		Assert(Cursegp->special < MAX_CENTER_TYPES);
//		strncpy(temp_text, Center_names[Cursegp->special], strlen(Center_names[Cursegp->special]));
//		ui_wprintf_at( MainWindow, 12, 23, " Type: %s", temp_text );
		Update_flags |= UF_WORLD_CHANGED;
	}

	if ( QuitButton->pressed || (last_keypress==KEY_ESC) )	{
		close_centers_window();
		return;
	}		

	old_seg_num = Cursegp-Segments;
}
Exemplo n.º 8
0
void do_trigger_window()
{
	int i;
	short Markedwall, trigger_num;

	if ( MainWindow == NULL ) return;
	if (!Markedsegp) {
		close_trigger_window();
		return;
	}

	//------------------------------------------------------------
	// Call the ui code..
	//------------------------------------------------------------
	ui_button_any_drawn = 0;
	ui_window_do_gadgets(MainWindow);
	
	//------------------------------------------------------------
	// If we change walls, we need to reset the ui code for all
	// of the checkboxes that control the wall flags.  
	//------------------------------------------------------------
	Markedwall = Markedsegp->sides[Markedside].wall_num;
	if (Markedwall != -1)
		trigger_num = Walls[Markedwall].trigger;
	else trigger_num = -1;

	if (old_trigger_num != trigger_num ) {
		for (	i=0; i < NUM_TRIGGER_FLAGS; i++ )	{
			TriggerFlag[i]->flag = 0;				// Tells ui that this button isn't checked
			TriggerFlag[i]->status = 1;				// Tells ui to redraw button
		}

		if (trigger_num != -1) {
  			if (Triggers[trigger_num].flags & TRIGGER_CONTROL_DOORS)
				TriggerFlag[0]->flag = 1;
 			if (Triggers[trigger_num].flags & TRIGGER_SHIELD_DAMAGE)
				TriggerFlag[1]->flag = 1;
 			if (Triggers[trigger_num].flags & TRIGGER_ENERGY_DRAIN)
				TriggerFlag[2]->flag = 1;
 			if (Triggers[trigger_num].flags & TRIGGER_EXIT)
				TriggerFlag[3]->flag = 1;
 			if (Triggers[trigger_num].flags & TRIGGER_ONE_SHOT)
				TriggerFlag[4]->flag = 1;
 			if (Triggers[trigger_num].flags & TRIGGER_ILLUSION_ON)
				TriggerFlag[5]->flag = 1;
 			if (Triggers[trigger_num].flags & TRIGGER_ILLUSION_OFF)
				TriggerFlag[6]->flag = 1;
 			if (Triggers[trigger_num].flags & TRIGGER_ON)
				TriggerFlag[7]->flag = 1;
 			if (Triggers[trigger_num].flags & TRIGGER_MATCEN)
				TriggerFlag[8]->flag = 1;
 			if (Triggers[trigger_num].flags & TRIGGER_SECRET_EXIT)
				TriggerFlag[9]->flag = 1;
		}
	}
	
	//------------------------------------------------------------
	// If any of the checkboxes that control the wallflags are set, then
	// update the cooresponding wall flag.
	//------------------------------------------------------------
	if (IS_CHILD(Markedsegp->children[Markedside])) {
		if (TriggerFlag[0]->flag == 1) 
			trigger_add_to_Markedside(TRIGGER_CONTROL_DOORS); 
		else
			trigger_remove_flag_from_Markedside(TRIGGER_CONTROL_DOORS);
		if (TriggerFlag[1]->flag == 1)
			trigger_add_to_Markedside(TRIGGER_SHIELD_DAMAGE); 
		else
			trigger_remove_flag_from_Markedside(TRIGGER_SHIELD_DAMAGE);
		if (TriggerFlag[2]->flag == 1)
			trigger_add_to_Markedside(TRIGGER_ENERGY_DRAIN); 
		else
			trigger_remove_flag_from_Markedside(TRIGGER_ENERGY_DRAIN);
		if (TriggerFlag[3]->flag == 1)
			trigger_add_to_Markedside(TRIGGER_EXIT); 
		else
			trigger_remove_flag_from_Markedside(TRIGGER_EXIT);
		if (TriggerFlag[4]->flag == 1)
			trigger_add_to_Markedside(TRIGGER_ONE_SHOT); 
		else
			trigger_remove_flag_from_Markedside(TRIGGER_ONE_SHOT);
		if (TriggerFlag[5]->flag == 1)
			trigger_add_to_Markedside(TRIGGER_ILLUSION_ON); 
		else
			trigger_remove_flag_from_Markedside(TRIGGER_ILLUSION_ON);
		if (TriggerFlag[6]->flag == 1)
			trigger_add_to_Markedside(TRIGGER_ILLUSION_OFF);
		else
			trigger_remove_flag_from_Markedside(TRIGGER_ILLUSION_OFF);
		if (TriggerFlag[7]->flag == 1)
			trigger_add_to_Markedside(TRIGGER_ON);
		else
			trigger_remove_flag_from_Markedside(TRIGGER_ON);

		if (TriggerFlag[8]->flag == 1) 
			trigger_add_to_Markedside(TRIGGER_MATCEN);
		else
			trigger_remove_flag_from_Markedside(TRIGGER_MATCEN);

		if (TriggerFlag[9]->flag == 1) 
			trigger_add_to_Markedside(TRIGGER_SECRET_EXIT);
		else
			trigger_remove_flag_from_Markedside(TRIGGER_SECRET_EXIT);

	} else
		for (	i=0; i < NUM_TRIGGER_FLAGS; i++ )
			if (TriggerFlag[i]->flag == 1) { 
				TriggerFlag[i]->flag = 0;					// Tells ui that this button isn't checked
				TriggerFlag[i]->status = 1;				// Tells ui to redraw button
			}
	
	//------------------------------------------------------------
	// Draw the wall in the little 64x64 box
	//------------------------------------------------------------
  	gr_set_current_canvas( WallViewBox->canvas );

	if ((Markedsegp->sides[Markedside].wall_num == -1) || (Walls[Markedsegp->sides[Markedside].wall_num].trigger) == -1)
		gr_clear_canvas( CBLACK );
	else {
		if (Markedsegp->sides[Markedside].tmap_num2 > 0)  {
			gr_ubitmap(0,0, texmerge_get_cached_bitmap( Markedsegp->sides[Markedside].tmap_num, Markedsegp->sides[Markedside].tmap_num2));
		} else {
			if (Markedsegp->sides[Markedside].tmap_num > 0)	{
				PIGGY_PAGE_IN(Textures[Markedsegp->sides[Markedside].tmap_num]);
				gr_ubitmap(0,0, &GameBitmaps[Textures[Markedsegp->sides[Markedside].tmap_num].index]);
			} else
				gr_clear_canvas( CGREY );
		}
 	}

	//------------------------------------------------------------
	// If anything changes in the ui system, redraw all the text that
	// identifies this robot.
	//------------------------------------------------------------
	if (ui_button_any_drawn || (old_trigger_num != trigger_num) ) {
		if ( Markedsegp->sides[Markedside].wall_num > -1 )	{
			ui_wprintf_at( MainWindow, 12, 6, "Trigger: %d    ", trigger_num);
		}	else {
			ui_wprintf_at( MainWindow, 12, 6, "Trigger: none ");
		}
		Update_flags |= UF_WORLD_CHANGED;
	}

	if ( QuitButton->pressed || (last_keypress==KEY_ESC))	{
		close_trigger_window();
		return;
	}		

	old_trigger_num = trigger_num;
}
Exemplo n.º 9
0
Arquivo: file.c Projeto: 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;
}