Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8509 in orxonox.OLD


Ignore:
Timestamp:
Jun 16, 2006, 12:22:35 AM (18 years ago)
Author:
bensch
Message:

gui: notifier: outputs stuff

Location:
branches/gui/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/gui/gl/glgui_style.cc

    r8469 r8509  
    3030  {
    3131    _font = NULL;
     32    this->reset();
    3233
    3334
     
    6566
    6667  void GLGuiStyle::loadParams(const TiXmlElement* root)
    67   {
    68   }
     68  {}
    6969
    7070  void GLGuiStyle::setBorderLeft(float value)
     
    8181  void GLGuiStyle::setBorderLeftS(float value, const std::string& state)
    8282  {
    83 
    8483  }
    8584
     
    107106
    108107  void GLGuiStyle::setBorderTop(float value, OrxGui::State state)
    109 {
    110   _style[state]._borderTop = value;
     108  {
     109    _style[state]._borderTop = value;
     110  }
     111
     112  void GLGuiStyle::setBorderTopS(float value, const std::string& state)
     113  {}
     114
     115
     116  void GLGuiStyle::setBorderBottom(float value)
     117  {
     118    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     119      setBorderBottom(value, (OrxGui::State)i);
     120  }
     121
     122  void GLGuiStyle::setBorderBottom(float value, OrxGui::State state)
     123  {
     124    _style[state]._borderBottom = value;
     125  }
     126
     127  void GLGuiStyle::setBorderBottomS(float value, const std::string& state)
     128  {}
     129
     130
     131  void GLGuiStyle::setTextSize(float value)
     132  {
     133    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     134      setTextSize(value, (OrxGui::State)i);
     135  }
     136
     137  void GLGuiStyle::setTextSize(float value, OrxGui::State state)
     138  {
     139    _style[state]._textSize = value;
     140  }
     141
     142  void GLGuiStyle::setTextSizeS(float value, const std::string& state)
     143  {}
     144
     145
     146  void GLGuiStyle::setBackgroundColor(const Color& color)
     147  {
     148    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     149      setBackgroundColor(color, (OrxGui::State)i);
     150  }
     151
     152  void GLGuiStyle::setBackgroundColor(const Color& color, OrxGui::State state)
     153  {
     154    _style[state]._backgroundColor = color;
     155  }
     156
     157  void GLGuiStyle::setBackgroundColorS(float r, float g, float b, float a, const std::string& state)
     158  {}
     159
     160
     161  void GLGuiStyle::setBackgroundTexture(const Texture& texture)
     162  {
     163    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     164      setBackgroundTexture(texture, (OrxGui::State)i);
     165  }
     166
     167  void GLGuiStyle::setBackgroundTexture(const Texture& texture, OrxGui::State state)
     168  {
     169    _style[state]._backgroundTexture = texture;
     170  }
     171
     172  void GLGuiStyle::setBackgroundTexture(const std::string& textureName, const std::string& state)
     173  {}
     174
     175
     176  void GLGuiStyle::setForegroundColor(const Color& color)
     177  {
     178    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     179      setForegroundColor(color, (OrxGui::State)i);
     180  }
     181
     182  void GLGuiStyle::setForegroundColor(const Color& color, OrxGui::State state)
     183  {
     184    _style[state]._foregroundColor = color;
     185  }
     186
     187  void GLGuiStyle::setForegroundColorS(float r, float g, float b, float a, const std::string& state)
     188  {}
     189
     190
     191
     192  void GLGuiStyle::setFeaturePosition(FeaturePosition featurePosition)
     193  {
     194    this->_featurePosition = featurePosition;
     195  }
     196
     197  void GLGuiStyle::setFeaturePosition(const std::string& featurePosition)
     198  {}
     199
     200
     201  void GLGuiStyle::setFont(Font* font)
     202  {
     203    this->_font = font;
     204  }
     205
     206  void GLGuiStyle::setFont(const std::string& fontName)
     207  {
     208    //this->font = new Font(fontName);
     209  }
     210
     211
     212  void GLGuiStyle::setAnimated(bool animated)
     213  {
     214    this->_animated = animated;
     215  }
     216
     217  void GLGuiStyle::setAnimatedStateChanges(bool animated)
     218  {
     219    this->_animatedStateChanges = animated;
     220  }
     221
    111222}
    112 
    113   void GLGuiStyle::setBorderTopS(float value, const std::string& state)
    114   {}
    115 
    116 
    117   void GLGuiStyle::setBorderBottom(float value)
    118   {
    119     for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
    120       setBorderBottom(value, (OrxGui::State)i);
    121   }
    122 
    123   void GLGuiStyle::setBorderBottom(float value, OrxGui::State state)
    124 {
    125   _style[state]._borderBottom = value;
    126 }
    127 
    128   void GLGuiStyle::setBorderBottomS(float value, const std::string& state)
    129   {}
    130 
    131 
    132   void GLGuiStyle::setTextSize(float value)
    133   {
    134     for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
    135       setTextSize(value, (OrxGui::State)i);
    136   }
    137 
    138   void GLGuiStyle::setTextSize(float value, OrxGui::State state)
    139 {
    140   _style[state]._textSize= value;
    141 }
    142 
    143   void GLGuiStyle::setTextSizeS(float value, const std::string& state)
    144   {}
    145 
    146 
    147   void GLGuiStyle::setBackgroundColor(const Color& color)
    148   {
    149     for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
    150       setBackgroundColor(color, (OrxGui::State)i);
    151   }
    152 
    153   void GLGuiStyle::setBackgroundColor(const Color& color, OrxGui::State state)
    154 {
    155   _style[state]._backgroundColor = color;
    156 }
    157 
    158   void GLGuiStyle::setBackgroundColorS(float r, float g, float b, float a, const std::string& state)
    159   {}
    160 
    161 
    162   void GLGuiStyle::setBackgroundTexture(const Texture& texture)
    163   {
    164     for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
    165       setBackgroundTexture(texture, (OrxGui::State)i);
    166   }
    167 
    168   void GLGuiStyle::setBackgroundTexture(const Texture& texture, OrxGui::State state)
    169 {
    170   _style[state]._backgroundTexture = texture;
    171 }
    172 
    173   void GLGuiStyle::setBackgroundTexture(const std::string& textureName, const std::string& state)
    174   {}
    175 
    176 
    177   void GLGuiStyle::setForegroundColor(const Color& color)
    178   {
    179     for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
    180       setForegroundColor(color, (OrxGui::State)i);
    181   }
    182 
    183   void GLGuiStyle::setForegroundColor(const Color& color, OrxGui::State state)
    184   {
    185     _style[state]._foregroundColor = color;
    186   }
    187 
    188   void GLGuiStyle::setForegroundColorS(float r, float g, float b, float a, const std::string& state)
    189   {}
    190 
    191 
    192 
    193   void GLGuiStyle::setFeaturePosition(FeaturePosition featurePosition)
    194   {
    195     this->_featurePosition = featurePosition;
    196   }
    197 
    198   void GLGuiStyle::setFeaturePosition(const std::string& featurePosition)
    199   {
    200   }
    201 
    202 
    203   void GLGuiStyle::setFont(Font* font)
    204   {
    205     this->_font = font;
    206   }
    207 
    208   void GLGuiStyle::setFont(const std::string& fontName)
    209   {
    210     //this->font = new Font(fontName);
    211   }
    212 
    213 
    214   void GLGuiStyle::setAnimated(bool animated)
    215   {
    216     this->_animated = animated;
    217   }
    218 
    219   void GLGuiStyle::setAnimatedStateChanges(bool animated)
    220   {
    221     this->_animatedStateChanges = animated;
    222   }
    223 
    224 }
  • branches/gui/src/lib/gui/gl/glgui_widget.h

    r8448 r8509  
    6666    void disconnect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver);
    6767
     68
     69    GLGuiStyle& style() { return this->_style; };
     70    const GLGuiStyle style() const { return this->_style; };
    6871
    6972    /// MATERIAL (looks)
  • branches/gui/src/lib/gui/gl/specials/glgui_notifier.cc

    r8503 r8509  
    3333    // Element2D and generals
    3434    this->lineSpacing = 0;
     35    this->linesProcessed = 0;
    3536
    36     this->setBufferDisplaySize(10);
     37    this->setDisplayLineCount(10);
    3738  }
    3839
     
    4344  {
    4445    // delete the displayable Buffers
    45     while (!this->bufferText.empty())
     46    /*    while (!this->displayLines.empty())
     47        {
     48          delete this->displayLines.front().text;
     49          this->displayLines.pop_front();
     50        }
     51
     52        while (!this->hiddenText.empty())
     53        {
     54          delete this->hiddenText.top();
     55          this->hiddenText.pop();
     56        }*/
     57  }
     58
     59  void GLGuiNotifier::pushNotifyMessage(const std::string& message)
     60  {
     61    if (!this->hiddenText.empty())
    4662    {
    47       delete this->bufferText.front();
    48       this->bufferText.pop_front();
     63      printf("%s\n", message.c_str());
     64      DisplayLine dl;
     65      dl.text = this->hiddenText.top();
     66
     67      dl.text->setText(message);
     68      this->hiddenText.pop();
     69      dl.age = 0.0f;
     70      this->displayLines.push_back(dl);
     71
     72      this->repositionText();
     73    }
     74    else
     75    {
     76      printf("grumble... must be fixed\n");
    4977    }
    5078  }
    5179
     80
     81  void GLGuiNotifier::setDisplayLineCount(unsigned int count)
     82  {
     83    unsigned int currentCount = displayLines.size() + hiddenText.size();
     84
     85    for (unsigned int i = currentCount; i < count; ++i)
     86    {
     87      MultiLineText* text = new MultiLineText();
     88      this->applyTextSettings(text);
     89      this->hiddenText.push(text);
     90    }
     91    bufferDisplaySize = count;
     92  }
    5293
    5394
     
    5899  {
    59100    int linePos = -1;
    60     std::list<MultiLineText*>::iterator textIt;
    61     for (textIt = this->bufferText.begin() ; textIt != this->bufferText.end(); ++textIt )
     101    std::list<DisplayLine>::iterator textIt;
     102    for (textIt = this->displayLines.begin() ; textIt != this->displayLines.end(); ++textIt )
    62103    {
    63       linePos += (*textIt)->getLineCount();
    64       (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(linePos), 8);
     104      linePos += (*textIt).text->getLineCount();
     105      (*textIt).text->setRelCoorSoft2D(this->calculateLinePosition(linePos), 8);
     106      //      printf("%f %f\n", (*textIt).text->getAbsCoor2D().x, (*textIt).text->getAbsCoor2D().y);
    65107    }
    66108  }
     
    71113   * @param text the Text to apply the settings to.
    72114   */
    73   void GLGuiNotifier::applyTextSettings(Text* text)
     115  void GLGuiNotifier::applyTextSettings(MultiLineText* text)
    74116  {
    75 /*    text->setSize(this->textSize);
    76     text->setFont(this->fontFile, this->textSize);
    77     text->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
    78     text->setBlending(this->textColor[3]);
    79     text->setLayer(this->getLayer());
     117    text->setSize(this->style().textSize());
     118    text->setLineWidth( 300 );
     119    //text->setFont(this->fontFile, this->textSize);
     120
     121    //text->setColor( Color(1,1,1,1)/*this->style().foregroundColor() */);
    80122    if (text->getParent2D() != this)
    81       text->setParent2D(this);*/
     123      text->setParent2D(this);
    82124  }
    83125
     
    113155  Vector2D GLGuiNotifier::calculateLinePosition(unsigned int lineNumber)
    114156  {
    115 //    return Vector2D(5.0f, (float)(this->textSize + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));
    116     return Vector2D();
     157    return Vector2D(0.0f, (float)(this->style().textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));
    117158  }
    118159
    119160
     161  void GLGuiNotifier::resize()
     162  {}
    120163
    121164  /**
  • branches/gui/src/lib/gui/gl/specials/glgui_notifier.h

    r8503 r8509  
    1313#include "event_listener.h"
    1414
     15#include <stack>
     16
    1517// FORWARD DECLARATION
    1618class MultiLineText;
     
    2224  class GLGuiNotifier : public GLGuiWidget
    2325  {
    24 
    2526  public:
    2627    GLGuiNotifier();
     
    3031
    3132    // BUFFERS
    32     void setBufferDisplaySize(unsigned int bufferDisplaySize);
    33     void printToDisplayBuffer(const std::string& text);
     33    void setDisplayLineCount(unsigned int count);
    3434
    3535    void clear();
    3636
    37     // EventListener
    38     virtual void processEvents(const Event &event);
    3937    // Element2D-functions
    4038    virtual void tick(float dt);
    4139    virtual void draw() const;
    4240
    43 
    4441    void debug() const;
    4542
     43  protected:
     44    virtual void resize();
     45
    4646  private:
    47     void updateResolution(unsigned int width);
    4847    void repositionText();
    49     void applyTextSettings(Text* text);
     48    void applyTextSettings(MultiLineText* text);
    5049    void applySettings();
    5150    // helpers //
    5251    Vector2D calculateLinePosition(unsigned int lineNumber);
    5352
     53
     54
    5455  private:
     56    typedef struct
     57    {
     58      float             age;
     59      MultiLineText*    text;
     60
     61    }
     62    DisplayLine;
     63
    5564    unsigned int                lineSpacing;            //!< The Spacing between lines.
    5665
    5766    // BUFFER
    5867    unsigned int                bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
    59     std::list<MultiLineText*>   bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
     68    std::list<DisplayLine>      displayLines;           //!< A list of stored bufferTexts for the display of the buffer.
    6069
    61     unsigned long               linesProcessed;         //!< How many Lines have been processed.
     70    std::stack<MultiLineText*>  hiddenText;             //!< Text that is not shown, and not used is thrown in here
     71
     72
     73    unsigned long               linesProcessed;         //!< How many Lines have been processed so far.
     74    std::list<std::string>      inputBuffer;            //!<
     75
    6276  };
    6377
  • branches/gui/src/story_entities/simple_game_menu.cc

    r8479 r8509  
    4242
    4343#include "glgui.h"
     44#include "gui/gl/specials/glgui_notifier.h"
    4445
    4546//! This creates a Factory to fabricate a SimpleGameMenu
     
    8889{
    8990
     91  OrxGui::GLGuiNotifier* notifier = new OrxGui::GLGuiNotifier();
     92  notifier->show();
     93  notifier->setAbsCoor2D(300, 300);
     94
     95
     96
    9097  OrxGui::GLGuiBox* box = new OrxGui::GLGuiBox();
    9198  {
     
    107114    OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine();
    108115    input->setText("input some text here");
    109     input->connect(SIGNAL(input, textChanged), this, SLOT(SimpleGameMenu, TEST));
     116    input->connect(SIGNAL(input, textChanged), notifier, SLOT(OrxGui::GLGuiNotifier, pushNotifyMessage));
     117
    110118    box->pack(input);
    111119
Note: See TracChangeset for help on using the changeset viewer.