Bubba-3D  0.9.0
Awesome game engine!
HUDGraphic.h
1 /*
2  * This file is part of Bubba-3D.
3  *
4  * Bubba-3D is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Bubba-3D 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 Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with Bubba-3D. If not, see http://www.gnu.org/licenses/.
16  */
17 #pragma once
18 
19 #include <Dimension.h>
20 #include <linmath/float2.h>
21 #include <linmath/float3.h>
22 #include <linmath/float4.h>
23 
24 class Texture;
25 
29 class HUDGraphic {
30 
31 public:
32 
36  class Color {
37  public:
44  Color(std::string hexString);
52  Color(std::string hexString, float opacity);
53 
58  Color(int red, int green, int blue);
59 
65  Color(int red, int green, int blue, float opacity);
66 
70  Color(chag::float4 rawColor);
71 
75  chag::float4 getColor();
76 
77  private:
78  chag::float4 color;
79  void hexStringToFloat(std::string hexString,unsigned int pos, unsigned int len, float* target);
80  };
81 
82  template <typename T>
84  T botLeftX, botLeftY,topRightX,topRightY;
85  bool empty = true;
86  TexturePosition(T botLeftX, T botLeftY, T topRightX, T topRightY)
87  : botLeftX(botLeftX), botLeftY(botLeftY), topRightX(topRightX), topRightY(topRightY), empty(false) {}
88  TexturePosition() {}
89  bool isEmpty();
90  };
91 
96  HUDGraphic(Texture* texture);
97 
101  HUDGraphic(Color color);
102 
106  HUDGraphic* setCenterOffset(Dimension offsetX, Dimension offsetY);
107 
112 
116  TexturePosition<float> getTexturePosition();
117 
121  chag::float3 getCenterOffset(float width, float height);
122 
127  Texture* getTexture();
128 
133  chag::float4 getColor();
134 
138  bool isTextureElseColor();
139 
144  int* getRoundedCorners();
145 
150  int* getBorders();
151 
155  chag::float4 getBorderColor();
156 
157  HUDGraphic* setRoundedCorners(int pixels);
158  HUDGraphic* setRoundedCorners(int topLeft, int topRight, int botRight, int botLeft);
159  HUDGraphic* setBorder(int pixels, Color borderColor);
160  HUDGraphic* setBorder(int botAndTop, int leftAndRight, Color borderColor);
161  HUDGraphic* setBorder(int top, int right, int bot, int left, Color borderColor);
162  HUDGraphic* setBorderSize(int top, int right, int bot, int left);
163  HUDGraphic* setBorderColor(Color borderColor);
164  HUDGraphic* setBackground(Color color);
165  HUDGraphic* setBackground(Texture* texture);
166 
167 protected:
168 
169  Dimension offsetX, offsetY;
170  Texture* texture = nullptr;
171  chag::float4 color;
172  TexturePosition<int> texturePosition;
173  bool textureElseColor;
174  int roundedCorners[4] = {0, 0, 0, 0};
175  int borders[4] = {0, 0, 0, 0};
176  chag::float4 borderColor;
177 };
chag::float4 getColor()
Definition: HUDGraphic.cpp:211
HUDGraphic * setCenterOffset(Dimension offsetX, Dimension offsetY)
Definition: HUDGraphic.cpp:38
Color(std::string hexString)
Definition: HUDGraphic.cpp:168
chag::float4 getBorderColor()
Definition: HUDGraphic.cpp:102
Texture * getTexture()
Definition: HUDGraphic.cpp:69
int * getBorders()
Definition: HUDGraphic.cpp:106
bool isTextureElseColor()
Definition: HUDGraphic.cpp:75
HUDGraphic * setTexturePosition(TexturePosition< int > texturePosition)
Definition: HUDGraphic.cpp:44
HUDGraphic(Texture *texture)
Definition: HUDGraphic.cpp:29
int * getRoundedCorners()
Definition: HUDGraphic.cpp:122