Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10194 in orxonox.OLD


Ignore:
Timestamp:
Jan 8, 2007, 9:19:39 PM (17 years ago)
Author:
muellmic
Message:

implementing interface 'by hand' without still buggy packing-function. can't test with spaceship because of segfault

Location:
branches/playability/src
Files:
7 edited

Legend:

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

    r10139 r10194  
    2222#include "network_log.h"
    2323
     24
    2425namespace OrxGui
    2526{
     
    188189      for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    189190      {
    190         float radDir = (*widget)->getAbsDir2D() * 2 * M_PI / 360;
    191         float realSizeX = fabsf((*widget)->getSizeX2D() * cosf(radDir)) + fabsf((*widget)->getSizeY2D() * sinf(radDir));
    192         float realSizeY = fabsf((*widget)->getSizeX2D() * sinf(radDir)) + fabsf((*widget)->getSizeY2D() * cosf(radDir));
     191        //float radDir = (*widget)->getAbsDir2D() * 2 * M_PI / 360;
     192        //float realSizeX = fabsf((*widget)->getSizeX2D() * cosf(radDir)) + fabsf((*widget)->getSizeY2D() * sinf(radDir));
     193        //float realSizeY = fabsf((*widget)->getSizeX2D() * sinf(radDir)) + fabsf((*widget)->getSizeY2D() * cosf(radDir));
     194        float realSizeX, realSizeY;
     195        int angleAbs = (int)(*widget)->getAbsDir2D();
     196        int angleRel = (int)(*widget)->getRelDir2D();
     197        //std::cout << "absangle: " << angleAbs << ", relangle: " << angleRel << '\n';
     198        if ((*widget)->getAbsDir2D() == 0 || (*widget)->getAbsDir2D() == 180)
     199        {
     200          realSizeX = (*widget)->getSizeX2D();
     201          realSizeY = (*widget)->getSizeY2D();
     202          //std::cout<<"box vertical, widget 0or180";
     203        }
     204        else if ((*widget)->getAbsDir2D() == 90 || (*widget)->getAbsDir2D() == 270)
     205        {
     206          realSizeX = (*widget)->getSizeY2D();
     207          realSizeY = (*widget)->getSizeX2D();
     208          //std::cout<<"box vertical, widget 90or270";
     209        }
    193210
    194211        (*widget)->setRelCoor2D(borderLeft(), height + borderTop());
     
    211228      for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    212229      {
    213         float radDir = (*widget)->getAbsDir2D() * 2 * M_PI / 360;
     230        //float radDir = (*widget)->getAbsDir2D() * 2 * M_PI / 360;
    214231        //std::cout << "size X: " << (*widget)->getSizeX2D() << "size Y: " << (*widget)->getSizeY2D() << '\n';
    215         float realSizeX = fabsf((*widget)->getSizeX2D() * cosf(radDir)) + fabsf((*widget)->getSizeY2D() * sinf(radDir));
    216         float realSizeY = fabsf((*widget)->getSizeX2D() * sinf(radDir)) + fabsf((*widget)->getSizeY2D() * cosf(radDir));
     232        //float realSizeX = fabsf((*widget)->getSizeX2D() * cosf(radDir)) + fabsf((*widget)->getSizeY2D() * sinf(radDir));
     233        //float realSizeY = fabsf((*widget)->getSizeX2D() * sinf(radDir)) + fabsf((*widget)->getSizeY2D() * cosf(radDir));
     234        float realSizeX, realSizeY;
     235        int angleAbs = (int)(*widget)->getAbsDir2D();
     236        int angleRel = (int)(*widget)->getRelDir2D();
     237        //std::cout << "absangle: " << angleAbs << ", relangle: " << angleRel << '\n';
     238        if ((*widget)->getAbsDir2D() == 0 || (*widget)->getAbsDir2D() == 180)
     239        {
     240          realSizeX = (*widget)->getSizeX2D();
     241          realSizeY = (*widget)->getSizeY2D();
     242          //std::cout<<"box horicontal, widget 0or180";
     243        }
     244        else if ((*widget)->getAbsDir2D() == 90 || (*widget)->getAbsDir2D() == 270)
     245        {
     246          realSizeX = (*widget)->getSizeY2D();
     247          realSizeY = (*widget)->getSizeX2D();
     248          //std::cout<<"box horicontal, widget 90or270";
     249        }
    217250
    218251        (*widget)->setRelCoor2D(width, borderTop());
  • branches/playability/src/util/hud.cc

    r10139 r10194  
    6565  this->subscribeEvent(ES_ALL, SDLK_TAB);
    6666
    67   this->shipValuesBox = NULL;
     67  //this->shipValuesBox = NULL;
    6868}
    6969
     
    7878
    7979  delete this->_radar;
    80   delete this->shipValuesBox;
     80  //if (this->shipValuesBox != NULL)
     81    //delete this->shipValuesBox;
    8182
    8283  // delete what has to be deleted here
     
    99100void Hud::setEnergyWidget(OrxGui::GLGuiWidget* widget)
    100101{
    101   if (this->shipValuesBox == NULL)
    102     this->createShipValuesBox();
     102  //if (this->shipValuesBox == NULL)
     103    //this->createShipValuesBox();
     104
    103105  // decopple old widget
    104106  if (this->energyWidget != NULL)
     
    111113  {
    112114    //this->energyWidget->shiftDir2D(270);
    113     dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics");
    114     this->shipValuesBox->pack(this->energyWidget);
     115    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics");
     116    //this->shipValuesBox->pack(this->energyWidget);
    115117    this->energyWidget->show();
    116118    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     
    123125void Hud::setShiledWidget(OrxGui::GLGuiWidget* widget)
    124126{
     127  /*
    125128  if (this->shipValuesBox == NULL)
    126129    this->createShipValuesBox();
     130  */
     131
    127132  // decopple old widget
    128133  if (this->shieldWidget != NULL)
     
    135140  {
    136141    //this->shieldWidget->shiftDir2D(270);
    137     this->shipValuesBox->pack(this->shieldWidget);
     142    //this->shipValuesBox->pack(this->shieldWidget);
    138143    this->shieldWidget->show();
    139144    /*    this->shieldWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     
    148153void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget)
    149154{
     155  /*
    150156  if (this->shipValuesBox == NULL)
    151157    this->createShipValuesBox();
     158  */
    152159
    153160// decopple old widget
     
    161168  {
    162169    //this->armorWidget->shiftDir2D(270);
    163     this->shipValuesBox->pack(this->armorWidget);
     170    //this->shipValuesBox->pack(this->armorWidget);
    164171    this->armorWidget->show();
    165172    /*    this->armorWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     
    277284    this->_radar->setRange(300);
    278285    this->_radar->show();
    279   }
    280 
    281  
     286
     287    if (this->armorWidget != NULL)
     288      this->armorWidget->setRelCoor2D(0.1*this->resX, this->armorWidget->getSizeX2D());
     289    if (this->shieldWidget != NULL)
     290      this->shieldWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeY2D(), this->armorWidget->getSizeX2D());
     291    if (this->energyWidget != NULL)
     292      this->energyWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeY2D() + this->shieldWidget->getSizeY2D(), this->armorWidget->getSizeX2D());
     293    //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D(),0);
     294    //this->energyWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0);
     295  }
     296
     297  /*
    282298  if (this->shipValuesBox != NULL)
    283299  {
     
    287303  else
    288304    createShipValuesBox();
    289 
     305  */
    290306
    291307  std::list<OrxGui::GLGuiWidget*>::iterator weaponWidget;
     
    323339}
    324340
     341/*
    325342void Hud::createShipValuesBox()
    326343{
    327   this->shipValuesBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     344  this->shipValuesBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
    328345  //this->shipValuesBox->setWidgetSize(1000,500);
    329346  //this->shipValuesBox->setBackgroundTexture("maps/gui_container_background.png");
     
    332349  this->shipValuesBox->setVisibility(true);
    333350}
    334 
    335 
     351*/
     352
     353
  • branches/playability/src/util/hud.h

    r10139 r10194  
    5959  private:
    6060    void updateResolution();
    61     void createShipValuesBox();
     61    //void createShipValuesBox();
    6262
    6363private:
     
    6868  OrxGui::GLGuiWidget*     shieldWidget;
    6969  OrxGui::GLGuiWidget*     armorWidget;
    70   OrxGui::GLGuiBox*        shipValuesBox;
     70  //OrxGui::GLGuiBox*        shipValuesBox;
    7171
    7272  OrxGui::GLGuiNotifier*   notifier;
  • branches/playability/src/world_entities/elements/glgui_energywidgetvertical.cc

    r10139 r10194  
    1919
    2020#include "multi_type.h"
     21#include <iostream>
     22#include "math.h"
    2123
    2224namespace OrxGui
     
    3335    //this->_name.setRelCoor2D(20,0);
    3436    //this->_valueText.setRelCoor2D(,0);
    35     this->shiftDir2D(270);
    36     this->setOrientation(OrxGui::Horizontal);
    37     this->pack(&this->_name);
    38     this->pack(&this->_valueText);
    39     this->_bar.setParent2D(&this->_valueText);
     37    this->setAbsDir2D(270);
     38    //std::cout << "absAngle: " << int(this->getAbsDir2D()) << ", relAngle: " << int(this->getRelDir2D()) << '\n';
     39    //this->setOrientation(OrxGui::Vertical);
    4040
    41     this->_name.setForegroundColor(Color(1,1,1,.8));
     41    //this->pack(&this->_name);
     42    //this->pack(&this->_valueText);
     43
     44    this->_image.setParent2D(this);
     45    this->_image.setSize2D(20,20);
     46    this->_image.setBackgroundColor(Color(1,1,1,.8));
     47    this->_image.setBackgroundTexture("maps/TE2.png");
     48    this->_image.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D());
     49
     50    this->_valueText.setParent2D(this);
     51    this->_valueText.setSize2D(100,20);
     52    this->_valueText.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D());
    4253    this->_valueText.setChangedTextColor(Color::white);
    43     this->_bar.setBackgroundTexture(Texture());
    4454
    4555    this->setBackgroundTexture(Texture());
    46     this->setBackgroundColor(Color(.5,.5,.5,0.5));
     56    this->setBackgroundColor(Color(.5,.5,.5,0));
     57    this->setSize2D(120,20);
    4758
    4859    //this->_name.setBackgroundTexture(Texture());
    4960    //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
     61
     62    this->_bar.setParent2D(&this->_valueText);
    5063    this->_bar.setBackgroundTexture(Texture());
    5164    this->_bar.setBackgroundColor(Color(0,0,0,0));
     
    5366    this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
    5467    this->_bar.setChangedValueColor(Color::black);
     68    this->_bar.setSize2D(100,20);
     69    this->_bar.setRelCoor2D(borderLeft(), 0);
    5570  }
    5671
     
    6176  GLGuiEnergyWidgetVertical::~GLGuiEnergyWidgetVertical ()
    6277  {
    63   }
    64 
    65 
    66   void GLGuiEnergyWidgetVertical::setDisplayedName(const std::string& name)
    67   {
    68     this->_name.setText(name);
    69     this->_bar.setWidgetSize(this->_name.getSize2D());
    7078  }
    7179
     
    8593    this->_bar.setFrontColor(Color(1,1,1,1), true);
    8694    this->_valueText.setText(val.getString());
     95    //this->_valueText.setText("asdfas");
    8796  }
    8897
    8998  void GLGuiEnergyWidgetVertical::resize()
    9099  {
    91     GLGuiBox::resize();
     100    //GLGuiBox::resize();
    92101  }
    93102
     
    95104  void GLGuiEnergyWidgetVertical::showing()
    96105  {
    97     this->_name.show();
     106    this->_image.show();
    98107    this->_valueText.show();
    99108    this->_bar.show();
     
    102111  void GLGuiEnergyWidgetVertical::hiding()
    103112  {
    104     this->_name.hide();
     113    this->_image.hide();
    105114    this->_valueText.hide();
    106115    this->_bar.hide();
  • branches/playability/src/world_entities/elements/glgui_energywidgetvertical.h

    r10107 r10194  
    1010#include "glgui_bar.h"
    1111#include "glgui_text.h"
     12#include "glgui_widget.h"
    1213
    1314namespace OrxGui
     
    1516
    1617  //! A class for ...
    17   class GLGuiEnergyWidgetVertical : public GLGuiBox
     18  class GLGuiEnergyWidgetVertical : public GLGuiWidget
    1819  {
    1920
     
    2223    virtual ~GLGuiEnergyWidgetVertical();
    2324
    24     void setDisplayedName(const std::string& name);
    2525    void setMaximum(float max);
    2626    void setValue(float value);
    2727
    28     inline GLGuiWidget* getNameWidget() {return &this->_name;};
     28    inline GLGuiWidget* getImageWidget() {return &this->_image;};
    2929    inline GLGuiWidget* getValueWidget() {return &this->_valueText;};
    3030    inline GLGuiWidget* getBarWidget() {return &this->_bar;};
     
    3636
    3737  private:
    38     GLGuiText               _name;
     38    GLGuiWidget             _image;
    3939    GLGuiText               _valueText;
    4040    GLGuiBar                _bar;
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10188 r10194  
    416416  this->secWeaponMan.showCrosshair();
    417417  this->toList( OM_GROUP_01 );
    418   dynamic_cast <OrxGui::GLGuiEnergyWidgetVertical*> (State::getPlayer()->hud().getArmorWidget())->setDisplayedName("Armor");
     418  //dynamic_cast <OrxGui::GLGuiEnergyWidgetVertical*> (State::getPlayer()->hud().getArmorWidget())->setDisplayedName("Armor");
    419419  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
    420420  //this->attachCamera();
     
    10471047  { //create the widget
    10481048    this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    1049     this->electronicWidget->setDisplayedName("Electronics:");
     1049    //this->electronicWidget->setDisplayedName("Electronics:");
    10501050    //this->electronicWidget->setSize2D(100,20);
    10511051    //this->electronicWidget->setAbsCoor2D(150,200);
     
    10661066  {
    10671067    this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    1068     this->shieldWidget->setDisplayedName("Shield:");
     1068    //this->shieldWidget->setDisplayedName("Shield:");
    10691069    //his->shieldWidget->setSize2D(100,20);
    10701070    //this->shieldWidget->setAbsCoor2D(200,200);
  • branches/playability/src/world_entities/world_entity.cc

    r10139 r10194  
    752752  {
    753753    this->healthWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    754     this->healthWidget->setDisplayedName("Health");
     754    //this->healthWidget->setDisplayedName("Health");
    755755    //this->healthWidget->setSize2D(100,20);
    756756    //this->healthWidget->setAbsCoor2D(100,200);
Note: See TracChangeset for help on using the changeset viewer.