Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10120 in orxonox.OLD


Ignore:
Timestamp:
Dec 20, 2006, 12:02:01 PM (17 years ago)
Author:
muellmic
Message:

some interface hacks

Location:
branches/playability/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/util/hud.cc

    r10111 r10120  
    2424#include "glgui_widget.h"
    2525#include "glgui_box.h"
     26#include "elements/glgui_energywidgetvertical.h"
    2627
    2728#include "glgui_inputline.h"
     
    108109    this->energyWidget->show();
    109110    this->energyWidget->shiftDir2D(270);
    110     //this->energyWidget->setDisplayedName("Electronics")
     111    dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics");
    111112    this->shipValuesBox->pack(this->energyWidget);
    112113    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     
    118119
    119120void Hud::setShiledWidget(OrxGui::GLGuiWidget* widget)
    120 {}
     121{
     122  // decopple old widget
     123  if (this->shieldWidget != NULL)
     124  {
     125    this->shieldWidget->hide();
     126  }
     127
     128  this->shieldWidget = widget;
     129  if (this->shieldWidget != NULL)
     130  {
     131    this->shieldWidget->show();
     132    this->shieldWidget->shiftDir2D(270);
     133    this->shipValuesBox->pack(this->shieldWidget);
     134    /*    this->shieldWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     135        this->shieldWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     136  }
     137
     138  this->updateResolution();
     139}
    121140
    122141void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget)
    123 {}
     142{
     143// decopple old widget
     144  if (this->armorWidget != NULL)
     145  {
     146    this->armorWidget->hide();
     147  }
     148
     149  this->armorWidget = widget;
     150  if (this->armorWidget != NULL)
     151  {
     152    this->armorWidget->show();
     153    this->armorWidget->shiftDir2D(270);
     154    //this->shipValuesBox->pack(this->armorWidget);
     155    /*    this->armorWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     156        this->armorWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     157  }
     158
     159  this->updateResolution();
     160}
    124161
    125162void Hud::setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec)
     
    235272  if (this->shipValuesBox != NULL)
    236273  {
    237     this->shipValuesBox->setAbsCoor2D(0.2 * this->resX, 0.85 * this->resY);
     274    this->shipValuesBox->setAbsCoor2D(0.8 * this->resX, 0.85 * this->resY);
    238275    this->shipValuesBox->setWidgetSize(.4 * this->resX, 0.1 * this->resY);
    239276  }
  • branches/playability/src/world_entities/elements/glgui_energywidgetvertical.cc

    r10111 r10120  
    3232
    3333    this->_bar.setSize2D(100, 30);
    34     this->_name.setRelCoor2D(20,0);
     34    this->_name.setRelCoor2D(200,0);
    3535    this->_valueText.setRelCoor2D(22,0);
    3636
  • branches/playability/src/world_entities/player.cc

    r10030 r10120  
    7474    PRINTF(4)("Enter new Playable\n");
    7575    this->playable = playable;
    76     this->_hud.setEnergyWidget(this->playable->getHealthWidget());
     76    this->_hud.setArmorWidget(this->playable->getHealthWidget());
    7777    if (dynamic_cast<SpaceShip*>(this->playable) != 0)
    7878      this->_hud.setWeaponManager(&this->playable->getWeaponManager(), &dynamic_cast<SpaceShip*>(this->playable)->getWeaponManagerSecondary());
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10119 r10120  
    3030#include "weapons/turret.h"
    3131#include "weapons/cannon.h"
     32
     33#include "elements/glgui_energywidgetvertical.h"
    3234
    3335#include "particles/dot_emitter.h"
     
    238240  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    239241
    240 
     242  // widget handling
     243  this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     244  this->electronicWidget->setDisplayedName(std::string(this->getClassName()) + " Electronics:");
     245  this->electronicWidget->setSize2D(30,400);
     246  this->electronicWidget->setAbsCoor2D(150,200);
     247  this->electronicWidget->shiftDir2D(270);
     248  this->updateElectronicWidget();
     249  this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     250  this->shieldWidget->setDisplayedName(std::string(this->getClassName()) + " Shield:");
     251  this->shieldWidget->setSize2D(30,400);
     252  this->shieldWidget->setAbsCoor2D(200,200);
     253  this->shieldWidget->shiftDir2D(270);
     254  this->updateShieldWidget();
     255  if (this->hasPlayer())
     256  {
     257    State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
     258    State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
     259  }
    241260
    242261  //add events to the eventlist
     
    694713    this->destroy(this);
    695714
     715  updateElectronicWidget();
     716  updateShieldWidget();
     717
    696718  this->setHealth( this->armorCur);
    697719}
     
    714736      this->shieldCur = tmp;
    715737    this->shieldActive = ( this->shieldActive || this->shieldCur > shieldTH);
     738
     739    updateShieldWidget();
    716740  }
    717741
     
    724748    else
    725749      this->electronicCur = tmp;
    726   }
     750
     751    updateElectronicWidget();
     752  }
     753
    727754}
    728755
     
    9931020  //this->collidesWith(killer, this->getAbsCoor());
    9941021}
     1022
     1023void SpaceShip::updateElectronicWidget()
     1024{
     1025  this->electronicWidget->setMaximum(this->electronicMax);
     1026  this->electronicWidget->setValue(this->electronicCur);
     1027  if (this->hasPlayer())
     1028    this->electronicWidget->show();
     1029}
     1030
     1031void SpaceShip::updateShieldWidget()
     1032{
     1033  this->shieldWidget->setMaximum(this->shieldMax);
     1034  this->shieldWidget->setValue(this->shieldCur);
     1035  if (this->hasPlayer())
     1036    this->shieldWidget->show();
     1037}
  • branches/playability/src/world_entities/space_ships/space_ship.h

    r10117 r10120  
    7575    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
    7676
     77    //included by Michel: ((
    7778    virtual void enterPlaymode(Playable::Playmode playmode);
    78     void setPlaymodeXML(const std::string& playmode);
     79    void setPlaymodeXML(const std::string& playmode); //recieves the playmode from a string (useful for script implementation)
    7980    virtual void movement (float dt);
     81
     82    //))
    8083
    8184    void nextWeaponConfig();
     
    9497
    9598    inline bool systemFailure() {  return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };
     99
     100    void updateElectronicWidget();
     101    void updateShieldWidget();
    96102
    97103    //WeaponManager         weaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
     
    107113    float       shieldTH;           //!< shield threshhold for reactivation
    108114    bool        shieldActive;       //!< wheather the shield is working
     115    OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar
    109116
    110117    float       armorCur;           //!< current armor
    111118    float       armorMax;           //!< maximum armor
    112119    float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
     120    //note that the armor widget is set on the health- widget in world- entity (see in player.cc)
    113121
    114122    float       electronicCur;      //!< current electronic
     
    116124    float       electronicRegen;    //!< electronic regenration rate per tick
    117125    float       electronicTH;       //!< Threshhold for electronic failure
     126    OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar
    118127
    119128    float       engineSpeedCur;     //!< speed output for movement = speed base + energy share part
  • branches/playability/src/world_entities/world_entity.cc

    r10113 r10120  
    752752  {
    753753    this->healthWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    754     this->healthWidget->setDisplayedName(std::string(this->getClassName()) + " Energy:");
     754    this->healthWidget->setDisplayedName("Electronics");
    755755    this->healthWidget->setSize2D(30,400);
    756     this->healthWidget->setAbsCoor2D(10,100);
     756    this->healthWidget->setAbsCoor2D(100,200);
    757757
    758758    this->updateHealthWidget();
Note: See TracChangeset for help on using the changeset viewer.