Пример #1
0
void RenderEditorItemsInfo()
{
	UINT8	*pDestBuf, *pSrcBuf;
	UINT32 uiSrcPitchBYTES, uiDestPitchBYTES;
	INVTYPE *item;
	HVOBJECT hVObject;
	UINT32 uiVideoObjectIndex;
	INT16 i;
	INT16 minIndex, maxIndex;
	INT16 sWidth, sOffset, sStart, x, y;
	UINT16 usNumItems;
	UINT16 usQuantity;

	if(!eInfo.fActive)
	{
		return;
	}

	if( gusMouseXPos < (iScreenWidthOffset + 110) || gusMouseXPos > (iScreenWidthOffset + 480) || gusMouseYPos < (2 * iScreenHeightOffset + 360) || gusMouseYPos > (2 * iScreenHeightOffset + 440) )
	{ //Mouse has moved out of the items display region -- so nothing can be highlighted.
		eInfo.sHilitedItemIndex = -1;
	}
	pDestBuf = LockVideoSurface(FRAME_BUFFER, &uiDestPitchBYTES);
	pSrcBuf = LockVideoSurface(eInfo.uiBuffer, &uiSrcPitchBYTES);

	Blt16BPPTo16BPP((UINT16 *)pDestBuf, uiDestPitchBYTES,
				(UINT16 *)pSrcBuf, uiSrcPitchBYTES, iScreenWidthOffset + 110, 2 * iScreenHeightOffset + 360, 60*eInfo.sScrollIndex, 0, 360, 80 );

	UnLockVideoSurface(eInfo.uiBuffer);
	UnLockVideoSurface(FRAME_BUFFER);

	//calculate the min and max index that is currently shown.	This determines
	//if the highlighted and/or selected items are drawn with the outlines.
	minIndex = eInfo.sScrollIndex * 2;
	maxIndex = minIndex + 11;

	//draw the hilighted item if applicable.
	if( eInfo.sHilitedItemIndex >= minIndex && eInfo.sHilitedItemIndex <= maxIndex )
	{
		if( eInfo.pusItemIndex )
		{
			item = &Item[eInfo.pusItemIndex[eInfo.sHilitedItemIndex]];
			uiVideoObjectIndex = GetInterfaceGraphicForItem( item );
			GetVideoObject( &hVObject, uiVideoObjectIndex );

			x = iScreenWidthOffset + (eInfo.sHilitedItemIndex/2 - eInfo.sScrollIndex)*60 + 110;
			y = 2 * iScreenHeightOffset + 360 + (eInfo.sHilitedItemIndex % 2) * 40;

			UINT16 usGraphicNum = g_bUsePngItemImages ? 0 : item->ubGraphicNum;
			sWidth = hVObject->pETRLEObject[usGraphicNum].usWidth;
			sOffset = hVObject->pETRLEObject[usGraphicNum].sOffsetX;
			sStart = x + (60 - sWidth - sOffset*2) / 2;
			if( sWidth )
			{
				BltVideoObjectOutlineFromIndex( FRAME_BUFFER, uiVideoObjectIndex, usGraphicNum, sStart, y+2, Get16BPPColor(FROMRGB(250, 250, 0)), TRUE );
			}
		}
	}
	//draw the selected item
	if( eInfo.sSelItemIndex >= minIndex && eInfo.sSelItemIndex <= maxIndex )
	{
		if( eInfo.pusItemIndex )
		{
			item = &Item[eInfo.pusItemIndex[eInfo.sSelItemIndex]];
			uiVideoObjectIndex = GetInterfaceGraphicForItem( item );
			GetVideoObject( &hVObject, uiVideoObjectIndex );

			x = iScreenWidthOffset + (eInfo.sSelItemIndex/2 - eInfo.sScrollIndex)*60 + 110;
			y = 2 * iScreenHeightOffset + 360 + (eInfo.sSelItemIndex % 2) * 40;

			UINT16 usGraphicNum = g_bUsePngItemImages ? 0 : item->ubGraphicNum;
			sWidth = hVObject->pETRLEObject[usGraphicNum].usWidth;
			sOffset = hVObject->pETRLEObject[usGraphicNum].sOffsetX;
			sStart = x + (60 - sWidth - sOffset*2) / 2;
			if( sWidth )
			{
				BltVideoObjectOutlineFromIndex( FRAME_BUFFER, uiVideoObjectIndex, usGraphicNum, sStart, y+2, Get16BPPColor(FROMRGB(250, 0, 0)), TRUE );
			}
		}
	}
	//draw the numbers of each visible item that currently resides in the world.
	maxIndex = min( maxIndex, eInfo.sNumItems-1 );
	for( i = minIndex; i <= maxIndex; i++ )
	{
		usNumItems = CountNumberOfEditorPlacementsInWorld( i, &usQuantity );
		if( usNumItems )
		{
			x = iScreenWidthOffset + (i/2 - eInfo.sScrollIndex)*60 + 110;
			y = 2 * iScreenHeightOffset + 360 + (i % 2) * 40;
			SetFont( FONT10ARIAL );
			SetFontForeground( FONT_YELLOW );
			SetFontShadow( FONT_NEARBLACK );
			if( usNumItems == usQuantity )
				mprintf( x + 12, y + 4, L"%d", usNumItems );
			else
				mprintf( x + 12, y + 4, L"%d(%d)", usNumItems, usQuantity );
		}
	}
}
Пример #2
0
void RevealRoofsAndItems(SOLDIERTYPE *pSoldier, UINT32 itemsToo, BOOLEAN fShowLocators, UINT8 ubLevel, BOOLEAN fForce )
{
	INT32		maincnt,markercnt,marker,tilesLeftToSee,prevmarker;
	UINT8		cnt;
	INT32		Inc[6],Dir[6];
	INT8		itemVisible = FALSE;
	INT8		Blocking,twoMoreTiles,markerDir;
	INT8		nextDir=0;
	UINT8		who; //,itemIndex; // for each square checked
	UINT8		dir,range,Path2;
	//DBrot: More Rooms
	//UINT8		ubRoomNo;
	UINT16		usRoomNo;
	BOOLEAN		fCheckForRooms = FALSE;
	ITEM_POOL	*pItemPool;
	BOOLEAN		fHiddenStructVisible;
	UINT8		ubMovementCost;
	BOOLEAN		fTravelCostObs;
	BOOLEAN		fGoneThroughDoor = FALSE;
	BOOLEAN		fThroughWindow = FALSE;
	BOOLEAN		fItemsQuoteSaid = FALSE;
	UINT16		usIndex;
	BOOLEAN		fRevealItems = TRUE;
	BOOLEAN		fStopRevealingItemsAfterThisTile = FALSE;
	INT8		bTallestStructureHeight;
	INT32		iDoorGridNo;
	STRUCTURE   *pStructure, *pDummy;
	INT8		bStructHeight;
	INT8		bThroughWindowDirection;

	if ( pSoldier->flags.uiStatusFlags & SOLDIER_ENEMY )
	{
		//pSoldier->needToLookForItems = FALSE;
		return;
	}

	if ( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE )
	{
		return;
	}

	// Return if this guy has no gridno, has bad life, etc	
	if(TileIsOutOfBounds(pSoldier->sGridNo) || !pSoldier->bInSector || pSoldier->stats.bLife < OKLIFE )
	{
		return;
	}

	if (pSoldier->bBlindedCounter > 0)
	{
		return;
	}


	gubGridNoValue++;

	if ( gubGridNoValue == 255 )
	{
		// Reset!
		Assert(gubGridNoMarkers);
        memset(gubGridNoMarkers, 0, sizeof(UINT8)*WORLD_MAX);
		gubGridNoValue = 1;
	}


	// OK, look for doors
	MercLooksForDoors( pSoldier, TRUE );


	who = pSoldier->ubID;
	dir = pSoldier->ubDirection;

	//NumMessage("good old reveal",dir);

	// a gassed merc can only see 1 tile away due to blurred vision
	if ( pSoldier->flags.uiStatusFlags & SOLDIER_GASSED )
	{
		range = 1;
	}
	else
	{
		range = pSoldier->bViewRange;

		// Flugente: adjust sightrange
		range = (UINT8)( (range * (100 + pSoldier->GetSightRangeBonus()) ) / 100);

		// balance item viewing range between normal and the limit set by opplist-type functions -- CJC
		range = (AdjustMaxSightRangeForEnvEffects( pSoldier, LightTrueLevel( pSoldier->sGridNo, pSoldier->pathing.bLevel), range ) + range) / 2;
	}


	BuildSightDir(dir,(UINT32 *)&Dir[0],(UINT32 *)&Dir[1],(UINT32 *)&Dir[2],(UINT32 *)&Dir[3],(UINT32 *)&Dir[4]);

	for (cnt = 0; cnt < 5; cnt++)
		Inc[cnt] = DirectionInc( (UINT8) Dir[cnt]);

	// create gridno increment for NOVIEW - in other words, no increment!
	Inc[5] = 0;
	Dir[5] = pSoldier->ubDirection;

	if (dir % 2 == 1)	/* even numbers use ViewPath2 */
		Path2 = TRUE;
	else
		Path2 = FALSE;


	// ATE: if in this special cercumstance... our guys are moving on their own...
	// Stop sighting items
	// IN the future, we may want to do something else here...

	if ( gTacticalStatus.uiFlags & OUR_MERCS_AUTO_MOVE )
	{
		itemsToo = FALSE;
	}

	for (maincnt = 0; maincnt < MAXVIEWPATHS; maincnt++)
	{
		marker = pSoldier->sGridNo;
		Blocking = FALSE;
		twoMoreTiles = FALSE;
		tilesLeftToSee = 99;
		fRevealItems = TRUE;
		fStopRevealingItemsAfterThisTile = FALSE;

#ifdef _DEBUG
		if ( _KeyDown( NUM_LOCK ) )
		{
			memset( gubFOVDebugInfoInfo, 0, sizeof( gubFOVDebugInfoInfo ) );

			SetRenderFlags( RENDER_FLAG_FULL );
			RenderWorld( );
		}
#endif

		for (markercnt = 0; markercnt < range; markercnt++)
		{
			//fGoneThroughDoor = FALSE;
			//fThroughWindow		= FALSE;


			prevmarker = marker;

			nextDir = 99;
			fCheckForRooms = FALSE;
			fTravelCostObs = FALSE;
			if ( fStopRevealingItemsAfterThisTile )
			{
				fRevealItems = FALSE;
				fStopRevealingItemsAfterThisTile = FALSE;
			}


			if (Path2)
			{
				markerDir = ViewPath2[maincnt][markercnt];
				if (markercnt < 12)
					nextDir = ViewPath2[maincnt][markercnt+1];
			}
			else
			{
				markerDir = ViewPath[maincnt][markercnt];
				if (markercnt < 12)
					nextDir = ViewPath[maincnt][markercnt+1];
			}

			// OK, check flags for going through door/window last tile
			if ( fThroughWindow == 1 )
			{
				// ATE: Make sure we are going through the same direction!
				// THis is to solve the drassen SAM problem with seeing through walls
				if ( Dir[markerDir] == bThroughWindowDirection)
				{
					 fThroughWindow = 2;
				}
				else
				{
					 fThroughWindow = 0;
				}
			}
			else if ( fThroughWindow == 2 )
			{
					// We've overstayed our welcome - remove!
				fThroughWindow = 0;
			}


			if ( fGoneThroughDoor == 1 )
			{
				fGoneThroughDoor = 2;
			}
			else if ( fGoneThroughDoor == 2 )
			{
				// We've overstayed our welcome - remove!
				fGoneThroughDoor = 0;
			}

			//ATE CHECK FOR NOVIEW!
			if ( nextDir == NOVIEW )
			{
				nextDir = 99;
			}

			marker = NewGridNo(marker,(INT16)Inc[markerDir]);

			if ( marker == 12426 )
			{
				int i = 0;
			}

			// End if this is a no view...
			if ( markerDir == NOVIEW && markercnt != 0 )
			{
				break;
			}

#ifdef _DEBUG
			if ( _KeyDown( NUM_LOCK ) )
			{
				int cnt = GetJA2Clock( );

				gubFOVDebugInfoInfo[ marker ] = (UINT8)markercnt;

				StartFrameBufferRender();

				RenderFOVDebug( );

				SetFont( LARGEFONT1 );
				SetFontBackground( FONT_MCOLOR_BLACK );
				SetFontForeground( FONT_MCOLOR_WHITE );
				mprintf( 10,	10 , L"%d", maincnt	);
				//mprintf( 10,	20 , L"%d", marker	);
				//mprintf( 50,	20 , L"%d", pSoldier->sGridNo	);

				InvalidateScreen( );
				EndFrameBufferRender();
				RefreshScreen( NULL );

				do
				{

				} while( ( GetJA2Clock( ) - cnt ) < 250 );

			}
#endif

			// Check if we can get to this gridno from our direction in
			ubMovementCost = gubWorldMovementCosts[ marker ][ Dir[ markerDir ] ][ ubLevel ];

			// ATE: Added: If our current sector is below ground, ignore any blocks!
			if ( gfCaves && ubMovementCost != TRAVELCOST_CAVEWALL )
			{
				ubMovementCost = TRAVELCOST_FLAT;
			}

			if ( IS_TRAVELCOST_DOOR( ubMovementCost ) )
			{
				ubMovementCost = DoorTravelCost( pSoldier, marker, ubMovementCost, (BOOLEAN) (pSoldier->bTeam == gbPlayerNum), &iDoorGridNo );
				pStructure = FindStructure( iDoorGridNo, STRUCTURE_ANYDOOR );
				if ( pStructure != NULL && pStructure->fFlags & STRUCTURE_TRANSPARENT)
				{
					// cell door or somehow otherwise transparent; allow merc to see through
					ubMovementCost = TRAVELCOST_FLAT;
				}
			}

			// If we have hit an obstacle, STOP HERE
			if ( ubMovementCost >= TRAVELCOST_BLOCKED )
			{
				// We have an obstacle here...

				// If it is bigger than a breadbox... err... taller than a man...
				// Then stop path altogether
				// otherwise just stop revealing items

				// CJC:	only do this when the direction is horizontal; easier and faster to check
				// and the effect should still be good enough

				if ( ubMovementCost == TRAVELCOST_WALL || ubMovementCost == TRAVELCOST_DOOR || ubMovementCost == TRAVELCOST_EXITGRID )
				{
					fTravelCostObs = TRUE;
					fRevealItems = FALSE;
				}
				else
				{
					// walls are handled above, so the blocking object is guaranteed not to be a wall
					bTallestStructureHeight = GetTallestStructureHeight( marker, FALSE );
					if (bTallestStructureHeight >= 3)
					{
						fTravelCostObs = TRUE;
						fStopRevealingItemsAfterThisTile = TRUE;
					}
					else if ( bTallestStructureHeight != 0 )
					{
						// stop revealing items after this tile but keep going
						fStopRevealingItemsAfterThisTile = TRUE;
					}

				}


				if ( (Dir[markerDir] % 2) == 1 )
				{
					// diagonal
					fTravelCostObs = TRUE;
					// cheap hack... don't reveal items
					fRevealItems = FALSE;
				}
				else
				{

					bTallestStructureHeight = GetTallestStructureHeight( marker, FALSE );
					if (bTallestStructureHeight >= 3)
					{
						fTravelCostObs = TRUE;
						fStopRevealingItemsAfterThisTile = TRUE;
					}
					else if ( bTallestStructureHeight != 0 )
					{
						// stop revealing items after this tile but keep going
						fStopRevealingItemsAfterThisTile = TRUE;
					}
				}

			}

			// Check if it's been done already!
			if ( gubGridNoMarkers[ marker ] != gubGridNoValue )
			{

				// Mark gridno
				gubGridNoMarkers[ marker ] = gubGridNoValue;

				// check and see if the gridno changed
				// if the gridno is the same, avoid redundancy and break
				if (marker==prevmarker && markercnt != 0 )
				{

				}
				else	// it changed
				{

					// Skip others if we have gone through a door but are too far away....
					if ( fGoneThroughDoor )
					{
						if (markercnt > 5 )	// Are we near the door?
						{
							break;
						}
					}
					// DO MINE FINDING STUFF
					// GET INDEX FOR ITEM HERE
					// if there IS a direction after this one, nextdir WILL NOT be 99
					if (nextDir != 99)
					{
						Blocking = GetBlockingStructureInfo( marker, (INT8)Dir[ markerDir ], (INT8)Dir[ nextDir ], ubLevel, &bStructHeight, &pDummy, FALSE );
					}
					else // no "next" direction, so pass in a NOWHERE so that
					// "SpecialViewObstruction" will know not to take it UINT32o consideration
					{
						Blocking = GetBlockingStructureInfo( marker, (INT8)Dir[markerDir], (INT8)30, ubLevel, &bStructHeight, &pDummy, FALSE  );
					}

					if ( gfCaves )
					{
						Blocking = NOTHING_BLOCKING;
					}

					// CHECK FOR ROOMS
					if ( Blocking == BLOCKING_TOPLEFT_WINDOW || Blocking == BLOCKING_TOPLEFT_OPEN_WINDOW )
					{
						// CHECK FACING DIRECTION!
						if ( Dir[markerDir] == NORTH || Dir[markerDir] == SOUTH )
						{
							if (markercnt <= 1 )	// Are we right beside it?
							{
								fThroughWindow = TRUE;
								bThroughWindowDirection = ( INT8 ) Dir[ markerDir ];
							}
						}
					}
					if ( Blocking == BLOCKING_TOPRIGHT_WINDOW || Blocking == BLOCKING_TOPRIGHT_OPEN_WINDOW )
					{
						// CHECK FACING DIRECTION!
						if ( Dir[markerDir] == EAST || Dir[markerDir] == WEST )
						{
							if (markercnt <= 1 )	// Are we right beside it?
							{
								fThroughWindow = TRUE;
								bThroughWindowDirection = ( INT8 ) Dir[ markerDir ];
							}
						}
					}

					if ( Blocking == BLOCKING_TOPLEFT_DOOR )
					{
						fGoneThroughDoor = TRUE;
					}
					if ( Blocking == BLOCKING_TOPRIGHT_DOOR )
					{
						fGoneThroughDoor = TRUE;
					}

					// ATE: If we hit this tile, find item always!
					//if (Blocking < FULL_BLOCKING )
					{

						// Handle special things for our mercs, like uncovering roofs
						// and revealing objects...
						//gpSoldier->shad |= SEENBIT;

						//itemVisible = ObjList[itemIndex].visible;

						// NOTE: don't allow object viewing if gassed XXX

						if (itemsToo && fRevealItems ) // && itemIndex < MAXOBJECTLIST)
						{
							// OK, look for corpses...
							LookForAndMayCommentOnSeeingCorpse( pSoldier, marker, ubLevel );

							if ( GetItemPool( marker, &pItemPool, ubLevel ) )
							{
								itemVisible = pItemPool->bVisible;

								if ( SetItemPoolVisibilityOn( pItemPool, INVISIBLE, fShowLocators ) )
								{
									SetRenderFlags(RENDER_FLAG_FULL);

									// WANNE: Should we pause when item was found in tactical?
									bool enableItemSpottingAction = true;

									if ( !is_networked && gGameExternalOptions.fItemSpottedNoTalk && gTacticalStatus.uiFlags & TURNBASED && gTacticalStatus.uiFlags & INCOMBAT)
										enableItemSpottingAction = false;

									if (enableItemSpottingAction)
									{
										if ( fShowLocators )
										{
											// Set makred render flags
											//gpWorldLevelData[marker].uiFlags|=MAPELEMENT_REDRAW;
											//gpWorldLevelData[gusCurMousePos].pTopmostHead->uiFlags |= LEVELNODE_DYNAMIC;

											//SetRenderFlags(RENDER_FLAG_MARKED);
											SetRenderFlags(RENDER_FLAG_FULL);

											// Hault soldier
											// ATE: Only if in combat...
											if ( gTacticalStatus.uiFlags & INCOMBAT )
											{
												pSoldier->HaultSoldierFromSighting( FALSE );
											}
											else
											{
												// ATE: Make sure we show locators...
												gTacticalStatus.fLockItemLocators = FALSE;
											}

											if ( !fItemsQuoteSaid && gTacticalStatus.fLockItemLocators == FALSE )
											{
												gTacticalStatus.fLockItemLocators = TRUE;

												if ( gTacticalStatus.ubAttackBusyCount > 0 && ( gTacticalStatus.uiFlags & INCOMBAT ) )
												{
													gTacticalStatus.fItemsSeenOnAttack = TRUE;
													gTacticalStatus.ubItemsSeenOnAttackSoldier = pSoldier->ubID;
													gTacticalStatus.usItemsSeenOnAttackGridNo  = marker;
												}
												else
												{

													// Display quote!
													if ( !AM_AN_EPC( pSoldier ) )
													{

														TacticalCharacterDialogueWithSpecialEvent( pSoldier, (UINT16)( QUOTE_SPOTTED_SOMETHING_ONE + Random( 2 ) ), DIALOGUE_SPECIAL_EVENT_SIGNAL_ITEM_LOCATOR_START, marker, 0 );

													}
													else
													{
														 // Turn off item lock for locators...
														 gTacticalStatus.fLockItemLocators = FALSE;
														 // Slide to location!
														SlideToLocation( 0, marker );
													}
												}

												fItemsQuoteSaid = TRUE;
											}
										}

									}
								}
							}
						}

						// if blood here, let the user see it now...
						//if (ExtGrid[marker].patrolInfo < MAXBLOOD)
						//		gpSoldier->blood = ExtGrid[marker].patrolInfo;

						//DoRoofs(marker,gpSoldier);

						tilesLeftToSee--;
					}

					// CHECK FOR HIDDEN STRUCTS
					// IF we had a hidden struct here that is not visible ( which will still be true because
					// we set it revealed below...
					if ( DoesGridNoContainHiddenStruct( marker, &fHiddenStructVisible ) )
					{
						if ( !fHiddenStructVisible )
						{
							gpWorldLevelData[marker].uiFlags|=MAPELEMENT_REDRAW;
							SetRenderFlags(RENDER_FLAG_MARKED);
							RecompileLocalMovementCosts( marker );
						}
					}

					if (tilesLeftToSee <= 0)
						break;

					if ( Blocking == FULL_BLOCKING || ( fTravelCostObs && !fThroughWindow ) )
					{
						break;
					}

					//if ( Blocking == NOTHING_BLOCKING || Blocking == BLOCKING_NEXT_TILE )
					if ( Blocking == NOTHING_BLOCKING )
					{
						fCheckForRooms = TRUE;
					}

					if ( ubLevel != 0 )
					{
						fCheckForRooms = FALSE;
					}

					// CHECK FOR SLANT ROOF!
					{
						STRUCTURE	*pStructure, *pBase;

						pStructure = FindStructure( marker, STRUCTURE_SLANTED_ROOF );

						if ( pStructure != NULL )
						{
							pBase = FindBaseStructure( pStructure );

							// ADD TO SLANTED ROOF LIST!
							AddSlantRoofFOVSlot( marker );
						}
					}

					// Set gridno as revealed
					if ( ubLevel == FIRST_LEVEL )
					{
						if ( gfBasement || gfCaves )
						{
							// OK, if we are underground, we don't want to reveal stuff if
							// 1 ) there is a roof over us and
							// 2 ) we are not in a room
							if ( gusWorldRoomInfo[ marker ] == NO_ROOM && TypeRangeExistsInRoofLayer( marker, FIRSTROOF, FOURTHROOF, &usIndex ) )
							{
								int i = 0;
							}
							else
							{
								gpWorldLevelData[ marker ].uiFlags |= MAPELEMENT_REVEALED;
								if( gfCaves )
								{
									RemoveFogFromGridNo( marker );
								}
							}
						}
						else
						{
							gpWorldLevelData[ marker ].uiFlags |= MAPELEMENT_REVEALED;
						}

						// CHECK FOR ROOMS
						//if ( fCheckForRooms )
						{
							if ( InAHiddenRoom( marker, &usRoomNo ) )
							{
								RemoveRoomRoof( marker, usRoomNo, pSoldier );
								if ( usRoomNo == ROOM_SURROUNDING_BOXING_RING && gWorldSectorX == BOXING_SECTOR_X && gWorldSectorY == BOXING_SECTOR_Y && gbWorldSectorZ == BOXING_SECTOR_Z )
								{
									// reveal boxing ring at same time
									RemoveRoomRoof( marker, BOXING_RING, pSoldier );
								}
							}
						}
					}
					else
					{
						gpWorldLevelData[ marker ].uiFlags |= MAPELEMENT_REVEALED_ROOF;
					}

					// Check for blood....
					UpdateBloodGraphics( marker, ubLevel );

					if ( Blocking != NOTHING_BLOCKING && Blocking != BLOCKING_TOPLEFT_DOOR && Blocking != BLOCKING_TOPRIGHT_DOOR && Blocking != BLOCKING_TOPLEFT_WINDOW && Blocking != BLOCKING_TOPRIGHT_WINDOW && Blocking != BLOCKING_TOPRIGHT_OPEN_WINDOW && Blocking != BLOCKING_TOPLEFT_OPEN_WINDOW)
					{
						break;
					}

					//gpWorldLevelData[ marker ].uiFlags |= MAPELEMENT_SHADELAND;
				}
			} // End of duplicate check
			else
			{
				if ( fTravelCostObs )
				{
					break;
				}
			}

		} // end of one path

	} // end of path loop

	// Loop through all availible slant roofs we collected and perform cool stuff on them
	ExamineSlantRoofFOVSlots( );

	//pSoldier->needToLookForItems = FALSE;

	//LookForDoors(pSoldier,UNAWARE);
}
Пример #3
0
BOOLEAN RenderCharProfileFinishFace( void )
{

// render the portrait of the current picture
  VOBJECT_DESC    VObjectDesc;
	HVOBJECT hHandle;
	UINT32 uiGraphicHandle;

  if( fCharacterIsMale == TRUE )
	{
	  switch( LaptopSaveInfo.iVoiceId )
		{
		  case( 0 ):
        // first portrait

			  // load it
        VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
	      FilenameForBPP("Faces\\SmallFaces\\00.sti", VObjectDesc.ImageFile);
	      CHECKF(AddVideoObject(&VObjectDesc, &uiGraphicHandle));
       
			  // show it
        GetVideoObject(&hHandle, uiGraphicHandle);
        BltVideoObject(FRAME_BUFFER, hHandle, 0, LAPTOP_SCREEN_UL_X + sFaceX, LAPTOP_SCREEN_WEB_UL_Y + sFaceY , VO_BLT_SRCTRANSPARENCY,NULL);


  			// and kick it's sorry ..umm never mind, outta here
        DeleteVideoObjectFromIndex( uiGraphicHandle );

		  break;
      case( 1 ):
        // first portrait

			  // load it
        VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
	      FilenameForBPP("Faces\\SmallFaces\\01.sti", VObjectDesc.ImageFile);
	      CHECKF(AddVideoObject(&VObjectDesc, &uiGraphicHandle));
      
			  // show it
        GetVideoObject(&hHandle, uiGraphicHandle);
        BltVideoObject(FRAME_BUFFER, hHandle, 0, LAPTOP_SCREEN_UL_X + sFaceX, LAPTOP_SCREEN_WEB_UL_Y + sFaceY , VO_BLT_SRCTRANSPARENCY,NULL);


			  // and kick it's sorry ..umm never mind, outta here
        DeleteVideoObjectFromIndex( uiGraphicHandle );

		  break;
		  case( 2 ):
        // first portrait

			  // load it
        VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
	      FilenameForBPP("Faces\\SmallFaces\\02.sti", VObjectDesc.ImageFile);
	      CHECKF(AddVideoObject(&VObjectDesc, &uiGraphicHandle));
      
		  	// show it
        GetVideoObject(&hHandle, uiGraphicHandle);
        BltVideoObject(FRAME_BUFFER, hHandle, 0, LAPTOP_SCREEN_UL_X + sFaceX, LAPTOP_SCREEN_WEB_UL_Y + sFaceY , VO_BLT_SRCTRANSPARENCY,NULL);


			  // and kick it's sorry ..umm never mind, outta here
        DeleteVideoObjectFromIndex( uiGraphicHandle );
        

		  break;
		}
	
	}
	else
	{
    switch( LaptopSaveInfo.iVoiceId )
		{
		  case( 0 ):
        // first portrait

			  // load it
        VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
	      FilenameForBPP("Faces\\SmallFaces\\03.sti", VObjectDesc.ImageFile);
	      CHECKF(AddVideoObject(&VObjectDesc, &uiGraphicHandle));
       
			  // show it
        GetVideoObject(&hHandle, uiGraphicHandle);
        BltVideoObject(FRAME_BUFFER, hHandle, 0, LAPTOP_SCREEN_UL_X + sFaceX, LAPTOP_SCREEN_WEB_UL_Y + sFaceY , VO_BLT_SRCTRANSPARENCY,NULL);


  			// and kick it's sorry ..umm never mind, outta here
        DeleteVideoObjectFromIndex( uiGraphicHandle );

		  break;
      case( 1 ):
        // first portrait

			  // load it
        VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
	      FilenameForBPP("Faces\\SmallFaces\\04.sti", VObjectDesc.ImageFile);
	      CHECKF(AddVideoObject(&VObjectDesc, &uiGraphicHandle));
      
			  // show it
        GetVideoObject(&hHandle, uiGraphicHandle);
        BltVideoObject(FRAME_BUFFER, hHandle, 0, LAPTOP_SCREEN_UL_X + sFaceX, LAPTOP_SCREEN_WEB_UL_Y + sFaceY , VO_BLT_SRCTRANSPARENCY,NULL);


			  // and kick it's sorry ..umm never mind, outta here
        DeleteVideoObjectFromIndex( uiGraphicHandle );

		  break;
		  case( 2 ):
        // first portrait

			  // load it
        VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
	      FilenameForBPP("Faces\\SmallFaces\\05.sti", VObjectDesc.ImageFile);
	      CHECKF(AddVideoObject(&VObjectDesc, &uiGraphicHandle));
      
		  	// show it
        GetVideoObject(&hHandle, uiGraphicHandle);
        BltVideoObject(FRAME_BUFFER, hHandle, 0, LAPTOP_SCREEN_UL_X + sFaceX, LAPTOP_SCREEN_WEB_UL_Y + sFaceY , VO_BLT_SRCTRANSPARENCY,NULL);


			  // and kick it's sorry ..umm never mind, outta here
        DeleteVideoObjectFromIndex( uiGraphicHandle );

		  break;
		}
	}

  // render the nickname
  SetFontForeground( FONT_WHITE );
	SetFontBackground( FONT_BLACK );
  SetFont( FONT12ARIAL );

	mprintf( 253, 350, pNickName );

	return( TRUE );

}
Пример #4
0
void InitEditorItemsInfo(UINT32 uiItemType)
{
	VSURFACE_DESC		vs_desc;
	UINT8	*pDestBuf, *pSrcBuf;
	UINT32 uiSrcPitchBYTES, uiDestPitchBYTES;
	INVTYPE *item;
	SGPRect	SaveRect, NewRect;
	HVOBJECT hVObject;
	UINT32 uiVideoObjectIndex;
	UINT16 usUselessWidth, usUselessHeight;
	INT16 sWidth, sOffset, sStart;
	INT16 i, x, y;
	UINT16 usCounter;
	CHAR16 pStr[ 100 ];//, pStr2[ 100 ];
	CHAR16 pItemName[SIZE_ITEM_NAME];
	UINT8						ubBitDepth;
	BOOLEAN fTypeMatch;
	INT32 iEquipCount = 0;

	// Check to make sure that there isn't already a valid eInfo
	if( eInfo.fActive )
	{
		if( eInfo.uiItemType == uiItemType )
		{	//User clicked on the same item classification -- ignore
			return;
		}
		else
		{	//User selected a different item classification -- delete it first.
			ClearEditorItemsInfo();
			ClearTaskbarRegion( iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 360, iScreenWidthOffset + 480, 2 * iScreenHeightOffset + 440 );
		}
	}
	else
	{
		//Clear the menu area, so that the buffer doesn't get corrupted.
		ClearTaskbarRegion( iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 360, iScreenWidthOffset + 480, 2 * iScreenHeightOffset + 440 );
	}
	EnableEditorRegion( ITEM_REGION_ID );

	eInfo.uiItemType = uiItemType;
	eInfo.fActive = TRUE;
	//Begin initialization of data.
	switch(uiItemType)
	{
		case TBAR_MODE_ITEM_WEAPONS:
			eInfo.sNumItems = eInfo.sNumWeapons;
			eInfo.sScrollIndex = eInfo.sSaveWeaponsScrollIndex;
			eInfo.sSelItemIndex = eInfo.sSaveSelWeaponsIndex;
			break;
		case TBAR_MODE_ITEM_AMMO:
			eInfo.sNumItems = eInfo.sNumAmmo;
			eInfo.sScrollIndex = eInfo.sSaveAmmoScrollIndex;
			eInfo.sSelItemIndex = eInfo.sSaveSelAmmoIndex;
			break;
		case TBAR_MODE_ITEM_ARMOUR:
			eInfo.sNumItems = eInfo.sNumArmour;
			eInfo.sScrollIndex = eInfo.sSaveArmourScrollIndex;
			eInfo.sSelItemIndex = eInfo.sSaveSelArmourIndex;
			break;
		case TBAR_MODE_ITEM_LBEGEAR:
			eInfo.sNumItems = eInfo.sLBEGear;
			eInfo.sScrollIndex = eInfo.sSaveLBEScrollIndex;
			eInfo.sSelItemIndex = eInfo.sSaveSelLBEIndex;
			break;
		case TBAR_MODE_ITEM_EXPLOSIVES:
			eInfo.sNumItems = eInfo.sNumExplosives;
			eInfo.sScrollIndex = eInfo.sSaveExplosivesScrollIndex;
			eInfo.sSelItemIndex = eInfo.sSaveSelExplosivesIndex;
			break;
		case TBAR_MODE_ITEM_EQUIPMENT1:
			eInfo.sNumItems = eInfo.sNumEquipment1;
			eInfo.sScrollIndex = eInfo.sSaveEquipment1ScrollIndex;
			eInfo.sSelItemIndex = eInfo.sSaveSelEquipment1Index;
			break;
		case TBAR_MODE_ITEM_EQUIPMENT2:
			eInfo.sNumItems = eInfo.sNumEquipment2;
			eInfo.sScrollIndex = eInfo.sSaveEquipment2ScrollIndex;
			eInfo.sSelItemIndex = eInfo.sSaveSelEquipment2Index;
			break;
		case TBAR_MODE_ITEM_EQUIPMENT3:
			eInfo.sNumItems = eInfo.sNumEquipment3;
			eInfo.sScrollIndex = eInfo.sSaveEquipment3ScrollIndex;
			eInfo.sSelItemIndex = eInfo.sSaveSelEquipment3Index;
			break;
		case TBAR_MODE_ITEM_TRIGGERS:
			eInfo.sNumItems = eInfo.sNumTriggers;
			eInfo.sScrollIndex = eInfo.sSaveTriggersScrollIndex;
			eInfo.sSelItemIndex = eInfo.sSaveSelTriggersIndex;
			break;
		case TBAR_MODE_ITEM_KEYS:
			eInfo.sNumItems = eInfo.sNumKeys;
			eInfo.sScrollIndex = eInfo.sSaveKeysScrollIndex;
			eInfo.sSelItemIndex = eInfo.sSaveSelKeysIndex;
			break;
		default:
			//error
			return;
	}
	//Allocate memory to store all the item pointers.
	eInfo.pusItemIndex = (UINT16*)MemAlloc( sizeof(UINT16) * eInfo.sNumItems );

	//Disable the appropriate scroll buttons based on the saved scroll index if applicable
	//Left most scroll position
	DetermineItemsScrolling();
	//calculate the width of the buffer based on the number of items.
	//every pair of items (odd rounded up) requires 60 pixels for width.
	//the minimum buffer size is 420.	Height is always 80 pixels.

	eInfo.sWidth = (eInfo.sNumItems > 12) ? ((eInfo.sNumItems+1)/2)*60 : SCREEN_HEIGHT - 120;
	eInfo.sHeight = 80;
	// Create item buffer
	GetCurrentVideoSettings( &usUselessWidth, &usUselessHeight, &ubBitDepth );
	vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
	vs_desc.usWidth = eInfo.sWidth;
	vs_desc.usHeight = eInfo.sHeight;
	vs_desc.ubBitDepth = ubBitDepth;

	//!!!Memory check.	Create the item buffer
	if(!AddVideoSurface( &vs_desc, &eInfo.uiBuffer ))
	{
		eInfo.fKill = TRUE;
		eInfo.fActive = FALSE;
		return;
	}

	pDestBuf = LockVideoSurface(eInfo.uiBuffer, &uiDestPitchBYTES);
	pSrcBuf = LockVideoSurface(FRAME_BUFFER, &uiSrcPitchBYTES);

	//copy a blank chunk of the editor interface to the new buffer.
	for( i=0; i<eInfo.sWidth; i+=60 )
	{
		Blt16BPPTo16BPP((UINT16 *)pDestBuf, uiDestPitchBYTES,
			(UINT16 *)pSrcBuf, uiSrcPitchBYTES, 0+i, 0, iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 360, 60, 80 );
	}

	UnLockVideoSurface(eInfo.uiBuffer);
	UnLockVideoSurface(FRAME_BUFFER);

	x = 0;
	y = 0;
	usCounter = 0;
	NewRect.iTop = 0;
	NewRect.iBottom = eInfo.sHeight;
	NewRect.iLeft = 0;
	NewRect.iRight = eInfo.sWidth;
	GetClippingRect(&SaveRect);
	SetClippingRect(&NewRect);
	if( eInfo.uiItemType == TBAR_MODE_ITEM_KEYS )
	{ //Keys use a totally different method for determining
		for( i = 0; i < eInfo.sNumItems; i++ )
		{
			item = &Item[ KeyTable[ 0 ].usItem + LockTable[ i ].usKeyItem ];
			uiVideoObjectIndex = GetInterfaceGraphicForItem( item );
			GetVideoObject( &hVObject, uiVideoObjectIndex );

			//Store these item pointers for later when rendering selected items.
			eInfo.pusItemIndex[i] = KeyTable[ 0 ].usItem + LockTable[ i ].usKeyItem;

			SetFont(SMALLCOMPFONT);
			SetFontForeground( FONT_MCOLOR_WHITE );
			SetFontDestBuffer( eInfo.uiBuffer, 0, 0, eInfo.sWidth, eInfo.sHeight, FALSE );

			swprintf( pStr, L"%S", LockTable[ i ].ubEditorName );
			DisplayWrappedString(x, (UINT16)(y+25), 60, 2, SMALLCOMPFONT, FONT_WHITE,	pStr, FONT_BLACK, TRUE, CENTER_JUSTIFIED );

			UINT16 usGraphicNum = g_bUsePngItemImages ? 0 : item->ubGraphicNum;
			//Calculate the center position of the graphic in a 60 pixel wide area.
			sWidth = hVObject->pETRLEObject[usGraphicNum].usWidth;
			sOffset = hVObject->pETRLEObject[usGraphicNum].sOffsetX;
			sStart = x + (60 - sWidth - sOffset*2) / 2;

			BltVideoObjectOutlineFromIndex( eInfo.uiBuffer, uiVideoObjectIndex, usGraphicNum, sStart, y+2, 0, FALSE );

			//cycle through the various slot positions (0,0), (0,40), (60,0), (60,40), (120,0)...
			if( y == 0 )
			{
				y = 40;
			}
			else
			{
				y = 0;
				x += 60;
			}
		}
	}
	else for( i = 0; i < eInfo.sNumItems; i++ )
	{

		fTypeMatch = FALSE;
		while( usCounter<MAXITEMS && !fTypeMatch )
		{
			if ( Item[usCounter].usItemClass	== 0 )
				break;
			item = &Item[usCounter];
			//if( Item[usCounter].fFlags & ITEM_NOT_EDITOR )
			if(item->notineditor)
			{
				usCounter++;
				continue;
			}
			if( eInfo.uiItemType == TBAR_MODE_ITEM_TRIGGERS )
			{
				if( i < PRESSURE_ACTION_ID )
					usCounter = ( i % 2 ) ? ACTION_ITEM : SWITCH;
				else
					usCounter = ACTION_ITEM;
				fTypeMatch = TRUE;
				item = &Item[usCounter];
			}
			else switch( item->usItemClass )
			{
				case IC_GUN:
				case IC_BLADE:
				case IC_LAUNCHER:
				case IC_THROWN:
				case IC_THROWING_KNIFE:
					fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_WEAPONS;
					break;
				case IC_PUNCH:
					if ( i != NOTHING )
					{
						fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_WEAPONS;
					}
					else
					{
						fTypeMatch = FALSE;
					}
					break;
				case IC_AMMO:
					fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_AMMO;
					break;
				case IC_ARMOUR:
					fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_ARMOUR;
					break;
				case IC_LBEGEAR:
					fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_LBEGEAR;
					break;
				case IC_GRENADE:
				case IC_BOMB:
					fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_EXPLOSIVES;
					break;
				case IC_MEDKIT:
				case IC_KIT:
				case IC_FACE:
				case IC_MONEY:
				case IC_BELTCLIP:
					fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_EQUIPMENT1;
					break;
				case IC_MISC:
					if( usCounter == ACTION_ITEM || usCounter == SWITCH )
						break;
					if( iEquipCount < eInfo.sNumEquipment2 )
						fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_EQUIPMENT2;
					else
						fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_EQUIPMENT3;
					iEquipCount++;
					break;
			}
			if( fTypeMatch )
			{

				uiVideoObjectIndex = GetInterfaceGraphicForItem( item );
				GetVideoObject( &hVObject, uiVideoObjectIndex );

				//Store these item pointers for later when rendering selected items.
				eInfo.pusItemIndex[i] = usCounter;

				SetFont(SMALLCOMPFONT);
				SetFontForeground( FONT_MCOLOR_WHITE );
				SetFontDestBuffer( eInfo.uiBuffer, 0, 0, eInfo.sWidth, eInfo.sHeight, FALSE );


				if( eInfo.uiItemType != TBAR_MODE_ITEM_TRIGGERS )
				{
					LoadItemInfo( usCounter, pItemName, NULL );
					swprintf( pStr, L"%s", pItemName );
				}
				else
				{
					if( i == PRESSURE_ACTION_ID )
					{
						swprintf( pStr, pInitEditorItemsInfoText[0] );
					}
					else if( i < 2 )
					{
						if( usCounter == SWITCH )
							swprintf( pStr, pInitEditorItemsInfoText[5] );
						else
							swprintf( pStr, pInitEditorItemsInfoText[1] );
					}
					else if( i < 4 )
					{
						if( usCounter == SWITCH )
							swprintf( pStr, pInitEditorItemsInfoText[6] );
						else
							swprintf( pStr, pInitEditorItemsInfoText[2] );
					}
					else if( i < 6 )
					{
						if( usCounter == SWITCH )
							swprintf( pStr, pInitEditorItemsInfoText[7] );
						else
							swprintf( pStr, pInitEditorItemsInfoText[3] );
					}
					else
					{
						if( usCounter == SWITCH )
							swprintf( pStr, pInitEditorItemsInfoText[8], (i-4)/2 );
						else
							swprintf( pStr, pInitEditorItemsInfoText[4], (i-4)/2 );
					}
				}

				DisplayWrappedString(x, (UINT16)(y+25), 60, 2, SMALLCOMPFONT, FONT_WHITE, pStr, FONT_BLACK, TRUE, CENTER_JUSTIFIED );

				UINT16 usGraphicNum = g_bUsePngItemImages ? 0 : item->ubGraphicNum;
				if(usGraphicNum < hVObject->usNumberOfObjects)
				{
					//Calculate the center position of the graphic in a 60 pixel wide area.
					sWidth = hVObject->pETRLEObject[usGraphicNum].usWidth;
					sOffset = hVObject->pETRLEObject[usGraphicNum].sOffsetX;
					sStart = x + (60 - sWidth - sOffset*2) / 2;

					if( sWidth && sWidth > 0 )
					{
						BltVideoObjectOutlineFromIndex( eInfo.uiBuffer, uiVideoObjectIndex, usGraphicNum, sStart, y+2, 0, FALSE );
					}

					//cycle through the various slot positions (0,0), (0,40), (60,0), (60,40), (120,0)...
					if( y == 0 )
					{
						y = 40;
					}
					else
					{
						y = 0;
						x += 60;
					}
				}
				else
				{
					static vfs::Log& editorLog = *vfs::Log::create(L"EditorItems.log");
					editorLog	<< L"Tried to access item [" 
								<< item->ubGraphicNum << L"/" << hVObject->usNumberOfObjects 
								<< L"]" << vfs::Log::endl;
				}
			}
			usCounter++;
		}
	}
	SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
	SetClippingRect(&SaveRect);
	gfRenderTaskbar = TRUE;
}
Пример #5
0
UINT32 LoadSaveScreenHandle(void)
{
	FDLG_LIST *FListNode;
	INT32 x;
	InputAtom DialogEvent;

	if( fEnteringLoadSaveScreen )
	{
		LoadSaveScreenEntry();
	}

	if( gbCurrentFileIOStatus ) //loading or saving map
	{
		UINT32 uiScreen;
		uiScreen = ProcessFileIO();
		if( uiScreen == EDIT_SCREEN && gbCurrentFileIOStatus == LOADING_MAP )
			RemoveProgressBar( 0 );
		return uiScreen;
	}

	if( gubMessageBoxStatus )
	{
		if( MessageBoxHandled() )
			return ProcessLoadSaveScreenMessageBoxResult();
		return LOADSAVE_SCREEN;
	}

	//handle all key input.
	while( DequeueEvent(&DialogEvent) )
	{
		if( !HandleTextInput(&DialogEvent) && (DialogEvent.usEvent == KEY_DOWN || DialogEvent.usEvent == KEY_REPEAT) )
		{
			HandleMainKeyEvents( &DialogEvent );
		}
	}

	HandleMouseWheelEvents();//dnl ch36 150909

	DrawFileDialog();

	// Skip to first filename to show
	FListNode = FileList;
	for(x=0;x<iTopFileShown && x<iTotalFiles && FListNode != NULL;x++)
	{
		FListNode = FListNode->pNext;
	}

	// Show up to 8 filenames in the window
	SetFont( FONT12POINT1 );
	if( gfNoFiles )
	{
		SetFontForeground( FONT_LTRED );
		SetFontBackground( 142 );
	  mprintf( iScreenWidthOffset + 226, iScreenHeightOffset + 126, L"NO FILES IN \\MAPS DIRECTORY" );
	}
	else for(x=iTopFileShown;x<(iTopFileShown+8) && x<iTotalFiles && FListNode != NULL; x++)
	{
		if( !EditingText() && x == iCurrFileShown  )
		{
			SetFontForeground( FONT_GRAY2 );
			SetFontBackground( FONT_METALGRAY );
		}
		else
		{
			SetFontForeground( FONT_BLACK );
			SetFontBackground( 142 );
		}
		mprintf( iScreenWidthOffset + 186,(iScreenHeightOffset + 73+ (x-iTopFileShown)*15 ), L"%S", FListNode->FileInfo.zFileName);
		FListNode = FListNode->pNext;
	}

	RenderAllTextFields();

	InvalidateScreen();

	ExecuteBaseDirtyRectQueue();
	EndFrameBufferRender();

	switch( iFDlgState )
	{
		case DIALOG_CANCEL:
			RemoveFileDialog();
			fEnteringLoadSaveScreen = TRUE;
			return EDIT_SCREEN;
		case DIALOG_DELETE:
			sprintf( gszCurrFilename, "MAPS\\%S", gzFilename );
			if( GetFileFirst(gszCurrFilename, &FileInfo) )
			{
				CHAR16 str[40];
				if( FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_HIDDEN|FILE_IS_SYSTEM) )
				{
					swprintf( str, L" Delete READ-ONLY file %s? ", gzFilename );
					gfReadOnly = TRUE;
				}
				else
					swprintf( str, L" Delete file %s? ", gzFilename );
				gfDeleteFile = TRUE;
				CreateMessageBox( str );
			}
			return LOADSAVE_SCREEN;
		case DIALOG_SAVE://dnl ch37 230909
		{
			if(!ExtractFilenameFromFields())
			{
				CreateMessageBox(L" Illegal filename.  Try another filename? ");
				gfIllegalName = TRUE;
				iFDlgState = DIALOG_NONE;
				return(LOADSAVE_SCREEN);
			}
			sprintf(gszCurrFilename, "MAPS\\%S", gzFilename);
			gfFileExists = FALSE;
#ifndef USE_VFS
			gfReadOnly = FALSE;
			if(FileExists(gszCurrFilename))
			{
				gfFileExists = TRUE;
				if(GetFileFirst(gszCurrFilename, &FileInfo))
				{
					if(FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_DIRECTORY|FILE_IS_HIDDEN|FILE_IS_SYSTEM|FILE_IS_OFFLINE|FILE_IS_TEMPORARY))
						gfReadOnly = TRUE;
					GetFileClose(&FileInfo);
				}
			}
#else
			gfReadOnly = TRUE;
			vfs::CProfileStack* st = getVFS()->getProfileStack();
			vfs::CProfileStack::Iterator it = st->begin();
			while(!it.end())
			{
				vfs::CVirtualProfile* prof = it.value();
				if(prof->cWritable == true)
				{
					gfReadOnly = FALSE;
					vfs::Path const& path = gszCurrFilename;
					vfs::IBaseFile *file = prof->getFile(path);
					if(file)
					{
						gfFileExists = TRUE;
						if(file->implementsWritable() == false)
							gfReadOnly = TRUE;
					}
					break;
				}
				it.next();
			}
#endif
			if(gfReadOnly)
			{
				CreateMessageBox(L" File is read only!  Choose a different name? ");
				return( LOADSAVE_SCREEN);
			}
			else if(gfFileExists)
			{
				CreateMessageBox(L" File exists, Overwrite? ");
				return(LOADSAVE_SCREEN);
			}
			RemoveFileDialog();
			gbCurrentFileIOStatus = INITIATE_MAP_SAVE;
			return(LOADSAVE_SCREEN);
		}
		case DIALOG_LOAD:
			if( !ExtractFilenameFromFields() )
			{
				CreateMessageBox( L" Illegal filename.  Try another filename? " );
				gfIllegalName = TRUE;
				iFDlgState = DIALOG_NONE;
				return LOADSAVE_SCREEN;
			}
			RemoveFileDialog();
			CreateProgressBar( 0, iScreenWidthOffset + 118, iScreenHeightOffset + 183, iScreenWidthOffset + 522, iScreenHeightOffset + 202 );
			DefineProgressBarPanel( 0, 65, 79, 94, iScreenWidthOffset + 100, iScreenHeightOffset + 155, iScreenWidthOffset + 540, iScreenHeightOffset + 235 );
			swprintf( zOrigName, L"Loading map:  %s", gzFilename );
			SetProgressBarTitle( 0, zOrigName, BLOCKFONT2, FONT_RED, FONT_NEARBLACK );
			gbCurrentFileIOStatus = INITIATE_MAP_LOAD;
			return LOADSAVE_SCREEN ;
		default:
			iFDlgState = DIALOG_NONE;
	}
	iFDlgState = DIALOG_NONE;
	return LOADSAVE_SCREEN ;
}
Пример #6
0
//Because loading and saving the map takes a few seconds, we want to post a message
//on the screen and then update it which requires passing the screen back to the main loop.
//When we come back for the next frame, we then actually save or load the map.  So this
//process takes two full screen cycles.
UINT32 ProcessFileIO()
{
	INT16 usStartX, usStartY;
	CHAR8 ubNewFilename[50];
	BOOLEAN fAltMap;//dnl ch31 150909
	switch( gbCurrentFileIOStatus )
	{
		case INITIATE_MAP_SAVE:	//draw save message 
			StartFrameBufferRender( );
			SaveFontSettings();
			SetFont( HUGEFONT );
			SetFontForeground( FONT_LTKHAKI );
			SetFontShadow( FONT_DKKHAKI );
			SetFontBackground( 0 );
			swprintf( zOrigName, L"Saving map:  %s", gzFilename );
			usStartX = iScreenWidthOffset + 320 - StringPixLength( zOrigName, LARGEFONT1 ) / 2;
			usStartY = iScreenHeightOffset + 180 - GetFontHeight( LARGEFONT1 ) / 2;
			mprintf( usStartX, usStartY, zOrigName );

			InvalidateScreen( );
			EndFrameBufferRender( );
			gbCurrentFileIOStatus = SAVING_MAP;
			return LOADSAVE_SCREEN;
		case SAVING_MAP: //save map
			sprintf( ubNewFilename, "%S", gzFilename );
			RaiseWorldLand();
			if( gfShowPits )
				RemoveAllPits();
			OptimizeSchedules();
			ShowHighGround(4);//dnl ch41 210909
			//dnl ch33 091009
			BOOLEAN fRet;
			if(gfVanillaMode && iNewMapWorldRows == OLD_WORLD_ROWS && iNewMapWorldCols == OLD_WORLD_COLS)
				fRet = SaveWorld(ubNewFilename, VANILLA_MAJOR_MAP_VERSION, VANILLA_MINOR_MAP_VERSION);
			else
				fRet = SaveWorld(ubNewFilename);
			if(!fRet)
			{
				//dnl ch37 150909
				gfSaveError = TRUE;
				if(gfErrorCatch)
				{
					InitErrorCatchDialog();
					return(EDIT_SCREEN);
				}
				gbCurrentFileIOStatus = IOSTATUS_NONE;
				CreateMessageBox((STR16)(_BS(L" Error saving ") << (const char*)ubNewFilename << L" file. Try another filename? " << _BS::wget).c_str() );
				return(guiCurrentScreen);
			}
			if( gfShowPits )
				AddAllPits();
			GetSectorFromFileName(gzFilename, gWorldSectorX, gWorldSectorY, gbWorldSectorZ, fAltMap);//dnl ch31 140909
			if( gfGlobalSummaryExists )
				UpdateSectorSummary( gzFilename, gfUpdateSummaryInfo );
			else//dnl ch30 150909
				ReEvaluateWorld(ubNewFilename);
			iCurrentAction = ACTION_NULL;
			gbCurrentFileIOStatus = IOSTATUS_NONE;
			gfRenderWorld = TRUE;
			gfRenderTaskbar = TRUE;
			fEnteringLoadSaveScreen = TRUE;
			RestoreFontSettings();
			if( gfErrorCatch )
			{
				InitErrorCatchDialog();
				return EDIT_SCREEN;
			}

			fNewMapSaved = TRUE;

			return EDIT_SCREEN;
		case INITIATE_MAP_LOAD: //draw load message
			SaveFontSettings();
			gbCurrentFileIOStatus = LOADING_MAP;
			if( gfEditMode && iCurrentTaskbar == TASK_MERCS )
				IndicateSelectedMerc( SELECT_NO_MERC );
			SpecifyItemToEdit( NULL, -1 );
			return LOADSAVE_SCREEN;
		case LOADING_MAP: //load map
			DisableUndo();
			sprintf( ubNewFilename, "%S", gzFilename );
			
			RemoveMercsInSector( );

			 // Want to override crash, so user can do something else.
			if(!ReEvaluateWorld(ubNewFilename) || !LoadWorld(ubNewFilename))//dnl ch36 140909
			{
				EnableUndo();
				gbCurrentFileIOStatus = IOSTATUS_NONE;
				gfGlobalError = FALSE;
				gfLoadError = TRUE;
				CreateMessageBox((STR16)(_BS(L" Error loading ") << (const char*)ubNewFilename << L" file. Try another filename? " << _BS::wget).c_str());
				return(guiCurrentScreen);
			}
			//ADB these are NOT set yet! but they need to be, duh
			CompileWorldMovementCosts();
			GetSectorFromFileName(gzFilename, gWorldSectorX, gWorldSectorY, gbWorldSectorZ, fAltMap);//dnl ch31 140909
			RestoreFontSettings();

			//Load successful, update necessary information.

			//ATE: Any current mercs are transfered here...
			//UpdateMercsInSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ );

			AddSoldierInitListTeamToWorld( ENEMY_TEAM,		255 );
			AddSoldierInitListTeamToWorld( CREATURE_TEAM,	255 );
			AddSoldierInitListTeamToWorld( MILITIA_TEAM,	255 );
			AddSoldierInitListTeamToWorld( CIV_TEAM,		255 );
			iCurrentAction = ACTION_NULL;
			gbCurrentFileIOStatus = IOSTATUS_NONE;
			if( !gfCaves && !gfBasement )
			{
				gusLightLevel = 12;
				if( ubAmbientLightLevel != 4 )
				{
					ubAmbientLightLevel = 4;
					LightSetBaseLevel( ubAmbientLightLevel );
				}
			}
			else
				gusLightLevel = (UINT16)(EDITOR_LIGHT_MAX - ubAmbientLightLevel );
			gEditorLightColor = gpLightColors[ 0 ];
			gfRenderWorld = TRUE;
			gfRenderTaskbar = TRUE;
			fEnteringLoadSaveScreen = TRUE;
			InitJA2SelectionWindow();
			ShowEntryPoints();
			EnableUndo();
			RemoveAllFromUndoList();
			SetEditorSmoothingMode( gMapInformation.ubEditorSmoothingType );
			if( gMapInformation.ubEditorSmoothingType == SMOOTHING_CAVES )
				AnalyseCaveMapForStructureInfo();

			AddLockedDoorCursors();
			gubCurrRoomNumber = gubMaxRoomNumber;
			UpdateRoofsView();
			UpdateWallsView();
			ShowLightPositionHandles();
			SetMercTeamVisibility( ENEMY_TEAM, gfShowEnemies );
			SetMercTeamVisibility( CREATURE_TEAM, gfShowCreatures );
			SetMercTeamVisibility( MILITIA_TEAM, gfShowRebels );
			SetMercTeamVisibility( CIV_TEAM, gfShowCivilians );
			BuildItemPoolList();
			gpItemPool = NULL;//dnl ch26 210909
			fShowHighGround = FALSE;//dnl ch2 210909
			fRaiseWorld = FALSE;//dnl ch3 210909
			ShowHighGround(4);//dnl ch41 210909
			SetRenderCenter(WORLD_COLS/2, WORLD_ROWS/2);//dnl ch43 280909
			if( gfShowPits )
				AddAllPits();

			if( iCurrentTaskbar == TASK_MAPINFO )
			{ //We have to temporarily remove the current textinput mode,
				//update the disabled text field values, then restore the current
				//text input fields.
				SaveAndRemoveCurrentTextInputMode();
				UpdateMapInfoFields();
				RestoreSavedTextInputMode();
			}
			return EDIT_SCREEN;
	}
	gbCurrentFileIOStatus = IOSTATUS_NONE;
	return LOADSAVE_SCREEN;
}
Пример #7
0
UINT32 LoadSaveScreenHandle(void)
{
    FDLG_LIST *FListNode;
    INT32 x;
    InputAtom DialogEvent;

    if( fEnteringLoadSaveScreen )
    {
        LoadSaveScreenEntry();
    }

    if( gbCurrentFileIOStatus ) //loading or saving map
    {
        UINT32 uiScreen;
        uiScreen = ProcessFileIO();
        if( uiScreen == EDIT_SCREEN && gbCurrentFileIOStatus == LOADING_MAP )
            RemoveProgressBar( 0 );
        return uiScreen;
    }

    if( gubMessageBoxStatus )
    {
        if( MessageBoxHandled() )
            return ProcessLoadSaveScreenMessageBoxResult();
        return LOADSAVE_SCREEN;
    }

    //handle all key input.
    while( DequeueEvent(&DialogEvent) )
    {
        if( !HandleTextInput(&DialogEvent) && (DialogEvent.usEvent == KEY_DOWN || DialogEvent.usEvent == KEY_REPEAT) )
        {
            HandleMainKeyEvents( &DialogEvent );
        }
    }

    DrawFileDialog();

    // Skip to first filename to show
    FListNode = FileList;
    for(x=0; x<iTopFileShown && x<iTotalFiles && FListNode != NULL; x++)
    {
        FListNode = FListNode->pNext;
    }

    // Show up to 8 filenames in the window
    SetFont( FONT12POINT1 );
    if( gfNoFiles )
    {
        SetFontForeground( FONT_LTRED );
        SetFontBackground( 142 );
        mprintf( 226, 126, L"NO FILES IN \\MAPS DIRECTORY" );
    }
    else for(x=iTopFileShown; x<(iTopFileShown+8) && x<iTotalFiles && FListNode != NULL; x++)
        {
            if( !EditingText() && x == iCurrFileShown  )
            {
                SetFontForeground( FONT_GRAY2 );
                SetFontBackground( FONT_METALGRAY );
            }
            else
            {
                SetFontForeground( FONT_BLACK );
                SetFontBackground( 142 );
            }
            mprintf( 186,(73+ (x-iTopFileShown)*15 ), L"%S", FListNode->FileInfo.zFileName);
            FListNode = FListNode->pNext;
        }

    RenderAllTextFields();

    InvalidateScreen();

    ExecuteBaseDirtyRectQueue();
    EndFrameBufferRender();

    switch( iFDlgState )
    {
    case DIALOG_CANCEL:
        RemoveFileDialog();
        fEnteringLoadSaveScreen = TRUE;
        return EDIT_SCREEN;
    case DIALOG_DELETE:
        sprintf( gszCurrFilename, "MAPS\\%S", gzFilename );
        if( GetFileFirst(gszCurrFilename, &FileInfo) )
        {
            UINT16 str[40];
            if( FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_HIDDEN|FILE_IS_SYSTEM) )
            {
                swprintf( str, L" Delete READ-ONLY file %s? ", gzFilename );
                gfReadOnly = TRUE;
            }
            else
                swprintf( str, L" Delete file %s? ", gzFilename );
            gfDeleteFile = TRUE;
            CreateMessageBox( str );
        }
        return LOADSAVE_SCREEN;
    case DIALOG_SAVE:
        if( !ExtractFilenameFromFields() )
        {
            CreateMessageBox( L" Illegal filename.  Try another filename? " );
            gfIllegalName = TRUE;
            iFDlgState = DIALOG_NONE;
            return LOADSAVE_SCREEN;
        }
        sprintf( gszCurrFilename, "MAPS\\%S", gzFilename );
        if ( FileExists( gszCurrFilename ) )
        {
            gfFileExists = TRUE;
            gfReadOnly = FALSE;
            if( GetFileFirst(gszCurrFilename, &FileInfo) )
            {
                if( FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_DIRECTORY|FILE_IS_HIDDEN|FILE_IS_SYSTEM|FILE_IS_OFFLINE|FILE_IS_TEMPORARY) )
                    gfReadOnly = TRUE;
                GetFileClose(&FileInfo);
            }
            if( gfReadOnly )
                CreateMessageBox( L" File is read only!  Choose a different name? " );
            else
                CreateMessageBox( L" File exists, Overwrite? " );
            return( LOADSAVE_SCREEN );
        }
        RemoveFileDialog();
        gbCurrentFileIOStatus = INITIATE_MAP_SAVE;
        return LOADSAVE_SCREEN ;
    case DIALOG_LOAD:
        if( !ExtractFilenameFromFields() )
        {
            CreateMessageBox( L" Illegal filename.  Try another filename? " );
            gfIllegalName = TRUE;
            iFDlgState = DIALOG_NONE;
            return LOADSAVE_SCREEN;
        }
        RemoveFileDialog();
        CreateProgressBar( 0, 118, 183, 522, 202 );
        DefineProgressBarPanel( 0, 65, 79, 94, 100, 155, 540, 235 );
        swprintf( zOrigName, L"Loading map:  %s", gzFilename );
        SetProgressBarTitle( 0, zOrigName, BLOCKFONT2, FONT_RED, FONT_NEARBLACK );
        gbCurrentFileIOStatus = INITIATE_MAP_LOAD;
        return LOADSAVE_SCREEN ;
    default:
        iFDlgState = DIALOG_NONE;
    }
    iFDlgState = DIALOG_NONE;
    return LOADSAVE_SCREEN ;
}
Пример #8
0
//Because loading and saving the map takes a few seconds, we want to post a message
//on the screen and then update it which requires passing the screen back to the main loop.
//When we come back for the next frame, we then actually save or load the map.  So this
//process takes two full screen cycles.
UINT32 ProcessFileIO()
{
    INT16 usStartX, usStartY;
    UINT8 ubNewFilename[50];
    switch( gbCurrentFileIOStatus )
    {
    case INITIATE_MAP_SAVE:	//draw save message
        StartFrameBufferRender( );
        SaveFontSettings();
        SetFont( HUGEFONT );
        SetFontForeground( FONT_LTKHAKI );
        SetFontShadow( FONT_DKKHAKI );
        SetFontBackground( 0 );
        swprintf( zOrigName, L"Saving map:  %s", gzFilename );
        usStartX = 320 - StringPixLength( zOrigName, LARGEFONT1 ) / 2;
        usStartY = 180 - GetFontHeight( LARGEFONT1 ) / 2;
        mprintf( usStartX, usStartY, zOrigName );

        InvalidateScreen( );
        EndFrameBufferRender( );
        gbCurrentFileIOStatus = SAVING_MAP;
        return LOADSAVE_SCREEN;
    case SAVING_MAP: //save map
        sprintf( ubNewFilename, "%S", gzFilename );
        RaiseWorldLand();
        if( gfShowPits )
            RemoveAllPits();
        OptimizeSchedules();
        if ( !SaveWorld( ubNewFilename ) )
        {
            if( gfErrorCatch )
            {
                InitErrorCatchDialog();
                return EDIT_SCREEN;
            }
            return ERROR_SCREEN;
        }
        if( gfShowPits )
            AddAllPits();

        SetGlobalSectorValues( gzFilename );

        if( gfGlobalSummaryExists )
            UpdateSectorSummary( gzFilename, gfUpdateSummaryInfo );

        iCurrentAction = ACTION_NULL;
        gbCurrentFileIOStatus = IOSTATUS_NONE;
        gfRenderWorld = TRUE;
        gfRenderTaskbar = TRUE;
        fEnteringLoadSaveScreen = TRUE;
        RestoreFontSettings();
        if( gfErrorCatch )
        {
            InitErrorCatchDialog();
            return EDIT_SCREEN;
        }
        if( gMapInformation.ubMapVersion != gubMinorMapVersion )
            ScreenMsg( FONT_MCOLOR_RED, MSG_ERROR, L"Map data has just been corrupted!!!  What did you just do?  KM : 0" );
        return EDIT_SCREEN;
    case INITIATE_MAP_LOAD: //draw load message
        SaveFontSettings();
        gbCurrentFileIOStatus = LOADING_MAP;
        if( gfEditMode && iCurrentTaskbar == TASK_MERCS )
            IndicateSelectedMerc( SELECT_NO_MERC );
        SpecifyItemToEdit( NULL, -1 );
        return LOADSAVE_SCREEN;
    case LOADING_MAP: //load map
        DisableUndo();
        sprintf( ubNewFilename, "%S", gzFilename );

        RemoveMercsInSector( );

        if( !LoadWorld( ubNewFilename ) )
        {   //Want to override crash, so user can do something else.
            EnableUndo();
            SetPendingNewScreen( LOADSAVE_SCREEN );
            gbCurrentFileIOStatus = IOSTATUS_NONE;
            gfGlobalError = FALSE;
            gfLoadError = TRUE;
            //RemoveButton( iTempButton );
            CreateMessageBox( L" Error loading file.  Try another filename?" );
            return LOADSAVE_SCREEN;
        }
        SetGlobalSectorValues( gzFilename );

        RestoreFontSettings();

        //Load successful, update necessary information.

        //ATE: Any current mercs are transfered here...
        //UpdateMercsInSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ );

        AddSoldierInitListTeamToWorld( ENEMY_TEAM,		255 );
        AddSoldierInitListTeamToWorld( CREATURE_TEAM, 255 );
        AddSoldierInitListTeamToWorld( MILITIA_TEAM,	255 );
        AddSoldierInitListTeamToWorld( CIV_TEAM,			255 );
        iCurrentAction = ACTION_NULL;
        gbCurrentFileIOStatus = IOSTATUS_NONE;
        if( !gfCaves && !gfBasement )
        {
            gusLightLevel = 12;
            if( ubAmbientLightLevel != 4 )
            {
                ubAmbientLightLevel = 4;
                LightSetBaseLevel( ubAmbientLightLevel );
            }
        }
        else
            gusLightLevel = (UINT16)(EDITOR_LIGHT_MAX - ubAmbientLightLevel );
        gEditorLightColor = gpLightColors[ 0 ];
        gfRenderWorld = TRUE;
        gfRenderTaskbar = TRUE;
        fEnteringLoadSaveScreen = TRUE;
        InitJA2SelectionWindow();
        ShowEntryPoints();
        EnableUndo();
        RemoveAllFromUndoList();
        SetEditorSmoothingMode( gMapInformation.ubEditorSmoothingType );
        if( gMapInformation.ubEditorSmoothingType == SMOOTHING_CAVES )
            AnalyseCaveMapForStructureInfo();

        AddLockedDoorCursors();
        gubCurrRoomNumber = gubMaxRoomNumber;
        UpdateRoofsView();
        UpdateWallsView();
        ShowLightPositionHandles();
        SetMercTeamVisibility( ENEMY_TEAM, gfShowEnemies );
        SetMercTeamVisibility( CREATURE_TEAM, gfShowCreatures );
        SetMercTeamVisibility( MILITIA_TEAM, gfShowRebels );
        SetMercTeamVisibility( CIV_TEAM, gfShowCivilians );
        BuildItemPoolList();
        if( gfShowPits )
            AddAllPits();

        if( iCurrentTaskbar == TASK_MAPINFO )
        {   //We have to temporarily remove the current textinput mode,
            //update the disabled text field values, then restore the current
            //text input fields.
            SaveAndRemoveCurrentTextInputMode();
            UpdateMapInfoFields();
            RestoreSavedTextInputMode();
        }
        return EDIT_SCREEN;
    }
    gbCurrentFileIOStatus = IOSTATUS_NONE;
    return LOADSAVE_SCREEN;
}
Пример #9
0
void DrawHistoryRecordsText( void )
{
  // draws the text of the records
  HistoryUnitPtr pCurHistory=pHistoryListHead;
  HistoryUnitPtr pTempHistory=pHistoryListHead;
	wchar_t sString[512];
  INT32 iCounter=0;
	UINT16 usX, usY;
  INT32 iBalance=0;
	INT16 sX =0, sY =0;

  // setup the font stuff
	SetFont(HISTORY_TEXT_FONT);
  SetFontForeground(FONT_BLACK);
	SetFontBackground(FONT_BLACK);
  SetFontShadow(NO_SHADOW);

	// error check
	if( !pCurHistory)
		return;


	// loop through record list
	for(iCounter; iCounter <NUM_RECORDS_PER_PAGE; iCounter++)
	{
		if( pCurHistory->ubColor == 0 )
		{
			SetFontForeground(FONT_BLACK);
		}
		else
		{
			SetFontForeground(FONT_RED);
		}
		// get and write the date
		swprintf(sString, L"%d", ( pCurHistory->uiDate / ( 24 * 60 ) ) );
		FindFontCenterCoordinates(RECORD_DATE_X + 5, 0, RECORD_DATE_WIDTH,0, sString, HISTORY_TEXT_FONT,&usX, &usY);
		mprintf(usX, RECORD_Y + ( iCounter * ( BOX_HEIGHT ) ) + 3, sString);
	  
		// now the actual history text
    //FindFontCenterCoordinates(RECORD_DATE_X + RECORD_DATE_WIDTH,0,RECORD_HISTORY_WIDTH,0,  pHistoryStrings[pCurHistory->ubCode], HISTORY_TEXT_FONT,&usX, &usY);
		ProcessHistoryTransactionString(sString, pCurHistory);
//	mprintf(RECORD_DATE_X + RECORD_DATE_WIDTH + 25, RECORD_Y + ( iCounter * ( BOX_HEIGHT ) ) + 3, pHistoryStrings[pCurHistory->ubCode] );
		mprintf(RECORD_DATE_X + RECORD_LOCATION_WIDTH +RECORD_DATE_WIDTH + 15, RECORD_Y + ( iCounter * ( BOX_HEIGHT ) ) + 3, sString );
    
		
		// no location
		if( ( pCurHistory->sSectorX == -1 )||( pCurHistory->sSectorY == -1 ) ||( pCurHistory->sSectorX == 0 ) || ( pCurHistory->sSectorY == 0 ) )
		{
			FindFontCenterCoordinates( RECORD_DATE_X + RECORD_DATE_WIDTH, 0,RECORD_LOCATION_WIDTH + 10, 0,  pHistoryLocations[0] ,HISTORY_TEXT_FONT, &sX, &sY );
		  mprintf(sX, RECORD_Y + ( iCounter * ( BOX_HEIGHT ) ) + 3, pHistoryLocations[0] );
    }
		else
		{
			GetSectorIDString( pCurHistory->sSectorX, pCurHistory->sSectorY, pCurHistory->bSectorZ, sString, TRUE );
			FindFontCenterCoordinates( RECORD_DATE_X + RECORD_DATE_WIDTH, 0, RECORD_LOCATION_WIDTH + 10, 0,  sString ,HISTORY_TEXT_FONT, &sX, &sY );
	
			ReduceStringLength( sString, RECORD_LOCATION_WIDTH + 10, HISTORY_TEXT_FONT );
			
			mprintf(sX, RECORD_Y + ( iCounter * ( BOX_HEIGHT ) ) + 3, sString );
		}

		// restore font color
		SetFontForeground(FONT_BLACK);

		// next History
		pCurHistory = pCurHistory->Next;
		
		// last page, no Historys left, return
		if( ! pCurHistory )
		{

			// restore shadow
      SetFontShadow(DEFAULT_SHADOW);	
			return;
		}

	}

	// restore shadow
  SetFontShadow(DEFAULT_SHADOW);	
	return;
}
Пример #10
0
void DisplayPageNumberAndDateRange( void )
{
	// this function will go through the list of 'histories' starting at current until end or 
	// MAX_PER_PAGE...it will get the date range and the page number
	INT32 iLastPage=0;
	INT32 iCounter=0;
  UINT32 uiLastDate;
	HistoryUnitPtr pTempHistory=pHistoryListHead;
  wchar_t sString[50];



  // setup the font stuff
	SetFont(HISTORY_TEXT_FONT);
  SetFontForeground(FONT_BLACK);
	SetFontBackground(FONT_BLACK);
  SetFontShadow(NO_SHADOW);

	if( !pCurrentHistory )
	{
    swprintf( sString, L"%s  %d / %d",pHistoryHeaders[1], 1, 1 );
	  mprintf( PAGE_NUMBER_X, PAGE_NUMBER_Y, sString );

    swprintf( sString, L"%s %d - %d",pHistoryHeaders[2], 1 , 1 );
    mprintf( HISTORY_DATE_X, HISTORY_DATE_Y, sString );
 
    // reset shadow
	  SetFontShadow(DEFAULT_SHADOW);	
	
		return;
  }
 
	uiLastDate=pCurrentHistory->uiDate;

/*
	// find last page
	while(pTempHistory)
	{
		iCounter++;
		pTempHistory=pTempHistory->Next;
	}

  // set last page
	iLastPage=iCounter/NUM_RECORDS_PER_PAGE;
*/

	iLastPage = GetNumberOfHistoryPages();

	// set temp to current, to get last date
  pTempHistory=pCurrentHistory;
	
	// reset counter
	iCounter=0;

	// run through list until end or num_records, which ever first
  while((pTempHistory)&&(iCounter < NUM_RECORDS_PER_PAGE))
	{
		uiLastDate=pTempHistory->uiDate;
		iCounter++;

		pTempHistory = pTempHistory->Next;
	}

  

	// get the last page
   
  swprintf( sString, L"%s  %d / %d",pHistoryHeaders[1], iCurrentHistoryPage , iLastPage +1 );
	mprintf( PAGE_NUMBER_X, PAGE_NUMBER_Y, sString );

  swprintf( sString, L"%s %d - %d",pHistoryHeaders[2], pCurrentHistory->uiDate / ( 24 * 60 ) , uiLastDate/( 24 * 60 ) );
  mprintf( HISTORY_DATE_X, HISTORY_DATE_Y, sString );

	
	// reset shadow
	SetFontShadow(DEFAULT_SHADOW);
	
	return;
}
Пример #11
0
void RenderSelectedItemBlownUp()
{
	UINT32 uiVideoObjectIndex;
	HVOBJECT hVObject;
	INT16 sScreenX, sScreenY, xp, yp;
	ITEM_POOL	*pItemPool;
	UINT16 szItemName[ SIZE_ITEM_NAME ];
	INT32 i;
	INT16 sWidth, sHeight, sOffsetX, sOffsetY;

	GetGridNoScreenPos( gsItemGridNo, 0, &sScreenX, &sScreenY );

	if( sScreenY > 340 )
		return;

	//Display the enlarged item graphic
	uiVideoObjectIndex = GetInterfaceGraphicForItem( &Item[ gpItem->usItem ] );
	GetVideoObject( &hVObject, uiVideoObjectIndex );
	
	sWidth = hVObject->pETRLEObject[ Item[ gpItem->usItem ].ubGraphicNum ].usWidth;
	sOffsetX = hVObject->pETRLEObject[ Item[ gpItem->usItem ].ubGraphicNum ].sOffsetX;
	xp = sScreenX + (40 - sWidth - sOffsetX*2) / 2;
	
	sHeight = hVObject->pETRLEObject[ Item[ gpItem->usItem ].ubGraphicNum ].usHeight;
	sOffsetY = hVObject->pETRLEObject[ Item[ gpItem->usItem ].ubGraphicNum ].sOffsetY;
	yp = sScreenY + (20 - sHeight - sOffsetY*2) / 2;

	BltVideoObjectOutlineFromIndex( FRAME_BUFFER, uiVideoObjectIndex, Item[ gpItem->usItem ].ubGraphicNum, xp, yp, Get16BPPColor(FROMRGB(0, 140, 170)), TRUE );

	//Display the item name above it
	SetFont( FONT10ARIAL );
	SetFontForeground( FONT_YELLOW );
	SetFontShadow( FONT_NEARBLACK );
	if( gpItem->usItem == ACTION_ITEM || gpItem->usItem == SWITCH )
	{
		BuildTriggerName( gpItem, szItemName );
	}
	else if( Item[ gpItem->usItem ].usItemClass == IC_KEY )
	{
		swprintf( szItemName, L"%S", LockTable[ gpItem->ubKeyID ].ubEditorName );
	}
	else
	{
		LoadItemInfo( gpItem->usItem, szItemName, NULL );
	}
	xp = sScreenX - (StringPixLength( szItemName, FONT10ARIAL ) - 40) / 2;
	yp -= 10;
	mprintf( xp, yp, szItemName );

	if( gpItem->usItem == ACTION_ITEM )
	{
		UINT16 *pStr;
		pStr = GetActionItemName( gpItem );
		xp = sScreenX - (StringPixLength( pStr, FONT10ARIALBOLD ) - 40) / 2;
		yp += 10;
		SetFont( FONT10ARIALBOLD );
		SetFontForeground( FONT_LTKHAKI );
		mprintf( xp, yp, pStr );
		SetFontForeground( FONT_YELLOW );
	}

	//Count the number of items in the current pool, and display that.
	i = 0;
	GetItemPool( gsItemGridNo, &pItemPool, 0 );
	Assert( pItemPool );
	while( pItemPool )
	{
		i++;
		pItemPool = pItemPool->pNext;
	}
	xp = sScreenX;
	yp = sScreenY + 10;
	mprintf( xp, yp, L"%d", i );
	
	//If the item is hidden, render a blinking H (just like DG)
	if( gWorldItems[ gpItemPool->iItemIndex ].bVisible == HIDDEN_ITEM || 
			gWorldItems[ gpItemPool->iItemIndex ].bVisible == BURIED )
	{
		SetFont( FONT10ARIALBOLD );
		if( GetJA2Clock() % 1000 > 500 )
		{
			SetFontForeground( 249 );
		}
		mprintf( sScreenX + 16, sScreenY + 7, L"H" );
		InvalidateRegion( sScreenX + 16, sScreenY + 7, sScreenX + 24, sScreenY + 27 );
	}
}
Пример #12
0
void RenderMapEntryPointsAndLights()
{
	INT16 sGridNo;
	INT16 sScreenX, sScreenY;
	INT32 i;
	if( gfSummaryWindowActive )
		return;
	SetFont( FONT10ARIAL );
	SetFontForeground( FONT_YELLOW );
	SetFontShadow( FONT_NEARBLACK );
	sGridNo = gMapInformation.sNorthGridNo;
	if( sGridNo != -1 )
	{
		GetGridNoScreenPos( sGridNo, 0, &sScreenX, &sScreenY );
		if( sScreenY >= -20 && sScreenY < 340 && sScreenX >= -40  && sScreenX < 640 )
		{
			DisplayWrappedString( sScreenX, (INT16)(sScreenY-5), 40, 2, FONT10ARIAL, FONT_YELLOW, L"North Entry Point", FONT_BLACK, TRUE, CENTER_JUSTIFIED );
		}
	}
	sGridNo = gMapInformation.sWestGridNo;
	if( sGridNo != -1 )
	{
		GetGridNoScreenPos( sGridNo, 0, &sScreenX, &sScreenY );
		if( sScreenY >= -20 && sScreenY < 340 && sScreenX >= -40  && sScreenX < 640 )
		{
			DisplayWrappedString( sScreenX, (INT16)(sScreenY-5), 40, 2, FONT10ARIAL, FONT_YELLOW, L"West Entry Point", FONT_BLACK, TRUE, CENTER_JUSTIFIED );
		}
	}
	sGridNo = gMapInformation.sEastGridNo;
	if( sGridNo != -1 )
	{
		GetGridNoScreenPos( sGridNo, 0, &sScreenX, &sScreenY );
		if( sScreenY >= -20 && sScreenY < 340 && sScreenX >= -40  && sScreenX < 640 )
		{
			DisplayWrappedString( sScreenX, (INT16)(sScreenY-5), 40, 2, FONT10ARIAL, FONT_YELLOW, L"East Entry Point", FONT_BLACK, TRUE, CENTER_JUSTIFIED );
		}
	}
	sGridNo = gMapInformation.sSouthGridNo;
	if( sGridNo != -1 )
	{
		GetGridNoScreenPos( sGridNo, 0, &sScreenX, &sScreenY );
		if( sScreenY >= -20 && sScreenY < 340 && sScreenX >= -40  && sScreenX < 640 )
		{
			DisplayWrappedString( sScreenX, (INT16)(sScreenY-5), 40, 2, FONT10ARIAL, FONT_YELLOW, L"South Entry Point", FONT_BLACK, TRUE, CENTER_JUSTIFIED );
		}
	}
	sGridNo = gMapInformation.sCenterGridNo;
	if( sGridNo != -1 )
	{
		GetGridNoScreenPos( sGridNo, 0, &sScreenX, &sScreenY );
		if( sScreenY >= -20 && sScreenY < 340 && sScreenX >= -40  && sScreenX < 640 )
		{
			DisplayWrappedString( sScreenX, (INT16)(sScreenY-5), 40, 2, FONT10ARIAL, FONT_YELLOW, L"Center Entry Point", FONT_BLACK, TRUE, CENTER_JUSTIFIED );
		}
	}
	sGridNo = gMapInformation.sIsolatedGridNo;
	if( sGridNo != -1 )
	{
		GetGridNoScreenPos( sGridNo, 0, &sScreenX, &sScreenY );
		if( sScreenY >= -20 && sScreenY < 340 && sScreenX >= -40  && sScreenX < 640 )
		{
			DisplayWrappedString( sScreenX, (INT16)(sScreenY-5), 40, 2, FONT10ARIAL, FONT_YELLOW, L"Isolated Entry Point", FONT_BLACK, TRUE, CENTER_JUSTIFIED );
		}
	}
	//Do the lights now.
	for( i = 0; i < MAX_LIGHT_SPRITES; i++ )
	{
		if( LightSprites[ i ].uiFlags & LIGHT_SPR_ACTIVE )
		{
			sGridNo = LightSprites[ i ].iY * WORLD_COLS + LightSprites[ i ].iX;
			GetGridNoScreenPos( sGridNo, 0, &sScreenX, &sScreenY );
			if( sScreenY >= -50 && sScreenY < 300 && sScreenX >= -40  && sScreenX < 640 )
			{
				if( LightSprites[ i ].uiFlags & LIGHT_PRIMETIME )
					DisplayWrappedString( sScreenX, (INT16)(sScreenY-5), 50, 2, FONT10ARIAL, FONT_ORANGE, L"Prime", FONT_BLACK, TRUE, CENTER_JUSTIFIED );
				else if( LightSprites[ i ].uiFlags & LIGHT_NIGHTTIME )
					DisplayWrappedString( sScreenX, (INT16)(sScreenY-5), 50, 2, FONT10ARIAL, FONT_RED, L"Night", FONT_BLACK, TRUE, CENTER_JUSTIFIED );
				else
					DisplayWrappedString( sScreenX, (INT16)(sScreenY-5), 50, 2, FONT10ARIAL, FONT_YELLOW, L"24Hour", FONT_BLACK, TRUE, CENTER_JUSTIFIED );
			}
		}
	}
}
Пример #13
0
void DoTaskbar(void)
{
	if(!iTaskMode || iTaskMode == iCurrentTaskbar )
	{
		return;
	}

	gfRenderTaskbar = TRUE;
	
	HideEditorToolbar( iCurrentTaskbar );

	//Special code when exiting previous editor tab
	switch( iCurrentTaskbar )
	{
		case TASK_TERRAIN:
			UnclickEditorButton( TAB_TERRAIN );
			HideTerrainTileButtons();
			break;
		case TASK_BUILDINGS:
			UnclickEditorButton( TAB_BUILDINGS );
			KillTextInputMode();
			break;
		case TASK_ITEMS:
			UnclickEditorButton( TAB_ITEMS );
			HideItemStatsPanel();
			if( eInfo.fActive )
				ClearEditorItemsInfo();
			gfShowPits = FALSE;
			RemoveAllPits();
			break;
		case TASK_MERCS:
			UnclickEditorButton( TAB_MERCS );
			IndicateSelectedMerc( SELECT_NO_MERC );
			SetMercEditingMode( MERC_NOMODE );
			break;
		case TASK_MAPINFO:
			UnclickEditorButton( TAB_MAPINFO );
			ExtractAndUpdateMapInfo();
			KillTextInputMode();
			HideExitGrids();
			break;
		case TASK_OPTIONS:
			UnclickEditorButton( TAB_OPTIONS );
			break;
	}

	//Setup the new tab mode
	iCurrentTaskbar = iTaskMode;
	ShowEditorToolbar( iTaskMode );
	iTaskMode = TASK_NONE;

	//Special code when entering a new editor tab
	switch( iCurrentTaskbar )
	{
		case TASK_MERCS:
			ClickEditorButton( TAB_MERCS );
			ClickEditorButton( MERCS_ENEMY);
			iDrawMode = DRAW_MODE_ENEMY;
			SetMercEditingMode( MERC_TEAMMODE );
			fBuildingShowRoofs = FALSE;
			UpdateRoofsView();
			break;
		case TASK_TERRAIN:
			ClickEditorButton( TAB_TERRAIN );
			ShowTerrainTileButtons();
			SetEditorTerrainTaskbarMode( TERRAIN_FGROUND_TEXTURES );
			break;
		case TASK_BUILDINGS:
			ClickEditorButton( TAB_BUILDINGS );
			if(fBuildingShowRoofs) 
				ClickEditorButton( BUILDING_TOGGLE_ROOF_VIEW );
			if(fBuildingShowWalls)
				ClickEditorButton( BUILDING_TOGGLE_WALL_VIEW );
			if(fBuildingShowRoomInfo)
				ClickEditorButton( BUILDING_TOGGLE_INFO_VIEW );
			if( gfCaves )
			{
				ClickEditorButton( BUILDING_CAVE_DRAWING );
				iDrawMode = DRAW_MODE_CAVES;
			}
			else
			{
				ClickEditorButton( BUILDING_NEW_ROOM );
				iDrawMode = DRAW_MODE_ROOM;
			}
			TerrainTileDrawMode = TERRAIN_TILES_BRETS_STRANGEMODE;
			SetEditorSmoothingMode( gMapInformation.ubEditorSmoothingType );
			gusSelectionType = gusSavedBuildingSelectionType;
			SetupTextInputForBuildings();
			break;
		case TASK_ITEMS:
			SetFont( FONT10ARIAL );
			SetFontForeground( FONT_YELLOW );
			ClickEditorButton( TAB_ITEMS );
			ClickEditorButton( ITEMS_WEAPONS + eInfo.uiItemType - TBAR_MODE_ITEM_WEAPONS );
			InitEditorItemsInfo( eInfo.uiItemType );
			ShowItemStatsPanel();
			gfShowPits = TRUE;
			AddAllPits();
			iDrawMode = DRAW_MODE_PLACE_ITEM;
			break;
		case TASK_MAPINFO:
			ClickEditorButton( TAB_MAPINFO );
			if ( gfFakeLights )
				ClickEditorButton( MAPINFO_TOGGLE_FAKE_LIGHTS );
			ClickEditorButton( MAPINFO_ADD_LIGHT1_SOURCE );
			iDrawMode = DRAW_MODE_LIGHT;
			TerrainTileDrawMode = TERRAIN_TILES_BRETS_STRANGEMODE;
			SetupTextInputForMapInfo();
			break;
		case TASK_OPTIONS:
			ClickEditorButton( TAB_OPTIONS );
			TerrainTileDrawMode = TERRAIN_TILES_NODRAW;
			break;
	}
}
Пример #14
0
//called from the taskbar renderer.
void UpdateItemStatsPanel()
{
	SetFont( FONT10ARIAL );
	SetFontForeground( FONT_GRAY2 );
	SetFontShadow( FONT_NEARBLACK );
	SetFontBackground( FONT_BLACK );
	if( gpItem && iCurrentTaskbar == TASK_ITEMS && 
			gbEditingMode != EDITING_TRIGGERS && gbEditingMode != EDITING_ACTIONITEMS )
	{
		mprintf( 500, 366, L"Toggle hide flag" );
	}
	SetFontForeground( FONT_YELLOW );
	switch( gbEditingMode )
	{
		case EDITING_NOTHING:
			if( iCurrentTaskbar == TASK_ITEMS )
				mprintf( 520, 400, L"No item selected." );
			else
			{
				mprintf( 500, 390, L"Slot available for" );
				mprintf( 500, 400, L"random generation." );
			}
			return;
		case EDITING_KEYS:
			if( !gpEditingItemPool )
			{
				mprintf( 500, 400, L"Keys not editable." );
				return;
			}
			break;
		case EDITING_OWNERSHIP:
			mprintf( 512, 384, L"ProfileID of owner" );
			return;
		case EDITING_NOT_YET_IMPLEMENTED:
			mprintf( 500, 400, L"Item class not implemented." );
			return;
		case EDITING_DROPPABLE:
			mprintf( 500, 400, L"Slot locked as empty.");
			return;
		case EDITING_GUNS:
			mprintf( 512, 384, L"Status" );
			mprintf( 512, 404, L"Rounds" );
			mprintf( 512, 424, L"Trap Level" );
			break;
		case EDITING_AMMO:
			mprintf( 512, 384, L"Quantity" );
			mprintf( 512, 404, L"Trap Level" );
			break;
		case EDITING_ARMOUR:
		case EDITING_EQUIPMENT:
			mprintf( 512, 384, L"Status" );
			mprintf( 512, 404, L"Trap Level" );
			break;
		case EDITING_EXPLOSIVES:
			mprintf( 512, 380, L"Status" );
			mprintf( 512, 404, L"Quantity" );
			mprintf( 512, 424, L"Trap Level" );
			break;
		case EDITING_MONEY:
			mprintf( 532, 384, L"Dollars" );
			break;
		case EDITING_ACTIONITEMS:
			mprintf( 512, 369, L"Status" );
			mprintf( 512, 389, L"Trap Level" );
			break;
		case EDITING_TRIGGERS:
			mprintf( 512, 369, L"Trap Level");
			mprintf( 512, 389, L"Tolerance" );
			if( gpEditingItemPool && gpItem->bFrequency >= PANIC_FREQUENCY_3 && gpItem->bFrequency <= PANIC_FREQUENCY )
				mprintf( 500, 407, L"Alarm Trigger" );
			break;
	}
	if( gpEditingItemPool )
	{
		INT32 iPercent = 100 - gWorldItems[ gpEditingItemPool->iItemIndex ].ubNonExistChance;
		if( iPercent == 100 )
			SetFontForeground( FONT_YELLOW );
		else if( iPercent >= 50 )
			SetFontForeground( FONT_ORANGE );
		else 
			SetFontForeground( FONT_RED );
		mprintf( 512, 444, L"Exist Chance" );
		mprintf( 587, 366, L"B" );
		mprintf( 609, 366, L"R" );
		mprintf( 630, 366, L"S" );
	}
	InvalidateRegion( 477, 362, 161, 97 );
}
Пример #15
0
void RenderPopupMenu()
{
	UINT16 usX, usY;
	UINT8 ubColumn, ubEntry, ubCounter;
	UINT8 *pDestBuf;
	UINT32 uiDestPitchBYTES;
	UINT16 usLineColor;
	UINT16 usStringWidth;
	UINT16 usStart;

	//Draw the menu
	ColorFillVideoSurfaceArea(FRAME_BUFFER,
		gPopup.usLeft, gPopup.usTop, gPopup.usRight, gPopup.usBottom,
		Get16BPPColor(FROMRGB(128, 128, 128) ) );
	pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
	SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, 640, 480 );
	usLineColor = Get16BPPColor( FROMRGB( 64, 64, 64 ) );
	RectangleDraw( TRUE, gPopup.usLeft, gPopup.usTop, gPopup.usRight, gPopup.usBottom,
		usLineColor, pDestBuf );
	if( gPopup.ubColumns > 1 )
	{ //draw a vertical line between each column
		usStart = gPopup.usLeft + gPopup.ubColumnWidth[ 0 ];
		for( ubColumn = 1; ubColumn < gPopup.ubColumns; ubColumn++ )
		{
			LineDraw( TRUE, usStart, gPopup.usTop, usStart, gPopup.usBottom, usLineColor, pDestBuf );
		}
		usStart += (UINT16)gPopup.ubColumnWidth[ ubColumn ];
	}
	UnLockVideoSurface( FRAME_BUFFER );

	//Set up the text attributes.
	SetFont( gPopup.usFont);
	SetFontBackground( FONT_MCOLOR_BLACK );
	SetFontForeground( FONT_MCOLOR_WHITE );

	usX = gPopup.usLeft + 1;
	ubCounter = 0;
	usStart = gPopup.usLeft;
	for( ubColumn = 0; ubColumn < gPopup.ubColumns; ubColumn++ )
	{
		for( ubEntry = 0; ubEntry < gPopup.ubMaxEntriesPerColumn; ubEntry++ )
		{
			if( ubCounter >= gPopup.ubNumEntries )
				return; //done
			//Calc current string's width in pixels.  Adding 14 pixels which is the width of
			//two padded gPopup.usFont spaces not stored in the string.
			usStringWidth = 14 + StringPixLength( GetPopupMenuString( ubCounter ), gPopup.usFont );
			//Horizontally center the string inside the popup menu
			usX = usStart + ( gPopup.ubColumnWidth[ ubColumn ] - usStringWidth ) / 2;
			usY = gPopup.usTop + 1 + ubEntry * gusEntryHeight;
			if( ubCounter == gPopup.ubSelectedIndex - 1 )
			{
				//This is the highlighted menu entry.
				SetFontForeground( FONT_MCOLOR_LTBLUE );
				mprintf( usX, usY, L" %s ", GetPopupMenuString( ubCounter ) );
				SetFontForeground( FONT_MCOLOR_WHITE );
			}
			else
			{
				mprintf( usX, usY, L" %s ", GetPopupMenuString( ubCounter ) );
			}
			ubCounter++;
		}
		usStart += gPopup.ubColumnWidth[ ubColumn ];
	}
}