CInterfaceManager and CViewText will no longer depend on the TextContext global variable.

--HG--
branch : gui-refactoring
hg/feature/sse2
dfighter1985 13 years ago
parent 8c5b47f979
commit 598ab0b6dc

@ -1075,7 +1075,7 @@ void prelogInit()
// resetTextContext ("bremenb.ttf", false); // resetTextContext ("bremenb.ttf", false);
resetTextContext ("ryzom.ttf", false); resetTextContext ("ryzom.ttf", false);
CInterfaceManager::getInstance(); CInterfaceManager::getInstance()->setTextContext( TextContext );
ProgressBar.setFontFactor(0.85f); ProgressBar.setFontFactor(0.85f);

@ -342,6 +342,7 @@ _ViewRenderer( Driver, TextContext )
_DebugTrackGroupCreateCount = 0; _DebugTrackGroupCreateCount = 0;
_DebugTrackGroupDestroyCount = 0; _DebugTrackGroupDestroyCount = 0;
#endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS #endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS
textcontext = NULL;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -1354,7 +1355,7 @@ void CInterfaceManager::updateFrameViews(NL3D::UCamera camera)
drawViews(camera); drawViews(camera);
// The interface manager may change usual Global setup. reset them. // The interface manager may change usual Global setup. reset them.
TextContext->setShadeColor(CRGBA::Black); textcontext->setShadeColor(CRGBA::Black);
} }
@ -6603,5 +6604,6 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr)
void CInterfaceManager::setTextContext( NL3D::UTextContext *textcontext ) void CInterfaceManager::setTextContext( NL3D::UTextContext *textcontext )
{ {
this->textcontext = textcontext;
_ViewRenderer.setTextContext( textcontext ); _ViewRenderer.setTextContext( textcontext );
} }

@ -48,9 +48,6 @@
static const float ROLLOVER_MIN_DELTA_PER_MS = 0.28f; static const float ROLLOVER_MIN_DELTA_PER_MS = 0.28f;
static const float ROLLOVER_MAX_DELTA_PER_MS = 0.12f; static const float ROLLOVER_MAX_DELTA_PER_MS = 0.12f;
//the NEL 3d textcontext
extern NL3D::UTextContext *TextContext;
//the network database node //the network database node
extern CCDBSynchronised IngameDbMngr; extern CCDBSynchronised IngameDbMngr;
@ -723,8 +720,12 @@ public:
/// Sets the current TextContext. /// Sets the current TextContext.
void setTextContext( NL3D::UTextContext *textcontext ); void setTextContext( NL3D::UTextContext *textcontext );
/// Retrueves the current TextContext
inline NL3D::UTextContext* getTextContext() const{ return textcontext; };
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
private: private:
NL3D::UTextContext *textcontext;
// Observer for copying db branch changes // Observer for copying db branch changes
class CServerToLocalAutoCopy class CServerToLocalAutoCopy

