Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/elements/glgui_energywidget.cc @ 8984

Last change on this file since 8984 was 8984, checked in by bensch, 18 years ago

orxonox/trunk: gui with fading :)

File size: 2.2 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: ...
13   co-programmer: ...
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
17
18#include "glgui_energywidget.h"
19
20namespace OrxGui
21{
22  /**
23   * @brief standard constructor
24   */
25  GLGuiEnergyWidget::GLGuiEnergyWidget ()
26  {
27    //   this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget");
28
29    this->_bar.setSize2D(100, 30);
30    this->pack(&this->_name);
31    this->pack(&this->_valueText);
32    this->pack(&this->_bar);
33
34    this->setBackgroundTexture("maps/gui_element_background_2.png");
35    this->setBackgroundColor(Color(.5,.5,.5,1));
36
37    this->_name.setBackgroundTexture(Texture());
38    this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
39    this->_bar.setBackgroundTexture(Texture());
40    this->_bar.setBackgroundColor(Color(0,0,0,0));
41    this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
42    this->_bar.font().setBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
43  }
44
45
46  /**
47   * @brief standard deconstructor
48   */
49  GLGuiEnergyWidget::~GLGuiEnergyWidget ()
50  {
51  }
52
53
54  void GLGuiEnergyWidget::setDisplayedName(const std::string& name)
55  {
56    this->_name.setText(name);
57    this->_bar.setWidgetSize(this->_name.getSize2D());
58  }
59
60  void GLGuiEnergyWidget::setMaximum(float max)
61  {
62    this->_bar.setMaximum(max);
63  }
64
65  void GLGuiEnergyWidget::setValue(float value)
66  {
67    MultiType val(value);
68    val.setType(MT_INT);
69
70
71    this->_bar.setValue(value);
72    this->_bar.setForegroundColor(Color(1 - (value / this->_bar.getMaximum()), value / this->_bar.getMaximum(),0,1));
73    this->_valueText.setText(val.getString());
74  }
75
76  void GLGuiEnergyWidget::resize()
77  {
78    GLGuiBox::resize();
79  }
80
81
82  void GLGuiEnergyWidget::showing()
83  {
84    this->_name.show();
85    this->_valueText.show();
86    this->_bar.show();
87  }
88
89  void GLGuiEnergyWidget::hiding()
90  {
91    this->_name.hide();
92    this->_valueText.hide();
93    this->_bar.hide();
94  }
95}
Note: See TracBrowser for help on using the repository browser.