UINT32 MPChatScreenHandle( ) { InputAtom InputEvent; if ( gfNewChatBox ) { // If in game screen.... if ( ( gfStartedFromGameScreen )||( gfStartedFromMapScreen ) ) { //UINT32 uiDestPitchBYTES, uiSrcPitchBYTES; //UINT8 *pDestBuf, *pSrcBuf; if( gfStartedFromGameScreen ) { HandleTacticalUILoseCursorFromOtherScreen( ); } else { HandleMAPUILoseCursorFromOtherScreen( ); } gfStartedFromGameScreen = FALSE; gfStartedFromMapScreen = FALSE; } gfNewChatBox = FALSE; return( MP_CHAT_SCREEN ); } UnmarkButtonsDirty( ); // Render the box! if ( gChatBox.fRenderBox ) { // Render the Background ( this includes the text string) RenderMercPopUpBoxFromIndex( gChatBox.iBoxId, gChatBox.sX, gChatBox.sY, FRAME_BUFFER ); UINT16 usWidth = StringPixLength( gzMPChatboxText[0], CHATBOX_FONT_TITLE ); int usPosY = 0; int usPosX = 0; usPosY = gChatBox.sY + 10; usPosX = gChatBox.sX + ((gChatBox.usWidth - usWidth) / 2); DrawTextToScreen( gzMPChatboxText[0], usPosX, usPosY, usWidth, CHATBOX_FONT_TITLE, CHATBOX_FONT_COLOR, DEFAULT_SHADOW, FALSE, CENTER_JUSTIFIED | TEXT_SHADOWED ); // Render the toggle button strings for(UINT8 cnt=0; cnt<NUM_CHAT_TOGGLES; cnt++) { GUI_BUTTON* btn = ButtonList[ guiChatToggles[ cnt ] ]; usPosX = btn->XLoc + 12 + 10; usPosY = btn->YLoc; usWidth = StringPixLength( gzMPChatToggleText[ cnt ], CHATBOX_FONT_TOGGLE ); DrawTextToScreen( gzMPChatToggleText[ cnt ], usPosX, usPosY, usWidth, CHATBOX_FONT_TOGGLE, CHATBOX_FONT_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED ); } if (gIncludeChatLog) { // draw chatbox HVOBJECT hHandle; // get and blt panel GetVideoObject(&hHandle, guiCHATLOGIMG ); BltVideoObject( FRAME_BUFFER , hHandle, 0, gChatMessageLogRegion.iLeft, gChatMessageLogRegion.iTop, VO_BLT_SRCTRANSPARENCY,NULL ); BltVideoObject( FRAME_BUFFER , hHandle, 1, gChatMessageLogRegion.iRight+CHATBOX_SLIDER_GAP, gChatMessageLogRegion.iTop, VO_BLT_SRCTRANSPARENCY,NULL ); // draw slider DisplayChatLogScrollBarSlider( ); // draw chat log text DisplayStringsInChatLogMessageList(); } } MarkButtonsDirty(); EnableDisableChatLogScrollButtonsAndRegions(); // Render buttons RenderButtons( ); // render text boxes //SaveFontSettings(); SetFontDestBuffer( FRAME_BUFFER, gChatTextBoxRegion.iLeft , gChatTextBoxRegion.iTop , gChatTextBoxRegion.iRight , gChatTextBoxRegion.iBottom, FALSE ); RenderAllTextFields(); // textbox system call SetFontDestBuffer( FRAME_BUFFER, 0 , 0 , SCREEN_WIDTH , SCREEN_HEIGHT , FALSE ); //RestoreFontSettings(); EndFrameBufferRender( ); // carter, need key shortcuts for clearing up message boxes // Check for esc bool bHandled; while (DequeueEvent(&InputEvent) == TRUE) { bHandled = false; if(InputEvent.usEvent == KEY_DOWN ) { if( ( InputEvent.usParam == ESC ) ) { // Exit messagebox gChatBox.bHandled = MSG_BOX_RETURN_NO; memset(gszChatBoxInputString,0,sizeof(CHAR16)*255); bHandled = true; } if( InputEvent.usParam == ENTER ) { // retrieve the string from the text box Get16BitStringFromField( 0, gszChatBoxInputString, 255 ); // these indexes are based on the order created // Exit messagebox gChatBox.bHandled = MSG_BOX_RETURN_OK; bHandled = true; } // OJW - 20090403 - add better key control UINT8 ubDesiredMessageIndex; UINT8 ubNumMessages; ubNumMessages = GetRangeOfChatLogMessages(); if ( ubNumMessages > MAX_CHATLOG_MESSAGES ) { if (InputEvent.usParam == PGUP) { //move up a page ChatScreenMsgScrollUp( MAX_CHATLOG_MESSAGES ); bHandled = true; } if (InputEvent.usParam == PGDN) { // move down a page ChatScreenMsgScrollDown( MAX_CHATLOG_MESSAGES ); bHandled = true; } if (InputEvent.usParam == HOME) { // move to the beginning ChangeCurrentChatScreenMessageIndex( 0 ); bHandled = true; } if (InputEvent.usParam == END) { // move to end ubDesiredMessageIndex = ubNumMessages - MAX_CHATLOG_MESSAGES; ChangeCurrentChatScreenMessageIndex( ubDesiredMessageIndex ); bHandled = true; } } } // send to text box if (!bHandled) HandleTextInput( &InputEvent ); } if ( gChatBox.bHandled ) { SetRenderFlags( RENDER_FLAG_FULL ); return( ExitChatBox( gChatBox.bHandled ) ); } return( MP_CHAT_SCREEN ); }
UINT32 MessageBoxScreenHandle( ) { InputAtom InputEvent; if ( gfNewMessageBox ) { // If in game screen.... if ( ( gfStartedFromGameScreen )||( gfStartedFromMapScreen ) ) { //UINT32 uiDestPitchBYTES, uiSrcPitchBYTES; //UINT8 *pDestBuf, *pSrcBuf; if( gfStartedFromGameScreen ) { HandleTacticalUILoseCursorFromOtherScreen( ); } else { HandleMAPUILoseCursorFromOtherScreen( ); } gfStartedFromGameScreen = FALSE; gfStartedFromMapScreen = FALSE; /* // 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, gMsgBox.usWidth, gMsgBox.usHeight ); UnLockVideoSurface( gMsgBox.uiSaveBuffer ); UnLockVideoSurface( FRAME_BUFFER ); */ } gfNewMessageBox = FALSE; return( MSG_BOX_SCREEN ); } UnmarkButtonsDirty( ); // Render the box! if ( gMsgBox.fRenderBox ) { if ( gMsgBox.usFlags & MSG_BOX_FLAG_FOUR_NUMBERED_BUTTONS ) { MarkAButtonDirty( gMsgBox.uiButton[0] ); MarkAButtonDirty( gMsgBox.uiButton[1] ); MarkAButtonDirty( gMsgBox.uiButton[2] ); MarkAButtonDirty( gMsgBox.uiButton[3] ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_OK ) { MarkAButtonDirty( gMsgBox.uiOKButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_CANCEL ) { MarkAButtonDirty( gMsgBox.uiOKButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_YESNO ) { MarkAButtonDirty( gMsgBox.uiYESButton ); MarkAButtonDirty( gMsgBox.uiNOButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_OKCONTRACT ) { MarkAButtonDirty( gMsgBox.uiYESButton ); MarkAButtonDirty( gMsgBox.uiNOButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_YESNOCONTRACT ) { MarkAButtonDirty( gMsgBox.uiYESButton ); MarkAButtonDirty( gMsgBox.uiNOButton ); MarkAButtonDirty( gMsgBox.uiOKButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_GENERICCONTRACT ) { MarkAButtonDirty( gMsgBox.uiYESButton ); MarkAButtonDirty( gMsgBox.uiNOButton ); MarkAButtonDirty( gMsgBox.uiOKButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_GENERIC ) { MarkAButtonDirty( gMsgBox.uiYESButton ); MarkAButtonDirty( gMsgBox.uiNOButton ); } if( gMsgBox.usFlags & MSG_BOX_FLAG_CONTINUESTOP ) { // Exit messagebox MarkAButtonDirty( gMsgBox.uiYESButton ); MarkAButtonDirty( gMsgBox.uiNOButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_YESNOLIE ) { MarkAButtonDirty( gMsgBox.uiYESButton ); MarkAButtonDirty( gMsgBox.uiNOButton ); MarkAButtonDirty( gMsgBox.uiOKButton ); } if ( gMsgBox.usFlags & MSG_BOX_FLAG_OKSKIP ) { MarkAButtonDirty( gMsgBox.uiYESButton ); MarkAButtonDirty( gMsgBox.uiNOButton ); } RenderMercPopUpBoxFromIndex( gMsgBox.iBoxId, gMsgBox.sX, gMsgBox.sY, FRAME_BUFFER ); //gMsgBox.fRenderBox = FALSE; // ATE: Render each frame... } // Render buttons RenderButtons( ); EndFrameBufferRender( ); // carter, need key shortcuts for clearing up message boxes // Check for esc while (DequeueEvent(&InputEvent) == TRUE) { if( InputEvent.usEvent == KEY_UP ) { if( ( InputEvent.usParam == ESC ) || ( InputEvent.usParam == 'n') ) { if ( gMsgBox.usFlags & MSG_BOX_FLAG_YESNO ) { // Exit messagebox gMsgBox.bHandled = MSG_BOX_RETURN_NO; } } if( InputEvent.usParam == ENTER ) { if ( gMsgBox.usFlags & MSG_BOX_FLAG_YESNO ) { // Exit messagebox gMsgBox.bHandled = MSG_BOX_RETURN_YES; } else if( gMsgBox.usFlags & MSG_BOX_FLAG_OK ) { // Exit messagebox gMsgBox.bHandled = MSG_BOX_RETURN_OK; } else if( gMsgBox.usFlags & MSG_BOX_FLAG_CONTINUESTOP ) { // Exit messagebox gMsgBox.bHandled = MSG_BOX_RETURN_OK; } } if( InputEvent.usParam == 'o' ) { if( gMsgBox.usFlags & MSG_BOX_FLAG_OK ) { // Exit messagebox gMsgBox.bHandled = MSG_BOX_RETURN_OK; } } if( InputEvent.usParam == 'y' ) { if( gMsgBox.usFlags & MSG_BOX_FLAG_YESNO ) { // Exit messagebox gMsgBox.bHandled = MSG_BOX_RETURN_YES; } } if( InputEvent.usParam == '1' ) { if ( gMsgBox.usFlags & MSG_BOX_FLAG_FOUR_NUMBERED_BUTTONS ) { // Exit messagebox gMsgBox.bHandled = 1; } } if( InputEvent.usParam == '2' ) { if ( gMsgBox.usFlags & MSG_BOX_FLAG_FOUR_NUMBERED_BUTTONS ) { // Exit messagebox gMsgBox.bHandled = 1; } } if( InputEvent.usParam == '3' ) { if ( gMsgBox.usFlags & MSG_BOX_FLAG_FOUR_NUMBERED_BUTTONS ) { // Exit messagebox gMsgBox.bHandled = 1; } } if( InputEvent.usParam == '4' ) { if ( gMsgBox.usFlags & MSG_BOX_FLAG_FOUR_NUMBERED_BUTTONS ) { // Exit messagebox gMsgBox.bHandled = 1; } } } } if ( gMsgBox.bHandled ) { SetRenderFlags( RENDER_FLAG_FULL ); return( ExitMsgBox( gMsgBox.bHandled ) ); } return( MSG_BOX_SCREEN ); }