Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5344 in orxonox.OLD for trunk/src/lib/graphics/text_engine/text.cc


Ignore:
Timestamp:
Oct 10, 2005, 12:39:21 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: new Way to load and unload Text

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/text_engine/text.cc

    r5343 r5344  
    3838  if (fontFile != NULL)
    3939    this->setFont(fontFile, fontSize);
    40   this->setType(type);
    41 }
    42 
    43 /**
    44  *  creates a new Text Element
    45  * @param font the Font to render this text in
    46  * @param type The renderType to display this font in
    47  *
    48  * this constructor is private, because the user should initialize
    49  * a text with the TextEngine.
    50  */
    51 Text::Text(Font* font, TEXT_RENDER_TYPE type)
    52 {
    53   this->init();
    54 
    55   this->font = font;
    5640  this->setType(type);
    5741}
     
    8973
    9074/**
    91  * sets the Font of this Text to font
    92  * @param font the Font (normaly from the ResourceManager) to allocate to this Text
    93  */
    94 void Text::setFont(Font* font)
    95 {
    96   if (this->font != NULL)
    97     ResourceManager::getInstance()->unload(this->font);
    98   this->font = font;
    99 }
    100 
    101 /**
    10275 * sets the Font of this Text to font from fontFile
    10376 * @param fontFile the File to load the Font from.
     
    11184
    11285  tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, &fontSize);
    113   if (tmpFont == NULL)
     86  if (tmpFont != NULL)
     87  {
     88    if (this->font != NULL)
     89      ResourceManager::getInstance()->unload(this->font);
     90    this->font = tmpFont;
     91  }
     92
     93  else
    11494  {
    11595    PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile);
    116     this->setFont(NULL);
    117   }
    118   else
    119     this->setFont(tmpFont);
     96    if (this->font != NULL)
     97      ResourceManager::getInstance()->unload(this->font);
     98    this->font = NULL;
     99  }
    120100}
    121101
Note: See TracChangeset for help on using the changeset viewer.