Beispiel #1
0
static int FScreenGetPrimaryScreen(XEvent *ev)
{
	if (!is_xinerama_enabled)
	{
		return 0;
	}
	if (primary_scr == FSCREEN_GLOBAL)
	{
		return 0;
	}
	else if (primary_scr == FSCREEN_CURRENT)
	{
		int mx;
		int my;

		/* use current screen as primary screen */
		GetMouseXY(ev, &mx, &my);
		return FindScreenOfXY(mx, my);
	}
	else if (primary_scr < 0 || primary_scr >= last_to_check)
	{
		/* out of range */
		return 0;
	}

	return primary_scr + 1;
}
Beispiel #2
0
static int FindScreen(
	fscreen_scr_arg *arg, fscreen_scr_t screen)
{
	fscreen_scr_arg tmp;

	if (num_screens == 0)
	{
		screen = FSCREEN_GLOBAL;
	}
	switch (screen)
	{
	case FSCREEN_GLOBAL:
		screen = 0;
		break;
	case FSCREEN_PRIMARY:
		screen =
			FScreenGetPrimaryScreen(
				(arg && arg->mouse_ev) ? arg->mouse_ev : NULL);
		break;
	case FSCREEN_CURRENT:
		/* translate to xypos format */
		if (!arg)
		{
			tmp.mouse_ev = NULL;
			arg = &tmp;
		}
		GetMouseXY(arg->mouse_ev, &arg->xypos.x, &arg->xypos.y);
		/* fall through */
	case FSCREEN_XYPOS:
		/* translate to screen number */
		if (!arg)
		{
			tmp.xypos.x = 0;
			tmp.xypos.y = 0;
			arg = &tmp;
		}
		screen = FindScreenOfXY(arg->xypos.x, arg->xypos.y);
		break;
	default:
		/* screen is given counting from 0; translate to counting from
		 * 1 */
		screen++;
		break;
	}

	return screen;
}
void RenderEditorInfo( )
{
	CHAR16					FPSText[ 50 ];
	static INT32		iSpewWarning = 0;
	INT32				iMapIndexD;

	//dnl ch52 091009
	SetFont(FONT12ARIAL);
	SetFontShadow(FONT_NEARBLACK);
	SetFontForeground(FONT_GRAY2);
	SetFontBackground(FONT_BLACK);

	//dnl ch1 101009 Display the mapindex position
	if(GetMouseMapPos(&iMapIndexD))
	{
		INT16 sGridX, sGridY;
		GetMouseXY(&sGridX, &sGridY);
		swprintf(FPSText, L"%4d %4d %6d ", sGridX, sGridY, iMapIndexD);
	}
	else
		swprintf(FPSText, L"                  ");

	mprintfEditor( (UINT16)(iScreenWidthOffset + 50-StringPixLength( FPSText, FONT12POINT1 )/2), 2 * iScreenHeightOffset + 463, FPSText );

	switch( iCurrentTaskbar )
	{
		case TASK_OPTIONS:
			mprintf(iScreenWidthOffset+71+15, SCREEN_HEIGHT-117, iRenderEditorInfoText[0]);//dnl ch33 160909
			if( !gfWorldLoaded || giCurrentTilesetID < 0 )
				mprintf( iScreenWidthOffset + 260, 2 * iScreenHeightOffset + 445, iRenderEditorInfoText[1] );
			else
				mprintf( iScreenWidthOffset + 260, 2 * iScreenHeightOffset + 445, iRenderEditorInfoText[2], gubFilename, gTilesets[ giCurrentTilesetID ].zName );

			// TODO.MAP
			mprintf(iScreenWidthOffset+20, SCREEN_HEIGHT-40, iRenderEditorInfoText[3]);

			UpdateOptions();
			break;
		case TASK_TERRAIN:

			// WANNE: Comment this two lines, because we always get an exception here.
			//if( gusSelectionType == LINESELECTION )
			//	swprintf( wszSelType[LINESELECTION], L"Width: %d", gusSelectionWidth );

			DrawEditorInfoBox( wszSelType[gusSelectionType], FONT12POINT1, iScreenWidthOffset + 220, 2 * iScreenHeightOffset + 430, 60, 30 );
			swprintf( FPSText, L"%d%%", gusSelectionDensity );
			DrawEditorInfoBox( FPSText, FONT12POINT1, iScreenWidthOffset + 310, 2 * iScreenHeightOffset + 430, 40, 30 );
			break;
		case TASK_ITEMS:
			RenderEditorItemsInfo();
			UpdateItemStatsPanel();
			break;
		case TASK_BUILDINGS:
			UpdateBuildingsInfo();


			// WANNE: Comment this two lines, because we always get an exception here.
			//if( gusSelectionType == LINESELECTION )
			//	swprintf( wszSelType[LINESELECTION], L"%d", gusSelectionWidth );

			DrawEditorInfoBox( wszSelType[gusSelectionType], FONT12POINT1, iScreenWidthOffset + 530, 2 * iScreenHeightOffset + 430, 60, 30 );
			break;
		case TASK_MERCS:
			UpdateMercsInfo();
				#ifdef JA113DEMO
				DisableButton (iEditorButton[ MERCS_CIVILIANTOGGLE ]);
				DisableButton (iEditorButton[ MERCS_CIVILIAN ]);
				#endif
			break;
		case TASK_MAPINFO:
			UpdateMapInfo();
			// WANNE: EDITOR: Comment this two lines, because we always get an exception here!
			//if( gusSelectionType == LINESELECTION )
			//	swprintf( wszSelType[LINESELECTION], L"Width: %d", gusSelectionWidth );

			DrawEditorInfoBox( wszSelType[gusSelectionType], FONT12POINT1, iScreenWidthOffset + 440, 2 * iScreenHeightOffset + 430, 60, 30 );
			break;
	}
}
void UpdateCursorAreas()
{
	INT32 x, y, iMapIndex;

	RemoveCursors();

	EnsureSelectionType();

	//Determine if the mouse is currently in the world.
	if( gViewportRegion.uiFlags & MSYS_MOUSE_IN_AREA && GetMouseXY( &sGridX, &sGridY ) )
	{
		iMapIndex = MAPROWCOLTOPOS( sGridY, sGridX );
		if( gpBuildingLayoutList )
		{
			gSelectRegion.iLeft = gSelectRegion.iRight = sGridX;
			gSelectRegion.iTop = gSelectRegion.iBottom = sGridY;
			fValidCursor = TRUE;
			DrawBuildingLayout( iMapIndex );
		}
		else switch( gusSelectionType )
		{
			case SMALLSELECTION: 
				gSelectRegion.iLeft = gSelectRegion.iRight = sGridX;
				gSelectRegion.iTop = gSelectRegion.iBottom = sGridY;
				fValidCursor = TRUE;
				break;
			case MEDIUMSELECTION: 
			case LARGESELECTION:  
			case XLARGESELECTION: 
				//The mouse mode value reflects the size of the cursor.
				gSelectRegion.iTop = sGridY - gusSelectionType;
				gSelectRegion.iBottom = sGridY + gusSelectionType;
				gSelectRegion.iLeft = sGridX - gusSelectionType;
				gSelectRegion.iRight = sGridX + gusSelectionType;
				ValidateSelectionRegionBoundaries();
				fValidCursor = TRUE;
				break;
			case LINESELECTION:
				fValidCursor = HandleAreaSelection();
				ForceAreaSelectionWidth();
				ValidateSelectionRegionBoundaries();
				break;
			case AREASELECTION:
				fValidCursor = HandleAreaSelection();
				break;
		}
	}
	//Draw all of the area cursors here.
	if( fValidCursor )
	{
		if( iDrawMode == DRAW_MODE_ENEMY || iDrawMode == DRAW_MODE_CREATURE || 
				iDrawMode == DRAW_MODE_REBEL || iDrawMode == DRAW_MODE_CIVILIAN ||
				iDrawMode == DRAW_MODE_SCHEDULEACTION )
		{
			iMapIndex = gSelectRegion.iTop * WORLD_COLS + gSelectRegion.iLeft;
			if( !IsLocationSittable( iMapIndex, gfRoofPlacement ) && iDrawMode != DRAW_MODE_SCHEDULEACTION || 
				  !IsLocationSittableExcludingPeople( iMapIndex, gfRoofPlacement ) && iDrawMode == DRAW_MODE_SCHEDULEACTION )
			{
				if( sBadMarker != iMapIndex )
				{
					RemoveBadMarker();
					if( gfRoofPlacement && FlatRoofAboveGridNo( iMapIndex ) )
					{
						AddTopmostToTail( iMapIndex + ROOF_OFFSET, BADMARKER1 );
						sBadMarker = (INT16)(iMapIndex + ROOF_OFFSET );
					}
					else
					{
						AddTopmostToTail( (iMapIndex), BADMARKER1 );
						sBadMarker = (INT16)(iMapIndex);
					}
				}
			}
			else
			{
				RemoveBadMarker();
				if( gfRoofPlacement && FlatRoofAboveGridNo( iMapIndex ) )
				{
					AddTopmostToTail( iMapIndex + ROOF_OFFSET, FIRSTPOINTERS5 );
					gfUsingOffset = TRUE;
				}
				else
					AddTopmostToTail( iMapIndex, FIRSTPOINTERS1 );
			}
		}
		else for( y = gSelectRegion.iTop; y <= gSelectRegion.iBottom; y++ )
		{	
			for( x = gSelectRegion.iLeft; x <= gSelectRegion.iRight; x++ )
			{
				iMapIndex = y * WORLD_COLS + x;
				AddTopmostToTail( iMapIndex, FIRSTPOINTERS1 );
			}
		}
	}
}
Beispiel #5
0
/* Same as above, but dump screen return value to keep compatible with the X
 * function. */
