[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 | |
---|
[9406] | 20 | #include "multi_type.h" |
---|
| 21 | |
---|
[8972] | 22 | namespace OrxGui |
---|
[3365] | 23 | { |
---|
[8972] | 24 | /** |
---|
| 25 | * @brief standard constructor |
---|
[8981] | 26 | */ |
---|
[8972] | 27 | GLGuiEnergyWidget::GLGuiEnergyWidget () |
---|
| 28 | { |
---|
| 29 | // this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget"); |
---|
[8983] | 30 | |
---|
| 31 | this->_bar.setSize2D(100, 30); |
---|
[8980] | 32 | this->pack(&this->_name); |
---|
| 33 | this->pack(&this->_valueText); |
---|
[8988] | 34 | this->_bar.setParent2D(&this->_valueText); |
---|
[8973] | 35 | |
---|
[8991] | 36 | this->_name.setForegroundColor(Color(1,1,1,.8)); |
---|
| 37 | this->_valueText.setChangedTextColor(Color::white); |
---|
| 38 | |
---|
[10317] | 39 | //this->setBackgroundTexture("textures/gui/gui_element_background_2.png"); |
---|
[8980] | 40 | this->setBackgroundColor(Color(.5,.5,.5,1)); |
---|
| 41 | |
---|
[8991] | 42 | //this->_name.setBackgroundTexture(Texture()); |
---|
[10317] | 43 | //this->_valueText.setBackgroundTexture("textures/gui/gui_element_background_2.png"); |
---|
[8980] | 44 | this->_bar.setBackgroundTexture(Texture()); |
---|
[8983] | 45 | this->_bar.setBackgroundColor(Color(0,0,0,0)); |
---|
[10317] | 46 | this->_bar.setForegroundTexture("textures/gui/gui_element_background_faded.png"); |
---|
[8984] | 47 | this->_bar.setForegroundColor(Color(.5, .5, .5, 1)); |
---|
[8991] | 48 | this->_bar.setChangedValueColor(Color::black); |
---|
[8972] | 49 | } |
---|
[4320] | 50 | |
---|
| 51 | |
---|
[8972] | 52 | /** |
---|
| 53 | * @brief standard deconstructor |
---|
[4320] | 54 | */ |
---|
[8972] | 55 | GLGuiEnergyWidget::~GLGuiEnergyWidget () |
---|
| 56 | { |
---|
| 57 | } |
---|
[8974] | 58 | |
---|
| 59 | |
---|
[8977] | 60 | void GLGuiEnergyWidget::setDisplayedName(const std::string& name) |
---|
| 61 | { |
---|
[8980] | 62 | this->_name.setText(name); |
---|
[8983] | 63 | this->_bar.setWidgetSize(this->_name.getSize2D()); |
---|
[8977] | 64 | } |
---|
[8975] | 65 | |
---|
[8974] | 66 | void GLGuiEnergyWidget::setMaximum(float max) |
---|
| 67 | { |
---|
[8980] | 68 | this->_bar.setMaximum(max); |
---|
[8974] | 69 | } |
---|
| 70 | |
---|
| 71 | void GLGuiEnergyWidget::setValue(float value) |
---|
| 72 | { |
---|
[8976] | 73 | MultiType val(value); |
---|
| 74 | val.setType(MT_INT); |
---|
[8974] | 75 | |
---|
[8984] | 76 | |
---|
[8980] | 77 | this->_bar.setValue(value); |
---|
[8986] | 78 | this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum())); |
---|
[8985] | 79 | this->_bar.setFrontColor(Color(1,1,1,1), true); |
---|
[8980] | 80 | this->_valueText.setText(val.getString()); |
---|
[8974] | 81 | } |
---|
| 82 | |
---|
[8981] | 83 | void GLGuiEnergyWidget::resize() |
---|
| 84 | { |
---|
| 85 | GLGuiBox::resize(); |
---|
| 86 | } |
---|
[8974] | 87 | |
---|
[8981] | 88 | |
---|
[8975] | 89 | void GLGuiEnergyWidget::showing() |
---|
| 90 | { |
---|
[8980] | 91 | this->_name.show(); |
---|
| 92 | this->_valueText.show(); |
---|
| 93 | this->_bar.show(); |
---|
[8975] | 94 | } |
---|
[8974] | 95 | |
---|
[8975] | 96 | void GLGuiEnergyWidget::hiding() |
---|
| 97 | { |
---|
[8980] | 98 | this->_name.hide(); |
---|
| 99 | this->_valueText.hide(); |
---|
| 100 | this->_bar.hide(); |
---|
[8975] | 101 | } |
---|
[3365] | 102 | } |
---|