Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10230 was 10230, checked in by muellmic, 18 years ago

interface changes

File size: 3.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#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  }
33
34
35  /**
36   * @brief standard deconstructor
37   */
38  GLGuiEnergyWidgetVertical::~GLGuiEnergyWidgetVertical ()
39  {
40  }
41
42  void GLGuiEnergyWidgetVertical::setMaximum(float max)
43  {
44    this->_bar.setMaximum(max);
45  }
46
47  void GLGuiEnergyWidgetVertical::setValue(float value)
48  {
49    MultiType val(value);
50    //MultiType val(200.00);
51    val.setType(MT_INT);
52
53
54    this->_bar.setValue(value);
55    this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
56    this->_bar.setFrontColor(Color(1,1,1,1), true);
57    this->_valueText.setText(val.getString());
58    //this->_valueText.setText("asdfas");
59  }
60
61  void GLGuiEnergyWidgetVertical::setDisplayedImage(const std::string& imageName)
62  {
63    this->_image.loadImageFromFile(imageName);
64  }
65
66  void GLGuiEnergyWidgetVertical::resize()
67  {
68    //GLGuiBox::resize();
69  }
70
71
72  void GLGuiEnergyWidgetVertical::showing()
73  {
74    this->setAbsDir2D(270);
75    this->setBackgroundTexture(Texture());
76    this->setBackgroundColor(Color(1,1,1,0));
77    this->setBorderTop(10);
78    this->setBorderLeft(10);
79    this->setBorderRight(10);
80    this->setBorderBottom(10);
81    this->setWidgetSize(120,50);
82
83    this->_bar.setParent2D(&this->_valueText);
84    this->_bar.setBackgroundTexture(Texture());
85    this->_bar.setBackgroundColor(Color(0,0,0,0));
86    this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
87    this->_bar.setForegroundColor(Color::green);
88    this->_bar.setChangedValueColor(Color(1,0,0,0.2));
89    this->_bar.setBorderTop(0);
90    this->_bar.setBorderLeft(0);
91    this->_bar.setBorderRight(0);
92    this->_bar.setBorderBottom(0);
93    this->_bar.setWidgetSize(100,30);
94    //this->_bar.setRelCoor2D(borderLeft(), 0);
95    this->_bar.setRelCoor2D(0,0);
96    this->_bar.show();
97 
98    this->_image.setParent2D(this);
99    this->_image.setBorderTop(0);
100    this->_image.setBorderLeft(0);
101    this->_image.setBorderRight(0);
102    this->_image.setBorderBottom(0);
103    this->_image.setWidgetSize(30,30);
104    this->_image.setForegroundColor(Color(1,1,1,0.6));
105    this->_image.setBackgroundColor(Color(1,1,1,0));
106    this->_image.setBackgroundTexture(Texture());
107    this->_image.loadImageFromFile("maps/evil-flower.png");
108    //this->_image.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D());
109    this->_image.setRelCoor2D(0,0);
110    this->_image.setRelDir2D(90);
111    this->_image.setVisibility(true);
112    this->_image.show();
113
114    this->_valueText.setParent2D(this);
115    this->_valueText.setWidgetSize(100,20);
116    //this->_valueText.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D());
117    this->_valueText.setRelCoor2D(0,0);
118    this->_valueText.setChangedTextColor(Color::black);
119    this->_valueText.show();
120  }
121
122  void GLGuiEnergyWidgetVertical::hiding()
123  {
124    this->_image.hide();
125    this->_valueText.hide();
126    this->_bar.hide();
127  }
128}
Note: See TracBrowser for help on using the repository browser.