git repos / blockattack-game

commit 41f037b2

sago007 · 2016-04-17 16:37
41f037b226ceedc128fe6c597b51b4973c616f6b patch · browse files
parent 8b26cda872df54900167cef17c3c2d5a360075ee

Now with two different colors for rectangles

Changed files

M Game/data/sprites/gui_rect_white.sprite before
A Game/data/sprites/gui_rect_yellow.sprite
D Game/data/textures/gui_back.png before
A Game/data/textures/gui_back_white.png
A Game/data/textures/gui_back_yellow.png
M source/code/DialogBox.cpp before
diff --git a/Game/data/sprites/gui_rect_white.sprite b/Game/data/sprites/gui_rect_white.sprite index 8b200d1..e551532 100644 --- a/Game/data/sprites/gui_rect_white.sprite +++ b/Game/data/sprites/gui_rect_white.sprite
@@ -1,7 +1,7 @@
{
"ui_rect_white_nw" : {
- "texture" : "gui_back",
+ "texture" : "gui_back_white",
"topx" : 0,
"topy" : 0,
"height" : 32,
@@ -9,7 +9,7 @@
},
"ui_rect_white_n" : {
- "texture" : "gui_back",
+ "texture" : "gui_back_white",
"topx" : 32,
"topy" : 0,
"height" : 32,
@@ -17,7 +17,7 @@
},
"ui_rect_white_ne" : {
- "texture" : "gui_back",
+ "texture" : "gui_back_white",
"topx" : 160,
"topy" : 0,
"height" : 32,
@@ -25,7 +25,7 @@
},
"ui_rect_white_e" : {
- "texture" : "gui_back",
+ "texture" : "gui_back_white",
"topx" : 160,
"topy" : 32,
"height" : 32,
@@ -33,7 +33,7 @@
},
"ui_rect_white_se" : {
- "texture" : "gui_back",
+ "texture" : "gui_back_white",
"topx" : 160,
"topy" : 160,
"height" : 32,
@@ -41,7 +41,7 @@
},
"ui_rect_white_s" : {
- "texture" : "gui_back",
+ "texture" : "gui_back_white",
"topx" : 32,
"topy" : 160,
"height" : 32,
@@ -49,7 +49,7 @@
},
"ui_rect_white_sw" : {
- "texture" : "gui_back",
+ "texture" : "gui_back_white",
"topx" : 0,
"topy" : 160,
"height" : 32,
@@ -57,7 +57,7 @@
},
"ui_rect_white_w" : {
- "texture" : "gui_back",
+ "texture" : "gui_back_white",
"topx" : 0,
"topy" : 32,
"height" : 32,
@@ -65,7 +65,7 @@
},
"ui_rect_white_fill" : {
- "texture" : "gui_back",
+ "texture" : "gui_back_white",
"topx" : 32,
"topy" : 32,
"height" : 32,
diff --git a/Game/data/sprites/gui_rect_yellow.sprite b/Game/data/sprites/gui_rect_yellow.sprite new file mode 100644 index 0000000..22c33bd --- /dev/null +++ b/Game/data/sprites/gui_rect_yellow.sprite
@@ -0,0 +1,75 @@
+{
+
+"ui_rect_yellow_nw" : {
+ "texture" : "gui_back_yellow",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 32,
+ "width" : 32
+},
+
+"ui_rect_yellow_n" : {
+ "texture" : "gui_back_yellow",
+ "topx" : 32,
+ "topy" : 0,
+ "height" : 32,
+ "width" : 32
+},
+
+"ui_rect_yellow_ne" : {
+ "texture" : "gui_back_yellow",
+ "topx" : 160,
+ "topy" : 0,
+ "height" : 32,
+ "width" : 32
+},
+
+"ui_rect_yellow_e" : {
+ "texture" : "gui_back_yellow",
+ "topx" : 160,
+ "topy" : 32,
+ "height" : 32,
+ "width" : 32
+},
+
+"ui_rect_yellow_se" : {
+ "texture" : "gui_back_yellow",
+ "topx" : 160,
+ "topy" : 160,
+ "height" : 32,
+ "width" : 32
+},
+
+"ui_rect_yellow_s" : {
+ "texture" : "gui_back_yellow",
+ "topx" : 32,
+ "topy" : 160,
+ "height" : 32,
+ "width" : 32
+},
+
+"ui_rect_yellow_sw" : {
+ "texture" : "gui_back_yellow",
+ "topx" : 0,
+ "topy" : 160,
+ "height" : 32,
+ "width" : 32
+},
+
+"ui_rect_yellow_w" : {
+ "texture" : "gui_back_yellow",
+ "topx" : 0,
+ "topy" : 32,
+ "height" : 32,
+ "width" : 32
+},
+
+"ui_rect_yellow_fill" : {
+ "texture" : "gui_back_yellow",
+ "topx" : 32,
+ "topy" : 32,
+ "height" : 32,
+ "width" : 32
+}
+
+}
diff --git a/Game/data/textures/gui_back.png b/Game/data/textures/gui_back.png deleted file mode 100644 index 93a1c21..0000000
Binary files a/Game/data/textures/gui_back.png and /dev/null differ
diff --git a/Game/data/textures/gui_back_white.png b/Game/data/textures/gui_back_white.png new file mode 100644 index 0000000..0368709
Binary files /dev/null and b/Game/data/textures/gui_back_white.png differ
diff --git a/Game/data/textures/gui_back_yellow.png b/Game/data/textures/gui_back_yellow.png new file mode 100644 index 0000000..538eb7d
Binary files /dev/null and b/Game/data/textures/gui_back_yellow.png differ
diff --git a/source/code/DialogBox.cpp b/source/code/DialogBox.cpp index b69e9c2..ff412b7 100644 --- a/source/code/DialogBox.cpp +++ b/source/code/DialogBox.cpp
@@ -30,9 +30,7 @@ static void NFont_Write(SDL_Renderer* target, int x, int y, const std::string& t
nf_standard_blue_font.draw(target, x, y, "%s", text.c_str());
}
-static void DrawRect(SDL_Renderer* target, int topx, int topy, int height, int width) {
-
- std::string name = "ui_rect_white_";
+static void DrawRect(SDL_Renderer* target, int topx, int topy, int height, int width, const std::string& name) {
const int size = 32;
SDL_Rect bounds_ns = {topx, topy+size, width, height-2*size}; //bounds for south
SDL_Rect bounds_e = {topx, topy, width-size, height};
@@ -59,7 +57,16 @@ static void DrawRect(SDL_Renderer* target, int topx, int topy, int height, int w
ne.Draw(target, SDL_GetTicks(), topx+width-size, topy);
se.Draw(target, SDL_GetTicks(), topx+width-size, topy+height-size);
sw.Draw(target, SDL_GetTicks(), topx, topy+height-size);
-
+}
+
+static void DrawRectWhite(SDL_Renderer* target, int topx, int topy, int height, int width) {
+ std::string name = "ui_rect_white_";
+ DrawRect(target, topx, topy, height, width, name);
+}
+
+static void DrawRectYellow(SDL_Renderer* target, int topx, int topy, int height, int width) {
+ std::string name = "ui_rect_yellow_";
+ DrawRect(target, topx, topy, height, width, name);
}
bool OpenDialogbox(int x, int y, std::string& name) {
@@ -90,8 +97,8 @@ bool DialogBox::IsActive() {
void DialogBox::Draw(SDL_Renderer* target) {
backgroundImage.Draw(screen, SDL_GetTicks(), 0, 0);
//dialogBox.Draw(screen, SDL_GetTicks(), x, y);
- DrawRect(screen, 200, 100, 200, 600);
- DrawRect(screen, 226, 164, 54, 600-2*26);
+ DrawRectYellow(screen, 200, 100, 200, 600);
+ DrawRectWhite(screen, 226, 164, 54, 600-2*26);
NFont_Write(screen, x+40,y+76,rk->GetString());
std::string strHolder = rk->GetString();
strHolder.erase((int)rk->CharsBeforeCursor());