- Timestamp:
- Jan 23, 2007, 3:20:26 PM (18 years ago)
- Location:
- branches/playability/src/world_entities/elements
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/elements/glgui_energywidgetvertical.cc
r10234 r10301 30 30 GLGuiEnergyWidgetVertical::GLGuiEnergyWidgetVertical () 31 31 { 32 this->_bar = new GLGuiBar(); 33 this->_valueText = new GLGuiText(); 34 this->_image = new GLGuiImage(); 32 35 33 36 this->setAbsDir2D(270); … … 40 43 this->setWidgetSize(120,50); 41 44 42 this->_bar .setParent2D(this);43 this->_bar .setBackgroundTexture(Texture());44 this->_bar .setBackgroundColor(Color(0,0,0,0));45 this->_bar .setForegroundTexture("maps/gui_element_background_faded.png");46 this->_bar .setForegroundColor(Color::green);47 this->_bar .setChangedValueColor(Color(1,0,0,0.2));48 this->_bar .setBorderTop(0);49 this->_bar .setBorderLeft(0);50 this->_bar .setBorderRight(0);51 this->_bar .setBorderBottom(0);52 this->_bar .setWidgetSize(100,30);45 this->_bar->setParent2D(this); 46 this->_bar->setBackgroundTexture(Texture()); 47 this->_bar->setBackgroundColor(Color(0,0,0,0)); 48 this->_bar->setForegroundTexture("maps/gui_element_background_faded.png"); 49 this->_bar->setForegroundColor(Color::green); 50 this->_bar->setChangedValueColor(Color(1,0,0,0.2)); 51 this->_bar->setBorderTop(0); 52 this->_bar->setBorderLeft(0); 53 this->_bar->setBorderRight(0); 54 this->_bar->setBorderBottom(0); 55 this->_bar->setWidgetSize(100,30); 53 56 //this->_bar.setRelCoor2D(borderLeft(), 0); 54 this->_bar .setRelCoor2D(0,0);57 this->_bar->setRelCoor2D(0,0); 55 58 56 this->_image .setParent2D(this);57 this->_image .setBorderTop(0);58 this->_image .setBorderLeft(0);59 this->_image .setBorderRight(0);60 this->_image .setBorderBottom(0);61 this->_image .setWidgetSize(30,30);62 this->_image .setForegroundColor(Color(1,1,1,0.6));63 this->_image .setBackgroundColor(Color(1,1,1,0));64 this->_image .setBackgroundTexture(Texture());65 this->_image .loadImageFromFile("maps/evil-flower.png");59 this->_image->setParent2D(this); 60 this->_image->setBorderTop(0); 61 this->_image->setBorderLeft(0); 62 this->_image->setBorderRight(0); 63 this->_image->setBorderBottom(0); 64 this->_image->setWidgetSize(30,30); 65 this->_image->setForegroundColor(Color(1,1,1,0.6)); 66 this->_image->setBackgroundColor(Color(1,1,1,0)); 67 this->_image->setBackgroundTexture(Texture()); 68 this->_image->loadImageFromFile("maps/evil-flower.png"); 66 69 //this->_image.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D()); 67 this->_image .setRelCoor2D(0,0);68 this->_image .setRelDir2D(90);69 this->_image .setVisibility(true);70 this->_image->setRelCoor2D(0,0); 71 this->_image->setRelDir2D(90); 72 this->_image->setVisibility(true); 70 73 71 this->_valueText.setParent2D(&this->_bar); 72 this->_valueText.setWidgetSize(100,20); 74 75 this->_valueText->setParent2D(this->_bar); 76 this->_valueText->setWidgetSize(100,20); 73 77 //this->_valueText.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D()); 74 this->_valueText .setAbsCoor2D(-15,-20);75 this->_valueText .setChangedTextColor(Color::white);76 this->_valueText .setForegroundColor(Color::white);77 this->_valueText .setBackgroundTexture(Texture());78 this->_valueText .setBackgroundColor(Color(0,0,0,0));78 this->_valueText->setAbsCoor2D(-15,-20); 79 this->_valueText->setChangedTextColor(Color::white); 80 this->_valueText->setForegroundColor(Color::white); 81 this->_valueText->setBackgroundTexture(Texture()); 82 this->_valueText->setBackgroundColor(Color(0,0,0,0)); 79 83 } 80 84 … … 85 89 GLGuiEnergyWidgetVertical::~GLGuiEnergyWidgetVertical () 86 90 { 91 if ( this->_valueText ) 92 { 93 delete this->_valueText; 94 this->_valueText = NULL; 95 } 96 97 if ( this->_image ) 98 { 99 delete this->_image; 100 this->_image = NULL; 101 } 87 102 } 88 103 89 104 void GLGuiEnergyWidgetVertical::setMaximum(float max) 90 105 { 91 this->_bar .setMaximum(max);106 this->_bar->setMaximum(max); 92 107 } 93 108 … … 99 114 100 115 101 this->_bar .setValue(value);102 this->_bar .setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));116 this->_bar->setValue(value); 117 this->_bar->setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar->maximum())); 103 118 //this->_bar.setFrontColor(Color(1,1,1,1), true); 104 this->_valueText .setText(val.getString());119 this->_valueText->setText(val.getString()); 105 120 //this->_valueText.setText("asdfas"); 106 121 } … … 108 123 void GLGuiEnergyWidgetVertical::setDisplayedImage(const std::string& imageName) 109 124 { 110 this->_image .loadImageFromFile(imageName);125 this->_image->loadImageFromFile(imageName); 111 126 } 112 127 … … 120 135 this->setBorderRight(widgetSize.x * 0.2); 121 136 122 this->_bar .setWidgetSize(widgetSize.x * 0.8, widgetSize.y * 0.6);123 this->_image .setWidgetSize(widgetSize.y * 0.6, widgetSize.y * 0.6);124 this->_valueText .setWidgetSize(widgetSize.x* 0.8, widgetSize.y * 0.4);137 this->_bar->setWidgetSize(widgetSize.x * 0.8, widgetSize.y * 0.6); 138 this->_image->setWidgetSize(widgetSize.y * 0.6, widgetSize.y * 0.6); 139 this->_valueText->setWidgetSize(widgetSize.x* 0.8, widgetSize.y * 0.4); 125 140 } 126 141 … … 129 144 { 130 145 131 this->_bar .show();132 this->_image .show();133 this->_valueText .show();146 this->_bar->show(); 147 this->_image->show(); 148 this->_valueText->show(); 134 149 } 135 150 136 151 void GLGuiEnergyWidgetVertical::hiding() 137 152 { 138 this->_image .hide();139 this->_valueText .hide();140 this->_bar .hide();153 this->_image->hide(); 154 this->_valueText->hide(); 155 this->_bar->hide(); 141 156 } 142 157 } -
branches/playability/src/world_entities/elements/glgui_energywidgetvertical.h
r10230 r10301 27 27 void setDisplayedImage(const std::string& imageName); 28 28 29 inline GLGuiImage* getImageWidget() {return &this->_image;};30 inline GLGuiText* getValueWidget() {return &this->_valueText;};31 inline GLGuiBar* getBarWidget() {return &this->_bar;};29 inline GLGuiImage* getImageWidget() {return this->_image;}; 30 inline GLGuiText* getValueWidget() {return this->_valueText;}; 31 inline GLGuiBar* getBarWidget() {return this->_bar;}; 32 32 33 33 protected: … … 37 37 38 38 private: 39 GLGuiImage _image;40 GLGuiText _valueText;41 GLGuiBar _bar;39 GLGuiImage* _image; 40 GLGuiText* _valueText; 41 GLGuiBar* _bar; 42 42 43 43 };
Note: See TracChangeset
for help on using the changeset viewer.