/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Grauer co-programmer: ... */ //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ #include "glgui_energywidgetvertical.h" #include "multi_type.h" namespace OrxGui { /** * @brief standard constructor */ GLGuiEnergyWidgetVertical::GLGuiEnergyWidgetVertical () { // this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget"); //this->_bar.setSize2D(100, 30); //this->_bar.setRelCoor2D(-10,0); //this->_name.setRelCoor2D(20,0); //this->_valueText.setRelCoor2D(,0); this->shiftDir2D(270); this->setOrientation(OrxGui::Horizontal); this->pack(&this->_name); this->pack(&this->_valueText); this->_bar.setParent2D(&this->_valueText); this->_name.setForegroundColor(Color(1,1,1,.8)); this->_valueText.setChangedTextColor(Color::white); this->_bar.setBackgroundTexture(Texture()); this->setBackgroundTexture(Texture()); this->setBackgroundColor(Color(.5,.5,.5,0.5)); //this->_name.setBackgroundTexture(Texture()); //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png"); this->_bar.setBackgroundTexture(Texture()); this->_bar.setBackgroundColor(Color(0,0,0,0)); this->_bar.setForegroundTexture("maps/gui_element_background_faded.png"); this->_bar.setForegroundColor(Color(.5, .5, .5, 1)); this->_bar.setChangedValueColor(Color::black); } /** * @brief standard deconstructor */ GLGuiEnergyWidgetVertical::~GLGuiEnergyWidgetVertical () { } void GLGuiEnergyWidgetVertical::setDisplayedName(const std::string& name) { this->_name.setText(name); this->_bar.setWidgetSize(this->_name.getSize2D()); } void GLGuiEnergyWidgetVertical::setMaximum(float max) { this->_bar.setMaximum(max); } void GLGuiEnergyWidgetVertical::setValue(float value) { MultiType val(value); val.setType(MT_INT); this->_bar.setValue(value); this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum())); this->_bar.setFrontColor(Color(1,1,1,1), true); this->_valueText.setText(val.getString()); } void GLGuiEnergyWidgetVertical::resize() { GLGuiBox::resize(); } void GLGuiEnergyWidgetVertical::showing() { this->_name.show(); this->_valueText.show(); this->_bar.show(); } void GLGuiEnergyWidgetVertical::hiding() { this->_name.hide(); this->_valueText.hide(); this->_bar.hide(); } }