Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6438 in orxonox.OLD


Ignore:
Timestamp:
Jan 8, 2006, 1:51:55 PM (18 years ago)
Author:
bensch
Message:

trunk: widget war

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/gui/gl_gui/glgui_widget.h

    r6431 r6438  
    6363    virtual void removeFocus() {};
    6464
    65     virtual void update() = 0;
     65    virtual void update() {};
    6666    virtual void draw() const;
    6767
  • trunk/src/util/hud.cc

    r6437 r6438  
    2727Hud::Hud ()
    2828{
    29    this->setClassID(CL_HUD, "Hud");
     29  this->setClassID(CL_HUD, "Hud");
    3030
    3131}
     
    3939  // delete what has to be deleted here
    4040}
     41
     42
     43void Hud::loadParams(const TiXmlElement* root)
     44{
     45
     46}
     47
     48void Hud::setBackGround()
     49{
     50
     51}
     52
     53void Hud::setEnergyWidget(GLGuiWidget* widget)
     54{
     55
     56}
     57
     58void Hud::setShiledWidget(GLGuiWidget* widget)
     59{
     60
     61}
     62
     63void Hud::setArmorWidget(GLGuiWidget* widget)
     64{
     65
     66}
     67
     68void Hud::addWeaponWidget(GLGuiWidget* widget)
     69{
     70
     71}
     72
     73void Hud::removeWeaponWidget(GLGuiWidget* widget)
     74{
     75
     76}
     77
     78void setResolution(unsigned int resX, unsigned int resY);
  • trunk/src/util/hud.h

    r6437 r6438  
    77#define _HUD_H
    88
    9 #include "element_2d.h"
     9#include "glgui_widget.h"
    1010#include <list>
    1111
    1212// FORWARD DECLARATION
    13 #include "glgui_widget.h"
    14 
     13class TiXmlElement;
    1514
    1615
    1716//! A class that renders a HUD.
    18 class Hud : private GLGuiWidget {
     17class Hud : private GLGuiWidget
     18{
    1919
    20  public:
     20public:
    2121  Hud();
    2222  virtual ~Hud();
     23
     24  void loadParams(const TiXmlElement* root);
    2325
    2426  void setBackGround();
     
    3032  void removeWeaponWidget(GLGuiWidget* widget);
    3133
     34  void setResolution(unsigned int resX, unsigned int resY);
    3235
    33  private:
    34    unsigned int             resX;          //!< The X-Resolution needed for resizing the Hud.
    35    unsigned int             resY;          //!< The Y-Resolution needed for resizing the Hud.
     36private:
     37  unsigned int             resX;          //!< The X-Resolution needed for resizing the Hud.
     38  unsigned int             resY;          //!< The Y-Resolution needed for resizing the Hud.
    3639
    37    GLGuiWidget*             energyWidget;
    38    GLGuiWidget*             shieldWidget;
    39    GLGuiWidget*             armorWidget;
     40  GLGuiWidget*             energyWidget;
     41  GLGuiWidget*             shieldWidget;
     42  GLGuiWidget*             armorWidget;
    4043
    41    std::list<GLGuiWidget*>  weaponsWidgets; //!< WeaponWidgets will be displayed one after another
     44  std::list<GLGuiWidget*>  weaponsWidgets; //!< WeaponWidgets will be displayed one after another
    4245};
    4346
  • trunk/src/world_entities/player.cc

    r6241 r6438  
    2222#include "class_list.h"
    2323#include "state.h"
     24#include "util/hud.h"
    2425
    2526using namespace std;
     
    5657
    5758  this->controllable = NULL;
     59  this->hud = new Hud();
    5860}
    5961
     
    9597         if (this->controllable != (*node) && (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->controllable->getAbsCoor()).len() < 10.0)
    9698       {
    97  
     99
    98100         this->disconnectControllable();
    99101         this->setControllable(dynamic_cast<Playable*>(*node));
  • trunk/src/world_entities/player.h

    r5915 r6438  
    1111/* Forward Declaration */
    1212class Playable;
     13class Hud;
    1314
    1415//! Basic controllable WorldEntity
     
    3940  private:
    4041    Playable*         controllable;                  //!< The one we controll or NULL if none
     42    Hud*              hud;                           //!< The HUD to be displayed.
    4143};
    4244
  • trunk/src/world_entities/weapons/turret.cc

    r6435 r6438  
    9696  this->setEmissionPoint(1.684, 0.472, 0);
    9797  //this->getProjectileFactory()->prepare(100);
    98 
    99   this->bar = new GLGuiBar;
    100   this->bar->setSize2D( 20, 100);
    101   this->bar->setMaximum(this->getEnergyMax());
    102   this->bar->setValue(this->getEnergy());
    103   this->loadedBar = new GLGuiBar;
    104   this->loadedBar->setParent2D(this->bar);
    105   this->loadedBar->setRelCoor2D(20,0);
    106   this->loadedBar->setSize2D(10,50);
    107   this->loadedBar->setMaximum(this->getLoadedEnergyMax());
    10898}
    10999
     
    116106void Turret::activate()
    117107{
    118   this->bar->show();
    119   this->loadedBar->show();
    120108}
    121109
    122110void Turret::deactivate()
    123111{
    124   this->bar->hide();
    125   this->loadedBar->hide();
    126112}
    127113
     
    156142  pj->setAbsDir(this->getAbsDir());
    157143  pj->activate();
    158 
    159   this->bar->setValue( this->getEnergy());
    160   this->loadedBar->setValue(this->getLoadedEnergy());
    161144}
    162145
  • trunk/src/world_entities/weapons/turret.h

    r6306 r6438  
    88
    99#include "weapon.h"
    10 
    11 #include "glgui_bar.h"
    1210
    1311class Turret : public Weapon
     
    3028
    3129  private:
    32     GLGuiBar*    bar;
    33     GLGuiBar*    loadedBar;
    3430  };
    3531
  • trunk/src/world_entities/weapons/weapon.cc

    r6435 r6438  
    3434#include "sound_buffer.h"
    3535
     36#include "glgui_bar.h"
     37
    3638////////////////////
    3739// INITAILISATION //
     
    7577  this->stateDuration    = 0.0;                    //< All the States have zero duration
    7678  for (int i = 0; i < WS_STATE_COUNT; i++)         //< Every State has:
    77     {
    78       this->times[i] = 0.0;                        //< An infinitesimal duration
    79       this->animation[i] = NULL;                   //< No animation
    80     }
     79  {
     80    this->times[i] = 0.0;                        //< An infinitesimal duration
     81    this->animation[i] = NULL;                   //< No animation
     82  }
    8183  for (int i = 0; i < WA_ACTION_COUNT; i++)
    8284    this->soundBuffers[i] = NULL;                  //< No Sounds
     
    98100  this->energyMax = 10.0;                          //< How much energy can be carried
    99101  this->capability = WTYPE_ALL;                    //< The Weapon has all capabilities @see W_Capability.
     102
     103  this->energyWidget = NULL;
     104  this->energyLoadedWidget = NULL;
    100105}
    101106
     
    109114
    110115  LoadParam(root, "projectile", this, Weapon, setProjectileType)
    111       .describe("Sets the name of the Projectile to load onto the Entity");
     116  .describe("Sets the name of the Projectile to load onto the Entity");
    112117
    113118  LoadParam(root, "emission-point", this, Weapon, setEmissionPoint)
    114       .describe("Sets the Point of emission of this weapon");
     119  .describe("Sets the Point of emission of this weapon");
    115120
    116121  LoadParam(root, "state-duration", this, Weapon, setStateDuration)
    117       .describe("Sets the duration of a given state (1: state-Name; 2: duration in seconds)");
     122  .describe("Sets the duration of a given state (1: state-Name; 2: duration in seconds)");
    118123
    119124  LoadParam(root, "action-sound", this, Weapon, setActionSound)
    120       .describe("Sets a given sound to an action (1: action-Name; 2: name of the sound (relative to the Data-Path))");
     125  .describe("Sets a given sound to an action (1: action-Name; 2: name of the sound (relative to the Data-Path))");
    121126}
    122127
     
    271276}
    272277
     278GLGuiWidget* Weapon::getEnergyWidget()
     279{
     280  if (this->energyWidget == NULL)
     281  {
     282    this->energyWidget = new GLGuiBar;
     283    this->energyWidget->setSize2D( 20, 100);
     284    this->energyWidget->setMaximum(this->getEnergyMax());
     285    this->energyWidget->setValue(this->getEnergy());
     286  }
     287  return this->energyWidget;
     288}
     289
     290
     291GLGuiWidget* Weapon::getMaxEnergyWidget()
     292{
     293  if (this->energyLoadedWidget == NULL)
     294  {
     295    this->energyLoadedWidget = new GLGuiBar;
     296    //this->energyLoadedWidget->setParent2D(this->bar);
     297    this->energyLoadedWidget->setRelCoor2D(20,0);
     298    this->energyLoadedWidget->setSize2D(10,50);
     299    this->energyLoadedWidget->setMaximum(this->getLoadedEnergyMax());
     300  }
     301  return this->energyLoadedWidget;
     302}
     303
     304void Weapon::updateWidgets()
     305{
     306  if (this->energyWidget != NULL)
     307  {
     308    this->energyWidget->setMaximum(this->energyMax);
     309    this->energyWidget->setValue(this->energy);
     310  }
     311  if (this->energyLoadedWidget != NULL)
     312  {
     313    this->energyLoadedWidget->setMaximum(this->energyLoadedMax);
     314    this->energyLoadedWidget->setValue(this->energyLoaded);
     315  }
     316}
     317
    273318/////////////////
    274319//  EXECUTION  //
     
    371416bool Weapon::activateW()
    372417{
    373 //  if (this->currentState == WS_INACTIVE)
     418  //  if (this->currentState == WS_INACTIVE)
    374419  {
    375420    // play Sound
    376421    if (likely(this->soundBuffers[WA_ACTIVATE] != NULL))
    377422      this->soundSource->play(this->soundBuffers[WA_ACTIVATE]);
    378         // activate
     423    // activate
    379424    PRINTF(4)("Activating the Weapon %s\n", this->getName());
    380425    this->activate();
     
    390435bool Weapon::deactivateW()
    391436{
    392 //  if (this->currentState != WS_INACTIVE)
     437  //  if (this->currentState != WS_INACTIVE)
    393438  {
    394439    PRINTF(4)("Deactivating the Weapon %s\n", this->getName());
    395         // play Sound
     440    // play Sound
    396441    if (this->soundBuffers[WA_DEACTIVATE] != NULL)
    397442      this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]);
     
    410455  if ( this->currentState != WS_INACTIVE && this->energyLoaded >= this->minCharge)
    411456  {
    412         // playing Sound
     457    // playing Sound
    413458    if (this->soundBuffers[WA_CHARGE] != NULL)
    414459      this->soundSource->play(this->soundBuffers[WA_CHARGE]);
    415460
    416         // charge
     461    // charge
    417462    this->charge();
    418         // setting up for the next state
     463    // setting up for the next state
    419464    this->enterState(WS_CHARGING);
    420465  }
     
    431476bool Weapon::fireW()
    432477{
    433      //if (likely(this->currentState != WS_INACTIVE))
     478  //if (likely(this->currentState != WS_INACTIVE))
    434479  if (this->minCharge <= this->energyLoaded)
    435480  {
    436           // playing Sound
     481    // playing Sound
    437482    if (this->soundBuffers[WA_SHOOT] != NULL)
    438483      this->soundSource->play(this->soundBuffers[WA_SHOOT]);
    439           // fire
     484    // fire
    440485    this->energyLoaded -= this->minCharge;
    441486    this->fire();
    442           // setting up for the next state
     487    // setting up for the next state
    443488    this->enterState(WS_SHOOTING);
    444489  }
     
    546591  bool retVal = true;
    547592
    548 //  if (this->projectile == NULL)
     593  //  if (this->projectile == NULL)
    549594  {
    550595    PRINTF(1)("There was no projectile assigned to the Weapon.\n");
     
    565610  PRINT(0)("Weapon-Debug %s, state: %s (duration: %fs), nextAction: %s\n", this->getName(), Weapon::stateToChar(this->currentState), this->stateDuration, Weapon::actionToChar(requestedAction));
    566611  PRINT(0)("Energy: max: %f; current: %f;  loadedMax: %f; loadedCurrent: %f; chargeMin: %f, chargeMax %f\n",
    567             this->energyMax, this->energy, this->energyLoadedMax, this->energyLoaded, this->minCharge, this->maxCharge);
     612           this->energyMax, this->energy, this->energyLoadedMax, this->energyLoaded, this->minCharge, this->maxCharge);
    568613
    569614
     
    595640    return WA_SPECIAL1;
    596641  else
    597     {
    598       PRINTF(2)("action %s could not be identified.\n", action);
    599       return WA_NONE;
    600     }
     642  {
     643    PRINTF(2)("action %s could not be identified.\n", action);
     644    return WA_NONE;
     645  }
    601646}
    602647
     
    658703    return WS_IDLE;
    659704  else
    660     {
    661       PRINTF(2)("state %s could not be identified.\n", state);
    662       return WS_NONE;
    663     }
     705  {
     706    PRINTF(2)("state %s could not be identified.\n", state);
     707    return WS_NONE;
     708  }
    664709}
    665710
  • trunk/src/world_entities/weapons/weapon.h

    r6435 r6438  
    2424class FastFactory;
    2525template<class T> class tFastFactory;
     26class GLGuiWidget;
    2627
    2728//! An enumerator defining Actions a Weapon can take
     
    148149    Animation3D* copyAnimation(WeaponState from, WeaponState to);
    149150
     151    GLGuiWidget* getEnergyWidget();
     152    GLGuiWidget* getMaxEnergyWidget();
     153
    150154    // FLOW
    151155    void tick(float dt); //!< this is a function that must be called by the weaponManager, or any other weaponHandler, all other functions are handled from within
     
    183187    bool fireW();
    184188    bool reloadW();
    185 
    186189    inline void enterState(WeaponState state);
    187190
     191    void updateWidgets();
    188192
    189193  private:
     
    200204    float                maxCharge;                        //!< The maximal energy to be loaded onto one projectile (this is only availible if chargeable is enabled)
    201205
     206    GLGuiBar*            energyWidget;
     207    GLGuiBar*            energyLoadedWidget;
     208
    202209    ////////////
    203210    // PHASES //
Note: See TracChangeset for help on using the changeset viewer.