Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 7, 2005, 1:55:44 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: loadScreen now loadable as well

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/glmenu/glmenu_imagescreen.cc

    r4101 r4104  
    2929/**
    3030   \brief standard constructor
    31 
    32    \todo this constructor is not jet implemented - do it
    3331*/
    3432GLMenuImageScreen::GLMenuImageScreen ()
    3533{
    36    this->setClassName ("GLMenuImageScreen");
    3734   this->init();
    3835}
    3936
    40 
     37/**
     38   \param root The Element to load the GLMenu from
     39*/
    4140GLMenuImageScreen::GLMenuImageScreen (TiXmlElement* root)
    4241{
    4342  this->init();
    44 
     43  this->load(root);
     44
     45}
     46
     47/**
     48   \brief Loads a GLMenu from an inputElement
     49   \param root The Element to load the GLMenu from
     50
     51   Tags are:
     52   \li BackgroundImage STRING: the background Image
     53   \li BarImage: STRING: the Image on the Bar
     54   \li BackgroundPS: FLOAT FLOAT FLOAT FLOAT: posX posY scaleX scaleY
     55   \li BarPS: FLOAT FLOAT FLOAT FLOAT: posX posY scaleX scaleY
     56   \li ElementCount: INT: how many elements will be loaded
     57*/
     58void GLMenuImageScreen::load(TiXmlElement* root)
     59{
    4560  const char* string;
    4661
     
    4964  if( string != NULL)
    5065    this->setBackgroundImage(string);
    51  
     66
     67  string = grabParameter(root, "BackgroundPS");
     68  if (string != NULL)
     69    {
     70      float f1, f2, f3, f4;
     71      sscanf (string, "%f %f %f %f", &f1, &f2, &f3, &f4);
     72      this->setPosition(f1,f2);
     73      this->setScale(f3,f4);
     74    }
     75
    5276  string = grabParameter( root, "BarImage");
    5377  if (string != NULL)
    5478    this->setBarImage(string);
    55 
    56 }
    57 
     79  string = grabParameter(root, "BarPS");
     80  if (string != NULL)
     81    {
     82      float f1, f2, f3, f4;
     83      sscanf (string, "%f %f %f %f", &f1, &f2, &f3, &f4);
     84      this->setBarPosScale(f1,f2,f3,f4);
     85    }
     86
     87  string = grabParameter( root, "ElementCount");
     88  if (string != NULL)
     89    this->setMaximum(atoi(string));
     90}
    5891
    5992/**
     
    72105void GLMenuImageScreen::init ()
    73106{
     107  this->setClassName ("GLMenuImageScreen");
     108
    74109  // Select Our VU Meter Background Texture
    75110  this->backMat = new Material("load_screen");
     
    200235
    201236  PRINTF(4)("GLMenuImagEscreen::draw() - drawing step %i/%i\n",
    202          this->currentValue, this->maxValue);
     237            this->currentValue, this->maxValue);
    203238
    204239  /* screen size */
     
    218253  int barH = (int)(this->barH *screenHeight);
    219254 
    220   int val = (int)(((float)this->currentValue/(float)this->maxValue)
    221                   * this->barW * (float)screenWidth);
     255  float val = (float)this->currentValue/(float)this->maxValue;
     256                 
    222257  if( val > barW)
    223258    val = barW;
     
    248283  barMat->select();
    249284  glBegin(GL_TRIANGLE_STRIP);
    250   glTexCoord2i(0, 0); glVertex2i(barX, barY + barH);
    251   glTexCoord2i(1, 0); glVertex2i(barX + val, barY + barH);
    252   glTexCoord2i(0, 1); glVertex2i(barX, barY);
    253   glTexCoord2i(1, 1); glVertex2i(barX + val, barY);
     285  glTexCoord2f(0, 0); glVertex2i(barX, barY + barH);
     286  glTexCoord2f(val, 0); glVertex2i(barX + (int)(val * this->barW * (float)screenWidth), barY + barH);
     287  glTexCoord2f(0, 1); glVertex2i(barX, barY);
     288  glTexCoord2f(val, 1); glVertex2i(barX + (int)(val * this->barW * (float)screenWidth), barY);
    254289  glEnd();
    255290
Note: See TracChangeset for help on using the changeset viewer.