示例#1
0
//Handle the operation of the home screen
void Base::BaseScreen()
{
	if(data->visited) sprintf_s(datastring,2048,"%s",data->txtrevisit);
	else sprintf_s(datastring,2048,"%s",data->txtarrive);

	//sprintf_s(descstring2,2048,"\0");
	
	if(playmode==SINGLEPLAYER)
	{
		char shieldstring[20];
		sprintf_s(descstring,2048,"Ship: %s\nEnergy: %.0f%%\nMissiles: %d\nMain: %s\nShields: %s%%\nPower Usage: %.0f%%\n\nCredits: %d",ship[player].name,100.0f*ship[player].energy/ship[player].maxenergy,ship[player].missiles,ship[player].weapon->name.c_str(),ship[player].equipment[SHIELD]?(sprintf_s(shieldstring,20,"%.0f",100.0f*ship[player].shields/ship[player].maxshields),shieldstring):"N/A",100.0f*ship[player].power/ship[player].maxpower,ship[player].credits);
		UINT m[6];
		m[0] = messageindex;
		for(int i=1;i<6;++i)
			m[i] = (m[0]+i)%6;
		if(newmessagetime<=thistick)
		{
			newmessagetime = thistick + rand()%800;
			PrintMessage(message[messageindex].txt);
			messageindex = (messageindex + 1)%6;
		}
		sprintf_s(descstring2,2048,"%s\n%s\n%s\n%s\n%s\n%s\n",message[m[0]].txt,message[m[1]].txt,message[m[2]].txt,message[m[3]].txt,message[m[4]].txt,message[m[5]].txt);
	}
	else
	{
		sprintf_s(descstring,2048," \0");
		sprintf_s(descstring2,2048," \0");
	}

	if(ship[player].keys.OPERATE)
	{
		ship[player].keys.OPERATE = false;
		soundeffect[MENUSELECT].SetSoundEffect(0);
		switch (button[buttonselector])
		{
		case EXIT:
			sprintf_s(messagestring,1024,"Leaving base ...");
			screen = HOME;
			LeaveBase();
			return;
		case SHIP:		//Ship screen
			ChangeScreen(SHIP);
			return;
		case WEAPON:		//Weapon screen
			ChangeScreen(WEAPON);
			return;
		case EQUIP:		//Equip screen
			ChangeScreen(EQUIP);
			return;
		}
	}
	return;
}
示例#2
0
 void Screen::ChangeScreenOnSettingsChange()
 {
     int iWidth   = (int) sm->GetVariable("screen", "width");
     int iHeight  = (int) sm->GetVariable("screen", "height");
     bool bFull   = (bool)sm->GetVariable("screen", "fullscreen");
     bool bResize = (bool)sm->GetVariable("screen", "resizable");
     bool bCursor = (bool)sm->GetVariable("screen", "showcursor");
     bool native  = (bool)sm->GetVariable("screen", "native");
     static SORE_Graphics::ScreenInfo screen;
     screen.width=iWidth;
     screen.height=iHeight;
     screen.fullscreen=bFull;
     screen.resizable=bResize;
     screen.showCursor=bCursor;
     screen.useNativeResolution = native;
     ChangeScreen(screen);
 }
