Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10139 in orxonox.OLD


Ignore:
Timestamp:
Dec 22, 2006, 12:21:38 AM (13 years ago)
Author:
muellmic
Message:

trying to adjust interface

Location:
branches/playability/src
Files:
7 edited

Legend:

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

    r9869 r10139  
    7171
    7272    this->_value = value;
    73     this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
     73    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum) / (_maximum -_minimum)
    7474        ,this->getSizeY2D() - borderTop() - borderBottom());
    7575  }
     
    9999
    100100    this->_frontRect.setTopLeft(borderLeft(), borderTop());
    101     this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
    102                              ,this->getSizeY2D() - borderTop() - borderBottom());
     101    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum) / (_maximum -_minimum)
     102        ,this->getSizeY2D() - borderTop() - borderBottom());
    103103
    104104  }
  • branches/playability/src/lib/gui/gl/glgui_box.cc

    r9869 r10139  
    1818#include "glgui_box.h"
    1919#include <cassert>
     20#include <iostream>
    2021#include "debug.h"
     22#include "network_log.h"
    2123
    2224namespace OrxGui
     
    177179  void GLGuiBox::resize()
    178180  {
    179     if (orientation() == OrxGui::Vertical)
     181    if (this->orientation() == OrxGui::Vertical)
    180182    {
    181183      float height = borderTop();
     
    186188      for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    187189      {
    188         (*widget)->setRelCoor2D(borderLeft(), height);
    189         height += (*widget)->getSizeY2D();
    190         width = fmax(width, (*widget)->getSizeX2D());
     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));
     193
     194        (*widget)->setRelCoor2D(borderLeft(), height + borderTop());
     195        height += realSizeY;
     196        width = fmax(width, realSizeX);
    191197      }
    192198
     
    205211      for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    206212      {
     213        float radDir = (*widget)->getAbsDir2D() * 2 * M_PI / 360;
     214        //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));
     217
    207218        (*widget)->setRelCoor2D(width, borderTop());
    208         height = fmax(height, (*widget)->getSizeY2D());
    209         width += (*widget)->getSizeX2D();
     219        height = fmax(height, realSizeY);
     220        width += realSizeX;
    210221      }
    211222
  • branches/playability/src/util/hud.cc

    r10120 r10139  
    6565  this->subscribeEvent(ES_ALL, SDLK_TAB);
    6666
    67   this->shipValuesBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
    68   this->shipValuesBox->setBackgroundTexture("maps/gui_container_background.png");
     67  this->shipValuesBox = NULL;
    6968}
    7069
     
    7978
    8079  delete this->_radar;
     80  delete this->shipValuesBox;
     81
    8182  // delete what has to be deleted here
    8283}
     
    9899void Hud::setEnergyWidget(OrxGui::GLGuiWidget* widget)
    99100{
     101  if (this->shipValuesBox == NULL)
     102    this->createShipValuesBox();
    100103  // decopple old widget
    101104  if (this->energyWidget != NULL)
     
    107110  if (this->energyWidget != NULL)
    108111  {
    109     this->energyWidget->show();
    110     this->energyWidget->shiftDir2D(270);
     112    //this->energyWidget->shiftDir2D(270);
    111113    dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics");
    112114    this->shipValuesBox->pack(this->energyWidget);
     115    this->energyWidget->show();
    113116    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    114117        this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     
    120123void Hud::setShiledWidget(OrxGui::GLGuiWidget* widget)
    121124{
     125  if (this->shipValuesBox == NULL)
     126    this->createShipValuesBox();
    122127  // decopple old widget
    123128  if (this->shieldWidget != NULL)
     
    129134  if (this->shieldWidget != NULL)
    130135  {
     136    //this->shieldWidget->shiftDir2D(270);
     137    this->shipValuesBox->pack(this->shieldWidget);
    131138    this->shieldWidget->show();
    132     this->shieldWidget->shiftDir2D(270);
    133     this->shipValuesBox->pack(this->shieldWidget);
    134139    /*    this->shieldWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    135140        this->shieldWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
    136141  }
     142  else
     143    printf("schild im hud nicht uebergeben!!!!!!!!!!!!!!!!!!!!!!!!!");
    137144
    138145  this->updateResolution();
     
    141148void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget)
    142149{
     150  if (this->shipValuesBox == NULL)
     151    this->createShipValuesBox();
     152
    143153// decopple old widget
    144154  if (this->armorWidget != NULL)
     
    150160  if (this->armorWidget != NULL)
    151161  {
     162    //this->armorWidget->shiftDir2D(270);
     163    this->shipValuesBox->pack(this->armorWidget);
    152164    this->armorWidget->show();
    153     this->armorWidget->shiftDir2D(270);
    154     //this->shipValuesBox->pack(this->armorWidget);
    155165    /*    this->armorWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    156166        this->armorWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     
    272282  if (this->shipValuesBox != NULL)
    273283  {
    274     this->shipValuesBox->setAbsCoor2D(0.8 * this->resX, 0.85 * this->resY);
     284    this->shipValuesBox->setAbsCoor2D(0.2 * this->resX, 0.4 * this->resY);
    275285    this->shipValuesBox->setWidgetSize(.4 * this->resX, 0.1 * this->resY);
    276286  }
     287  else
     288    createShipValuesBox();
    277289
    278290
     
    309321  //  this->inputLine->select();
    310322  }
    311 
    312 
    313 }
    314 
    315 
     323}
     324
     325void Hud::createShipValuesBox()
     326{
     327  this->shipValuesBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     328  //this->shipValuesBox->setWidgetSize(1000,500);
     329  //this->shipValuesBox->setBackgroundTexture("maps/gui_container_background.png");
     330  this->shipValuesBox->setBackgroundTexture(Texture());
     331  this->shipValuesBox->setBackgroundColor(Color(0,0,1,0.5));
     332  this->shipValuesBox->setVisibility(true);
     333}
     334
     335
  • branches/playability/src/util/hud.h

    r10111 r10139  
    4040  void setShiledWidget(OrxGui::GLGuiWidget* widget);
    4141  void setArmorWidget(OrxGui::GLGuiWidget* widget);
     42  inline OrxGui::GLGuiWidget* getEnergyWidget() {return this->energyWidget;};
     43  inline OrxGui::GLGuiWidget* getShieldWidget() {return this->shieldWidget;};
     44  inline OrxGui::GLGuiWidget* getArmorWidget() {return this->armorWidget;};
     45
    4246  void setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec = NULL);
    4347
     
    5559  private:
    5660    void updateResolution();
     61    void createShipValuesBox();
    5762
    5863private:
  • branches/playability/src/world_entities/elements/glgui_energywidgetvertical.cc

    r10120 r10139  
    2929    //   this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget");
    3030
    31    
    32 
    33     this->_bar.setSize2D(100, 30);
    34     this->_name.setRelCoor2D(200,0);
    35     this->_valueText.setRelCoor2D(22,0);
    36 
     31    //this->_bar.setSize2D(100, 30);
     32    //this->_bar.setRelCoor2D(-10,0);
     33    //this->_name.setRelCoor2D(20,0);
     34    //this->_valueText.setRelCoor2D(,0);
     35    this->shiftDir2D(270);
     36    this->setOrientation(OrxGui::Horizontal);
    3737    this->pack(&this->_name);
    3838    this->pack(&this->_valueText);
     
    4444
    4545    this->setBackgroundTexture(Texture());
    46     this->setBackgroundColor(Color(.5,.5,.5,0));
     46    this->setBackgroundColor(Color(.5,.5,.5,0.5));
    4747
    4848    //this->_name.setBackgroundTexture(Texture());
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10133 r10139  
    232232
    233233  // widget handling
     234  /*
    234235  this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    235236  this->electronicWidget->setDisplayedName(std::string(this->getClassName()) + " Electronics:");
     
    249250    State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
    250251  }
     252  */
     253  this->electronicWidget = NULL;
     254  this->shieldWidget = NULL;
    251255
    252256  //add events to the eventlist
     
    392396  this->secWeaponMan.showCrosshair();
    393397  this->toList( OM_GROUP_01 );
     398  dynamic_cast <OrxGui::GLGuiEnergyWidgetVertical*> (State::getPlayer()->hud().getArmorWidget())->setDisplayedName("Armor");
    394399  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
    395400  //this->attachCamera();
     
    10141019void SpaceShip::updateElectronicWidget()
    10151020{
    1016   this->electronicWidget->setMaximum(this->electronicMax);
    1017   this->electronicWidget->setValue(this->electronicCur);
    1018   if (this->hasPlayer())
    1019     this->electronicWidget->show();
     1021  if (this->electronicWidget != NULL)
     1022  { //if it exists already: update it
     1023     this->electronicWidget->setMaximum(this->electronicMax);
     1024     this->electronicWidget->setValue(this->electronicCur);
     1025  }
     1026  else
     1027  { //create the widget
     1028    this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     1029    this->electronicWidget->setDisplayedName("Electronics:");
     1030    //this->electronicWidget->setSize2D(100,20);
     1031    //this->electronicWidget->setAbsCoor2D(150,200);
     1032    this->updateElectronicWidget();
     1033    if (this->hasPlayer())
     1034      State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
     1035  }
    10201036}
    10211037
    10221038void SpaceShip::updateShieldWidget()
    10231039{
    1024   this->shieldWidget->setMaximum(this->shieldMax);
    1025   this->shieldWidget->setValue(this->shieldCur);
    1026   if (this->hasPlayer())
    1027     this->shieldWidget->show();
    1028 }
     1040  if (this->shieldWidget != NULL)
     1041  {
     1042    this->shieldWidget->setMaximum(this->shieldMax);
     1043    this->shieldWidget->setValue(this->shieldCur);;
     1044  }
     1045  else
     1046  {
     1047    this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     1048    this->shieldWidget->setDisplayedName("Shield:");
     1049    //his->shieldWidget->setSize2D(100,20);
     1050    //this->shieldWidget->setAbsCoor2D(200,200);
     1051    this->updateShieldWidget();
     1052    if (this->hasPlayer())
     1053      State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
     1054  }
     1055}
  • branches/playability/src/world_entities/world_entity.cc

    r10120 r10139  
    752752  {
    753753    this->healthWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    754     this->healthWidget->setDisplayedName("Electronics");
    755     this->healthWidget->setSize2D(30,400);
    756     this->healthWidget->setAbsCoor2D(100,200);
     754    this->healthWidget->setDisplayedName("Health");
     755    //this->healthWidget->setSize2D(100,20);
     756    //this->healthWidget->setAbsCoor2D(100,200);
    757757
    758758    this->updateHealthWidget();
Note: See TracChangeset for help on using the changeset viewer.