Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/world_entities/elements/glgui_energywidgetvertical.cc @ 10109

Last change on this file since 10109 was 10107, checked in by marcscha, 17 years ago

many additions, several fixes

File size: 2.5 KB
Line 
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_energywidgetvertical.h"
19
20#include "multi_type.h"
21
22namespace OrxGui
23{
24  /**
25   * @brief standard constructor
26   */
27  GLGuiEnergyWidgetVertical::GLGuiEnergyWidgetVertical ()
28  {
29    //   this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget");
30
31   
32
33    this->_bar.setSize2D(100, 30);
34    this->pack(&this->_name);
35    this->pack(&this->_valueText);
36    this->_bar.setParent2D(&this->_valueText);
37
38    this->_name.setForegroundColor(Color(1,1,1,.8));
39    this->_valueText.setChangedTextColor(Color::white);
40
41    //this->setBackgroundTexture("maps/gui_element_background_2.png");
42    this->setBackgroundColor(Color(.5,.5,.5,1));
43
44    //this->_name.setBackgroundTexture(Texture());
45    //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
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(.5, .5, .5, 1));
50    this->_bar.setChangedValueColor(Color::black);
51  }
52
53
54  /**
55   * @brief standard deconstructor
56   */
57  GLGuiEnergyWidgetVertical::~GLGuiEnergyWidgetVertical ()
58  {
59  }
60
61
62  void GLGuiEnergyWidgetVertical::setDisplayedName(const std::string& name)
63  {
64    this->_name.setText(name);
65    this->_bar.setWidgetSize(this->_name.getSize2D());
66  }
67
68  void GLGuiEnergyWidgetVertical::setMaximum(float max)
69  {
70    this->_bar.setMaximum(max);
71  }
72
73  void GLGuiEnergyWidgetVertical::setValue(float value)
74  {
75    MultiType val(value);
76    val.setType(MT_INT);
77
78
79    this->_bar.setValue(value);
80    this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
81    this->_bar.setFrontColor(Color(1,1,1,1), true);
82    this->_valueText.setText(val.getString());
83  }
84
85  void GLGuiEnergyWidgetVertical::resize()
86  {
87    GLGuiBox::resize();
88  }
89
90
91  void GLGuiEnergyWidgetVertical::showing()
92  {
93    this->_name.show();
94    this->_valueText.show();
95    this->_bar.show();
96  }
97
98  void GLGuiEnergyWidgetVertical::hiding()
99  {
100    this->_name.hide();
101    this->_valueText.hide();
102    this->_bar.hide();
103  }
104}
Note: See TracBrowser for help on using the repository browser.