示例#3
0
void Base::WeaponScreen()
{
	int first, items = 0, *elist, displaylist[7];
	bool available = false;
	selectbar = -1;
	elist = new int[numberofweapons];

	//dbout<<listselector<<endl;
	sprintf_s(descstring,2048,"\0");
	sprintf_s(descstring2,2048,"\0");

	//Make list of weapons available for selection
	for(int i=0;i<numberofweapons;i++) if(weaponlist[i].available) elist[items++] = i;

	if(ship[player].keys.UP)		//Move the selector bar with arrow keys
	{
		ship[player].keys.UP = false;
		if(listselector>0)
		{
			--listselector;
			soundeffect[MENUMOVE].SetSoundEffect(0);
		}
		else soundeffect[MENUREJECT].SetSoundEffect(0);
	}
	if(ship[player].keys.DOWN)
	{
		ship[player].keys.DOWN = false;
		if(listselector<(items-1))
		{
			++listselector;
			soundeffect[MENUMOVE].SetSoundEffect(0);
		}
		else soundeffect[MENUREJECT].SetSoundEffect(0);
	}


	if(listselector<=3) first = 0;		//First section
	else if(listselector>items-5) first = items-7;	//Last section
	else first = listselector-3;		//Scrolling section

	if(items<8)
	{
		for(int i=0;i<items;i++)		//Fit all items onto one list and move bar up and down
		{
			if(i==listselector)
			{
				sprintf_s(descstring,2048,"%s",weaponlist[elist[listselector]].description.c_str());
				sprintf_s(descstring2,2048,"Power: %.1f MW\nFire Rate: %.1f /sec\nRange: %d\nRebound: %s",weaponlist[elist[listselector]].power,1000.0f/weaponlist[elist[listselector]].firerate,(int)(weaponlist[elist[listselector]].speed/weaponlist[elist[listselector]].faderate),weaponlist[elist[listselector]].bounce?"yes":"no");
				//if ship power			-	power used by current weapon							+	proposed weapon power				>	maximum power available
				if( (ship[player].power - (ship[player].weapon!=NULL?ship[player].weapon->power:0) + weaponlist[elist[listselector]].power) > ship[player].maxpower)
				{	//Not available
					sprintf_s(messagestring,1024,"Insufficient power for this weapon");
				}
				else
				{	sprintf_s(messagestring,1024,"Power required: %.1lf",weaponlist[elist[listselector]].power);
					available = true;
				}
				selectbar = i;
			}
			displaylist[i] = elist[i];
		}
		if(items<7) for(int i=0;i<7-items;i++) displaylist[items+i] = -1;
	}
	else						//Put items into long list and scroll list
	{
		for(int i=0;i<7;i++,first++)
		{
			if(first==listselector)
			{
				sprintf_s(descstring,2048,"%s",weaponlist[elist[listselector]].description);
				//if ship power			-	power used by current weapon							+	proposed weapon power				>	maximum power available
				if( (ship[player].power - (ship[player].weapon!=NULL?ship[player].weapon->power:0) + weaponlist[elist[listselector]].power) > ship[player].maxpower)
				{	//Not available
					sprintf_s(messagestring,1024,"Insufficient power for this weapon");
				}
				else
				{	sprintf_s(messagestring,1024,"Power required: %.1lf",weaponlist[elist[listselector]].power);
					available = true;
				}
				selectbar = i;
			}
			displaylist[i] = elist[first];
		}
	}

	sprintf_s(datastring,2048,"%s\n%s\n%s\n%s\n%s\n%s\n%s\0",
		displaylist[0]>-1?weaponlist[displaylist[0]].name.c_str():"\0",
		displaylist[1]>-1?weaponlist[displaylist[1]].name.c_str():"\0",
		displaylist[2]>-1?weaponlist[displaylist[2]].name.c_str():"\0",
		displaylist[3]>-1?weaponlist[displaylist[3]].name.c_str():"\0",
		displaylist[4]>-1?weaponlist[displaylist[4]].name.c_str():"\0",
		displaylist[5]>-1?weaponlist[displaylist[5]].name.c_str():"\0",
		displaylist[6]>-1?weaponlist[displaylist[6]].name.c_str():"\0");


	meter[0].value = ship[player].power;			//Ship power usage
	meter[0].maxvalue = ship[player].maxpower;
	if(ship[player].weapon == &weaponlist[elist[listselector]])		//If this is the current weapon
	{
		meter[1].value = ship[player].weapon->power;			//Equipment power usage
		meter[1].maxvalue = ship[player].maxpower;
		meter[2].value = ship[player].power;			//Predicted power usage
		meter[2].maxvalue = ship[player].maxpower;
	}
	else
	{
		meter[1].value = weaponlist[elist[listselector]].power;			//Equipment power usage
		meter[1].maxvalue = ship[player].maxpower;
		meter[2].value = ship[player].power - ship[player].weapon->power + weaponlist[elist[listselector]].power;			//Predicted power usage
		meter[2].maxvalue = ship[player].maxpower;
	}
	meter[0].type = MUSED;
	meter[1].type = MPOWER;
	meter[2].type = MTOTAL;

	if(ship[player].keys.OPERATE)
	{
		ship[player].keys.OPERATE = false;
		switch (button[buttonselector])
		{
		case EXIT:
			soundeffect[MENUSELECT].SetSoundEffect(0);
			delete [] elist;
			ChangeScreen(HOME);
			return;
		case SELECT:		//Select
			if(available)
			{	soundeffect[MENUSELECT].SetSoundEffect(0);
				soundeffect[INSTALLITEM].SetSoundEffect(0);
				ship[player].power -= ship[player].weapon->power;
				ship[player].weapon = &weaponlist[elist[listselector]];
				ship[player].power += ship[player].weapon->power;
				sprintf_s(messagestring,1024,"Installed a %s",weaponlist[elist[listselector]].name.c_str());
			}
			else
			{	soundeffect[MENUREJECT].SetSoundEffect(0);
				//sprintf_s(messagestring,1024,"Insufficient power for this weapon");
			}
			delete [] elist;
			return;
		case EQUIP:		//Equip screen
			delete [] elist;
			ChangeScreen(EQUIP);
			return;
		case WEAPON:	//Weapon screen
			delete [] elist;
			ChangeScreen(WEAPON);
			return;
		case SHIP:		//Ship screen
			delete [] elist;
			ChangeScreen(SHIP);
			return;
		}
	}
	delete [] elist;
	return;
}
示例#4
0
void Base::EquipScreen()
{
	int first, elist[NUMEQUIPTYPES], displaylist[7];
	selectbar = -1;

	sprintf_s(descstring2,2048,"\0");

	int items = 0;
	for(int i=1;i<NUMEQUIPTYPES;i++) if(equipment[i]) elist[items++] = i;

	if(ship[player].keys.UP)
	{
		ship[player].keys.UP = false;
		if(listselector>0)
		{
			--listselector;
			glyph.CreateGraphicalObject(equipdata[elist[listselector]].graphics.c_str(),1);
			soundeffect[MENUMOVE].SetSoundEffect(0);
		}
		else soundeffect[MENUREJECT].SetSoundEffect(0);
	}
	if(ship[player].keys.DOWN)
	{
		ship[player].keys.DOWN = false;
		if(listselector<(items-1))
		{
			++listselector;
			glyph.CreateGraphicalObject(equipdata[elist[listselector]].graphics.c_str(),1);
			soundeffect[MENUMOVE].SetSoundEffect(0);
		}
		else soundeffect[MENUREJECT].SetSoundEffect(0);
	}

	meter[0].value = ship[player].power;			//Ship power usage
	meter[0].maxvalue = ship[player].maxpower;
	if(ship[player].equipment[elist[listselector]])
	{
		meter[1].value = 0;			//Equipment power usage
		meter[1].maxvalue = ship[player].maxpower;
		meter[2].value = ship[player].power;			//Predicted power usage
		meter[2].maxvalue = ship[player].maxpower;
	}
	else
	{
		if(elist[listselector] == AUXILIARY_GENERATOR)
		{
			meter[1].value = 0;									//Equipment power usage
			meter[1].maxvalue = ship[player].maxpower-equipdata[elist[listselector]].power;
			meter[2].value = ship[player].power;			//Predicted power usage
			meter[2].maxvalue = ship[player].maxpower-equipdata[elist[listselector]].power;
		}
		else
		{
			meter[1].value = equipdata[elist[listselector]].power;			//Equipment power usage
			meter[1].maxvalue = ship[player].maxpower;
			meter[2].value = ship[player].power+equipdata[elist[listselector]].power;			//Predicted power usage
			meter[2].maxvalue = ship[player].maxpower;
		}
	}
	meter[0].type = MUSED;
	meter[1].type = MPOWER;
	meter[2].type = MTOTAL;

	if(listselector<=3) first = 0;		//First section
	else if(listselector>=items-4) first = items-7;	//Last section
	else first = listselector-3;		//Scrolling section

	if(items<8)
	{
		for(int i=0;i<items;i++)
		{
			if(i==listselector)
			{
				selectbar = i;
				sprintf_s(descstring,2048,"%s \0",equipdata[elist[i]].description.c_str());
				//DrawSmallString(EqDesc[list[i]],391,276,621,false);
			}
			displaylist[i] = elist[i];
		}
		if(items<7) for(int i=0;i<7-items;i++) displaylist[items+i] = -1;
	}
	else
	{
		for(int i=0;i<7;i++,first++)
		{
			if(first==listselector)
			{
				selectbar = i;
				sprintf_s(descstring,2048,"%s \0",equipdata[elist[first]].description.c_str());
				//DrawSmallString(EqDesc[elist[first]],391,276,621,false);
			}
			displaylist[i] = elist[first];
		}
	}

	sprintf_s(datastring,2048,"%s\n%s\n%s\n%s\n%s\n%s\n%s\0",
				displaylist[0]>-1?equipdata[displaylist[0]].name.c_str():"\0",
				displaylist[1]>-1?equipdata[displaylist[1]].name.c_str():"\0",
				displaylist[2]>-1?equipdata[displaylist[2]].name.c_str():"\0",
				displaylist[3]>-1?equipdata[displaylist[3]].name.c_str():"\0",
				displaylist[4]>-1?equipdata[displaylist[4]].name.c_str():"\0",
				displaylist[5]>-1?equipdata[displaylist[5]].name.c_str():"\0",
				displaylist[6]>-1?equipdata[displaylist[6]].name.c_str():"\0");


	if(ship[player].keys.OPERATE)
	{
		ship[player].keys.OPERATE = false;
		switch (button[buttonselector])
		{
		case EXIT:
			ChangeScreen(HOME);
			return;
		case SELECT:		//Select
			if(!ship[player].equipment[elist[listselector]])
			{
				if((ship[player].power + equipdata[elist[listselector]].power)<=ship[player].maxpower )
				{
					ship[player].equipment[elist[listselector]] = true;
					ship[player].power += equipdata[elist[listselector]].power;
					sprintf_s(messagestring,1024,"Added %s ",equipdata[elist[listselector]].name.c_str());

					if(elist[listselector] == BOMB) data->equipment[BOMB]--;
					if(elist[listselector] == LASER_DRONE)
					{
						CreateDrone(player);
					}
					if(elist[listselector] == LIGHTNING_DRONE)
					{
						CreateLightningDrone(player);
					}
					if(elist[listselector] == SHIELD_DRONE)
					{
						for(int i=0;i<3;i++) CreateShieldDrone(player,i);
					}
					if(elist[listselector] == AUXILIARY_GENERATOR)
					{
						ship[player].maxpower -= equipdata[AUXILIARY_GENERATOR].power;
						ship[player].power -= equipdata[AUXILIARY_GENERATOR].power;		//To reverse the addition above
					}
					if(elist[listselector] == SHIELD)
					{
						ship[player].shields = ship[player].maxshields;
					}
					soundeffect[MENUSELECT].SetSoundEffect(0);
					soundeffect[INSTALLITEM].SetSoundEffect(0);
				}
				else
				{
					sprintf_s(messagestring,1024,"Not enough power");
					soundeffect[MENUREJECT].SetSoundEffect(0);
				}
			}
			else
			{
				sprintf_s(messagestring,1024,"Equipment already installed");
				soundeffect[MENUREJECT].SetSoundEffect(0);
			}
			break;
		case REMOVE:		//Remove
			if(elist[listselector]==RADAR || elist[listselector]==SCANNER)
			{
				sprintf_s(messagestring,1024,"Cannot remove Radar or Scanner");
			}
			else if(elist[listselector]==AUXILIARY_GENERATOR && (ship[player].maxpower + equipdata[AUXILIARY_GENERATOR].power < ship[player].power)) sprintf_s(messagestring,1024,"Cannot remove generator: power overload!");
			else if(ship[player].equipment[elist[listselector]])
			{
				ship[player].equipment[elist[listselector]] = false;
				//data->equipment[elist[listselector]]++;
				ship[player].power -= equipdata[elist[listselector]].power;
				sprintf_s(messagestring,1024,"Removed %s",equipdata[elist[listselector]].name.c_str());
				if(elist[listselector] == LASER_DRONE)
				{
					SET(ship[player].drone->state,FORDESTRUCTION);
					ship[player].drone = NULL;
				}
				if(elist[listselector] == LIGHTNING_DRONE)
				{
					SET(ship[player].lightningdrone->state,FORDESTRUCTION);
					ship[player].lightningdrone = NULL;
				}
				if(elist[listselector] == SHIELD_DRONE)
				{
					SET(ship[player].shielddrone[0]->state,FORDESTRUCTION);
					SET(ship[player].shielddrone[1]->state,FORDESTRUCTION);
					SET(ship[player].shielddrone[2]->state,FORDESTRUCTION);
					ship[player].shielddrone[0] = NULL;
					ship[player].shielddrone[1] = NULL;
					ship[player].shielddrone[2] = NULL;
				}
				if(elist[listselector] == BOMB) data->equipment[BOMB]++;
				if(elist[listselector] == AUXILIARY_GENERATOR)
				{
					ship[player].maxpower += equipdata[AUXILIARY_GENERATOR].power;
					ship[player].power += equipdata[AUXILIARY_GENERATOR].power;		//To reverse the subtraction above
				}
				if(elist[listselector]==RADAR)
				{
					if(ship[player].equipment[SCANNER])
					{
						ship[player].equipment[SCANNER] = false;
						ship[player].power -= equipdata[SCANNER].power;
						sprintf_s(messagestring,1024,"Removed Radar and Scanner");
					}
				}
				soundeffect[MENUSELECT].SetSoundEffect(0);
			}
			else
			{
				sprintf_s(messagestring,1024,"Equipment not installed");
				soundeffect[MENUREJECT].SetSoundEffect(0);
			}
			return;
		case EQUIP:		//Equip screen
			ChangeScreen(EQUIP);
			return;
		case WEAPON:		//Weapon screen
			ChangeScreen(WEAPON);
			return;
		case SHIP:
			ChangeScreen(SHIP);
			return;
		}
	}

	return;
}
示例#5
0
// ************ The ship handling screen ************ //
void Base::ShipScreen()
{
	char tempstring[200], temp2string[200];

	meter[0].value = dummy.maxpower;			//Ship power usage
	meter[0].maxvalue = MAXPOWERMETERVALUE;
	meter[0].type = MPOWER;
	meter[1].value = dummy.maxenergy;			//Ship energy
	meter[1].maxvalue = MAXENERGYMETERVALUE;
	meter[1].type = MENERGY;
	meter[2].value = dummy.forwardsspeed;			//Ship speed
	meter[2].maxvalue = MAXSPEEDMETERVALUE;
	meter[2].type = MSPEED;

	sprintf_s(descstring,2048,"%s",dummy.description);
	if(playmode==SINGLEPLAYER)
	{
		UINT m[6];
		m[0] = messageindex;
		for(int i=1;i<6;++i)
			m[i] = (m[0]+i)%6;
		if(newmessagetime<=thistick)
		{
			newmessagetime = thistick + rand()%800;
			PrintMessage(message[messageindex].txt);
			messageindex = (messageindex + 1)%6;
		}
		sprintf_s(descstring2,2048,"%s\n%s\n%s\n%s\n%s\n%s\n",message[m[0]].txt,message[m[1]].txt,message[m[2]].txt,message[m[3]].txt,message[m[4]].txt,message[m[5]].txt);
	}
	else sprintf_s(descstring2,2048," \0");

	sprintf_s(datastring,2048,"Ship: %s\nManufacturer: %s\nPower: %.1f\nEnergy: %.1f\nEngines: %d\nWeapon mounts: %d\nMissile capacity: %d \0",dummy.name,dummy.manufacturer,dummy.maxpower,dummy.maxenergy,dummy.engines,dummy.weaponmounts,dummy.maxmissiles);

	if(ship[player].keys.OPERATE)
	{
		ship[player].keys.OPERATE = false;
		soundeffect[MENUSELECT].SetSoundEffect(0);
		switch(button[buttonselector])
		{
		case EXIT:
			ChangeScreen(HOME);
			return;
		case SELECT:		//Select
			if(strcmp(data->ships[listselector].name,ship[player].name)==0)
			{
				soundeffect[MENUREJECT].SetSoundEffect(0);
				sprintf_s(messagestring,1024,"This is the same as your current ship!");
				break;
			}
			if(ship[player].credits>=dummy.cost)
			{
				ship[player].credits -= dummy.cost;

				if(ship[player].equipment[LASER_DRONE])
				{
					SET(ship[player].drone->state,FORDESTRUCTION);
					ship[player].drone = NULL;
				}
				if(ship[player].equipment[LIGHTNING_DRONE])
				{
					SET(ship[player].lightningdrone->state,FORDESTRUCTION);
					ship[player].lightningdrone = NULL;
				}
				if(ship[player].equipment[SHIELD_DRONE])
				{
					for(int i=0;i<3;i++)
					{
						SET(ship[player].shielddrone[i]->state,FORDESTRUCTION);
						ship[player].shielddrone[i] = NULL;
					}
				}
				for(int i=0;i<NUMEQUIPTYPES;i++)
					if(ship[player].equipment[i])
					{
						data->equipment[i] = true;
						ship[player].equipment[i] = false;
					}

				if(ship[player].missiles)
				{
					if(dummy.missilemount)
					{
						if(dummy.maxmissiles>=ship[player].missiles) dummy.missiles = ship[player].missiles;
						else dummy.missiles = dummy.maxmissiles;
					}
					else dummy.missiles = 0;
				}
				ship[player].power = 0;
				dummy.credits = ship[player].credits;
				strcpy_s(tempstring,50,ship[player].filename);	//Save file name of our ship
				strcpy_s(temp2string,50,ship[player].name);		//Save name of our ship
				DuplicatePlayer(&dummy,&ship[player]);
				ship[player].equipment[RADAR] = true;
				ship[player].equipment[SCANNER] = true;
				sprintf_s(messagestring,1024,"Changed to %s, charge %d",ship[player].name,ship[player].cost);
				//dbout<<"Current ship now "<<ship[player].name<<", ship in base "<<data->ships[listselector].name<<endl;
			}
			else
			{
				soundeffect[MENUREJECT].SetSoundEffect(0);
				sprintf_s(messagestring,1024,"Not enough credits - cost %d",dummy.cost);
			}
			break;
		case EQUIP:		//Equip screen
			ChangeScreen(EQUIP);
			return;
		case WEAPON:		//Weapon screen
			ChangeScreen(WEAPON);
			return;
		case SHIP:
			ChangeScreen(SHIP);
			return;
		}
	}
	if(ship[player].keys.UP)
	{
		ship[player].keys.UP = false;
		if(--listselector<0) listselector = data->numships-1;
		LoadDummy(data->ships[listselector].filename);
		//glyph.CreateGraphicalObject(dummy.blueprintfile,1);
		sprintf_s(messagestring,1024,"Cost: %d    Credits: %d",dummy.cost,ship[player].credits);
		soundeffect[MENUMOVE].SetSoundEffect(0);
	}
	else if(ship[player].keys.DOWN)
	{
		ship[player].keys.DOWN = false;
		if(++listselector==data->numships) listselector = 0;
		LoadDummy(data->ships[listselector].filename);
		//glyph.CreateGraphicalObject(dummy.blueprintfile,1);
		sprintf_s(messagestring,1024,"Cost: %d    Credits: %d",dummy.cost,ship[player].credits);
		soundeffect[MENUMOVE].SetSoundEffect(0);
	}

	return;
}
示例#6
0
/*
 * Implementation
 */
