Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8518 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jun 16, 2006, 10:23:05 AM (19 years ago)
Author:
bensch
Message:

merged the gui back to the trunk

Location:
trunk/src
Files:
14 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r8490 r8518  
    363363  CL_GLGUI_IMAGE                =    0x00000b70,
    364364
     365  CL_GLGUI_NOTIFIER             =    0x00000b80,
     366
    365367  // QT_GUI
    366368  CL_GUI_SAVEABLE               =    0x00b10000,
  • trunk/src/lib/graphics/graphics_engine.cc

    r8490 r8518  
    405405  this->setResolution(this->resolutionX, this->resolutionY, this->bitsPerPixel);
    406406}
     407
     408void GraphicsEngine::toggleFullscreen()
     409{
     410  if (this->fullscreenFlag == SDL_FULLSCREEN)
     411    this->fullscreenFlag = 0;
     412  else
     413    this->fullscreenFlag = SDL_FULLSCREEN;
     414  this->setResolution(this->resolutionX, this->resolutionY, this->bitsPerPixel);
     415}
     416
    407417
    408418/**
  • trunk/src/lib/graphics/graphics_engine.h

    r8490 r8518  
    4444    int setResolution(int width, int height, int bpp);
    4545    void setFullscreen(bool fullscreen = false);
     46    void toggleFullscreen();
    4647    static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0);
    4748
  • trunk/src/lib/graphics/text_engine/text.cc

    r8448 r8518  
    159159}
    160160
     161
     162/**
     163 * @brief clears the Text Line (empies it).
     164 */
     165void Text::clear()
     166{
     167  text.clear();
     168  this->setupTextWidth();
     169}
    161170
    162171/**
  • trunk/src/lib/graphics/text_engine/text.h

    r8448 r8518  
    4040    const std::string& operator<<(const std::string& appendText);
    4141    void removeCharacters(unsigned int chars);
     42    void clear();
    4243
    4344    /// SETUP
  • trunk/src/lib/gui/gl/Makefile.am

    r8145 r8518  
    2929                glgui_image.cc \
    3030                glgui_window.cc \
    31                 glgui_cursor.cc
     31                glgui_cursor.cc \
     32                \
     33                specials/glgui_notifier.cc
    3234
    3335
     
    5456                glgui_image.h \
    5557                glgui_window.h \
    56                 glgui_cursor.h
     58                glgui_cursor.h \
     59                \
     60                specials/glgui_notifier.h
     61
    5762
    5863
  • trunk/src/lib/gui/gl/glgui_inputline.cc

    r8448 r8518  
    4848    this->setFocusable(true);
    4949
     50    this->_clearOnEnter = false;
    5051    this->_text.setParent2D(this);
    5152    this->_text.setRelCoor2D(4,4);
     
    100101  }
    101102
     103  void GLGuiInputLine::clear()
     104  {
     105    this->_text.clear();
     106    this->changedText();
     107  }
     108
    102109  /**
    103110   * @brief If the Text has been changed this function is called.
     
    124131  }
    125132
     133  /**
     134   * @brief handles the EnterPush-Event.
     135   *
     136   * Emmits th EnterPushed Signal with the current Line,
     137   * and if _clearOnEnter is pushed clears the Line.
     138   */
     139  void GLGuiInputLine::pushEnter()
     140  {
     141    emit(this->enterPushed(this->_text.getText()));
     142    if (this->_clearOnEnter)
     143      this->clear();
     144  }
     145
    126146
    127147  /**
     
    140160        this->pressedKeyName = SDLK_BACKSPACE;
    141161        this->removeCharacters(1);
     162        return true;
     163      }
     164      else if(event.type == SDLK_RETURN || event.type == SDLK_KP_ENTER)
     165      {
     166        this->pushEnter();
    142167        return true;
    143168      }
  • trunk/src/lib/gui/gl/glgui_inputline.h

    r8448 r8518  
    3838    void appendCharacter(char character);
    3939    void removeCharacters(unsigned int chars);
     40    void clear();
     41
     42    void clearOnEnter(bool clear = true) { this->_clearOnEnter = clear; };
    4043
    4144    virtual void removedFocus();
     
    4750
    4851    DeclareSignal1(textChanged, const std::string&);
     52    DeclareSignal1(enterPushed, const std::string&);
    4953
    5054  protected:
     
    5761  private:
    5862    void init();
     63    void pushEnter();
    5964    void changedText();
     65
    6066
    6167  private:
    6268    Text                    _text;            //!< The Text to display inside of the InputLine.
     69    bool                    _clearOnEnter;    //!< Clear on Enter
    6370
    6471    Uint16                  pressedKey;       //!< the pressed key that will be repeated.
  • trunk/src/lib/gui/gl/glgui_style.cc

    r8450 r8518  
    2929  GLGuiStyle::GLGuiStyle (const TiXmlElement* root)
    3030  {
     31    _font = NULL;
     32    this->reset();
     33
     34
    3135    if (root != NULL)
    3236      this->loadParams(root);
     
    4347  }
    4448
     49  void GLGuiStyle::reset()
     50  {
     51    this->setBorderLeft(1.0);
     52    this->setBorderRight(1.0);
     53    this->setBorderTop(1.0);
     54    this->setBorderBottom(1.0);
     55
     56    this->setTextSize(20.0);
     57    this->setBackgroundColor(1.0);
     58    this->setForegroundColor(1.0);
     59
     60    this->setFeaturePosition(FeatureLeft);
     61    this->setFont(NULL);
     62
     63    this->setAnimated(true);
     64    this->setAnimatedStateChanges(true);
     65  }
     66
    4567  void GLGuiStyle::loadParams(const TiXmlElement* root)
    46   {
    47   }
     68  {}
    4869
    4970  void GLGuiStyle::setBorderLeft(float value)
     
    5475
    5576  void GLGuiStyle::setBorderLeft(float value, OrxGui::State state)
    56 {}
     77  {
     78    _style[state]._borderLeft = value;
     79  }
    5780
    5881  void GLGuiStyle::setBorderLeftS(float value, const std::string& state)
    59   {}
     82  {
     83  }
    6084
    6185
     
    6791
    6892  void GLGuiStyle::setBorderRight(float value, OrxGui::State state)
    69 {}
     93  {
     94    _style[state]._borderRight = value;
     95  }
    7096
    7197  void GLGuiStyle::setBorderRightS(float value, const std::string& state)
     
    80106
    81107  void GLGuiStyle::setBorderTop(float value, OrxGui::State state)
    82 {}
     108  {
     109    _style[state]._borderTop = value;
     110  }
    83111
    84112  void GLGuiStyle::setBorderTopS(float value, const std::string& state)
     
    93121
    94122  void GLGuiStyle::setBorderBottom(float value, OrxGui::State state)
    95 {}
     123  {
     124    _style[state]._borderBottom = value;
     125  }
    96126
    97127  void GLGuiStyle::setBorderBottomS(float value, const std::string& state)
     
    106136
    107137  void GLGuiStyle::setTextSize(float value, OrxGui::State state)
    108 {}
     138  {
     139    _style[state]._textSize = value;
     140  }
    109141
    110142  void GLGuiStyle::setTextSizeS(float value, const std::string& state)
     
    119151
    120152  void GLGuiStyle::setBackgroundColor(const Color& color, OrxGui::State state)
    121 {}
     153  {
     154    _style[state]._backgroundColor = color;
     155  }
    122156
    123157  void GLGuiStyle::setBackgroundColorS(float r, float g, float b, float a, const std::string& state)
     
    132166
    133167  void GLGuiStyle::setBackgroundTexture(const Texture& texture, OrxGui::State state)
    134 {}
     168  {
     169    _style[state]._backgroundTexture = texture;
     170  }
    135171
    136172  void GLGuiStyle::setBackgroundTexture(const std::string& textureName, const std::string& state)
     
    145181
    146182  void GLGuiStyle::setForegroundColor(const Color& color, OrxGui::State state)
    147   {}
     183  {
     184    _style[state]._foregroundColor = color;
     185  }
    148186
    149187  void GLGuiStyle::setForegroundColorS(float r, float g, float b, float a, const std::string& state)
     
    158196
    159197  void GLGuiStyle::setFeaturePosition(const std::string& featurePosition)
    160   {
    161 
    162   }
     198  {}
    163199
    164200
     
    179215  }
    180216
    181   void GLGuiStyle::animatedStateChanges(bool animated)
     217  void GLGuiStyle::setAnimatedStateChanges(bool animated)
    182218  {
    183219    this->_animatedStateChanges = animated;
  • trunk/src/lib/gui/gl/glgui_style.h

    r8448 r8518  
    4343
    4444    /// SETUP
     45    void reset();
    4546    void loadParams(const TiXmlElement* root);
    4647
     
    8586
    8687    void setAnimated(bool animated);
    87     void animatedStateChanges(bool animated);
     88    void setAnimatedStateChanges(bool animated);
    8889
    8990  private:
  • trunk/src/lib/gui/gl/glgui_widget.h

    r8448 r8518  
    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)
  • trunk/src/story_entities/simple_game_menu.cc

    r8376 r8518  
    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  {
     
    100107    box->pack(rdnpb);
    101108
     109    OrxGui::GLGuiCheckButton* fullscreen = new OrxGui::GLGuiCheckButton("Fullscreen");
     110    fullscreen->connect(SIGNAL(fullscreen, toggled), GraphicsEngine::getInstance(), SLOT(GraphicsEngine, setFullscreen));
     111
     112    box->pack(fullscreen);
     113
    102114    OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine();
    103115    input->setText("input some text here");
    104     input->connect(SIGNAL(input, textChanged), this, SLOT(SimpleGameMenu, TEST));
     116    input->connect(SIGNAL(input, textChanged), notifier, SLOT(OrxGui::GLGuiNotifier, pushNotifyMessage));
     117
    105118    box->pack(input);
    106119
  • trunk/src/util/hud.cc

    r8448 r8518  
    2323#include "glgui_widget.h"
    2424
     25#include "glgui_inputline.h"
     26#include "specials/glgui_notifier.h"
     27
    2528/**
    2629 * standard constructor
     
    3942  this->resY = 1;
    4043
     44  this->inputLine = new OrxGui::GLGuiInputLine();
     45  this->inputLine->setParent2D(this);
     46  this->notifier = new OrxGui::GLGuiNotifier();
     47  this->notifier->setParent2D(this);
     48  notifier->setAbsCoor2D(100,100);
     49
     50
     51
    4152}
    4253
     
    4758Hud::~Hud ()
    4859{
     60  delete this->inputLine;
     61  delete this->notifier;
    4962  // delete what has to be deleted here
    5063}
     
    5669}
    5770
     71void Hud::notifyUser(const std::string& message)
     72{
     73  this->notifier->pushNotifyMessage(message);
     74}
     75
    5876void Hud::setBackGround()
    59 {
    60 }
     77{}
    6178
    6279void Hud::setEnergyWidget(OrxGui::GLGuiWidget* widget)
     
    7491    this->energyWidget->backMaterial().setDiffuseMap("hud_energy_background.png");
    7592    this->energyWidget->backMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    76 /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    77     this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     93    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     94        this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
    7895  }
    7996
     
    8299
    83100void Hud::setShiledWidget(OrxGui::GLGuiWidget* widget)
    84 {
    85 }
     101{}
    86102
    87103void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget)
    88 {
    89 }
     104{}
    90105
    91106void Hud::setWeaponManager(WeaponManager* weaponMan)
     
    123138  if (this->weaponManager != NULL)
    124139    for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++)
    125   {
    126     Weapon* weapon = this->weaponManager->getWeapon(i);
    127     if (weapon != NULL)
    128140    {
    129       weapon->getEnergyWidget()->show();
    130       weapon->getEnergyWidget()->backMaterial().setDiffuse( .8,.2,.11);
    131       weapon->getEnergyWidget()->backMaterial().setTransparency(.1);
    132       weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
    133 //      weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
    134       this->weaponsWidgets.push_back(weapon->getEnergyWidget());
     141      Weapon* weapon = this->weaponManager->getWeapon(i);
     142      if (weapon != NULL)
     143      {
     144        weapon->getEnergyWidget()->show();
     145        weapon->getEnergyWidget()->backMaterial().setDiffuse( .8,.2,.11);
     146        weapon->getEnergyWidget()->backMaterial().setTransparency(.1);
     147        weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
     148        //      weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
     149        this->weaponsWidgets.push_back(weapon->getEnergyWidget());
     150      }
    135151    }
    136   }
    137152  this->updateResolution();
    138153}
    139154
    140155void Hud::addWeaponWidget(OrxGui::GLGuiWidget* widget)
    141 {
    142 }
     156{}
    143157
    144158void Hud::removeWeaponWidget(OrxGui::GLGuiWidget* widget)
    145 {
    146 }
     159{}
    147160
    148161void Hud::updateResolution()
     
    162175  for (weaponWidget = this->weaponsWidgets.begin(); weaponWidget != this->weaponsWidgets.end(); weaponWidget++, pos+=.03)
    163176  {
    164       (*weaponWidget)->setSize2D(.02*this->resX, .2 *this->resY);
    165       (*weaponWidget)->setAbsCoor2D(pos*this->resX, .75*this->resY);
     177    (*weaponWidget)->setSize2D(.02*this->resX, .2 *this->resY);
     178    (*weaponWidget)->setAbsCoor2D(pos*this->resX, .75*this->resY);
    166179
    167180  }
     
    171184void Hud::tick(float dt)
    172185{
    173   if (this->resY != State::getResY() || this->resX != State::getResY())
     186  if (this->resY != State::getResY() || this->resX != State::getResX())
     187  {
    174188    this->updateResolution();
     189  }
     190
    175191}
    176192
    177193void Hud::draw() const
    178194{
    179 //  GLGuiWidget::draw();
     195  //  GLGuiWidget::draw();
    180196}
    181197
  • trunk/src/util/hud.h

    r8448 r8518  
    1010// FORWARD DECLARATION
    1111class TiXmlElement;
     12
    1213class WeaponManager;
    13 namespace OrxGui { class GLGuiWidget; }
     14namespace OrxGui {
     15  class GLGuiWidget;
     16  class GLGuiNotifier;
     17  class GLGuiInputLine;
     18
     19}
    1420
    1521//! A class that renders a HUD.
     
    2329
    2430  virtual void loadParams(const TiXmlElement* root);
     31
     32  void notifyUser(const std::string& message);
     33
    2534
    2635  void setBackGround();
     
    4958  OrxGui::GLGuiWidget*     armorWidget;
    5059
     60  OrxGui::GLGuiNotifier*   notifier;
     61  OrxGui::GLGuiInputLine*  inputLine;
     62
    5163  WeaponManager*           weaponManager;
    5264
Note: See TracChangeset for help on using the changeset viewer.