1 | /* |
---|
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. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Benjamin Grauer |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
17 | |
---|
18 | #include "glgui_energywidget.h" |
---|
19 | |
---|
20 | #include "multi_type.h" |
---|
21 | |
---|
22 | namespace OrxGui |
---|
23 | { |
---|
24 | /** |
---|
25 | * @brief standard constructor |
---|
26 | */ |
---|
27 | GLGuiEnergyWidget::GLGuiEnergyWidget () |
---|
28 | { |
---|
29 | // this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget"); |
---|
30 | |
---|
31 | this->_bar.setSize2D(100, 30); |
---|
32 | this->pack(&this->_name); |
---|
33 | this->pack(&this->_valueText); |
---|
34 | this->_bar.setParent2D(&this->_valueText); |
---|
35 | |
---|
36 | this->_name.setForegroundColor(Color(1,1,1,.8)); |
---|
37 | this->_valueText.setChangedTextColor(Color::white); |
---|
38 | |
---|
39 | //this->setBackgroundTexture("maps/gui_element_background_2.png"); |
---|
40 | this->setBackgroundColor(Color(.5,.5,.5,1)); |
---|
41 | |
---|
42 | //this->_name.setBackgroundTexture(Texture()); |
---|
43 | //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png"); |
---|
44 | this->_bar.setBackgroundTexture(Texture()); |
---|
45 | this->_bar.setBackgroundColor(Color(0,0,0,0)); |
---|
46 | this->_bar.setForegroundTexture("maps/gui_element_background_faded.png"); |
---|
47 | this->_bar.setForegroundColor(Color(.5, .5, .5, 1)); |
---|
48 | this->_bar.setChangedValueColor(Color::black); |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | /** |
---|
53 | * @brief standard deconstructor |
---|
54 | */ |
---|
55 | GLGuiEnergyWidget::~GLGuiEnergyWidget () |
---|
56 | { |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | void GLGuiEnergyWidget::setDisplayedName(const std::string& name) |
---|
61 | { |
---|
62 | this->_name.setText(name); |
---|
63 | this->_bar.setWidgetSize(this->_name.getSize2D()); |
---|
64 | } |
---|
65 | |
---|
66 | void GLGuiEnergyWidget::setMaximum(float max) |
---|
67 | { |
---|
68 | this->_bar.setMaximum(max); |
---|
69 | } |
---|
70 | |
---|
71 | void GLGuiEnergyWidget::setValue(float value) |
---|
72 | { |
---|
73 | MultiType val(value); |
---|
74 | val.setType(MT_INT); |
---|
75 | |
---|
76 | |
---|
77 | this->_bar.setValue(value); |
---|
78 | this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum())); |
---|
79 | this->_bar.setFrontColor(Color(1,1,1,1), true); |
---|
80 | this->_valueText.setText(val.getString()); |
---|
81 | } |
---|
82 | |
---|
83 | void GLGuiEnergyWidget::resize() |
---|
84 | { |
---|
85 | GLGuiBox::resize(); |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | void GLGuiEnergyWidget::showing() |
---|
90 | { |
---|
91 | this->_name.show(); |
---|
92 | this->_valueText.show(); |
---|
93 | this->_bar.show(); |
---|
94 | } |
---|
95 | |
---|
96 | void GLGuiEnergyWidget::hiding() |
---|
97 | { |
---|
98 | this->_name.hide(); |
---|
99 | this->_valueText.hide(); |
---|
100 | this->_bar.hide(); |
---|
101 | } |
---|
102 | } |
---|