[4744] | 1 | /* |
---|
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[9014] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[3955] | 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
[1853] | 17 | |
---|
[8972] | 18 | #include "glgui_energywidget.h" |
---|
[1853] | 19 | |
---|
[8972] | 20 | namespace OrxGui |
---|
[3365] | 21 | { |
---|
[8972] | 22 | /** |
---|
| 23 | * @brief standard constructor |
---|
[8981] | 24 | */ |
---|
[8972] | 25 | GLGuiEnergyWidget::GLGuiEnergyWidget () |
---|
| 26 | { |
---|
| 27 | // this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget"); |
---|
[8983] | 28 | |
---|
| 29 | this->_bar.setSize2D(100, 30); |
---|
[8980] | 30 | this->pack(&this->_name); |
---|
| 31 | this->pack(&this->_valueText); |
---|
[8988] | 32 | this->_bar.setParent2D(&this->_valueText); |
---|
[8973] | 33 | |
---|
[8991] | 34 | this->_name.setForegroundColor(Color(1,1,1,.8)); |
---|
| 35 | this->_valueText.setChangedTextColor(Color::white); |
---|
| 36 | |
---|
| 37 | //this->setBackgroundTexture("maps/gui_element_background_2.png"); |
---|
[8980] | 38 | this->setBackgroundColor(Color(.5,.5,.5,1)); |
---|
| 39 | |
---|
[8991] | 40 | //this->_name.setBackgroundTexture(Texture()); |
---|
| 41 | //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png"); |
---|
[8980] | 42 | this->_bar.setBackgroundTexture(Texture()); |
---|
[8983] | 43 | this->_bar.setBackgroundColor(Color(0,0,0,0)); |
---|
[8990] | 44 | this->_bar.setForegroundTexture("maps/gui_element_background_faded.png"); |
---|
[8984] | 45 | this->_bar.setForegroundColor(Color(.5, .5, .5, 1)); |
---|
[8991] | 46 | this->_bar.setChangedValueColor(Color::black); |
---|
[8972] | 47 | } |
---|
[4320] | 48 | |
---|
| 49 | |
---|
[8972] | 50 | /** |
---|
| 51 | * @brief standard deconstructor |
---|
[4320] | 52 | */ |
---|
[8972] | 53 | GLGuiEnergyWidget::~GLGuiEnergyWidget () |
---|
| 54 | { |
---|
| 55 | } |
---|
[8974] | 56 | |
---|
| 57 | |
---|
[8977] | 58 | void GLGuiEnergyWidget::setDisplayedName(const std::string& name) |
---|
| 59 | { |
---|
[8980] | 60 | this->_name.setText(name); |
---|
[8983] | 61 | this->_bar.setWidgetSize(this->_name.getSize2D()); |
---|
[8977] | 62 | } |
---|
[8975] | 63 | |
---|
[8974] | 64 | void GLGuiEnergyWidget::setMaximum(float max) |
---|
| 65 | { |
---|
[8980] | 66 | this->_bar.setMaximum(max); |
---|
[8974] | 67 | } |
---|
| 68 | |
---|
| 69 | void GLGuiEnergyWidget::setValue(float value) |
---|
| 70 | { |
---|
[8976] | 71 | MultiType val(value); |
---|
| 72 | val.setType(MT_INT); |
---|
[8974] | 73 | |
---|
[8984] | 74 | |
---|
[8980] | 75 | this->_bar.setValue(value); |
---|
[8986] | 76 | this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum())); |
---|
[8985] | 77 | this->_bar.setFrontColor(Color(1,1,1,1), true); |
---|
[8980] | 78 | this->_valueText.setText(val.getString()); |
---|
[8974] | 79 | } |
---|
| 80 | |
---|
[8981] | 81 | void GLGuiEnergyWidget::resize() |
---|
| 82 | { |
---|
| 83 | GLGuiBox::resize(); |
---|
| 84 | } |
---|
[8974] | 85 | |
---|
[8981] | 86 | |
---|
[8975] | 87 | void GLGuiEnergyWidget::showing() |
---|
| 88 | { |
---|
[8980] | 89 | this->_name.show(); |
---|
| 90 | this->_valueText.show(); |
---|
| 91 | this->_bar.show(); |
---|
[8975] | 92 | } |
---|
[8974] | 93 | |
---|
[8975] | 94 | void GLGuiEnergyWidget::hiding() |
---|
| 95 | { |
---|
[8980] | 96 | this->_name.hide(); |
---|
| 97 | this->_valueText.hide(); |
---|
| 98 | this->_bar.hide(); |
---|
[8975] | 99 | } |
---|
[3365] | 100 | } |
---|