UINT32 IntroScreenHandle( void ) { if( gfIntroScreenEntry ) { EnterIntroScreen(); gfIntroScreenEntry = FALSE; gfIntroScreenExit = FALSE; InvalidateRegion( 0, 0, 640, 480 ); } RestoreBackgroundRects(); GetIntroScreenUserInput(); HandleIntroScreen(); ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); if( gfIntroScreenExit ) { ExitIntroScreen(); gfIntroScreenExit = FALSE; gfIntroScreenEntry = TRUE; } return( guiIntroExitScreen ); }
UINT32 GameInitOptionsScreenHandle( void ) { StartFrameBufferRender(); if( gfGIOScreenEntry ) { // PauseGame(); EnterGIOScreen(); gfGIOScreenEntry = FALSE; gfGIOScreenExit = FALSE; InvalidateRegion( 0, 0, 640, 480 ); } GetGIOScreenUserInput(); HandleGIOScreen(); // render buttons marked dirty MarkButtonsDirty( ); RenderButtons( ); // render help // RenderFastHelp( ); // RenderButtonsFastHelp( ); ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); if ( HandleFadeOutCallback( ) ) { ClearMainMenu(); return( gubGIOExitScreen ); } if ( HandleBeginFadeOut( gubGIOExitScreen ) ) { return( gubGIOExitScreen ); } if( gfGIOScreenExit ) { ExitGIOScreen(); } if ( HandleFadeInCallback( ) ) { // Re-render the scene! RenderGIOScreen(); } if ( HandleBeginFadeIn( gubGIOExitScreen ) ) { } return( gubGIOExitScreen ); }
BOOLEAN ExternalLoadMap( UINT16 *szFilename ) { Assert( szFilename ); if( !wcslen( szFilename ) ) return FALSE; wcscpy( gzFilename, szFilename ); if( !ValidFilename() ) return FALSE; gbCurrentFileIOStatus = INITIATE_MAP_LOAD; ProcessFileIO(); //always returns loadsave_screen and changes iostatus to loading_map. ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); RefreshScreen( NULL ); if( ProcessFileIO() == EDIT_SCREEN ) return TRUE; return FALSE; }
BOOLEAN ExternalSaveMap( UINT16 *szFilename ) { Assert( szFilename ); if( !wcslen( szFilename ) ) return FALSE; wcscpy( gzFilename, szFilename ); if( !ValidFilename() ) return FALSE; gbCurrentFileIOStatus = INITIATE_MAP_SAVE; if( ProcessFileIO() == ERROR_SCREEN ) return FALSE; ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); RefreshScreen( NULL ); if( ProcessFileIO() == EDIT_SCREEN ) return TRUE; return FALSE; }
//dnl ch37 200909 BOOLEAN ExternalLoadMap(STR16 szFilename) { gfLoadError = FALSE; Assert(szFilename); if(!wcslen( szFilename)) return(FALSE); wcscpy(gzFilename, szFilename); if(!ValidFilename()) return(FALSE); gbCurrentFileIOStatus = INITIATE_MAP_LOAD; ProcessFileIO(); ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); RefreshScreen(NULL); ProcessFileIO(); if(gfLoadError) return(FALSE); return(TRUE); }
BOOLEAN ProcessPopupMenuIfActive( ) { if( !gPopup.fActive && !fWaitingForLButtonRelease ) return FALSE; if( fWaitingForLButtonRelease ) { if( !gfLeftButtonState ) { fWaitingForLButtonRelease = FALSE; return FALSE; } return TRUE; } PopupMenuHandle(); RenderPopupMenu(); InvalidateRegion( gPopup.usLeft, gPopup.usTop, gPopup.usRight, gPopup.usBottom ); ExecuteBaseDirtyRectQueue(); EndFrameBufferRender( ); return TRUE; }
UINT32 CreditScreenHandle( void ) { StartFrameBufferRender(); if( gfCreditsScreenEntry ) { if( !EnterCreditsScreen() ) { gfCreditsScreenEntry = FALSE; gfCreditsScreenExit = TRUE; } else { gfCreditsScreenEntry = FALSE; gfCreditsScreenExit = FALSE; } gubCreditScreenRenderFlags = CRDT_RENDER_ALL; } GetCreditScreenUserInput(); HandleCreditScreen(); ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); if( gfCreditsScreenExit ) { ExitCreditScreen(); gfCreditsScreenEntry = TRUE; gfCreditsScreenExit = FALSE; } return( guiCreditsExitScreen ); }
//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 ); }
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 ; }
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 ; }