UINT32 ExitChatBox( INT8 ubExitCode ) { UINT32 uiDestPitchBYTES, uiSrcPitchBYTES; UINT8 *pDestBuf, *pSrcBuf; SGPPoint pPosition; // Delete popup! RemoveMercPopupBoxFromIndex( gChatBox.iBoxId ); gChatBox.iBoxId = -1; // OJW - 20090208 - Add text input box type // exit text input mode in this screen and clean up text boxes KillAllTextInputModes(); RemoveButton( gChatBox.uiOKButton ); RemoveButton( gChatBox.uiNOButton ); // Delete button images UnloadButtonImage( gChatBox.iButtonImages ); //Remove the toggle buttons for(int cnt=0; cnt<NUM_CHAT_TOGGLES; cnt++) { RemoveButton( guiChatToggles[ cnt ] ); } // delete graphics and scrolling buttons / slider if (gIncludeChatLog) { RemoveButton( guiChatLogScrollButtons[ 0 ] ); RemoveButton( guiChatLogScrollButtons[ 1 ] ); UnloadButtonImage( guiChatLogScrollButtonsImage[ 0 ] ); UnloadButtonImage( guiChatLogScrollButtonsImage[ 1 ] ); DeleteVideoObjectFromIndex( guiCHATLOGIMG ); DeleteChatLogSliderBar(); } #if 0 if (!gChatBox.fWasPaused) { // Unpause game.... UnLockPauseState(); UnPauseGame(); // UnPause timers as well.... PauseTime( FALSE ); } #endif // Restore mouse restriction region... RestrictMouseCursor( &gOldCursorLimitRectangle ); gfInChatBox = FALSE; // Call done callback! if ( gChatBox.ExitCallback != NULL ) { (*(gChatBox.ExitCallback))( ubExitCode ); } //if ur in a non gamescreen and DONT want the msg box to use the save buffer, unset gfDontOverRideSaveBuffer in ur callback if( ( ( gChatBox.uiExitScreen != GAME_SCREEN ) || ( fRestoreBackgroundForMessageBox == TRUE ) ) && gfDontOverRideSaveBuffer ) { // restore what we have under here... pSrcBuf = LockVideoSurface( gChatBox.uiSaveBuffer, &uiSrcPitchBYTES); pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES); Blt16BPPTo16BPP((UINT16 *)pDestBuf, uiDestPitchBYTES, (UINT16 *)pSrcBuf, uiSrcPitchBYTES, gChatBox.sX , gChatBox.sY, 0, 0, gChatBox.usWidth, gChatBox.usHeight ); UnLockVideoSurface( gChatBox.uiSaveBuffer ); UnLockVideoSurface( FRAME_BUFFER ); InvalidateRegion( gChatBox.sX, gChatBox.sY, (INT16)( gChatBox.sX + gChatBox.usWidth ), (INT16)( gChatBox.sY + gChatBox.usHeight ) ); } fRestoreBackgroundForMessageBox = FALSE; gfDontOverRideSaveBuffer = TRUE; if( fCursorLockedToArea == TRUE ) { GetMousePos( &pPosition ); if( ( pPosition.iX > ChatBoxRestrictedCursorRegion.iRight ) || ( pPosition.iX > ChatBoxRestrictedCursorRegion.iLeft ) && ( pPosition.iY < ChatBoxRestrictedCursorRegion.iTop ) && ( pPosition.iY > ChatBoxRestrictedCursorRegion.iBottom ) ) { SimulateMouseMovement( pOldMousePosition.iX , pOldMousePosition.iY ); } fCursorLockedToArea = FALSE; RestrictMouseCursor( &ChatBoxRestrictedCursorRegion ); } // Remove region MSYS_RemoveRegion(&(gChatBox.BackRegion) ); // Remove save buffer! DeleteVideoSurfaceFromIndex( gChatBox.uiSaveBuffer ); switch( gChatBox.uiExitScreen ) { case GAME_SCREEN: if ( InOverheadMap( ) ) { gfOverheadMapDirty = TRUE; } else { SetRenderFlags( RENDER_FLAG_FULL ); } break; case MAP_SCREEN: fMapPanelDirty = TRUE; break; } if ( gfFadeInitialized ) { SetPendingNewScreen(FADE_SCREEN); return( FADE_SCREEN ); } return( gChatBox.uiExitScreen ); }
UINT32 ExitMsgBox( INT8 ubExitCode ) { UINT32 uiDestPitchBYTES, uiSrcPitchBYTES; UINT8 *pDestBuf, *pSrcBuf; SGPPoint pPosition; // Delete popup! RemoveMercPopupBoxFromIndex( gMsgBox.iBoxId ); gMsgBox.iBoxId = -1; //Delete buttons! if ( gMsgBox.usFlags & MSG_BOX_FLAG_FOUR_NUMBERED_BUTTONS ) { RemoveButton( gMsgBox.uiButton[0] ); RemoveButton( gMsgBox.uiButton[1] ); RemoveButton( gMsgBox.uiButton[2] ); RemoveButton( gMsgBox.uiButton[3] ); } else { if ( gMsgBox.usFlags & MSG_BOX_FLAG_OK ) { RemoveButton( gMsgBox.uiOKButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_YESNO ) { RemoveButton( gMsgBox.uiYESButton ); RemoveButton( gMsgBox.uiNOButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_OKCONTRACT ) { RemoveButton( gMsgBox.uiYESButton ); RemoveButton( gMsgBox.uiNOButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_YESNOCONTRACT ) { RemoveButton( gMsgBox.uiYESButton ); RemoveButton( gMsgBox.uiNOButton ); RemoveButton( gMsgBox.uiOKButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_GENERICCONTRACT ) { RemoveButton( gMsgBox.uiYESButton ); RemoveButton( gMsgBox.uiNOButton ); RemoveButton( gMsgBox.uiOKButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_GENERIC ) { RemoveButton( gMsgBox.uiYESButton ); RemoveButton( gMsgBox.uiNOButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_YESNOLIE ) { RemoveButton( gMsgBox.uiYESButton ); RemoveButton( gMsgBox.uiNOButton ); RemoveButton( gMsgBox.uiOKButton ); } if( gMsgBox.usFlags & MSG_BOX_FLAG_CONTINUESTOP ) { RemoveButton( gMsgBox.uiYESButton ); RemoveButton( gMsgBox.uiNOButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_OKSKIP ) { RemoveButton( gMsgBox.uiYESButton ); RemoveButton( gMsgBox.uiNOButton ); } } // Delete button images UnloadButtonImage( gMsgBox.iButtonImages ); // Unpause game.... UnLockPauseState(); UnPauseGame(); // UnPause timers as well.... PauseTime( FALSE ); // Restore mouse restriction region... RestrictMouseCursor( &gOldCursorLimitRectangle ); gfInMsgBox = FALSE; // Call done callback! if ( gMsgBox.ExitCallback != NULL ) { (*(gMsgBox.ExitCallback))( ubExitCode ); } //if ur in a non gamescreen and DONT want the msg box to use the save buffer, unset gfDontOverRideSaveBuffer in ur callback if( ( ( gMsgBox.uiExitScreen != GAME_SCREEN ) || ( fRestoreBackgroundForMessageBox == TRUE ) ) && gfDontOverRideSaveBuffer ) { // restore what we have under here... pSrcBuf = LockVideoSurface( gMsgBox.uiSaveBuffer, &uiSrcPitchBYTES); pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES); Blt16BPPTo16BPP((UINT16 *)pDestBuf, uiDestPitchBYTES, (UINT16 *)pSrcBuf, uiSrcPitchBYTES, gMsgBox.sX , gMsgBox.sY, 0, 0, gMsgBox.usWidth, gMsgBox.usHeight ); UnLockVideoSurface( gMsgBox.uiSaveBuffer ); UnLockVideoSurface( FRAME_BUFFER ); InvalidateRegion( gMsgBox.sX, gMsgBox.sY, (INT16)( gMsgBox.sX + gMsgBox.usWidth ), (INT16)( gMsgBox.sY + gMsgBox.usHeight ) ); } fRestoreBackgroundForMessageBox = FALSE; gfDontOverRideSaveBuffer = TRUE; if( fCursorLockedToArea == TRUE ) { GetMousePos( &pPosition ); if( ( pPosition.iX > MessageBoxRestrictedCursorRegion.iRight ) || ( pPosition.iX > MessageBoxRestrictedCursorRegion.iLeft ) && ( pPosition.iY < MessageBoxRestrictedCursorRegion.iTop ) && ( pPosition.iY > MessageBoxRestrictedCursorRegion.iBottom ) ) { SimulateMouseMovement( pOldMousePosition.iX , pOldMousePosition.iY ); } fCursorLockedToArea = FALSE; RestrictMouseCursor( &MessageBoxRestrictedCursorRegion ); } // Remove region MSYS_RemoveRegion(&(gMsgBox.BackRegion) ); // Remove save buffer! DeleteVideoSurfaceFromIndex( gMsgBox.uiSaveBuffer ); switch( gMsgBox.uiExitScreen ) { case GAME_SCREEN: if ( InOverheadMap( ) ) { gfOverheadMapDirty = TRUE; } else { SetRenderFlags( RENDER_FLAG_FULL ); } break; case MAP_SCREEN: fMapPanelDirty = TRUE; break; } if ( gfFadeInitialized ) { SetPendingNewScreen(FADE_SCREEN); return( FADE_SCREEN ); } return( gMsgBox.uiExitScreen ); }