From 668aa9a9acfd6334ae368724e41c7b880ef0326c Mon Sep 17 00:00:00 2001 From: TwinAphex51224 Date: Thu, 16 Feb 2012 15:27:51 +0100 Subject: [PATCH] (360) removed some unused code in console/debug fonts --- 360/xdk360_video_console.cpp | 6 +- 360/xdk360_video_console.h | 8 +-- 360/xdk360_video_debugfonts.cpp | 104 ++++++++------------------------ 360/xdk360_video_debugfonts.h | 6 +- 4 files changed, 34 insertions(+), 90 deletions(-) diff --git a/360/xdk360_video_console.cpp b/360/xdk360_video_console.cpp index ee075f0877..2516906f3a 100644 --- a/360/xdk360_video_console.cpp +++ b/360/xdk360_video_console.cpp @@ -37,7 +37,7 @@ Console::~Console() } HRESULT Console::Create( LPCSTR strFontFileName, unsigned long colBackColor, - unsigned long colTextColor, unsigned int nLines ) + unsigned long colTextColor) { xdk360_video_t *vid = (xdk360_video_t*)g_d3d; D3DDevice *m_pd3dDevice = vid->xdk360_render_device; @@ -71,7 +71,7 @@ HRESULT Console::Create( LPCSTR strFontFileName, unsigned long colBackColor, m_cScreenHeight = (unsigned int)( m_cySafeArea / fCharHeight ); m_cScreenWidth = (unsigned int)( m_cxSafeArea / fCharWidth ); - m_cScreenHeightVirtual = max( m_cScreenHeight, nLines ); + m_cScreenHeightVirtual = m_cScreenHeight; m_fLineHeight = fCharHeight; @@ -119,7 +119,7 @@ void Console::Destroy() // Name: Render() // Desc: Render the console to the screen //-------------------------------------------------------------------------------------- -void Console::Render() +void Console::Render (void) { xdk360_video_t *vid = (xdk360_video_t*)g_d3d; D3DDevice *m_pd3dDevice = vid->xdk360_render_device; diff --git a/360/xdk360_video_console.h b/360/xdk360_video_console.h index a436b23677..54f00532c5 100644 --- a/360/xdk360_video_console.h +++ b/360/xdk360_video_console.h @@ -43,11 +43,7 @@ public: ~Console(); // Initialization - HRESULT Create( LPCSTR strFontFileName, - D3DCOLOR colBackColor, - D3DCOLOR colTextColor, - unsigned int nLines = 0 ); - + HRESULT Create( LPCSTR strFontFileName, D3DCOLOR colBackColor, D3DCOLOR colTextColor); void Destroy(); // Console output @@ -77,7 +73,7 @@ private: unsigned int m_cScreenHeight; // height in lines of screen area unsigned int m_cScreenHeightVirtual; // height in lines of text storage buffer unsigned int m_cScreenWidth; // width in characters - float m_fLineHeight; // height of a single line in pixels + float m_fLineHeight; // height of a single line in pixels wchar_t * m_Buffer; // buffer big enough to hold a full screen wchar_t ** m_Lines; // pointers to individual lines diff --git a/360/xdk360_video_debugfonts.cpp b/360/xdk360_video_debugfonts.cpp index e9e02e1f0d..e924f3da3c 100644 --- a/360/xdk360_video_debugfonts.cpp +++ b/360/xdk360_video_debugfonts.cpp @@ -600,9 +600,9 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor, // Set the starting screen position if( ( fOriginX < 0.0f ) || ( ( dwFlags & FONT_RIGHT ) && ( fOriginX <= 0.0f ) ) ) - fOriginX += ( m_rcWindow.x2 - m_rcWindow.x1 ); + fOriginX += m_rcWindow.x2; if( fOriginY < 0.0f ) - fOriginY += ( m_rcWindow.y2 - m_rcWindow.y1 ); + fOriginY += m_rcWindow.y2; m_fCursorX = floorf( fOriginX ); m_fCursorY = floorf( fOriginY ); @@ -610,25 +610,6 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor, // Adjust for padding fOriginY -= m_fFontTopPadding; - float fEllipsesPixelWidth = m_fXScaleFactor * 3.0f * ( m_Glyphs[m_TranslatorTable[L'.']].wOffset + - m_Glyphs[m_TranslatorTable[L'.']].wAdvance ); - - if( dwFlags & FONT_TRUNCATED ) - { - // Check if we will really need to truncate the string - if( fMaxPixelWidth <= 0.0f ) - dwFlags &= ( ~FONT_TRUNCATED ); - else - { - float w, h; - GetTextExtent( strText, &w, &h, TRUE ); - - // If not, then clear the flag - if( w <= fMaxPixelWidth ) - dwFlags &= ( ~FONT_TRUNCATED ); - } - } - // If vertically centered, offset the starting m_fCursorY value if( dwFlags & FONT_CENTER_Y ) { @@ -638,8 +619,8 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor, } // Add window offsets - float Winx = static_cast(m_rcWindow.x1); - float Winy = static_cast(m_rcWindow.y1); + float Winx = 0.0f; + float Winy = 0.0f; fOriginX += Winx; fOriginY += Winy; m_fCursorX += Winx; @@ -648,8 +629,6 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor, // Set a flag so we can determine initial justification effects BOOL bStartingNewLine = TRUE; - unsigned long dwNumEllipsesToDraw = 0; - // Begin drawing the vertices // Declared as volatile to force writing in ascending @@ -673,44 +652,34 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor, { wchar_t letter; - if( dwNumEllipsesToDraw ) - letter = L'.'; - else + // If starting text on a new line, determine justification effects + if( bStartingNewLine ) { - // If starting text on a new line, determine justification effects - if( bStartingNewLine ) + if( dwFlags & ( FONT_RIGHT | FONT_CENTER_X ) ) { - if( dwFlags & ( FONT_RIGHT | FONT_CENTER_X ) ) - { - // Get the extent of this line - float w, h; - GetTextExtent( strText, &w, &h, TRUE ); + // Get the extent of this line + float w, h; + GetTextExtent( strText, &w, &h, TRUE ); - // Offset this line's starting m_fCursorX value - if( dwFlags & FONT_RIGHT ) - m_fCursorX = floorf( fOriginX - w ); - if( dwFlags & FONT_CENTER_X ) - m_fCursorX = floorf( fOriginX - w * 0.5f ); - } - bStartingNewLine = FALSE; + // Offset this line's starting m_fCursorX value + if( dwFlags & FONT_RIGHT ) + m_fCursorX = floorf( fOriginX - w ); + if( dwFlags & FONT_CENTER_X ) + m_fCursorX = floorf( fOriginX - w * 0.5f ); } + bStartingNewLine = FALSE; + } - // Get the current letter in the string - letter = *strText++; + // Get the current letter in the string + letter = *strText++; - // Handle the newline character - if( letter == L'\n' ) - { - m_fCursorX = fOriginX; - m_fCursorY += m_fFontYAdvance * m_fYScaleFactor; - bStartingNewLine = TRUE; - continue; - } - - // Handle carriage return characters by ignoring them. This helps when - // displaying text from a file. - if( letter == L'\r' ) - continue; + // Handle the newline character + if( letter == L'\n' ) + { + m_fCursorX = fOriginX; + m_fCursorY += m_fFontYAdvance * m_fYScaleFactor; + bStartingNewLine = TRUE; + continue; } // Translate unprintable characters @@ -721,20 +690,6 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor, float fWidth = m_fXScaleFactor * (float)pGlyph->wWidth; float fHeight = m_fYScaleFactor * m_fFontHeight; - if( 0 == dwNumEllipsesToDraw ) - { - if( dwFlags & FONT_TRUNCATED ) - { - // Check if we will be exceeded the max allowed width - if( m_fCursorX + fOffset + fWidth + fEllipsesPixelWidth > fOriginX + fMaxPixelWidth ) - { - // Yup, draw the three ellipses dots instead - dwNumEllipsesToDraw = 3; - continue; - } - } - } - // Setup the screen coordinates m_fCursorX += fOffset; float X4 = m_fCursorX; @@ -795,13 +750,6 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor, reinterpret_cast(pVertex)[15] = dwChannelSelector; pVertex+=16; - // If drawing ellipses, exit when they're all drawn - if( dwNumEllipsesToDraw ) - { - if( --dwNumEllipsesToDraw == 0 ) - break; - } - dwNumChars--; } diff --git a/360/xdk360_video_debugfonts.h b/360/xdk360_video_debugfonts.h index df0370e9e5..32e5b024f6 100644 --- a/360/xdk360_video_debugfonts.h +++ b/360/xdk360_video_debugfonts.h @@ -72,17 +72,17 @@ public: float m_fXScaleFactor; // Scaling constants float m_fYScaleFactor; - D3DRECT m_rcWindow; // Bounds rect if the text window, modify via accessors only! + D3DRECT m_rcWindow; // Bounds rect of the text window, modify via accessors only! float m_fCursorX; // Current text cursor float m_fCursorY; // Translator table for supporting unicode ranges unsigned long m_cMaxGlyph; // Number of entries in the translator table - wchar_t * m_TranslatorTable; // ASCII to glyph lookup table + wchar_t * m_TranslatorTable; // ASCII to glyph lookup table // Glyph data for the font unsigned long m_dwNumGlyphs; // Number of valid glyphs - const GLYPH_ATTR* m_Glyphs; // Array of glyphs + const GLYPH_ATTR* m_Glyphs; // Array of glyphs // D3D rendering objects D3DTexture* m_pFontTexture;