XtPointer
MonitorConfig(XtPointer conf)
{
    XF86ConfMonitorPtr monitor = (XF86ConfMonitorPtr)conf;
    char monitor_name[48];
    Arg args[1];

    current_monitor = monitor;

    xf86info.cur_list = MONITOR;
    XtSetSensitive(back, xf86info.lists[MONITOR].cur_function > 0);
    XtSetSensitive(next, xf86info.lists[MONITOR].cur_function <
			 xf86info.lists[MONITOR].num_functions - 1);
    (xf86info.lists[MONITOR].functions[xf86info.lists[MONITOR].cur_function])
	(&xf86info);

    XawListUnhighlight(hlist);
    XawListUnhighlight(vlist);

    if (monitor != NULL) {
	XF86ConfScreenPtr screen = XF86Config->conf_screen_lst;
	char str[PARSER_RANGE_SIZE];

	XtSetArg(args[0], XtNstring, monitor->mon_identifier);
	XtSetValues(ident_widget, args, 1);

	while (screen != NULL) {
	    if (screen->scrn_monitor == monitor)
		break;

	    screen = (XF86ConfScreenPtr)(screen->list.next);
	}
	if (screen != NULL) {
	    oldcard = card = screen->scrn_device;
	    XtSetArg(args[0], XtNlabel, card->dev_identifier);
	}
	else {
	    oldcard = card = NULL;
	    XtSetArg(args[0], XtNlabel, "");
	}
	XtSetValues(cmenu, args, 1);

	mon_n_hsync = monitor->mon_n_hsync;
	memcpy(mon_hsync, monitor->mon_hsync,
	       sizeof(parser_range) * mon_n_hsync);
	*str = '\0';
	parser_range_to_string(str, mon_hsync, mon_n_hsync);
	XtSetArg(args[0], XtNstring, str);
	XtSetValues(hsync, args, 1);

	mon_n_vrefresh = monitor->mon_n_vrefresh;
	memcpy(mon_vrefresh, monitor->mon_vrefresh,
	       sizeof(parser_range) * mon_n_vrefresh);
	*str = '\0';
	parser_range_to_string(str, mon_vrefresh, mon_n_vrefresh);
	XtSetArg(args[0], XtNstring, str);
	XtSetValues(vsync, args, 1);
    }
    else {
	XF86ConfMonitorPtr monitor = XF86Config->conf_monitor_lst;
	int nmonitors = 0;

	oldcard = card = NULL;
	while (monitor != NULL) {
		++nmonitors;
	    monitor = (XF86ConfMonitorPtr)(monitor->list.next);
	}
	do {
	    XmuSnprintf(monitor_name, sizeof(monitor_name),
			"Monitor%d", nmonitors);
	    ++nmonitors;
	} while (xf86findMonitor(monitor_name,
		 XF86Config->conf_monitor_lst));

	XtSetArg(args[0], XtNstring, monitor_name);
	XtSetValues(ident_widget, args, 1);

	XtSetArg(args[0], XtNstring, "");
	XtSetValues(hsync, args, 1);
	XtSetValues(vsync, args, 1);

	XtSetArg(args[0], XtNlabel, "");
	XtSetValues(cmenu, args, 1);
    }

    if (ConfigLoop(MonitorConfigCheck) == True) {
	if (monitor == NULL) {
	    monitor = (XF86ConfMonitorPtr)
		XtCalloc(1, sizeof(XF86ConfMonitorRec));
	    monitor->mon_identifier = XtNewString(ident_string);
	}

	memcpy(monitor->mon_hsync, mon_hsync, sizeof(parser_range) *
	       (monitor->mon_n_hsync = mon_n_hsync));
	memcpy(monitor->mon_vrefresh, mon_vrefresh, sizeof(parser_range) *
	       (monitor->mon_n_vrefresh = mon_n_vrefresh));

	if (strcasecmp(monitor->mon_identifier, ident_string))
	    xf86renameMonitor(XF86Config, monitor, ident_string);

	if (oldcard != card) {
	    int i;

	    for (i = 0; i < computer.num_devices; i++)
		if (computer.devices[i]->widget == config)
		    break;
	    if (computer.devices[i]->config == NULL)
		XF86Config->conf_monitor_lst =
				xf86addMonitor(XF86Config->conf_monitor_lst,
					       monitor);
	    computer.devices[i]->config = (XtPointer)monitor;
	    ChangeScreen(monitor, monitor, card, oldcard);
	    DrawCables();
	}

	return (monitor);
    }

    return (NULL);
}