Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

changed style of vertical gui-element. textures still need to be done, though

File size: 4.1 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#include "glgui_image.h"
24
25namespace OrxGui
26{
27  /**
28   * @brief standard constructor
29   */
30  GLGuiEnergyWidgetVertical::GLGuiEnergyWidgetVertical ()
31  {
32    //   this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget");
33
34    //this->_bar.setSize2D(100, 30);
35    //this->_bar.setRelCoor2D(-10,0);
36    //this->_name.setRelCoor2D(20,0);
37    //this->_valueText.setRelCoor2D(,0);
38    this->setAbsDir2D(270);
39    //std::cout << "absAngle: " << int(this->getAbsDir2D()) << ", relAngle: " << int(this->getRelDir2D()) << '\n';
40    //this->setOrientation(OrxGui::Vertical);
41
42    //this->pack(&this->_name);
43    //this->pack(&this->_valueText);
44
45    this->_image.setParent2D(this);
46    this->_image.setBorderTop(0);
47    this->_image.setBorderLeft(0);
48    this->_image.setBorderRight(0);
49    this->_image.setBorderBottom(0);
50    this->_image.setWidgetSize(30,30);
51    this->_image.setForegroundColor(Color(1,1,1,0.6));
52    this->_image.setBackgroundColor(Color(1,1,1,0));
53    this->_image.setBackgroundTexture(Texture());
54    this->_image.loadImageFromFile("maps/evil-flower.png");
55    //this->_image.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D());
56    this->_image.setRelCoor2D(0,0);
57    this->_image.setRelDir2D(90);
58    this->_image.setVisibility(true);
59
60    this->_valueText.setParent2D(this);
61    this->_valueText.setWidgetSize(100,20);
62    //this->_valueText.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D());
63    this->_valueText.setRelCoor2D(0,0);
64    this->_valueText.setChangedTextColor(Color::white);
65
66    this->setBackgroundTexture(Texture());
67    this->setBackgroundColor(Color(1,1,1,0.5));
68    this->setBorderTop(10);
69    this->setBorderLeft(10);
70    this->setBorderRight(10);
71    this->setBorderBottom(10);
72    this->setWidgetSize(120,50);
73    this->setVisibility(true);
74   
75
76    //this->_name.setBackgroundTexture(Texture());
77    //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
78
79    this->_bar.setParent2D(&this->_valueText);
80    this->_bar.setBackgroundTexture(Texture());
81    this->_bar.setBackgroundColor(Color(0,0,0,0));
82    this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
83    this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
84    this->_bar.setChangedValueColor(Color::black);
85    this->_bar.setBorderTop(0);
86    this->_bar.setBorderLeft(0);
87    this->_bar.setBorderRight(0);
88    this->_bar.setBorderBottom(0);
89    this->_bar.setWidgetSize(100,30);
90    //this->_bar.setRelCoor2D(borderLeft(), 0);
91    this->_bar.setRelCoor2D(0,0);
92  }
93
94
95  /**
96   * @brief standard deconstructor
97   */
98  GLGuiEnergyWidgetVertical::~GLGuiEnergyWidgetVertical ()
99  {
100  }
101
102  void GLGuiEnergyWidgetVertical::setMaximum(float max)
103  {
104    this->_bar.setMaximum(max);
105  }
106
107  void GLGuiEnergyWidgetVertical::setValue(float value)
108  {
109    MultiType val(value);
110    //MultiType val(200.00);
111    val.setType(MT_INT);
112
113
114    this->_bar.setValue(value);
115    this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
116    this->_bar.setFrontColor(Color(1,1,1,1), true);
117    this->_valueText.setText(val.getString());
118    //this->_valueText.setText("asdfas");
119  }
120
121  void GLGuiEnergyWidgetVertical::setDisplayedImage(const std::string& imageName)
122  {
123    this->_image.loadImageFromFile(imageName);
124  }
125
126  void GLGuiEnergyWidgetVertical::resize()
127  {
128    //GLGuiBox::resize();
129  }
130
131
132  void GLGuiEnergyWidgetVertical::showing()
133  {
134    this->_image.show();
135    this->_valueText.show();
136    this->_bar.show();
137    //this->show();
138  }
139
140  void GLGuiEnergyWidgetVertical::hiding()
141  {
142    this->_image.hide();
143    this->_valueText.hide();
144    this->_bar.hide();
145  }
146}
Note: See TracBrowser for help on using the repository browser.