Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8983 in orxonox.OLD


Ignore:
Timestamp:
Jul 1, 2006, 4:12:44 PM (18 years ago)
Author:
bensch
Message:

blend-stuff

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/gui/gl/glgui_bar.cc

    r8974 r8983  
    1818#include "glgui_bar.h"
    1919
     20#include "debug.h"
    2021
    2122namespace OrxGui
     
    3637   */
    3738  GLGuiBar::~GLGuiBar()
    38   {
    39   }
     39  {}
    4040
    4141  /**
     
    5050    this->setSize2D(50, 10);
    5151
    52     this->value = 0.5f;
    53     this->minimum = 0.0f;
    54     this->maximum = 1.0f;
     52    this->_minimum = 0.0f;
     53    this->_maximum = 1.0f;
     54    this->setValue(0.5f);
     55    this->resize();
     56  }
     57
     58  void GLGuiBar::setValue(float value)
     59  {
     60    if (value > _maximum)
     61    {
     62      value = _maximum;
     63      PRINTF(2)("Oversteped range, set Value to %f\n", _maximum);
     64    }
     65    if (value < _minimum)
     66    {
     67      value = _minimum;
     68      PRINTF(2)("Oversteped range, set Value to %f\n", _minimum);
     69    }
     70
     71    this->_value = value;
     72
     73    this->_frontRect.setRight(this->getSizeX2D() * (_value -_minimum)/ (_minimum + _maximum));
     74  }
     75  void GLGuiBar::setMinimum(float minimum)
     76  {
     77    this->_minimum = minimum;
     78  }
     79  void GLGuiBar::setMaximum(float maximum)
     80  {
     81    this->_maximum = maximum;
     82  }
     83  void GLGuiBar::setRange(float minimum, float maximum)
     84  {
     85    this->setMinimum(minimum);
     86    this->setMaximum(maximum);
    5587  }
    5688
     
    5991    GLGuiWidget::resize();
    6092
     93    this->_frontRect.setTopLeft(borderLeft(), borderTop());
     94    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
     95                             ,this->getSizeY2D() - borderTop() - borderBottom());
    6196
    6297  }
     98
     99  void GLGuiBar::updateFrontColor()
     100  {
     101    this->font().setDiffuseColor(Color());
     102  }
     103
    63104
    64105
     
    71112    GLGuiWidget::draw();
    72113
     114    this->font().select();
     115    glDisable(GL_BLEND);
     116    this->drawRect(this->_frontRect);
     117
    73118    this->endDraw();
    74119  }
  • trunk/src/lib/gui/gl/glgui_bar.h

    r8972 r8983  
    2626    virtual ~GLGuiBar();
    2727
    28     void setValue(float value) { this->value = value; };
    29     void setMinimum(float minimum) { this->minimum = minimum; };
    30     void setMaximum(float maximum) { this->maximum = maximum; };
     28    void setValue(float value);
     29    void setMinimum(float minimum);
     30    void setMaximum(float maximum);
     31    void setRange(float minimum, float maximum);
    3132
    32     float getValue() const { return this->value; };
    33     float getMinimum() const { return this->minimum; };
    34     float getMaximum() const { return this->maximum; };
     33    float getValue() const { return this->_value; };
     34    float getMinimum() const { return this->_minimum; };
     35    float getMaximum() const { return this->_maximum; };
    3536
    3637    virtual void update() { };
     
    3940  protected:
    4041    virtual void resize();
     42    virtual void updateFrontColor();
    4143
    4244  private:
     
    4446
    4547  private:
    46     float value;
     48    float         _value;
    4749
    48     float minimum;
    49     float maximum;
     50    Rect2D        _frontRect;
     51
     52    float         _minimum;
     53    float         _maximum;
    5054  };
    5155}
  • trunk/src/lib/gui/gl/glgui_widget.h

    r8769 r8983  
    119119    /** @returns FeaturePosition */
    120120    inline FeaturePosition featurePosition() const { return _featurePosition; }
     121    /** @returns the constant font */
     122    inline const Font& font() const { return _font; }
    121123    /** @returns the font */
    122     inline const Font& font() const { return _font; }
     124    inline Font& font() { return _font; }
    123125    /** @returns true if the Element is Animated */
    124126    inline bool animating() const { return _animating; }
  • trunk/src/world_entities/elements/glgui_energywidget.cc

    r8981 r8983  
    2626  {
    2727    //   this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget");
     28
     29    this->_bar.setSize2D(100, 30);
    2830    this->pack(&this->_name);
    2931    this->pack(&this->_valueText);
     
    3638    this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
    3739    this->_bar.setBackgroundTexture(Texture());
     40    this->_bar.setBackgroundColor(Color(0,0,0,0));
     41    this->_bar.setForegroundColor(Color(1, 1, 1, 1));
     42    this->_bar.font().setBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
    3843  }
    3944
     
    5055  {
    5156    this->_name.setText(name);
     57    this->_bar.setWidgetSize(this->_name.getSize2D());
    5258  }
    5359
  • trunk/src/world_entities/weapons/test_gun.cc

    r8777 r8983  
    3232
    3333#include "fast_factory.h"
    34 
    35 
    36 using namespace std;
    3734
    3835CREATE_FACTORY(TestGun, CL_TEST_GUN);
     
    123120  this->setStateDuration(WS_DEACTIVATING, .4);
    124121
    125   this->setEnergyMax(100000);
    126   this->increaseEnergy(100000);
     122  this->setEnergyMax(10000);
     123  this->increaseEnergy(1000);
    127124  //this->minCharge = 2;
    128125
     
    133130  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    134131  this->setProjectileType(CL_LASER);
    135   this->prepareProjectiles(20);
     132  this->prepareProjectiles(100);
    136133
    137134}
Note: See TracChangeset for help on using the changeset viewer.