void HandleIntroScreen() { BOOLEAN fFlicStillPlaying = FALSE; //if we are exiting this screen, this frame, dont update the screen if( gfIntroScreenExit ) return; //handle smaker each frame fFlicStillPlaying = SmkPollFlics(); //if the flic is not playing if( !fFlicStillPlaying ) { INT32 iNextVideoToPlay = -1; iNextVideoToPlay = GetNextIntroVideo( giCurrentIntroBeingPlayed ); if( iNextVideoToPlay != -1 ) { StartPlayingIntroFlic( iNextVideoToPlay ); } else { PrepareToExitIntroScreen(); giCurrentIntroBeingPlayed = -1; } } InvalidateScreen(); }
void RemoveFileDialog(void) { INT32 x; MSYS_RemoveRegion( &BlanketRegion ); for(x=0; x<6; x++) { RemoveButton(iFileDlgButtons[x]); } if( iFileDlgButtons[6] != -1 ) { RemoveButton( iFileDlgButtons[6] ); } TrashFDlgList( FileList ); FileList = NULL; InvalidateScreen( ); EnableEditorTaskbar(); KillTextInputMode(); MarkWorldDirty(); RenderWorld(); EndFrameBufferRender(); }
void ShutdownJA2(void) { UINT32 uiIndex; // Clear screen.... ColorFillVideoSurfaceArea( FRAME_BUFFER, 0, 0, 640, 480, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) ); InvalidateScreen( ); // Remove cursor.... SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); RefreshScreen( NULL ); ShutdownStrategicLayer(); // remove temp files built by laptop ClearOutTempLaptopFiles( ); // Shutdown queue system ShutdownDialogueControl(); // Shutdown Screens for (uiIndex = 0; uiIndex < MAX_SCREENS; uiIndex++) { (*(GameScreens[uiIndex].ShutdownScreen))(); } // Shutdown animation system DeInitAnimationSystem( ); ShutdownLightingSystem(); CursorDatabaseClear(); ShutdownTacticalEngine( ); // Shutdown Overhead ShutdownOverhead( ); DeinitializeWorld( ); DeleteTileCache( ); ShutdownJA2Clock( ); ShutdownFonts(); ShutdownJA2Sound( ); ShutdownEventManager( ); ShutdownBaseDirtyRectQueue( ); // Unload any text box images! RemoveTextMercPopupImages( ); ClearOutVehicleList(); }
void ClearMainMenu() { UINT32 uiDestPitchBYTES; UINT8 *pDestBuf; // CLEAR THE FRAME BUFFER pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES ); memset(pDestBuf, 0, SCREEN_HEIGHT * uiDestPitchBYTES ); UnLockVideoSurface( FRAME_BUFFER ); InvalidateScreen( ); }
//rrr BOOLEAN RenderCreditScreen() { HVOBJECT hPixHandle; GetVideoObject(&hPixHandle, guiCreditBackGroundImage ); BltVideoObject( FRAME_BUFFER, hPixHandle, 0, xResOffset, yResOffset, VO_BLT_SRCTRANSPARENCY, NULL); if( !gfCrdtHaveRenderedFirstFrameToSaveBuffer ) { gfCrdtHaveRenderedFirstFrameToSaveBuffer = TRUE; //blit everything to the save buffer ( cause the save buffer can bleed through ) BlitBufferToBuffer(guiRENDERBUFFER, guiSAVEBUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); UnmarkButtonsDirty( ); } InvalidateScreen( ); return( TRUE ); }
void DisplaySirtechSplashScreen() { HVOBJECT hPixHandle; VOBJECT_DESC VObjectDesc; UINT32 uiLogoID; UINT32 uiDestPitchBYTES; UINT8 *pDestBuf; // JA3Gold: do nothing until we have a graphic to replace Talonsoft's //return; // CLEAR THE FRAME BUFFER pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES ); memset(pDestBuf, 0, SCREEN_HEIGHT * uiDestPitchBYTES ); UnLockVideoSurface( FRAME_BUFFER ); memset( &VObjectDesc, 0, sizeof( VOBJECT_DESC ) ); VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; FilenameForBPP("INTERFACE\\SirtechSplash.sti", VObjectDesc.ImageFile); // FilenameForBPP("INTERFACE\\TShold.sti", VObjectDesc.ImageFile); if( !AddVideoObject(&VObjectDesc, &uiLogoID) ) { AssertMsg( 0, String( "Failed to load %s", VObjectDesc.ImageFile ) ); return; } GetVideoObject(&hPixHandle, uiLogoID); BltVideoObject(FRAME_BUFFER, hPixHandle, 0,0, 0, VO_BLT_SRCTRANSPARENCY,NULL); DeleteVideoObjectFromIndex(uiLogoID); InvalidateScreen(); RefreshScreen( NULL ); }
UINT32 MainMenuScreenHandle( ) { UINT32 cnt; UINT32 uiTime; if( guiSplashStartTime + 4000 > GetJA2Clock() ) { SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); SetMusicMode( MUSIC_NONE ); return MAINMENU_SCREEN; //The splash screen hasn't been up long enough yet. } if( guiSplashFrameFade ) { uiTime = GetJA2Clock(); if( guiSplashFrameFade > 2 ) ShadowVideoSurfaceRectUsingLowPercentTable( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); else if( guiSplashFrameFade > 1 ) ColorFillVideoSurfaceArea( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0 ); else { uiTime = GetJA2Clock(); SetMusicMode( MUSIC_MAIN_MENU ); } guiSplashFrameFade--; InvalidateScreen(); EndFrameBufferRender(); SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); return MAINMENU_SCREEN; } SetCurrentCursorFromDatabase( CURSOR_NORMAL ); if( gfMainMenuScreenEntry ) { InitMainMenu( ); gfMainMenuScreenEntry = FALSE; gfMainMenuScreenExit = FALSE; guiMainMenuExitScreen = MAINMENU_SCREEN; SetMusicMode( MUSIC_MAIN_MENU ); } if ( fInitialRender ) { ClearMainMenu(); RenderMainMenu(); fInitialRender = FALSE; } RestoreButtonBackGrounds(); // Render buttons for ( cnt = 0; cnt < NUM_MENU_ITEMS; cnt++ ) { MarkAButtonDirty( iMenuButtons[ cnt ] ); } RenderButtons( ); EndFrameBufferRender( ); HandleMainMenuInput(); HandleMainMenuScreen(); if( gfMainMenuScreenExit ) { ExitMainMenu( ); gfMainMenuScreenExit = FALSE; gfMainMenuScreenEntry = TRUE; } if( guiMainMenuExitScreen != MAINMENU_SCREEN ) gfMainMenuScreenEntry = TRUE; return( guiMainMenuExitScreen ); }
//sets up the loadscreen with specified ID, and draws it to the FRAME_BUFFER, //and refreshing the screen with it. void DisplayLoadScreenWithID( UINT8 ubLoadScreenID ) { VSURFACE_DESC vs_desc; HVSURFACE hVSurface; UINT32 uiLoadScreen; vs_desc.fCreateFlags = VSURFACE_CREATE_FROMFILE | VSURFACE_SYSTEM_MEM_USAGE; switch( ubLoadScreenID ) { case LOADINGSCREEN_NOTHING: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_Heli.sti"); break; case LOADINGSCREEN_DAYGENERIC: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayGeneric.sti"); break; case LOADINGSCREEN_DAYTOWN1: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayTown1.sti"); break; case LOADINGSCREEN_DAYTOWN2: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayTown2.sti"); break; case LOADINGSCREEN_DAYWILD: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayWild.sti"); break; case LOADINGSCREEN_DAYTROPICAL: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayTropical.sti"); break; case LOADINGSCREEN_DAYFOREST: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayForest.sti"); break; case LOADINGSCREEN_DAYDESERT: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayDesert.sti"); break; case LOADINGSCREEN_DAYPALACE: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayPalace.sti"); break; case LOADINGSCREEN_NIGHTGENERIC: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightGeneric.sti"); break; case LOADINGSCREEN_NIGHTWILD: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightWild.sti"); break; case LOADINGSCREEN_NIGHTTOWN1: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightTown1.sti"); break; case LOADINGSCREEN_NIGHTTOWN2: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightTown2.sti"); break; case LOADINGSCREEN_NIGHTFOREST: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightForest.sti"); break; case LOADINGSCREEN_NIGHTTROPICAL: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightTropical.sti"); break; case LOADINGSCREEN_NIGHTDESERT: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightDesert.sti"); break; case LOADINGSCREEN_NIGHTPALACE: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightPalace.sti"); break; case LOADINGSCREEN_HELI: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_Heli.sti"); break; case LOADINGSCREEN_BASEMENT: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_Basement.sti"); break; case LOADINGSCREEN_MINE: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_Mine.sti"); break; case LOADINGSCREEN_CAVE: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_Cave.sti"); break; case LOADINGSCREEN_DAYPINE: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayPine.sti"); break; case LOADINGSCREEN_NIGHTPINE: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightPine.sti"); break; case LOADINGSCREEN_DAYMILITARY: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayMilitary.sti"); break; case LOADINGSCREEN_NIGHTMILITARY: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightMilitary.sti"); break; case LOADINGSCREEN_DAYSAM: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DaySAM.sti"); break; case LOADINGSCREEN_NIGHTSAM: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightSAM.sti"); break; case LOADINGSCREEN_DAYPRISON: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayPrison.sti"); break; case LOADINGSCREEN_NIGHTPRISON: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightPrison.sti"); break; case LOADINGSCREEN_DAYHOSPITAL: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayHospital.sti"); break; case LOADINGSCREEN_NIGHTHOSPITAL: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightHospital.sti"); break; case LOADINGSCREEN_DAYAIRPORT: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayAirport.sti"); break; case LOADINGSCREEN_NIGHTAIRPORT: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightAirport.sti"); break; case LOADINGSCREEN_DAYLAB: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayLab.sti"); break; case LOADINGSCREEN_NIGHTLAB: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightLab.sti"); break; case LOADINGSCREEN_DAYOMERTA: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayOmerta.sti"); break; case LOADINGSCREEN_NIGHTOMERTA: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightOmerta.sti"); break; case LOADINGSCREEN_DAYCHITZENA: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayChitzena.sti"); break; case LOADINGSCREEN_NIGHTCHITZENA: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightChitzena.sti"); break; case LOADINGSCREEN_DAYMINE: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayMine.sti" ); break; case LOADINGSCREEN_NIGHTMINE: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightMine.sti" ); break; case LOADINGSCREEN_DAYBALIME: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_DayBalime.sti" ); break; case LOADINGSCREEN_NIGHTBALIME: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_NightBalime.sti" ); break; default: strcpy(vs_desc.ImageFile, "LOADSCREENS\\LS_Heli.sti"); break; } if( gfSchedulesHosed ) { SetFont( FONT10ARIAL ); SetFontForeground( FONT_YELLOW ); SetFontShadow( FONT_NEARBLACK ); ColorFillVideoSurfaceArea( FRAME_BUFFER, 0, 0, 640, 480, 0 ); mprintf( 5, 5, L"Error loading save, attempting to patch save to version 1.02...", vs_desc.ImageFile ); } else if( AddVideoSurface( &vs_desc, &uiLoadScreen ) ) { //Blit the background image GetVideoSurface( &hVSurface, uiLoadScreen ); BltVideoSurfaceToVideoSurface( ghFrameBuffer, hVSurface, 0, 0, 0, 0, NULL ); DeleteVideoSurfaceFromIndex( uiLoadScreen ); } else { //Failed to load the file, so use a black screen and print out message. SetFont( FONT10ARIAL ); SetFontForeground( FONT_YELLOW ); SetFontShadow( FONT_NEARBLACK ); ColorFillVideoSurfaceArea( FRAME_BUFFER, 0, 0, 640, 480, 0 ); mprintf( 5, 5, L"%S loadscreen data file not found...", vs_desc.ImageFile ); } gubLastLoadingScreenID = ubLoadScreenID; InvalidateScreen( ); ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); RefreshScreen( NULL ); }
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); }
//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; }
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 ; }
//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; }
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 ; }
//Simply create videosurface, load image, and draw it to the screen. void InitJA2SplashScreen() { #ifdef ENGLISH ClearMainMenu(); #else UINT32 uiLogoID = 0; HVSURFACE hVSurface; // unused jonathanl // lalien reenabled for international versions VSURFACE_DESC VSurfaceDesc; //unused jonathanl // lalien reenabled for international versions # ifdef JA2TESTVERSION INT32 i = 0; memset( &VSurfaceDesc, 0, sizeof( VSURFACE_DESC ) ); VSurfaceDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE | VSURFACE_SYSTEM_MEM_USAGE | VSURFACE_CREATE_FROMPNG_FALLBACK; sprintf( VSurfaceDesc.ImageFile, "LOADSCREENS\\Notification.sti" ); if( !AddVideoSurface( &VSurfaceDesc, &uiLogoID ) ) { //AssertMsg( 0, String( "Failed to load %s", VSurfaceDesc.ImageFile ) ); return; } GetVideoSurface(&hVSurface, uiLogoID ); //BltVideoSurfaceToVideoSurface( ghFrameBuffer, hVSurface, 0, 0, 0, 0, NULL ); BltVideoSurfaceToVideoSurface( ghFrameBuffer, hVSurface, 0, iScreenWidthOffset, iScreenHeightOffset, 0, NULL ); DeleteVideoSurfaceFromIndex( uiLogoID ); InvalidateScreen(); RefreshScreen( NULL ); guiSplashStartTime = GetJA2Clock(); while( i < 60 * 15 )//guiSplashStartTime + 15000 > GetJA2Clock() ) { //Allow the user to pick his bum. InvalidateScreen(); RefreshScreen( NULL ); i++; } # endif // JA2TESTVERSION memset( &VSurfaceDesc, 0, sizeof( VSURFACE_DESC ) ); VSurfaceDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE | VSURFACE_SYSTEM_MEM_USAGE | VSURFACE_CREATE_FROMPNG_FALLBACK; GetMLGFilename( VSurfaceDesc.ImageFile, MLG_SPLASH ); try { if( !AddVideoSurface( &VSurfaceDesc, &uiLogoID ) ) { AssertMsg( 0, String( "Failed to load %s", VSurfaceDesc.ImageFile ) ); return; } } catch(std::exception &ex) { SGP_RETHROW(L"Failed loading splash screen", ex); } GetVideoSurface( &hVSurface, uiLogoID ); BltVideoSurfaceToVideoSurface( ghFrameBuffer, hVSurface, 0, iScreenWidthOffset, iScreenHeightOffset, 0, NULL ); DeleteVideoSurfaceFromIndex( uiLogoID ); #endif // ENGLISH InvalidateScreen(); RefreshScreen( NULL ); guiSplashStartTime = GetJA2Clock(); }
//Simply create videosurface, load image, and draw it to the screen. void InitJA2SplashScreen() { UINT32 uiLogoID = 0; STRING512 CurrentDir; STRING512 DataDir; HVSURFACE hVSurface; VSURFACE_DESC VSurfaceDesc; INT32 i = 0; InitializeJA2Clock(); //InitializeJA2TimerID(); // Get Executable Directory GetExecutableDirectory( CurrentDir ); // Adjust Current Dir sprintf( DataDir, "%s\\Data", CurrentDir ); if ( !SetFileManCurrentDirectory( DataDir ) ) { DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Could not find data directory, shutting down"); return; } //Initialize the file database InitializeFileDatabase( gGameLibaries, NUMBER_OF_LIBRARIES ); #if !defined( ENGLISH ) && defined( JA2TESTVERSION ) memset( &VSurfaceDesc, 0, sizeof( VSURFACE_DESC ) ); VSurfaceDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE | VSURFACE_SYSTEM_MEM_USAGE; sprintf( VSurfaceDesc.ImageFile, "LOADSCREENS\\Notification.sti" ); if( !AddVideoSurface( &VSurfaceDesc, &uiLogoID ) ) { AssertMsg( 0, String( "Failed to load %s", VSurfaceDesc.ImageFile ) ); return; } GetVideoSurface(&hVSurface, uiLogoID ); BltVideoSurfaceToVideoSurface( ghFrameBuffer, hVSurface, 0, 0, 0, 0, NULL ); DeleteVideoSurfaceFromIndex( uiLogoID ); InvalidateScreen(); RefreshScreen( NULL ); guiSplashStartTime = GetJA2Clock(); while( i < 60 * 15 )//guiSplashStartTime + 15000 > GetJA2Clock() ) { //Allow the user to pick his bum. InvalidateScreen(); RefreshScreen( NULL ); i++; } #endif #ifdef ENGLISH ClearMainMenu(); #else { memset( &VSurfaceDesc, 0, sizeof( VSURFACE_DESC ) ); VSurfaceDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE | VSURFACE_SYSTEM_MEM_USAGE; GetMLGFilename( VSurfaceDesc.ImageFile, MLG_SPLASH ); if( !AddVideoSurface( &VSurfaceDesc, &uiLogoID ) ) { AssertMsg( 0, String( "Failed to load %s", VSurfaceDesc.ImageFile ) ); return; } GetVideoSurface( &hVSurface, uiLogoID ); BltVideoSurfaceToVideoSurface( ghFrameBuffer, hVSurface, 0, 0, 0, 0, NULL ); DeleteVideoSurfaceFromIndex( uiLogoID ); } #endif InvalidateScreen(); RefreshScreen( NULL ); guiSplashStartTime = GetJA2Clock(); }
UINT32 FadeScreenHandle( ) { UINT32 uiTime; if ( !gfFadeInitialized ) { SET_ERROR( "Fade Screen called but not intialized " ); return( ERROR_SCREEN ); } // ATE: Remove cursor SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); if ( gfFirstTimeInFade ) { gfFirstTimeInFade = FALSE; // Calcuate delay guiTime = GetJA2Clock( ); } // Get time uiTime = GetJA2Clock( ); MusicPoll( TRUE ); if ( ( uiTime - guiTime ) > guiFadeDelay ) { // Fade! if ( !gfFadeIn ) { //gFadeFunction( ); } InvalidateScreen(); if ( !gfFadeInVideo ) { gFadeFunction( ); } gsFadeCount++; if ( gsFadeCount > gsFadeLimit ) { switch( gbFadeType ) { case FADE_OUT_REALFADE: // Clear framebuffer ColorFillVideoSurfaceArea( FRAME_BUFFER, 0, 0, 640, 480, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) ); break; } //End! gfFadeInitialized = FALSE; gfFadeIn = FALSE; return( guiExitScreen ); } } return( FADE_SCREEN ); }