/* 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" #include #include "math.h" #include "glgui_image.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->setAbsDir2D(270); //std::cout << "absAngle: " << int(this->getAbsDir2D()) << ", relAngle: " << int(this->getRelDir2D()) << '\n'; //this->setOrientation(OrxGui::Vertical); //this->pack(&this->_name); //this->pack(&this->_valueText); this->_image.setParent2D(this); this->_image.setBorderTop(0); this->_image.setBorderLeft(0); this->_image.setBorderRight(0); this->_image.setBorderBottom(0); this->_image.setWidgetSize(30,30); this->_image.setForegroundColor(Color(1,1,1,0.6)); this->_image.setBackgroundColor(Color(1,1,1,0)); this->_image.setBackgroundTexture(Texture()); this->_image.loadImageFromFile("maps/evil-flower.png"); //this->_image.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D()); this->_image.setRelCoor2D(0,0); this->_image.setRelDir2D(90); this->_image.setVisibility(true); this->_valueText.setParent2D(this); this->_valueText.setWidgetSize(100,20); //this->_valueText.setRelCoor2D(borderLeft(), borderTop() + this->_bar.getSizeX2D()); this->_valueText.setRelCoor2D(0,0); this->_valueText.setChangedTextColor(Color::white); this->setBackgroundTexture(Texture()); this->setBackgroundColor(Color(1,1,1,0.5)); this->setBorderTop(10); this->setBorderLeft(10); this->setBorderRight(10); this->setBorderBottom(10); this->setWidgetSize(120,50); this->setVisibility(true); //this->_name.setBackgroundTexture(Texture()); //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png"); this->_bar.setParent2D(&this->_valueText); 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); this->_bar.setBorderTop(0); this->_bar.setBorderLeft(0); this->_bar.setBorderRight(0); this->_bar.setBorderBottom(0); this->_bar.setWidgetSize(100,30); //this->_bar.setRelCoor2D(borderLeft(), 0); this->_bar.setRelCoor2D(0,0); } /** * @brief standard deconstructor */ GLGuiEnergyWidgetVertical::~GLGuiEnergyWidgetVertical () { } void GLGuiEnergyWidgetVertical::setMaximum(float max) { this->_bar.setMaximum(max); } void GLGuiEnergyWidgetVertical::setValue(float value) { MultiType val(value); //MultiType val(200.00); 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()); //this->_valueText.setText("asdfas"); } void GLGuiEnergyWidgetVertical::setDisplayedImage(const std::string& imageName) { this->_image.loadImageFromFile(imageName); } void GLGuiEnergyWidgetVertical::resize() { //GLGuiBox::resize(); } void GLGuiEnergyWidgetVertical::showing() { this->_image.show(); this->_valueText.show(); this->_bar.show(); //this->show(); } void GLGuiEnergyWidgetVertical::hiding() { this->_image.hide(); this->_valueText.hide(); this->_bar.hide(); } }