int FScreenParseGeometry(
	char *parsestring, int *x_return, int *y_return,
	unsigned int *width_return, unsigned int *height_return)
{
	int scr;
	int rc;
	int mx;
	int my;

	rc = FScreenParseGeometryWithScreen(
		parsestring, x_return, y_return, width_return, height_return,
		&scr);
	if (rc == 0)
	{
		return 0;
	}
	switch (scr)
	{
	case FSCREEN_GLOBAL:
		scr = 0;
		break;
	case FSCREEN_CURRENT:
		GetMouseXY(NULL, &mx, &my);
		scr = FindScreenOfXY(mx, my);
		break;
	case FSCREEN_PRIMARY:
		scr = FScreenGetPrimaryScreen(NULL);
		break;
	default:
		scr++;
		break;
	}
	if (scr <= 0 || scr > last_to_check)
	{
		scr = 0;
	}
	else
	{
		/* adapt geometry to selected screen */
		if (rc & XValue)
		{
			if (rc & XNegative)
			{
				*x_return -=
					(screens[0].width -
					 screens[scr].width -
					 screens[scr].x_org);
			}
			else
			{
				*x_return += screens[scr].x_org;
			}
		}
		if (rc & YValue)
		{
			if (rc & YNegative)
			{
				*y_return -=
					(screens[0].height -
					 screens[scr].height -
					 screens[scr].y_org);
			}
			else
			{
				*y_return += screens[scr].y_org;
			}
		}
	}

	return rc;
}