Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9839 in orxonox.OLD


Ignore:
Timestamp:
Sep 26, 2006, 6:31:56 PM (18 years ago)
Author:
bensch
Message:

Font completely ported to the new Resource-Format.
Now all the Basic Resources previously loaded from a central ResourceManager are Distributed over the Resource-Types

Location:
branches/new_class_id/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/Makefile.am

    r9836 r9839  
    4242                util/kill_target.cc \
    4343                \
    44                 subprojects/benchmark.cc \
    45                 \
    46                 \
    47                 lib/util/loading/old_resource_manager.cc
     44                subprojects/benchmark.cc
    4845
    4946noinst_HEADERS = \
  • branches/new_class_id/src/lib/graphics/Makefile.am

    r9820 r9839  
    2121                text_engine/limited_width_text.cc \
    2222                text_engine/font.cc \
    23                 text_engine/font_data.cc
     23                text_engine/font_data.cc \
     24                text_engine/resource_font.cc
    2425
    2526noinst_HEADERS =\
     
    4142                text_engine/font.h \
    4243                text_engine/font_data.h \
     44                text_engine/resource_font.h \
    4345                text_engine/default_font.xpm
    4446
  • branches/new_class_id/src/lib/graphics/text_engine/font.cc

    r9723 r9839  
    3535{
    3636  this->init();
    37 
    3837}
    3938
     
    119118  Material::operator=(font);
    120119  this->data = font.data;
     120  this->setTexture(this->data->textureData());
    121121
    122122  return *this;
  • branches/new_class_id/src/lib/graphics/text_engine/resource_font.cc

    r9838 r9839  
    66
    77
    8 ResourceFont::ResourceFont(const std::string& imageName, GLenum target)
    9     : NewResource(&ResourceFont::type)
     8ResourceFont::ResourceFont(const std::string& fontName, unsigned int renderSize)
     9  : Font(), NewResource(&ResourceFont::type)
    1010{
    11   Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + "TEST");
     11  assert(!fontName.empty());
     12  Resources::StorePointer* ptr = this->acquireResource(fontName + ',' + MultiType((int)renderSize).getString());
    1213
    1314  if (ptr)
    1415  {
    15     PRINTF(5)("FOUND FONT: %s\n", imageName.c_str());
    16     this->acquireData(static_cast<ResourceFont::FontResourcePointer*>(ptr)->ptr());
     16    PRINTF(5)("FOUND FONT: %s\n", fontName.c_str());
     17    this->Font::acquireData(static_cast<ResourceFont::FontResourcePointer*>(ptr)->ptr());
    1718  }
    1819  else
    1920  {
    20     PRINTF(5)("NOT FOUND FONT: %s\n", imageName.c_str());
    21     std::string fileName = this->NewResource::locateFile(imageName);
    22     this->Font::loadImage(fileName, target);
    23     this->NewResource::addResource(new ResourceFont::FontResourcePointer(imageName + ',' + "TEST", Resources::KeepLevel(0), this->Font::dataPointer()));
     21    PRINTF(5)("NOT FOUND FONT: %s\n", fontName.c_str());
     22    std::string fileName = this->NewResource::locateFile(fontName);
     23
     24    printf("FONTFILE %s TO %s\n", fontName.c_str(), fileName.c_str());
     25
     26    this->Font::loadFontFromTTF(fileName, renderSize);
     27    this->NewResource::addResource(new ResourceFont::FontResourcePointer(fontName + ',' + MultiType((int)renderSize).getString(), Resources::KeepLevel(0), this->Font::dataPointer()));
    2428  }
    2529}
     
    2832{
    2933  SubString loadValues(loadString, ',');
    30   std::string imageName;
    31   GLenum target = GL_FONT_2D;
     34  std::string fontName;
     35  unsigned int renderSize = 20;
    3236  if (loadValues.size() > 0)
    33     imageName = loadValues[0];
     37    fontName = loadValues[0];
    3438  if (loadValues.size() > 1)
    35     target = (GLenum)MultiType(loadValues[2]).getInt();
     39    renderSize = (unsigned int)MultiType(loadValues[2]).getInt();
    3640
    37   return ResourceFont(imageName, target);
     41  return ResourceFont(fontName, renderSize);
    3842}
    3943
  • branches/new_class_id/src/lib/graphics/text_engine/resource_font.h

    r9838 r9839  
    1515{
    1616public:
    17   ResourceFont(const std::string& imageName, GLenum target = GL_FONT_2D);
     17  ResourceFont(const std::string& fontName, unsigned int renderSize);
    1818  static ResourceFont createFromString(const std::string& loadString);
    1919
  • branches/new_class_id/src/lib/graphics/text_engine/text.cc

    r9836 r9839  
    1717
    1818#include "text.h"
     19#include "resource_font.h"
    1920#include "font.h"
    20 #include "loading/old_resource_manager.h"
    2121#include "debug.h"
    2222
     
    2929 */
    3030Text::Text(const std::string& fontFile, unsigned int textSize)
    31     // : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
     31// : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
    3232{
    3333  this->registerObject(this, Text::_objectList);
    3434
    3535  // initialize this Text
    36   this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
     36  if (!fontFile.empty())
     37    this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
     38  else
     39    this->setFont("fonts/final_frontier.ttf", FONT_DEFAULT_RENDER_SIZE);
    3740  this->_size = textSize;
    3841  this->setSizeY2D(textSize);
     
    170173void Text::setFont(const std::string& fontFile, unsigned int fontSize)
    171174{
    172   Font* newFont = NULL;
    173   //  Font* oldFont = this->_font;
    174 
    175   // load a new Font
    176   if (!fontFile.empty())
    177   {
    178     newFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, (int)fontSize);
    179     if (newFont == NULL)
    180     {
    181       //      newFont = &Font::();
    182       PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str());
    183     }
    184   }
    185 
    186   if (newFont == NULL)
    187     this->_font = Font();
    188   else
    189     this->_font = *newFont;
     175  this->_font = ResourceFont(fontFile, fontSize);
    190176
    191177  this->setupTextWidth();
  • branches/new_class_id/src/lib/util/loading/resource.cc

    r9836 r9839  
    5454    if (!locatedFile.empty())
    5555    {
    56       printf("FILE found %s\n", locatedFile.c_str());
    5756      return locatedFile;
    5857    }
     
    7776      Directory dir = directory + (*it);
    7877      File file = dir + File(fileName);
    79       printf("Testing %s (from %s in directory %s)\n", file.name().c_str(), fileName.c_str(), dir.name().c_str());
    8078      if ((dir+ File(fileName)).exists())
    8179        return (dir+File(fileName)).name();
  • branches/new_class_id/src/orxonox.cc

    r9836 r9839  
    364364  }
    365365
    366   ResourceManager::getInstance()->setDataDir(dataPath);
    367 
    368366  //! @todo this is a hack and should be loadable
    369367  Resources::ResourceManager::getInstance()->addResourceSubPath("Texture", "maps");
Note: See TracChangeset for help on using the changeset viewer.