void OnBoardFailed(IshipIGC* pshipRequestedParent) { if (trekClient.GetShip()->GetCluster() == NULL) { if (pshipRequestedParent && MannedTurrets(pshipRequestedParent) < NumTurrets(pshipRequestedParent)) { TRef<IMessageBox> pmsgBox = CreateMessageBox( "Teleportation canceled - no turret positions were open."); trekClient.PlaySoundEffect(noTurretsSound); GetWindow()->GetPopupContainer()->OpenPopup(pmsgBox, false); } else { TRef<IMessageBox> pmsgBox = CreateMessageBox("Teleportation failed."); GetWindow()->GetPopupContainer()->OpenPopup(pmsgBox, false); } } }
void Dismiss (void) { Slideshow::Dismiss (); // pop up the Connecting... dialog. GetWindow()->SetWaitCursor(); // open up a dialog to let the player know the world hasn't ended TRef<IMessageBox> pMsgBox = CreateMessageBox ("Training simulation initiated...", NULL, false); GetWindow ()->GetPopupContainer ()->OpenPopup (pMsgBox, false); // pause to let the "starting..." box draw itself // mdvalley: pause to add in another pointer and class name AddEventTarget (&TrainingSlideshow::OnSwitchOut, GetWindow(), 0.1f); }
void BH::Assert(Char * const expression, const Char * const message, const Char * const filename, const size_t line) { String file(filename); Ostringstream msg; msg << "Expression: " << expression << std::endl << "File: " << file.substr(file.find_last_of('\\') + 1) << ", Line: " << line << std::endl << std::endl << "Message: " << std::endl << message << std::endl; CreateMessageBox( msg.str( ).c_str( ), "Assertion Error" ); }
bool DoTrainLive (void) { // pop up the "creating game..." dialog. GetWindow()->SetWaitCursor (); TRef<IMessageBox> pMsgBox = CreateMessageBox ("Creating game...", NULL, false); GetWindow ()->GetPopupContainer ()->OpenPopup (pMsgBox, false); // pause to let the "creating game..." box draw itself // mdvalley: Pointer, name, repeat. AddEventTarget(&TrainingScreen::OnTrainLive, GetWindow(), 0.1f); // this then goes to OnTrainLive // return false, I don't know why return false; }
HRESULT CreateTrainingMissionGame (void) { HRESULT hr; assert (m_spAdminGamesPtr); // Create a GameParameters object IAGCGameParametersPtr spParams; if (!Error (hr = spParams.CreateInstance (CLSID_AGCGameParameters))) { // set up game parameters associated with the training game spParams->put_MinPlayers (1); spParams->put_TotalMaxPlayers (1); spParams->put_CivIDs (0, m_civID); // default is iron league, but user may pick a different one spParams->put_CivIDs (1, 35); // bios spParams->put_GameName (_bstr_t (TRAINING_MISSION_7_GAME_NAME)); spParams->put_LockTeamSettings (true); // Create a new game if (!Error (hr = m_spAdminGamesPtr->Add (spParams))) { // get the game if (!Error (hr = m_spAdminGamesPtr->get_Item (& (_variant_t) (0L), &m_spAdminGamePtr))) { // set up the teams m_spAdminGamePtr->SetTeamName (0, _bstr_t ("Training Academy")); m_spAdminGamePtr->SetTeamName (1, _bstr_t ("Bios")); // pop up the Connecting... dialog. GetWindow()->SetWaitCursor (); TRef<IMessageBox> pMsgBox = CreateMessageBox ("Connecting...", NULL, false); GetWindow ()->GetPopupContainer ()->OpenPopup (pMsgBox, false); // pause to let the "connecting..." box draw itself // mdvalley: repeat AddEventTarget(&TrainingScreen::OnTryLogon, GetWindow(), 0.1f); // this then goes to OnTryLogon } } } // terminate the games admin pointer m_spAdminGamesPtr = 0; return hr; }
void CheckForExistingGames (void) { // try to get a game pointer from the games list m_spAdminGamesPtr->get_Item (& (_variant_t) (0L), &m_spAdminGamePtr); // if we got a valid game if (m_spAdminGamePtr) { // put up a message about the existing game TRef<IMessageBox> pMsgBox = CreateMessageBox ("The training mission game could not be created because there is already a server running on this machine with an active game."); GetWindow ()->GetPopupContainer ()->OpenPopup (pMsgBox, false); // and we terminate the entire login process here m_spAdminGamePtr = 0; m_spAdminGamesPtr = 0; } else { // create the game we want CreateTrainingMissionGame (); } }
static bool Error (HRESULT hr) { if (FAILED (hr)) { // get the error codes IErrorInfoPtr spErr; ::GetErrorInfo(0, &spErr); // convert that to an english message _com_error e (hr, spErr, true); _bstr_t strError (e.Description().length() ? e.Description() : _bstr_t (e.ErrorMessage())); // debug just bail so I can trace the problem // assert (0); // put up a dialog about the error TRef<IMessageBox> pMsgBox = CreateMessageBox (ZString ("Unable to create a game. The home server may not be properly installed. Install the home server from your Allegiance CD.\n\nReason for failure: ") + (LPCTSTR)strError, NULL, true); GetWindow()->GetPopupContainer()->OpenPopup (pMsgBox, false); return true; } return false; }
//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 ; }
int main() { /* Local Variables */ int l_iResult = 0; unsigned int l_uiMesgNb = 0; #ifdef DEBUG #ifdef ONLYERRORS FileDebug = NULL; #else FileDebug = stderr; #endif FileOutput = stdout; FileError = stderr; #else FileDebug = NULL; FileOutput = stdout; FileError = NULL; #endif /* Verify Window size */ verifyTerminalSize(); /* Clear output screen */ if (FileOutput) fprintf(FileOutput, "\x1b[0m\x1b[2J"); /* Shuffle Messages */ melange(); /* Printing all messages */ for (l_uiMesgNb = 0; l_uiMesgNb < NBMESSAGES; l_uiMesgNb++) { #ifdef DEBUG if (FileDebug) { fprintf(FileDebug, "Msg (%d)\n", g_auiOrdre[l_uiMesgNb]); } #endif l_iResult = CreateMessageBox(MESSAGES[g_auiOrdre[l_uiMesgNb]]); #ifdef DEBUG if (FileDebug) { fprintf(FileDebug, "CreateMessageBox returned %d\n", l_iResult); } #endif sleep(SLEEP_BETWEEN_TWO_BOXES); } if (FileOutput) fprintf(FileOutput, "Appuyez sur ENTREE pour quitter... \n"); /* Wait for input */ fflush(stdin); getchar(); fflush(stdin); /* Last message */ if (FileOutput) { fflush(FileOutput); fprintf(FileOutput, "\x1b[0m\x1b[2J"); fprintf(FileOutput, "\x1b[%d;%df%s", getScreenHeight()/2, (getScreenWidth() - (unsigned int) sizeof(MERCI)) /2, MERCI); fprintf(FileOutput, "\x1b[%d;%df%s", getScreenHeight()-1, (getScreenWidth() - (unsigned int) (sizeof(REALISEPAR)-6*4)) /2, REALISEPAR); fprintf(FileOutput, "\x1b[%d;%df%s", getScreenHeight()-2, (getScreenWidth() - (unsigned int) sizeof(MESSAGESPAR))/2, MESSAGESPAR); fprintf(FileOutput, "\x1b[%d;1f",getScreenHeight()); fflush(FileOutput); } return l_iResult; }
void OnLogonGameServerFailed(bool bRetry, const char* szReason) { // tell the user why the logon failed TRef<IMessageBox> pmsgBox = CreateMessageBox(szReason); GetWindow()->GetPopupContainer()->OpenPopup(pmsgBox, false); }
bool OnTryLogon (void) { TList<TRef<LANServerInfo> > listResults; // try ten times int iTryCount = 10; while (iTryCount-- && (listResults.GetCount () == 0)) { // initiate a query for the local server trekClient.FindStandaloneServersByName ("127.0.0.1", listResults); //Imago REVIEW this hardly works now-a-days 6/10 // now, for 6 seconds, check to see if we found it every half second for (int i = 0; (i < 12) && (listResults.GetCount () == 0); i++) { Sleep (500); trekClient.FindStandaloneServersByName (NULL, listResults); } } // if we found a server... if (listResults.GetCount () == 1) { // there should be only one game on the server TList<TRef<LANServerInfo> >::Iterator iterNew(listResults); if (iterNew.Value ()->strGameName == TRAINING_MISSION_7_GAME_NAME) { // set ourselves to not be in the lobby or the zone trekClient.SetIsLobbied(false); trekClient.SetIsZoneClub(false); // set up the connection info BaseClient::ConnectInfo ci; ci.guidSession = iterNew.Value ()->guidSession; strcpy (ci.szName, "Cadet"); // we try five times iTryCount = 5; while (iTryCount-- && !trekClient.m_fm.IsConnected ()) { // close any popups while (!GetWindow()->GetPopupContainer()->IsEmpty()) GetWindow()->GetPopupContainer()->ClosePopup(NULL); GetWindow()->RestoreCursor(); // connect to the server trekClient.ConnectToServer (ci, NA, Time::Now(), "", true); } } } // if we didn't get connected if (!trekClient.m_fm.IsConnected ()) { // close any popups while (!GetWindow()->GetPopupContainer()->IsEmpty()) GetWindow()->GetPopupContainer()->ClosePopup(NULL); GetWindow()->RestoreCursor(); // give some indication of what happened TRef<IMessageBox> pmsgBox = CreateMessageBox("Connection to standalone server failed."); GetWindow()->GetPopupContainer()->OpenPopup(pmsgBox, false); // terminate the game so they can try again KillStandaloneGame (); // report the number of servers found as a diagnostic #ifdef _DEBUG char szBuffer[256]; sprintf (szBuffer, "Found %d servers.\n", listResults.GetCount ()); debugf (szBuffer); #endif } else { // tell training that this is the live mission Training::StartMission (Training::c_TM_7_Live); } return false; }
void ShowMessageBox( const char * msg ) { if ( MessageBox ) gtk_widget_destroy( MessageBox ); MessageBox=CreateMessageBox(); if ( strlen( msg ) < 20 ) gtk_widget_set_usize( MessageBox,196,-1 ); }