1 /*************************************************************************** 2 * Mechanized Assault and Exploration Reloaded Projectfile * 3 * * 4 * This program is free software; you can redistribute it and/or modify * 5 * it under the terms of the GNU General Public License as published by * 6 * the Free Software Foundation; either version 2 of the License, or * 7 * (at your option) any later version. * 8 * * 9 * This program is distributed in the hope that it will be useful, * 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 * GNU General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU General Public License * 15 * along with this program; if not, write to the * 16 * Free Software Foundation, Inc., * 17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 19 20 #ifndef ui_graphical_menu_widgets_special_resourcebarH 21 #define ui_graphical_menu_widgets_special_resourcebarH 22 23 #include "maxrconfig.h" 24 #include "ui/graphical/menu/widgets/clickablewidget.h" 25 #include "ui/graphical/orientation.h" 26 #include "utility/autosurface.h" 27 #include "sound.h" 28 #include "utility/signal/signal.h" 29 30 enum class eResourceBarType 31 { 32 Metal, 33 Oil, 34 Gold, 35 Blocked, 36 MetalSlim, 37 OilSlim, 38 GoldSlim, 39 }; 40 41 class cResourceBar : public cClickableWidget 42 { 43 public: 44 cResourceBar (const cBox<cPosition>& area, int minValue, int maxValue, eResourceBarType type, eOrientationType orientation, cSoundChunk* clickSound = &SoundData.SNDObjectMenu); 45 46 void setType (eResourceBarType type); 47 void setStepSize (int stepSize); 48 49 int getMinValue() const; 50 void setMinValue (int minValue); 51 52 int getMaxValue() const; 53 void setMaxValue (int maxValue); 54 55 int getFixedMinValue() const; 56 void setFixedMinValue (int minValue); 57 58 int getFixedMaxValue() const; 59 void setFixedMaxValue (int maxValue); 60 61 bool isInverted() const; 62 void setInverted (bool inverted); 63 64 int getValue() const; 65 void setValue (int value); 66 67 void increase (int offset); 68 void decrease (int offset); 69 70 cSignal<void ()> valueChanged; 71 72 virtual void draw (SDL_Surface& destination, const cBox<cPosition>& clipRect) MAXR_OVERRIDE_FUNCTION; 73 74 protected: 75 virtual bool handleClicked (cApplication& application, cMouse& mouse, eMouseButtonType button) MAXR_OVERRIDE_FUNCTION; 76 77 private: 78 AutoSurface surface; 79 cSoundChunk* clickSound; 80 81 eOrientationType orientation; 82 83 const cPosition additionalArea; 84 85 int minValue; 86 int maxValue; 87 88 int currentValue; 89 90 bool fixedMinEnabled; 91 int fixedMinValue; 92 bool fixedMaxEnabled; 93 int fixedMaxValue; 94 95 bool inverted; 96 97 int stepSize; 98 99 void createSurface (eResourceBarType type); 100 }; 101 102 #endif // ui_graphical_menu_widgets_special_resourcebarH 103