@ -125,7 +125,7 @@ CViewText:: CViewText (const std::string& id, const std::string Text, sint FontS
CViewText::~CViewText() CViewText::~CViewText()
{ {
if (_Index != 0xFFFFFFFF) if (_Index != 0xFFFFFFFF)
TextContext->erase (_Index); CInterfaceManager::getInstance()->getTextContext()->erase (_Index);
clearLines(); clearLines();
if (!_Setuped) if (!_Setuped)
@ -139,7 +139,7 @@ CViewText::~CViewText()
CViewText &CViewText::operator=(const CViewText &vt) CViewText &CViewText::operator=(const CViewText &vt)
{ {
if (_Index != 0xFFFFFFFF) if (_Index != 0xFFFFFFFF)
TextContext->erase (_Index); CInterfaceManager::getInstance()->getTextContext()->erase (_Index);
// Create database entries // Create database entries
_Active = vt._Active; _Active = vt._Active;
@ -436,6 +436,8 @@ void CViewText::draw ()
return; return;
rVR.getScreenOOSize (oow, ooh); rVR.getScreenOOSize (oow, ooh);
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
// *** get current color // *** get current color
CRGBA col, shcol; CRGBA col, shcol;
@ -459,6 +461,7 @@ void CViewText::draw ()
{ {
if (_Lines.size() == 0) return; if (_Lines.size() == 0) return;
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
@ -865,6 +868,8 @@ void CViewText::updateTextContextMultiLine(uint nMaxWidth)
rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_FontWidth); rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_FontWidth);
} }
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
// Parse the letter // Parse the letter
{ {
ucLetter = _Text[i]; ucLetter = _Text[i];
@ -1041,7 +1046,7 @@ void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandS
// Get the word value. // Get the word value.
wordValue = _Text.substr(spaceEnd, wordEnd - spaceEnd); wordValue = _Text.substr(spaceEnd, wordEnd - spaceEnd);
// compute width of word // compute width of word
si = TextContext->getStringInfo(wordValue); si = CInterfaceManager::getInstance()->getTextContext()->getStringInfo(wordValue);
// compute size of spaces/Tab + word // compute size of spaces/Tab + word
newLineWidth = lineWidth + numSpaces * _SpaceWidth; newLineWidth = lineWidth + numSpaces * _SpaceWidth;
@ -1120,7 +1125,7 @@ void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandS
for(currChar = 0; currChar < wordValue.length(); ++currChar) for(currChar = 0; currChar < wordValue.length(); ++currChar)
{ {
oneChar = wordValue[currChar]; oneChar = wordValue[currChar];
si = TextContext->getStringInfo(oneChar); si = CInterfaceManager::getInstance()->getTextContext()->getStringInfo(oneChar);
if ((uint) (px + si.StringWidth) > nMaxWidth) break; if ((uint) (px + si.StringWidth) > nMaxWidth) break;
px += si.StringWidth; px += si.StringWidth;
} }
@ -1239,6 +1244,8 @@ void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandS
// *************************************************************************** // ***************************************************************************
void CViewText::updateTextContext () void CViewText::updateTextContext ()
{ {
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
@ -1549,6 +1556,7 @@ void CViewText::setColorRGBA(NLMISC::CRGBA col)
void CViewText::getCharacterPositionFromIndex(sint index, bool cursorAtPreviousLineEnd, sint &x, sint &y, sint &height) const void CViewText::getCharacterPositionFromIndex(sint index, bool cursorAtPreviousLineEnd, sint &x, sint &y, sint &height) const
{ {
NLMISC::clamp(index, 0, (sint) _Text.length()); NLMISC::clamp(index, 0, (sint) _Text.length());
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
@ -1660,7 +1668,7 @@ static uint getCharacterIndex(const ucstring &textValue, float x)
{ {
// get character width // get character width
singleChar[0] = textValue[i]; singleChar[0] = textValue[i];
si = TextContext->getStringInfo(singleChar); si = CInterfaceManager::getInstance()->getTextContext()->getStringInfo(singleChar);
px += si.StringWidth; px += si.StringWidth;
// the character is at the i - 1 position // the character is at the i - 1 position
if (px > x) if (px > x)
@ -1677,6 +1685,8 @@ static uint getCharacterIndex(const ucstring &textValue, float x)
// *************************************************************************** // ***************************************************************************
void CViewText::getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &cursorAtPreviousLineEnd) const void CViewText::getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &cursorAtPreviousLineEnd) const
{ {
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
// setup the text context // setup the text context
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
@ -1815,7 +1825,7 @@ void CViewText::setStringSelectionSkipingSpace(uint stringId, const ucstring &te
quadSize--; quadSize--;
} }
// select what quad to skip // select what quad to skip
TextContext->setStringSelection(stringId, quadStart, quadSize); CInterfaceManager::getInstance()->getTextContext()->setStringSelection(stringId, quadStart, quadSize);
} }
// *************************************************************************** // ***************************************************************************
@ -1907,7 +1917,7 @@ void CViewText::CLine::clear()
for(uint k = 0; k < _Words.size(); ++k) for(uint k = 0; k < _Words.size(); ++k)
{ {
if (_Words[k].Index != 0xffffffff) if (_Words[k].Index != 0xffffffff)
TextContext->erase(_Words[k].Index); CInterfaceManager::getInstance()->getTextContext()->erase(_Words[k].Index);
} }
_Words.clear(); _Words.clear();
_NumChars = 0; _NumChars = 0;
@ -1928,6 +1938,7 @@ void CViewText::CWord::build(const ucstring &text, uint numSpaces/*=0*/)
{ {
Text = text; Text = text;
NumSpaces = numSpaces; NumSpaces = numSpaces;
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
Index = TextContext->textPush(text); Index = TextContext->textPush(text);
Info = TextContext->getStringInfo(Index); Info = TextContext->getStringInfo(Index);
} }
@ -1950,6 +1961,7 @@ sint32 CViewText::getMaxUsedW() const
static const ucstring lineFeedStr("\n"); static const ucstring lineFeedStr("\n");
float maxWidth = 0; float maxWidth = 0;
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
@ -2033,6 +2045,7 @@ sint32 CViewText::getMinUsedW() const
// If we can't clip the words, return the size of the largest word // If we can't clip the words, return the size of the largest word
else if ((_TextMode == DontClipWord) || (_TextMode == Justified)) else if ((_TextMode == DontClipWord) || (_TextMode == Justified))
{ {
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
@ -2083,6 +2096,7 @@ void CViewText::onInvalidateContent()
// *************************************************************************** // ***************************************************************************
void CViewText::computeFontSize () void CViewText::computeFontSize ()
{ {
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setHotSpot (UTextContext::BottomLeft);
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
@ -2436,6 +2450,7 @@ void CViewText::setSingleLineTextFormatTaged(const ucstring &text)
} }
// convert in ULetterColors // convert in ULetterColors
NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext();
ULetterColors * letterColors = TextContext->createLetterColors(); ULetterColors * letterColors = TextContext->createLetterColors();
for(uint i=0; i<tempLetterColors.size(); i++) for(uint i=0; i<tempLetterColors.size(); i++)
{ {

Loading…
Cancel
Save