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(); }
BOOLEAN EnterIntroScreen() { INT32 iFirstVideoID = -1; ClearMainMenu(); SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); // Don't play music.... SetMusicMode( MUSIC_NONE ); #ifdef JA2BETAVERSION if( FileExists( "..\\NoIntro.txt" ) ) { PrepareToExitIntroScreen(); return( TRUE ); } #endif //if the library doesnt exist, exit if( !IsLibraryOpened( LIBRARY_INTRO ) ) { PrepareToExitIntroScreen(); return( TRUE ); } //initialize smacker SmkInitialize( ghWindow, 640, 480); //get the index opf the first video to watch iFirstVideoID = GetNextIntroVideo( SMKINTRO_FIRST_VIDEO ); if( iFirstVideoID != -1 ) { StartPlayingIntroFlic( iFirstVideoID ); guiIntroExitScreen = INTRO_SCREEN; } //Got no intro video, exit else { PrepareToExitIntroScreen(); } return( TRUE ); }
void DoneFadeOutForExitGameInitOptionScreen( void ) { // loop through and get the status of all the buttons gGameOptions.fGunNut = GetCurrentGunButtonSetting(); gGameOptions.fSciFi = GetCurrentGameStyleButtonSetting(); gGameOptions.ubDifficultyLevel = GetCurrentDifficultyButtonSetting() + 1; // JA2Gold: no more timed turns setting //gGameOptions.fTurnTimeLimit = GetCurrentTimedTurnsButtonSetting(); // JA2Gold: iron man gGameOptions.fIronManMode = GetCurrentGameSaveButtonSetting(); // gubGIOExitScreen = INIT_SCREEN; gubGIOExitScreen = INTRO_SCREEN; //set the fact that we should do the intro videos // gbIntroScreenMode = INTRO_BEGINING; #ifdef JA2TESTVERSION if( gfKeyState[ ALT ] ) { if( gfKeyState[ CTRL ] ) { gMercProfiles[ MIGUEL ].bMercStatus = MERC_IS_DEAD; gMercProfiles[ SKYRIDER ].bMercStatus = MERC_IS_DEAD; } SetIntroType( INTRO_ENDING ); } else #endif SetIntroType( INTRO_BEGINING ); ExitGIOScreen(); // gFadeInDoneCallback = DoneFadeInForExitGameInitOptionScreen; // FadeInNextFrame( ); SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); }
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 ); }
INT32 DoChatBox( bool bIncludeChatLog, const STR16 zString, UINT32 uiExitScreen, MSGBOX_CALLBACK ReturnCallback, SGPRect *pCenteringRect ) { VSURFACE_DESC vs_desc; UINT16 usTextBoxWidth; UINT16 usTextBoxHeight; UINT16 usYMargin; SGPRect aRect; UINT32 uiDestPitchBYTES, uiSrcPitchBYTES; UINT8 *pDestBuf, *pSrcBuf; INT16 sButtonX, sButtonY; UINT8 ubMercBoxBackground = BASIC_MERC_POPUP_BACKGROUND, ubMercBoxBorder = BASIC_MERC_POPUP_BORDER; UINT8 ubFontColor, ubFontShadowColor; UINT16 usCursor; INT32 iId = -1; // clear the ouput string memset(gszChatBoxInputString,0,sizeof(CHAR16)*255); gIncludeChatLog = bIncludeChatLog; GetMousePos( &pOldMousePosition ); if (bIncludeChatLog) usYMargin = CHATBOX_Y_MARGIN_LOG; else usYMargin = CHATBOX_Y_MARGIN_NOLOG; //this variable can be unset if ur in a non gamescreen and DONT want the msg box to use the save buffer gfDontOverRideSaveBuffer = TRUE; SetCurrentCursorFromDatabase( CURSOR_NORMAL ); if( gChatBox.BackRegion.uiFlags & MSYS_REGION_EXISTS ) { return( 0 ); } // set style ubMercBoxBackground = DIALOG_MERC_POPUP_BACKGROUND; ubMercBoxBorder = DIALOG_MERC_POPUP_BORDER; // Add button images gChatBox.iButtonImages = LoadButtonImage( "INTERFACE\\popupbuttons.sti", -1,0,-1,1,-1 ); ubFontColor = CHATBOX_FONT_COLOR; ubFontShadowColor = DEFAULT_SHADOW; usCursor = CURSOR_NORMAL; // Use default! aRect.iTop = 0; aRect.iLeft = 0; aRect.iBottom = SCREEN_HEIGHT; aRect.iRight = SCREEN_WIDTH; // Set some values! //gChatBox.usFlags = usFlags; gChatBox.uiExitScreen = uiExitScreen; gChatBox.ExitCallback = ReturnCallback; gChatBox.fRenderBox = TRUE; gChatBox.bHandled = 0; // Init message box if (bIncludeChatLog) // we need a string just long enough to give 1 line, but max length of the box, we render the chatlog over this string so well never see it. DONT DELETE ANY SPACES gChatBox.iBoxId = PrepareMercPopupBox( iId, ubMercBoxBackground, ubMercBoxBorder, L"A string that will be hidden, ", CHATBOX_WIDTH, CHATBOX_X_MARGIN, usYMargin, CHATBOX_Y_MARGIN_BOTTOM, &usTextBoxWidth, &usTextBoxHeight ); else gChatBox.iBoxId = PrepareMercPopupBox( iId, ubMercBoxBackground, ubMercBoxBorder, zString, CHATBOX_WIDTH, CHATBOX_X_MARGIN, usYMargin, CHATBOX_Y_MARGIN_BOTTOM, &usTextBoxWidth, &usTextBoxHeight ); if( gChatBox.iBoxId == -1 ) { #ifdef JA2BETAVERSION AssertMsg( 0, "Failed in DoMessageBox(). Probable reason is because the string was too large to fit in max message box size." ); #endif return 0; } // Save height,width gChatBox.usWidth = usTextBoxWidth; gChatBox.usHeight = usTextBoxHeight; // Determine position ( centered in rect ) gChatBox.sX = (INT16)( ( ( ( aRect.iRight - aRect.iLeft ) - usTextBoxWidth ) / 2 ) + aRect.iLeft ); gChatBox.sY = (INT16)( ( ( ( aRect.iBottom - aRect.iTop ) - usTextBoxHeight ) / 2 ) + aRect.iTop ); if ( guiCurrentScreen == GAME_SCREEN ) { gfStartedFromGameScreen = TRUE; } if ( (fInMapMode == TRUE ) ) { // fMapExitDueToMessageBox = TRUE; gfStartedFromMapScreen = TRUE; fMapPanelDirty = TRUE; } // Set pending screen SetPendingNewScreen( MP_CHAT_SCREEN); // Init save buffer vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE; vs_desc.usWidth = usTextBoxWidth; vs_desc.usHeight = usTextBoxHeight; vs_desc.ubBitDepth = 16; if( AddVideoSurface( &vs_desc, &gChatBox.uiSaveBuffer) == FALSE ) { return( - 1 ); } //Save what we have under here... pDestBuf = LockVideoSurface( gChatBox.uiSaveBuffer, &uiDestPitchBYTES); pSrcBuf = LockVideoSurface( FRAME_BUFFER, &uiSrcPitchBYTES); Blt16BPPTo16BPP((UINT16 *)pDestBuf, uiDestPitchBYTES, (UINT16 *)pSrcBuf, uiSrcPitchBYTES, 0 , 0, gChatBox.sX , gChatBox.sY, usTextBoxWidth, usTextBoxHeight ); UnLockVideoSurface( gChatBox.uiSaveBuffer ); UnLockVideoSurface( FRAME_BUFFER ); // Create top-level mouse region MSYS_DefineRegion( &(gChatBox.BackRegion), 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, MSYS_PRIORITY_HIGHEST, usCursor, MSYS_NO_CALLBACK, ChatBoxClickCallback ); // Add region MSYS_AddRegion(&(gChatBox.BackRegion) ); // findout if cursor locked, if so, store old params and store, restore when done if( IsCursorRestricted() ) { fCursorLockedToArea = TRUE; GetRestrictedClipCursor( &ChatBoxRestrictedCursorRegion ); FreeMouseCursor( ); } // vars for positioning controls on the chatbox int usPosX = 0; int usPosY = gChatBox.sY + GetFontHeight(CHATBOX_FONT_TITLE) + CHATBOX_Y_GAP + 5; if (bIncludeChatLog) { // CREATE BUTTONS AND IMAGES FOR CHATLOG VOBJECT_DESC VObjectDesc; // will create buttons for interface bottom VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; FilenameForBPP( "INTERFACE\\mpchatbox.sti", VObjectDesc.ImageFile ); if( !AddVideoObject( &VObjectDesc, &guiCHATLOGIMG ) ) Assert( false ); gChatMessageLogRegion.iTop = usPosY; gChatMessageLogRegion.iLeft = gChatBox.sX + (CHATBOX_X_MARGIN / 2); gChatMessageLogRegion.iBottom = usPosY + CHATBOX_LOG_HEIGHT; gChatMessageLogRegion.iRight = gChatMessageLogRegion.iLeft + CHATBOX_LOG_WIDTH; // SETUP SCROLLING AREA BOUNDS CHATLOG_SCROLL_AREA_START_Y = gChatMessageLogRegion.iTop+20; CHATLOG_SCROLL_AREA_END_Y = gChatMessageLogRegion.iBottom-20; CHATLOG_SCROLL_AREA_HEIGHT = ( CHATLOG_SCROLL_AREA_END_Y - CHATLOG_SCROLL_AREA_START_Y + 1 ); CHATLOG_SCROLL_AREA_START_X = gChatMessageLogRegion.iRight + CHATBOX_SLIDER_GAP + 1; CHATLOG_SCROLL_AREA_END_X = gChatMessageLogRegion.iRight + CHATBOX_SLIDER_GAP + 1 + CHAT_SLIDER_WIDTH; CHATLOG_SCROLL_AREA_WIDTH = ( CHATLOG_SCROLL_AREA_END_X - CHATLOG_SCROLL_AREA_START_X + 1 ); CHAT_SLIDER_BAR_RANGE = ( CHATLOG_SCROLL_AREA_HEIGHT - CHAT_SLIDER_HEIGHT ); LoadChatLogSliderBar(); // Load Scroll button images guiChatLogScrollButtonsImage[ CHAT_SCROLL_MESSAGE_UP ]= LoadButtonImage( "INTERFACE\\map_screen_bottom_arrows.sti" ,11,4,-1,6,-1 ); guiChatLogScrollButtonsImage[ CHAT_SCROLL_MESSAGE_DOWN ]= LoadButtonImage( "INTERFACE\\map_screen_bottom_arrows.sti" ,12,5,-1,7,-1 ); // Create buttons guiChatLogScrollButtons[ CHAT_SCROLL_MESSAGE_UP ] = QuickCreateButton( guiChatLogScrollButtonsImage[ CHAT_SCROLL_MESSAGE_UP ], gChatMessageLogRegion.iRight + CHATBOX_SLIDER_GAP + 2 , gChatMessageLogRegion.iTop + 1 , BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST, (GUI_CALLBACK)BtnGenericMouseMoveButtonCallback, (GUI_CALLBACK)BtnMessageUpChatLogCallback); guiChatLogScrollButtons[ CHAT_SCROLL_MESSAGE_DOWN ] = QuickCreateButton( guiChatLogScrollButtonsImage[ CHAT_SCROLL_MESSAGE_DOWN ], gChatMessageLogRegion.iRight + CHATBOX_SLIDER_GAP + 2, gChatMessageLogRegion.iBottom - 16, BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST, (GUI_CALLBACK)BtnGenericMouseMoveButtonCallback, (GUI_CALLBACK)BtnMessageDownChatLogCallback); usPosY = gChatBox.sY + CHATBOX_Y_MARGIN_LOG + (CHATBOX_Y_GAP * 2) + GetFontHeight(FONT12ARIAL) + 5; // END CREATE CHATLOG } else usPosY = gChatBox.sY + CHATBOX_Y_MARGIN_NOLOG + (CHATBOX_Y_GAP * 2) + GetFontHeight(FONT12ARIAL); // get the middle of the box UINT16 middleBox = ( usTextBoxWidth / 2 ); // CREATE SEND TO ALLIES / ALL TOGGLES // send to all int toggleWidth = 32 + StringPixLength( gzMPChatToggleText[ 0 ], CHATBOX_FONT_TOGGLE ); usPosX = gChatBox.sX + ((middleBox - toggleWidth)/2); guiChatToggles[ 0 ] = CreateCheckBoxButton( usPosX, usPosY, "INTERFACE\\OptionsCheckBoxes_12x12.sti", MSYS_PRIORITY_HIGHEST, BtnChatTogglesCallback ); MSYS_SetBtnUserData( guiChatToggles[ 0 ], 0, 0 ); // send to allies toggleWidth = 32 + StringPixLength( gzMPChatToggleText[ 1 ], CHATBOX_FONT_TOGGLE ); usPosX = gChatBox.sX + middleBox + ((middleBox - toggleWidth)/2); guiChatToggles[ 1 ] = CreateCheckBoxButton( usPosX, usPosY, "INTERFACE\\OptionsCheckBoxes_12x12.sti", MSYS_PRIORITY_HIGHEST, BtnChatTogglesCallback ); MSYS_SetBtnUserData( guiChatToggles[ 1 ], 0, 1 ); usPosY += CHATBOX_TOGGLE_HEIGHT + CHATBOX_Y_GAP; // SET DEFAULT FLAGGED if (gbChatSendToAll) ButtonList[ guiChatToggles[ 0 ] ]->uiFlags |= BUTTON_CLICKED_ON; else ButtonList[ guiChatToggles[ 1 ] ]->uiFlags |= BUTTON_CLICKED_ON; // END CREATE TOGGLES // CREATE TEXT INPUT BOX InitTextInputMode(); // API call to initialise text input mode for this screen // does not mean we are inputting text right away // Player Name field SetTextInputCursor( CUROSR_IBEAM_WHITE ); SetTextInputFont( (UINT16) FONT12ARIALFIXEDWIDTH ); //FONT12ARIAL //FONT12ARIALFIXEDWIDTH Set16BPPTextFieldColor( Get16BPPColor(FROMRGB( 0, 0, 0) ) ); SetBevelColors( Get16BPPColor(FROMRGB(136, 138, 135)), Get16BPPColor(FROMRGB(24, 61, 81)) ); SetTextInputRegularColors( FONT_WHITE, 2 ); SetTextInputHilitedColors( 2, FONT_WHITE, FONT_WHITE ); SetCursorColor( Get16BPPColor(FROMRGB(255, 255, 255) ) ); usPosX = gChatBox.sX + (CHATBOX_X_MARGIN / 2); //Add Player Name textbox AddTextInputField( usPosX , usPosY , usTextBoxWidth - CHATBOX_X_MARGIN, 20, MSYS_PRIORITY_HIGH+2, gszChatBoxInputString, 255, INPUTTYPE_ASCII );//23 gChatTextBoxRegion.iTop = usPosY; gChatTextBoxRegion.iLeft = usPosX; gChatTextBoxRegion.iBottom = usPosY+20; gChatTextBoxRegion.iRight = usPosX+usTextBoxWidth - CHATBOX_X_MARGIN; // exit text input mode in this screen and clean up text boxes SetActiveField( 0 ); usPosY += CHATBOX_INPUT_HEIGHT + CHATBOX_Y_GAP; // END CREATE TEXT INPUT BOX // CREATE OK AND CANCEL BUTTONS // get the button width UINT16 btnWidth = GetChatBoxButtonWidth( gChatBox.iButtonImages ); // Create OK Button sButtonX = middleBox + ((middleBox - btnWidth)/2); sButtonY = usTextBoxHeight - CHATBOX_BUTTON_HEIGHT - 10; gChatBox.uiOKButton = CreateIconAndTextButton( gChatBox.iButtonImages, pMessageStrings[ MSG_OK ], FONT12ARIAL, CHATBOX_FONT_COLOR, ubFontShadowColor, CHATBOX_FONT_COLOR, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gChatBox.sX + sButtonX ), (INT16)(gChatBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)OKChatBoxCallback ); SetButtonCursor(gChatBox.uiOKButton, usCursor); ForceButtonUnDirty( gChatBox.uiOKButton ); // move the mouse over the ok button if( gGameSettings.fOptions[ TOPTION_DONT_MOVE_MOUSE ] == FALSE ) { SimulateMouseMovement( ( gChatBox.sX + sButtonX + 27 ), ( gChatBox.sY + sButtonY + 10) ); } // Create Cancel Button sButtonX = ((middleBox - btnWidth)/2); sButtonY = usTextBoxHeight - CHATBOX_BUTTON_HEIGHT - 10; gChatBox.uiNOButton = CreateIconAndTextButton( gChatBox.iButtonImages, pMessageStrings[ MSG_CANCEL ], FONT10ARIAL, CHATBOX_FONT_COLOR, ubFontShadowColor, CHATBOX_FONT_COLOR, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gChatBox.sX + sButtonX ), (INT16)(gChatBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)CancelChatBoxCallback ); SetButtonCursor(gChatBox.uiNOButton, usCursor); ForceButtonUnDirty( gChatBox.uiNOButton ); // END CREATE BUTTONS #if 0 gChatBox.fWasPaused = GamePaused(); if (!gChatBox.fWasPaused) { InterruptTime(); PauseGame(); LockPauseState( 1 ); // Pause timers as well.... PauseTime( TRUE ); } #endif // Save mouse restriction region... GetRestrictedClipCursor( &gOldCursorLimitRectangle ); FreeMouseCursor( ); gfNewChatBox = TRUE; gfInChatBox = TRUE; return( iId ); }
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 ); }
INT32 DoMessageBox( UINT8 ubStyle, INT16 *zString, UINT32 uiExitScreen, UINT16 usFlags, MSGBOX_CALLBACK ReturnCallback, SGPRect *pCenteringRect ) { VSURFACE_DESC vs_desc; UINT16 usTextBoxWidth; UINT16 usTextBoxHeight; SGPRect aRect; UINT32 uiDestPitchBYTES, uiSrcPitchBYTES; UINT8 *pDestBuf, *pSrcBuf; INT16 sButtonX, sButtonY, sBlankSpace; UINT8 ubMercBoxBackground = BASIC_MERC_POPUP_BACKGROUND, ubMercBoxBorder = BASIC_MERC_POPUP_BORDER; UINT8 ubFontColor, ubFontShadowColor; UINT16 usCursor; INT32 iId = -1; GetMousePos( &pOldMousePosition ); //this variable can be unset if ur in a non gamescreen and DONT want the msg box to use the save buffer gfDontOverRideSaveBuffer = TRUE; SetCurrentCursorFromDatabase( CURSOR_NORMAL ); if( gMsgBox.BackRegion.uiFlags & MSYS_REGION_EXISTS ) { return( 0 ); } // Based on style.... switch( ubStyle ) { //default case MSG_BOX_BASIC_STYLE: ubMercBoxBackground = DIALOG_MERC_POPUP_BACKGROUND; ubMercBoxBorder = DIALOG_MERC_POPUP_BORDER; // Add button images gMsgBox.iButtonImages = LoadButtonImage( "INTERFACE\\popupbuttons.sti", -1,0,-1,1,-1 ); ubFontColor = FONT_MCOLOR_WHITE; ubFontShadowColor = DEFAULT_SHADOW; usCursor = CURSOR_NORMAL; break; case MSG_BOX_RED_ON_WHITE: ubMercBoxBackground = WHITE_MERC_POPUP_BACKGROUND; ubMercBoxBorder = RED_MERC_POPUP_BORDER; // Add button images gMsgBox.iButtonImages = LoadButtonImage( "INTERFACE\\msgboxRedButtons.sti", -1,0,-1,1,-1 ); ubFontColor = 2; ubFontShadowColor = NO_SHADOW; usCursor = CURSOR_LAPTOP_SCREEN; break; case MSG_BOX_BLUE_ON_GREY: ubMercBoxBackground = GREY_MERC_POPUP_BACKGROUND; ubMercBoxBorder = BLUE_MERC_POPUP_BORDER; // Add button images gMsgBox.iButtonImages = LoadButtonImage( "INTERFACE\\msgboxGreyButtons.sti", -1,0,-1,1,-1 ); ubFontColor = 2; ubFontShadowColor = FONT_MCOLOR_WHITE; usCursor = CURSOR_LAPTOP_SCREEN; break; case MSG_BOX_IMP_STYLE: ubMercBoxBackground = IMP_POPUP_BACKGROUND; ubMercBoxBorder = DIALOG_MERC_POPUP_BORDER; // Add button images gMsgBox.iButtonImages = LoadButtonImage( "INTERFACE\\msgboxGreyButtons.sti", -1,0,-1,1,-1 ); ubFontColor = 2; ubFontShadowColor = FONT_MCOLOR_WHITE; usCursor = CURSOR_LAPTOP_SCREEN; break; case MSG_BOX_BASIC_SMALL_BUTTONS: ubMercBoxBackground = DIALOG_MERC_POPUP_BACKGROUND; ubMercBoxBorder = DIALOG_MERC_POPUP_BORDER; // Add button images gMsgBox.iButtonImages = LoadButtonImage( "INTERFACE\\popupbuttons.sti", -1,2,-1,3,-1 ); ubFontColor = FONT_MCOLOR_WHITE; ubFontShadowColor = DEFAULT_SHADOW; usCursor = CURSOR_NORMAL; break; case MSG_BOX_LAPTOP_DEFAULT: ubMercBoxBackground = LAPTOP_POPUP_BACKGROUND; ubMercBoxBorder = LAPTOP_POP_BORDER; // Add button images gMsgBox.iButtonImages = LoadButtonImage( "INTERFACE\\popupbuttons.sti", -1,0,-1,1,-1 ); ubFontColor = FONT_MCOLOR_WHITE; ubFontShadowColor = DEFAULT_SHADOW; usCursor = CURSOR_LAPTOP_SCREEN; break; default: ubMercBoxBackground = BASIC_MERC_POPUP_BACKGROUND; ubMercBoxBorder = BASIC_MERC_POPUP_BORDER; // Add button images gMsgBox.iButtonImages = LoadButtonImage( "INTERFACE\\msgboxbuttons.sti", -1,0,-1,1,-1 ); ubFontColor = FONT_MCOLOR_WHITE; ubFontShadowColor = DEFAULT_SHADOW; usCursor = CURSOR_NORMAL; break; } if ( usFlags & MSG_BOX_FLAG_USE_CENTERING_RECT && pCenteringRect != NULL ) { aRect.iTop = pCenteringRect->iTop; aRect.iLeft = pCenteringRect->iLeft; aRect.iBottom = pCenteringRect->iBottom; aRect.iRight = pCenteringRect->iRight; } else { // Use default! aRect.iTop = 0; aRect.iLeft = 0; aRect.iBottom = 480; aRect.iRight = 640; } // Set some values! gMsgBox.usFlags = usFlags; gMsgBox.uiExitScreen = uiExitScreen; gMsgBox.ExitCallback = ReturnCallback; gMsgBox.fRenderBox = TRUE; gMsgBox.bHandled = 0; // Init message box gMsgBox.iBoxId = PrepareMercPopupBox( iId, ubMercBoxBackground, ubMercBoxBorder, zString, MSGBOX_DEFAULT_WIDTH, 40, 10, 30, &usTextBoxWidth, &usTextBoxHeight ); if( gMsgBox.iBoxId == -1 ) { #ifdef JA2BETAVERSION AssertMsg( 0, "Failed in DoMessageBox(). Probable reason is because the string was too large to fit in max message box size." ); #endif return 0; } // Save height,width gMsgBox.usWidth = usTextBoxWidth; gMsgBox.usHeight = usTextBoxHeight; // Determine position ( centered in rect ) gMsgBox.sX = (INT16)( ( ( ( aRect.iRight - aRect.iLeft ) - usTextBoxWidth ) / 2 ) + aRect.iLeft ); gMsgBox.sY = (INT16)( ( ( ( aRect.iBottom - aRect.iTop ) - usTextBoxHeight ) / 2 ) + aRect.iTop ); if ( guiCurrentScreen == GAME_SCREEN ) { gfStartedFromGameScreen = TRUE; } if ( (fInMapMode == TRUE ) ) { // fMapExitDueToMessageBox = TRUE; gfStartedFromMapScreen = TRUE; fMapPanelDirty = TRUE; } // Set pending screen SetPendingNewScreen( MSG_BOX_SCREEN); // Init save buffer vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE; vs_desc.usWidth = usTextBoxWidth; vs_desc.usHeight = usTextBoxHeight; vs_desc.ubBitDepth = 16; if( AddVideoSurface( &vs_desc, &gMsgBox.uiSaveBuffer) == FALSE ) { return( - 1 ); } //Save what we have under here... pDestBuf = LockVideoSurface( gMsgBox.uiSaveBuffer, &uiDestPitchBYTES); pSrcBuf = LockVideoSurface( FRAME_BUFFER, &uiSrcPitchBYTES); Blt16BPPTo16BPP((UINT16 *)pDestBuf, uiDestPitchBYTES, (UINT16 *)pSrcBuf, uiSrcPitchBYTES, 0 , 0, gMsgBox.sX , gMsgBox.sY, usTextBoxWidth, usTextBoxHeight ); UnLockVideoSurface( gMsgBox.uiSaveBuffer ); UnLockVideoSurface( FRAME_BUFFER ); // Create top-level mouse region MSYS_DefineRegion( &(gMsgBox.BackRegion), 0, 0, 640, 480, MSYS_PRIORITY_HIGHEST, usCursor, MSYS_NO_CALLBACK, MsgBoxClickCallback ); if( gGameSettings.fOptions[ TOPTION_DONT_MOVE_MOUSE ] == FALSE ) { if( usFlags & MSG_BOX_FLAG_OK ) { SimulateMouseMovement( ( gMsgBox.sX + ( usTextBoxWidth / 2 ) + 27 ), ( gMsgBox.sY + ( usTextBoxHeight - 10 ) ) ); } else { SimulateMouseMovement( gMsgBox.sX + usTextBoxWidth / 2 , gMsgBox.sY + usTextBoxHeight - 4 ); } } // Add region MSYS_AddRegion(&(gMsgBox.BackRegion) ); // findout if cursor locked, if so, store old params and store, restore when done if( IsCursorRestricted() ) { fCursorLockedToArea = TRUE; GetRestrictedClipCursor( &MessageBoxRestrictedCursorRegion ); FreeMouseCursor( ); } // Create four numbered buttons if ( usFlags & MSG_BOX_FLAG_FOUR_NUMBERED_BUTTONS ) { // This is exclusive of any other buttons... no ok, no cancel, no nothing sBlankSpace = usTextBoxWidth - MSGBOX_SMALL_BUTTON_WIDTH * 4 - MSGBOX_SMALL_BUTTON_X_SEP * 3; sButtonX = sBlankSpace / 2; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiButton[0] = CreateIconAndTextButton( gMsgBox.iButtonImages, L"1", FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NumberedMsgBoxCallback ); MSYS_SetBtnUserData( gMsgBox.uiButton[0], 0, 1); SetButtonCursor(gMsgBox.uiButton[0], usCursor); sButtonX += MSGBOX_SMALL_BUTTON_WIDTH + MSGBOX_SMALL_BUTTON_X_SEP; gMsgBox.uiButton[1] = CreateIconAndTextButton( gMsgBox.iButtonImages, L"2", FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NumberedMsgBoxCallback ); MSYS_SetBtnUserData( gMsgBox.uiButton[1], 0, 2); SetButtonCursor(gMsgBox.uiButton[1], usCursor); sButtonX += MSGBOX_SMALL_BUTTON_WIDTH + MSGBOX_SMALL_BUTTON_X_SEP; gMsgBox.uiButton[2] = CreateIconAndTextButton( gMsgBox.iButtonImages, L"3", FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NumberedMsgBoxCallback ); MSYS_SetBtnUserData( gMsgBox.uiButton[2], 0, 3); SetButtonCursor(gMsgBox.uiButton[2], usCursor); sButtonX += MSGBOX_SMALL_BUTTON_WIDTH + MSGBOX_SMALL_BUTTON_X_SEP; gMsgBox.uiButton[3] = CreateIconAndTextButton( gMsgBox.iButtonImages, L"4", FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NumberedMsgBoxCallback ); MSYS_SetBtnUserData( gMsgBox.uiButton[3], 0, 4); SetButtonCursor(gMsgBox.uiButton[3], usCursor); ForceButtonUnDirty( gMsgBox.uiButton[3] ); ForceButtonUnDirty( gMsgBox.uiButton[2] ); ForceButtonUnDirty( gMsgBox.uiButton[1] ); ForceButtonUnDirty( gMsgBox.uiButton[0] ); } else { // Create text button if ( usFlags & MSG_BOX_FLAG_OK ) { // sButtonX = ( usTextBoxWidth - MSGBOX_BUTTON_WIDTH ) / 2; sButtonX = ( usTextBoxWidth - GetMSgBoxButtonWidth( gMsgBox.iButtonImages ) ) / 2; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiOKButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_OK ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)OKMsgBoxCallback ); SetButtonCursor(gMsgBox.uiOKButton, usCursor); ForceButtonUnDirty( gMsgBox.uiOKButton ); } // Create text button if ( usFlags & MSG_BOX_FLAG_CANCEL ) { sButtonX = ( usTextBoxWidth - GetMSgBoxButtonWidth( gMsgBox.iButtonImages ) ) / 2; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiOKButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_CANCEL ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)OKMsgBoxCallback ); SetButtonCursor(gMsgBox.uiOKButton, usCursor); ForceButtonUnDirty( gMsgBox.uiOKButton ); } if ( usFlags & MSG_BOX_FLAG_YESNO ) { sButtonX = ( usTextBoxWidth - ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ) / 2; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiYESButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_YES ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)YESMsgBoxCallback ); SetButtonCursor(gMsgBox.uiYESButton, usCursor); ForceButtonUnDirty( gMsgBox.uiYESButton ); gMsgBox.uiNOButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_NO ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NOMsgBoxCallback ); SetButtonCursor(gMsgBox.uiNOButton, usCursor); ForceButtonUnDirty( gMsgBox.uiNOButton ); } if ( usFlags & MSG_BOX_FLAG_CONTINUESTOP ) { sButtonX = ( usTextBoxWidth - ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ) / 2; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiYESButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pUpdatePanelButtons[ 0 ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)YESMsgBoxCallback ); SetButtonCursor(gMsgBox.uiYESButton, usCursor); ForceButtonUnDirty( gMsgBox.uiYESButton ); gMsgBox.uiNOButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pUpdatePanelButtons[ 1 ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NOMsgBoxCallback ); SetButtonCursor(gMsgBox.uiNOButton, usCursor); ForceButtonUnDirty( gMsgBox.uiNOButton ); } if ( usFlags & MSG_BOX_FLAG_OKCONTRACT ) { sButtonX = ( usTextBoxWidth - ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ) / 2; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiYESButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_OK ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)OKMsgBoxCallback ); SetButtonCursor(gMsgBox.uiYESButton, usCursor); ForceButtonUnDirty( gMsgBox.uiYESButton ); gMsgBox.uiNOButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_REHIRE ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)ContractMsgBoxCallback ); SetButtonCursor(gMsgBox.uiNOButton, usCursor); ForceButtonUnDirty( gMsgBox.uiNOButton ); } if ( usFlags & MSG_BOX_FLAG_YESNOCONTRACT ) { sButtonX = ( usTextBoxWidth - ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ) / 3; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiYESButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_YES ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)YESMsgBoxCallback ); SetButtonCursor(gMsgBox.uiYESButton, usCursor); ForceButtonUnDirty( gMsgBox.uiYESButton ); gMsgBox.uiNOButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_NO ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NOMsgBoxCallback ); SetButtonCursor(gMsgBox.uiNOButton, usCursor); ForceButtonUnDirty( gMsgBox.uiNOButton ); gMsgBox.uiOKButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_REHIRE ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + 2 * ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)ContractMsgBoxCallback ); SetButtonCursor(gMsgBox.uiOKButton, usCursor); ForceButtonUnDirty( gMsgBox.uiOKButton ); } if ( usFlags & MSG_BOX_FLAG_GENERICCONTRACT ) { sButtonX = ( usTextBoxWidth - ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ) / 3; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiYESButton = CreateIconAndTextButton( gMsgBox.iButtonImages, gzUserDefinedButton1, FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)YESMsgBoxCallback ); SetButtonCursor(gMsgBox.uiYESButton, usCursor); ForceButtonUnDirty( gMsgBox.uiYESButton ); gMsgBox.uiNOButton = CreateIconAndTextButton( gMsgBox.iButtonImages, gzUserDefinedButton2, FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NOMsgBoxCallback ); SetButtonCursor(gMsgBox.uiNOButton, usCursor); ForceButtonUnDirty( gMsgBox.uiNOButton ); gMsgBox.uiOKButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_REHIRE ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + 2 * ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)ContractMsgBoxCallback ); SetButtonCursor(gMsgBox.uiOKButton, usCursor); ForceButtonUnDirty( gMsgBox.uiOKButton ); } if ( usFlags & MSG_BOX_FLAG_GENERIC ) { sButtonX = ( usTextBoxWidth - ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ) / 2; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiYESButton = CreateIconAndTextButton( gMsgBox.iButtonImages, gzUserDefinedButton1, FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)YESMsgBoxCallback ); SetButtonCursor(gMsgBox.uiYESButton, usCursor); ForceButtonUnDirty( gMsgBox.uiYESButton ); gMsgBox.uiNOButton = CreateIconAndTextButton( gMsgBox.iButtonImages, gzUserDefinedButton2, FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NOMsgBoxCallback ); SetButtonCursor(gMsgBox.uiNOButton, usCursor); ForceButtonUnDirty( gMsgBox.uiNOButton ); } if ( usFlags & MSG_BOX_FLAG_YESNOLIE ) { sButtonX = ( usTextBoxWidth - ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ) / 3; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiYESButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_YES ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)YESMsgBoxCallback ); SetButtonCursor(gMsgBox.uiYESButton, usCursor); ForceButtonUnDirty( gMsgBox.uiYESButton ); gMsgBox.uiNOButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_NO ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NOMsgBoxCallback ); SetButtonCursor(gMsgBox.uiNOButton, usCursor); ForceButtonUnDirty( gMsgBox.uiNOButton ); gMsgBox.uiOKButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_LIE ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + 2 * ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)LieMsgBoxCallback ); SetButtonCursor(gMsgBox.uiOKButton, usCursor); ForceButtonUnDirty( gMsgBox.uiOKButton ); } if ( usFlags & MSG_BOX_FLAG_OKSKIP ) { sButtonX = ( usTextBoxWidth - ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ) / 2; sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10; gMsgBox.uiYESButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_OK ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)YESMsgBoxCallback ); SetButtonCursor(gMsgBox.uiYESButton, usCursor); ForceButtonUnDirty( gMsgBox.uiYESButton ); gMsgBox.uiNOButton = CreateIconAndTextButton( gMsgBox.iButtonImages, pMessageStrings[ MSG_SKIP ], FONT12ARIAL, ubFontColor, ubFontShadowColor, ubFontColor, ubFontShadowColor, TEXT_CJUSTIFIED, (INT16)(gMsgBox.sX + sButtonX + ( MSGBOX_BUTTON_WIDTH + MSGBOX_BUTTON_X_SEP ) ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NOMsgBoxCallback ); SetButtonCursor(gMsgBox.uiNOButton, usCursor); ForceButtonUnDirty( gMsgBox.uiNOButton ); } } InterruptTime(); PauseGame(); LockPauseState( 1 ); // Pause timers as well.... PauseTime( TRUE ); // Save mouse restriction region... GetRestrictedClipCursor( &gOldCursorLimitRectangle ); FreeMouseCursor( ); gfNewMessageBox = TRUE; gfInMsgBox = TRUE; return( iId ); }
BOOLEAN EnterGIOScreen() { VOBJECT_DESC VObjectDesc; UINT16 cnt; UINT16 usPosY; if( gfGIOButtonsAllocated ) return( TRUE ); SetCurrentCursorFromDatabase( CURSOR_NORMAL ); // load the Main trade screen backgroiund image VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; FilenameForBPP("InterFace\\OptionsScreenBackGround.sti", VObjectDesc.ImageFile); CHECKF(AddVideoObject(&VObjectDesc, &guiGIOMainBackGroundImage )); //Ok button giGIODoneBtnImage = LoadButtonImage("INTERFACE\\PreferencesButtons.sti", -1,0,-1,2,-1 ); guiGIODoneButton = CreateIconAndTextButton( giGIODoneBtnImage, gzGIOScreenText[GIO_OK_TEXT], OPT_BUTTON_FONT, OPT_BUTTON_ON_COLOR, DEFAULT_SHADOW, OPT_BUTTON_OFF_COLOR, DEFAULT_SHADOW, TEXT_CJUSTIFIED, GIO_BTN_OK_X, GIO_BTN_OK_Y, BUTTON_TOGGLE, MSYS_PRIORITY_HIGH, DEFAULT_MOVE_CALLBACK, BtnGIODoneCallback); SpecifyButtonSoundScheme( guiGIODoneButton, BUTTON_SOUND_SCHEME_BIGSWITCH3 ); SpecifyDisabledButtonStyle( guiGIODoneButton, DISABLED_STYLE_NONE ); //Cancel button giGIOCancelBtnImage = UseLoadedButtonImage( giGIODoneBtnImage, -1,1,-1,3,-1 ); guiGIOCancelButton = CreateIconAndTextButton( giGIOCancelBtnImage, gzGIOScreenText[GIO_CANCEL_TEXT], OPT_BUTTON_FONT, OPT_BUTTON_ON_COLOR, DEFAULT_SHADOW, OPT_BUTTON_OFF_COLOR, DEFAULT_SHADOW, TEXT_CJUSTIFIED, GIO_CANCEL_X, GIO_BTN_OK_Y, BUTTON_TOGGLE, MSYS_PRIORITY_HIGH, DEFAULT_MOVE_CALLBACK, BtnGIOCancelCallback ); SpecifyButtonSoundScheme( guiGIOCancelButton, BUTTON_SOUND_SCHEME_BIGSWITCH3 ); // //Check box to toggle Difficulty settings // usPosY = GIO_DIF_SETTINGS_Y - GIO_OFFSET_TO_TOGGLE_BOX_Y; for( cnt=0; cnt<NUM_DIFF_SETTINGS; cnt++) { guiDifficultySettingsToggles[ cnt ] = CreateCheckBoxButton( GIO_DIF_SETTINGS_X+GIO_OFFSET_TO_TOGGLE_BOX, usPosY, "INTERFACE\\OptionsCheck.sti", MSYS_PRIORITY_HIGH+10, BtnDifficultyTogglesCallback ); MSYS_SetBtnUserData( guiDifficultySettingsToggles[ cnt ], 0, cnt ); usPosY += GIO_GAP_BN_SETTINGS; } if( gGameOptions.ubDifficultyLevel == DIF_LEVEL_EASY ) ButtonList[ guiDifficultySettingsToggles[ GIO_DIFF_EASY ] ]->uiFlags |= BUTTON_CLICKED_ON; else if( gGameOptions.ubDifficultyLevel == DIF_LEVEL_MEDIUM ) ButtonList[ guiDifficultySettingsToggles[ GIO_DIFF_MED ] ]->uiFlags |= BUTTON_CLICKED_ON; else if( gGameOptions.ubDifficultyLevel == DIF_LEVEL_HARD ) ButtonList[ guiDifficultySettingsToggles[ GIO_DIFF_HARD ] ]->uiFlags |= BUTTON_CLICKED_ON; else ButtonList[ guiDifficultySettingsToggles[ GIO_DIFF_MED ] ]->uiFlags |= BUTTON_CLICKED_ON; // //Check box to toggle Game settings ( realistic, sci fi ) // usPosY = GIO_GAME_SETTINGS_Y - GIO_OFFSET_TO_TOGGLE_BOX_Y; for( cnt=0; cnt<NUM_GAME_STYLES; cnt++) { guiGameStyleToggles[ cnt ] = CreateCheckBoxButton( GIO_GAME_SETTINGS_X+GIO_OFFSET_TO_TOGGLE_BOX, usPosY, "INTERFACE\\OptionsCheck.sti", MSYS_PRIORITY_HIGH+10, BtnGameStyleTogglesCallback ); MSYS_SetBtnUserData( guiGameStyleToggles[ cnt ], 0, cnt ); usPosY += GIO_GAP_BN_SETTINGS; } if( gGameOptions.fSciFi ) ButtonList[ guiGameStyleToggles[ GIO_SCI_FI ] ]->uiFlags |= BUTTON_CLICKED_ON; else ButtonList[ guiGameStyleToggles[ GIO_REALISTIC ] ]->uiFlags |= BUTTON_CLICKED_ON; // JA2Gold: iron man buttons usPosY = GIO_IRON_MAN_SETTING_Y - GIO_OFFSET_TO_TOGGLE_BOX_Y; for( cnt=0; cnt<NUM_SAVE_OPTIONS; cnt++) { guiGameSaveToggles[ cnt ] = CreateCheckBoxButton( GIO_IRON_MAN_SETTING_X+GIO_OFFSET_TO_TOGGLE_BOX, usPosY, "INTERFACE\\OptionsCheck.sti", MSYS_PRIORITY_HIGH+10, BtnGameSaveTogglesCallback ); MSYS_SetBtnUserData( guiGameSaveToggles[ cnt ], 0, cnt ); usPosY += GIO_GAP_BN_SETTINGS; } if( gGameOptions.fIronManMode ) ButtonList[ guiGameSaveToggles[ GIO_IRON_MAN ] ]->uiFlags |= BUTTON_CLICKED_ON; else ButtonList[ guiGameSaveToggles[ GIO_CAN_SAVE ] ]->uiFlags |= BUTTON_CLICKED_ON; // // Check box to toggle Gun options // usPosY = GIO_GUN_SETTINGS_Y - GIO_OFFSET_TO_TOGGLE_BOX_Y; for( cnt=0; cnt<NUM_GUN_OPTIONS; cnt++) { guiGunOptionToggles[ cnt ] = CreateCheckBoxButton( GIO_GUN_SETTINGS_X+GIO_OFFSET_TO_TOGGLE_BOX, usPosY, "INTERFACE\\OptionsCheck.sti", MSYS_PRIORITY_HIGH+10, BtnGunOptionsTogglesCallback); MSYS_SetBtnUserData( guiGunOptionToggles[ cnt ], 0, cnt ); usPosY += GIO_GAP_BN_SETTINGS; } //if its the demo, make sure the defuat is for additional guns #ifdef JA2DEMO gGameOptions.fGunNut = TRUE; #endif if( gGameOptions.fGunNut ) ButtonList[ guiGunOptionToggles[ GIO_GUN_NUT ] ]->uiFlags |= BUTTON_CLICKED_ON; else ButtonList[ guiGunOptionToggles[ GIO_REDUCED_GUNS ] ]->uiFlags |= BUTTON_CLICKED_ON; //if its the demo, make sure to disable the buttons #ifdef JA2DEMO SpecifyDisabledButtonStyle( guiGunOptionToggles[ GIO_GUN_NUT ], DISABLED_STYLE_SHADED ); SpecifyDisabledButtonStyle( guiGunOptionToggles[ GIO_REDUCED_GUNS ], DISABLED_STYLE_SHADED ); DisableButton( guiGunOptionToggles[ GIO_GUN_NUT ] ); DisableButton( guiGunOptionToggles[ GIO_REDUCED_GUNS ] ); #endif // JA2 Gold: no more timed turns // // Check box to toggle the timed turn option // /* usPosY = GIO_TIMED_TURN_SETTING_Y - GIO_OFFSET_TO_TOGGLE_BOX_Y; for( cnt=0; cnt<GIO_NUM_TIMED_TURN_OPTIONS; cnt++) { guiTimedTurnToggles[ cnt ] = CreateCheckBoxButton( GIO_TIMED_TURN_SETTING_X+GIO_OFFSET_TO_TOGGLE_BOX, usPosY, "INTERFACE\\OptionsCheck.sti", MSYS_PRIORITY_HIGH+10, BtnTimedTurnsTogglesCallback ); MSYS_SetBtnUserData( guiTimedTurnToggles[ cnt ], 0, cnt ); usPosY += GIO_GAP_BN_SETTINGS; } if( gGameOptions.fTurnTimeLimit ) ButtonList[ guiTimedTurnToggles[ GIO_TIMED_TURNS ] ]->uiFlags |= BUTTON_CLICKED_ON; else ButtonList[ guiTimedTurnToggles[ GIO_NO_TIMED_TURNS ] ]->uiFlags |= BUTTON_CLICKED_ON; */ //Reset the exit screen gubGIOExitScreen = GAME_INIT_OPTIONS_SCREEN; //REnder the screen once so we can blt ot to ths save buffer RenderGIOScreen(); BlitBufferToBuffer(guiRENDERBUFFER, guiSAVEBUFFER, 0, 0, 639, 439 ); gfGIOButtonsAllocated = TRUE; return( TRUE ); }
void DoneFadeInForExitGameInitOptionScreen( void ) { SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); }