| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- /*
- ** Command & Conquer Generals Zero Hour(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // (c) 2001-2003 Electronic Arts Inc. //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- //----------------------------------------------------------------------------
- //
- // Westwood Studios Pacific.
- //
- // Confidential Information
- // Copyright (C) 2001 - All Rights Reserved
- //
- //----------------------------------------------------------------------------
- //
- // Project: Generals
- //
- // Module: Debug
- //
- // File name: DebugDisplay.cpp
- //
- // Created: 11/13/01 TR
- //
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Includes
- //----------------------------------------------------------------------------
- #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
- #include "GameClient/DebugDisplay.h"
- //----------------------------------------------------------------------------
- // Externals
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Defines
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Private Types
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Private Data
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Public Data
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Private Prototypes
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Private Functions
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Public Functions
- //----------------------------------------------------------------------------
- //============================================================================
- // DebugDisplay::DebugDisplay
- //============================================================================
- DebugDisplay::DebugDisplay()
- : m_width(0),
- m_height(0)
- {
- reset();
- }
- //============================================================================
- // DebugDisplay::reset
- //============================================================================
- void DebugDisplay::reset( void )
- {
- setCursorPos( 0, 0 );
- setTextColor( WHITE );
- setRightMargin( 0 );
- setLeftMargin( getWidth() );
- }
- //============================================================================
- // DebugDisplay::setCursorPos
- //============================================================================
- void DebugDisplay::setCursorPos( Int x, Int y )
- {
- m_xPos = x;
- m_yPos = y;
- }
- //============================================================================
- // DebugDisplay::getCursorXPos
- //============================================================================
- Int DebugDisplay::getCursorXPos( void )
- {
- return m_xPos;
- }
- //============================================================================
- // DebugDisplay::getCursorYPos
- //============================================================================
- Int DebugDisplay::getCursorYPos( void )
- {
- return m_yPos;
- }
- //============================================================================
- // DebugDisplay::getWidth
- //============================================================================
- Int DebugDisplay::getWidth( void )
- {
- return m_width;
- }
- //============================================================================
- // DebugDisplay::getHeight
- //============================================================================
- Int DebugDisplay::getHeight( void )
- {
- return m_height;
- }
- //============================================================================
- // DebugDisplay::setTextColor
- //============================================================================
- void DebugDisplay::setTextColor( Color color )
- {
- m_textColor = color;
- }
- //============================================================================
- // DebugDisplay::setRightMargin
- //============================================================================
- void DebugDisplay::setRightMargin( Int rightPos )
- {
- m_rightMargin = rightPos;
- }
- //============================================================================
- // DebugDisplay::setLeftMargin
- //============================================================================
- void DebugDisplay::setLeftMargin( Int leftPos )
- {
- m_leftMargin = leftPos;
- }
- //============================================================================
- // DebugDisplay::printf
- //============================================================================
- void DebugDisplay::printf( Char *format, ...)
- {
- va_list args;
- int result;
- static char text[5*1024];
- va_start( args, format );
- result = vsprintf( text, format, args );
- va_end( args );
- if ( result < 0 )
- {
- // error while printing string
- return;
- }
- DEBUG_ASSERTCRASH( result < sizeof(text), ("text overflow in DebugDisplay::printf() - string too long"));
- // find every line and print it
- Char *ptr = text;;
- Char *lineStart = ptr;
- Int lineLen = 0;
- Char ch;
- while ( (ch = *ptr++) != 0 )
- {
- switch ( ch )
- {
- case '\n':
- {
- if ( lineLen > 0 )
- {
- *(ptr -1) = 0; // replace '/n' with null
- drawText( m_rightMargin + m_xPos, m_yPos, lineStart );
- lineLen = 0;
- }
- lineStart = ptr;
- m_yPos++;
- m_xPos = 0;
- break;
- }
- default:
- {
- lineLen++;
- break;
- }
- }
- }
- if ( lineLen > 0 )
- {
- drawText( m_rightMargin + m_xPos, m_yPos, lineStart );
- m_xPos += lineLen;
- }
- }
|