Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7738 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
May 20, 2006, 12:23:05 AM (19 years ago)
Author:
bensch
Message:

Repositioning

Location:
trunk/src/lib
Files:
3 edited

Legend:

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

    r7737 r7738  
    9898      ++lineNumber;
    9999      posX = 0.0f;
    100       posY += this->lineSpacing + this->getFont()->getMaxHeight();
     100      posY += this->lineSpacing + this->getSize(); //this->getFont()->getMaxHeight();
    101101    }
    102102
  • trunk/src/lib/shell/shell.cc

    r7737 r7738  
    5151  ->describe("Sets the font of the Shell")
    5252  ->defaultValues(SHELL_DEFAULT_FONT)
    53       ->completionPlugin(0, OrxShell::CompletorFileSystem(".ttf", "fonts/"));
     53  ->completionPlugin(0, OrxShell::CompletorFileSystem(".ttf", "fonts/"));
    5454
    5555  /**
     
    7474    this->setLayer(E2D_LAYER_ABOVE_ALL);
    7575    this->shellInput.setLayer(E2D_LAYER_ABOVE_ALL);
    76 
    77     this->backgroundMaterial = new Material;
    7876
    7977    // Element2D and generals
     
    108106      this->bufferText.pop_front();
    109107    }
    110 
    111     // delete the inputLine
    112     delete this->backgroundMaterial;
    113108  }
    114109
     
    172167  void Shell::setFont(const std::string& fontFile)
    173168  {
    174     //   if (!ResourceManager::isInDataDir(fontFile))
    175     //     return false;
    176 
    177169    this->fontFile = fontFile;
    178170
    179     this->resetValues();
     171    this->applySettings();
    180172  }
    181173
     
    193185    this->lineSpacing = lineSpacing;
    194186
    195     this->resetValues();
     187    this->applySettings();
    196188  }
    197189
     
    210202    this->textColor[3] = a;
    211203
    212     this->resetValues();
    213   }
    214 
     204    this->applySettings();
     205  }
    215206
    216207  /**
     
    223214  void Shell::setBackgroundColor(float r, float g, float b, float a)
    224215  {
    225     this->backgroundMaterial->setDiffuse(r, g, b);
    226     this->backgroundMaterial->setTransparency(a);
     216    this->backgroundMaterial.setDiffuse(r, g, b);
     217    this->backgroundMaterial.setTransparency(a);
    227218  }
    228219
     
    233224  void Shell::setBackgroundImage(const std::string& fileName)
    234225  {
    235     this->backgroundMaterial->setDiffuseMap(fileName);
    236   }
    237 
    238 
    239   /**
    240    * @brief resets the Values of all visible shell's commandos to the Shell's stored values
    241    *
    242    * this functions synchronizes the stored Data with the visible one.
    243    */
    244   void Shell::resetValues()
    245   {
    246     this->resetText(&this->shellInput, 0);
    247     this->shellInput.setRelCoor2D(15, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize));
    248 
    249     unsigned int i = 0;
    250     /* Here we create a Copy of the Buffer, so that we do not f**k up the List when some
    251      * output is routed from Some other Thread or by Changing any Values.
    252      */
    253     std::list<MultiLineText*> bufferTextCopy = this->bufferText;
    254     for (std::list<MultiLineText*>::iterator text = bufferTextCopy.begin(); text != bufferTextCopy.end(); ++text, ++i)
    255     {
    256       this->resetText(*text, i);
    257       (*text)->setRelCoor2D( calculateLinePosition(i) );
    258     }
    259     this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
    260   }
    261 
    262   void Shell::resetText(Text* text, unsigned int position)
     226    this->backgroundMaterial.setDiffuseMap(fileName);
     227  }
     228
     229  /**
     230   * @brief repositiones all the Texts to their position.
     231   */
     232  void Shell::repositionText()
     233  {
     234    int linePos = -1;
     235    std::list<MultiLineText*>::iterator textIt;
     236    for (textIt = this->bufferText.begin() ; textIt != this->bufferText.end(); ++textIt )
     237    {
     238      linePos += (*textIt)->getLineCount();
     239      (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(linePos), 8);
     240    }
     241  }
     242
     243
     244  /**
     245   * @brief applies the Shells Settings to a single Text of the Shell.
     246   * @param text the Text to apply the settings to.
     247   */
     248  void Shell::applyTextSettings(Text* text)
    263249  {
    264250    text->setFont(this->fontFile, this->textSize);
     251    text->setSize(this->textSize);
    265252    text->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
    266253    text->setBlending(this->textColor[3]);
     
    270257  }
    271258
     259  /**
     260   * @brief resets the Values of all visible shell's commandos to the Shell's stored values
     261   *
     262   * this functions synchronizes the stored Data with the visible one.
     263   */
     264  void Shell::applySettings()
     265  {
     266    this->applyTextSettings(&this->shellInput);
     267    this->shellInput.setRelCoor2D(15, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize));
     268
     269    /* Here we create a Copy of the Buffer, so that we do not f**k up the List when some
     270     * output is routed from Some other Thread or by Changing any Values.
     271     */
     272    std::list<MultiLineText*> bufferTextCopy = this->bufferText;
     273    for (std::list<MultiLineText*>::iterator textIt = bufferTextCopy.begin(); textIt != bufferTextCopy.end(); ++textIt)
     274    {
     275      this->applyTextSettings(*textIt);
     276      (*textIt)->setLineSpacing(this->lineSpacing);
     277      (*textIt)->setLineWidth(this->getSizeX2D() * GraphicsEngine::getInstance()->getResolutionX());
     278    }
     279    this->repositionText();
     280
     281    this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
     282  }
    272283
    273284  /**
     
    291302      {
    292303        this->bufferText.push_back(new MultiLineText);
    293         this->bufferText.back()->setLineWidth(this->getSizeX2D() * GraphicsEngine::getInstance()->getResolutionX());
    294         this->bufferText.back()->setLineSpacing(0);
    295304      }
    296305    }
    297306    this->bufferDisplaySize = bufferDisplaySize;
    298     this->resetValues();
     307    this->applySettings();
    299308  }
    300309
     
    304313  void Shell::flush()
    305314  {
    306     for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)
    307     {
    308       (*text)->setText("");  // remove all chars from the BufferTexts.
     315    for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt)
     316    {
     317      (*textIt)->setText("");  // remove all chars from the BufferTexts.
    309318    }
    310319    ShellBuffer::getInstance()->flush();
     
    326335
    327336    // The LineCount will be started here.
    328     int linePos = -1;
    329337
    330338    // The First Line gets a special Animation
    331     this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(linePos)- Vector2D(-1000,0));
     339    this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(0)- Vector2D(-1000,0));
    332340
    333341    // Move all lines one Entry up.
    334     for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt)
    335     {
    336       linePos += (*textIt)->getLineCount();
    337       (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(linePos), 8);
    338     }
    339 
    340 
    341     /*  FANCY EFFECTS :)
    342       1:
    343           lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector(-1000,0,0));
    344           lastText->setRelCoorSoft2D(this->calculateLinePosition(0),10);
    345       2:
    346       lastText->setRelDir2D(-90);
    347       lastText->setRelDirSoft2D(0, 20);
    348     */
    349 
    350   }
    351 
    352   /**
    353    * moves the Display buffer (up + or down - )
     342    this->repositionText();
     343  }
     344
     345
     346  /**
     347   * @brief moves the Display buffer (up + or down - )
    354348   * @param lineCount the count by which to shift the InputBuffer.
    355349   *
     
    409403
    410404  /**
    411    * clears the Shell (empties all buffers)
     405   * @brief clears the Shell (empties all buffers)
    412406   */
    413407  void Shell::clear()
     
    418412
    419413  /**
    420    * listens for some event
     414   * @brief listens for some event
    421415   * @param event the Event happened
    422416   */
     
    451445    // setting the Blending effects
    452446
    453     this->backgroundMaterial->select();
     447    this->backgroundMaterial.select();
    454448
    455449    glBegin(GL_TRIANGLE_STRIP);
     
    481475  Vector2D Shell::calculateLinePosition(unsigned int lineNumber)
    482476  {
    483     Vector2D val(5, (int)(this->textSize + this->lineSpacing)*(int)((int)this->bufferDisplaySize - (int)lineNumber - (int)2) + (int)this->textSize);
    484      val.debug();
    485      return val;
     477    return Vector2D(5, (int)(this->textSize + this->lineSpacing)*(int)((int)this->bufferDisplaySize - (int)lineNumber - (int)2) + (int)this->textSize);
    486478  }
    487479
  • trunk/src/lib/shell/shell.h

    r7737 r7738  
    1414
    1515#include "shell_input.h"
     16#include "material.h"
    1617
    1718#define         SHELL_DEFAULT_FONT              "fonts/final_frontier.ttf"
     
    7980
    8081  private:
    81     void resetValues();
    82     void resetText(Text* text, unsigned int position);
     82    void repositionText();
     83    void applyTextSettings(Text* text);
     84    void applySettings();
    8385    // helpers //
    8486    Vector2D calculateLinePosition(unsigned int lineNumber);
     
    98100    float                       textColor[4];           //!< The text's color [r,g,b,a].
    99101    std::string                 fontFile;               //!< The file containing the font.
    100     Material*                   backgroundMaterial;     //!< A material for the background.
     102    Material                    backgroundMaterial;     //!< A material for the background.
    101103
    102104    // HANDLING TEXT INPUT
Note: See TracChangeset for help on using the changeset viewer.