| 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 "network_stats_widget.h" | 
|---|
| 19 |  | 
|---|
| 20 | namespace OrxGui | 
|---|
| 21 | { | 
|---|
| 22 |   /** | 
|---|
| 23 |    * @brief standard constructor | 
|---|
| 24 |    */ | 
|---|
| 25 |   NetworkStatsWidget::NetworkStatsWidget () | 
|---|
| 26 |   { | 
|---|
| 27 |     //   this->setClassID(CL_PROTO_ID, "NetworkStatsWidget"); | 
|---|
| 28 |  | 
|---|
| 29 |     this->_bar.setSize2D(100, 30); | 
|---|
| 30 |     this->pack(&this->_valueText); | 
|---|
| 31 |     this->_bar.setParent2D(&this->_valueText); | 
|---|
| 32 |  | 
|---|
| 33 |     this->_valueText.setChangedTextColor(Color::white); | 
|---|
| 34 |  | 
|---|
| 35 |     //this->setBackgroundTexture("maps/gui_element_background_2.png"); | 
|---|
| 36 |     this->setBackgroundColor(Color(.5,.5,.5,1)); | 
|---|
| 37 |  | 
|---|
| 38 |     //this->_name.setBackgroundTexture(Texture()); | 
|---|
| 39 |     //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png"); | 
|---|
| 40 |     this->_bar.setBackgroundTexture(Texture()); | 
|---|
| 41 |     this->_bar.setBackgroundColor(Color(0,0,0,0)); | 
|---|
| 42 |     this->_bar.setForegroundTexture("maps/gui_element_background_faded.png"); | 
|---|
| 43 |     this->_bar.setForegroundColor(Color(.5, .5, .5, 1)); | 
|---|
| 44 |     this->_bar.setChangedValueColor(Color::black); | 
|---|
| 45 |   } | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 |   /** | 
|---|
| 49 |    * @brief standard deconstructor | 
|---|
| 50 |    */ | 
|---|
| 51 |   NetworkStatsWidget::~NetworkStatsWidget () | 
|---|
| 52 |   { | 
|---|
| 53 |   } | 
|---|
| 54 |  | 
|---|
| 55 |  | 
|---|
| 56 |   void NetworkStatsWidget::setMaximum(float max) | 
|---|
| 57 |   { | 
|---|
| 58 |     this->_bar.setMaximum(max); | 
|---|
| 59 |   } | 
|---|
| 60 |  | 
|---|
| 61 |   void NetworkStatsWidget::setValue(float value) | 
|---|
| 62 |   { | 
|---|
| 63 |     MultiType val(value); | 
|---|
| 64 |     val.setType(MT_INT); | 
|---|
| 65 |  | 
|---|
| 66 |  | 
|---|
| 67 |     this->_bar.setValue(value); | 
|---|
| 68 |     this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum())); | 
|---|
| 69 |     this->_bar.setFrontColor(Color(1,1,1,1), true); | 
|---|
| 70 |     this->_valueText.setText(val.getString()); | 
|---|
| 71 |   } | 
|---|
| 72 |  | 
|---|
| 73 |   void NetworkStatsWidget::resize() | 
|---|
| 74 |   { | 
|---|
| 75 |     GLGuiBox::resize(); | 
|---|
| 76 |   } | 
|---|
| 77 |  | 
|---|
| 78 |  | 
|---|
| 79 |   void NetworkStatsWidget::showing() | 
|---|
| 80 |   { | 
|---|
| 81 |     this->_valueText.show(); | 
|---|
| 82 |     this->_bar.show(); | 
|---|
| 83 |   } | 
|---|
| 84 |  | 
|---|
| 85 |   void NetworkStatsWidget::hiding() | 
|---|
| 86 |   { | 
|---|
| 87 |     this->_valueText.hide(); | 
|---|
| 88 |     this->_bar.hide(); | 
|---|
| 89 |   } | 
|---|
| 90 | } | 
|---|