Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10194 was 10194, checked in by muellmic, 17 years ago

implementing interface 'by hand' without still buggy packing-function. can't test with spaceship because of segfault

File size: 3.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: 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#include <iostream>
22#include "math.h"
23
24namespace OrxGui
25{
26  /**
27   * @brief standard constructor
28   */
29  GLGuiEnergyWidgetVertical::GLGuiEnergyWidgetVertical ()
30  {
31    //   this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget");
32
33    //this->_bar.setSize2D(100, 30);
34    //this->_bar.setRelCoor2D(-10,0);
35    //this->_name.setRelCoor2D(20,0);
36    //this->_valueText.setRelCoor2D(,0);
37    this->setAbsDir2D(270);
38    //std::cout << "absAngle: " << int(this->getAbsDir2D()) << ", relAngle: " << int(this->getRelDir2D()) << '\n';
39    //this->setOrientation(OrxGui::Vertical);
40
41    //this->pack(&this->_name);
42    //this->pack(&this->_valueText);
43
44    this->_image.setParent2D(this);
45    this->_image.setSize2D(20,20);
46    this->_image.setBackgroundColor(Color(1,1,1,.8));
47    this->_image.setBackgroundTexture("maps/TE2.png");
48    this->_image.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D());
49
50    this->_valueText.setParent2D(this);
51    this->_valueText.setSize2D(100,20);
52    this->_valueText.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D());
53    this->_valueText.setChangedTextColor(Color::white);
54
55    this->setBackgroundTexture(Texture());
56    this->setBackgroundColor(Color(.5,.5,.5,0));
57    this->setSize2D(120,20);
58
59    //this->_name.setBackgroundTexture(Texture());
60    //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
61
62    this->_bar.setParent2D(&this->_valueText);
63    this->_bar.setBackgroundTexture(Texture());
64    this->_bar.setBackgroundColor(Color(0,0,0,0));
65    this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
66    this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
67    this->_bar.setChangedValueColor(Color::black);
68    this->_bar.setSize2D(100,20);
69    this->_bar.setRelCoor2D(borderLeft(), 0);
70  }
71
72
73  /**
74   * @brief standard deconstructor
75   */
76  GLGuiEnergyWidgetVertical::~GLGuiEnergyWidgetVertical ()
77  {
78  }
79
80  void GLGuiEnergyWidgetVertical::setMaximum(float max)
81  {
82    this->_bar.setMaximum(max);
83  }
84
85  void GLGuiEnergyWidgetVertical::setValue(float value)
86  {
87    MultiType val(value);
88    val.setType(MT_INT);
89
90
91    this->_bar.setValue(value);
92    this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
93    this->_bar.setFrontColor(Color(1,1,1,1), true);
94    this->_valueText.setText(val.getString());
95    //this->_valueText.setText("asdfas");
96  }
97
98  void GLGuiEnergyWidgetVertical::resize()
99  {
100    //GLGuiBox::resize();
101  }
102
103
104  void GLGuiEnergyWidgetVertical::showing()
105  {
106    this->_image.show();
107    this->_valueText.show();
108    this->_bar.show();
109  }
110
111  void GLGuiEnergyWidgetVertical::hiding()
112  {
113    this->_image.hide();
114    this->_valueText.hide();
115    this->_bar.hide();
116  }
117}
Note: See TracBrowser for help on using the repository browser.