aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--assets/dialog_en-us2
-rw-r--r--assets/ui/button_corners.pngbin0 -> 786 bytes
-rw-r--r--assets/ui/button_corners_flat.pngbin0 -> 282 bytes
-rw-r--r--assets/ui/button_side_borders.pngbin0 -> 203 bytes
-rw-r--r--assets/ui/button_side_borders_flat.pngbin0 -> 192 bytes
-rw-r--r--assets/ui/button_top_bot_borders.pngbin0 -> 198 bytes
-rw-r--r--assets/ui/button_top_bot_borders_flat.pngbin0 -> 196 bytes
-rw-r--r--brice.dat8
-rw-r--r--include/ui.hpp1
-rw-r--r--shaders/world.frag1
-rw-r--r--src/ui.cpp162
-rw-r--r--xml/000.xml2
-rw-r--r--xml/playerSpawnHill1_Building1.xml2
13 files changed, 167 insertions, 11 deletions
diff --git a/assets/dialog_en-us b/assets/dialog_en-us
index dfe7b03..2224aa6 100644
--- a/assets/dialog_en-us
+++ b/assets/dialog_en-us
@@ -4,7 +4,7 @@ I heard if you complete a quest, you'll get a special reward.
How much wood could a woodchuck chuck if a woodchuck could chuck wood?
I don't think anyone has ever been able to climb up that hill.
If you ever see a hole in the ground, watch out; it could mean the end for you.
-Did you know this game has over 5000 lines of code? I didn't. I didn't even know I was in a game until now...
+Did you know this game has over 10000 lines of code? I didn't. I didn't even know I was in a game until now...
HELP MY CAPS LOCK IS STUCK
You know, if anyone ever asked me who I wanted to be when I grow up, I would say Abby Ross.
I want to have the wallpaper in our house changed. It doesn't really fit the environment.
diff --git a/assets/ui/button_corners.png b/assets/ui/button_corners.png
new file mode 100644
index 0000000..38f0cf9
--- /dev/null
+++ b/assets/ui/button_corners.png
Binary files differ
diff --git a/assets/ui/button_corners_flat.png b/assets/ui/button_corners_flat.png
new file mode 100644
index 0000000..527500f
--- /dev/null
+++ b/assets/ui/button_corners_flat.png
Binary files differ
diff --git a/assets/ui/button_side_borders.png b/assets/ui/button_side_borders.png
new file mode 100644
index 0000000..4f0ec6d
--- /dev/null
+++ b/assets/ui/button_side_borders.png
Binary files differ
diff --git a/assets/ui/button_side_borders_flat.png b/assets/ui/button_side_borders_flat.png
new file mode 100644
index 0000000..ef9dbfe
--- /dev/null
+++ b/assets/ui/button_side_borders_flat.png
Binary files differ
diff --git a/assets/ui/button_top_bot_borders.png b/assets/ui/button_top_bot_borders.png
new file mode 100644
index 0000000..f78b1e3
--- /dev/null
+++ b/assets/ui/button_top_bot_borders.png
Binary files differ
diff --git a/assets/ui/button_top_bot_borders_flat.png b/assets/ui/button_top_bot_borders_flat.png
new file mode 100644
index 0000000..431e6b8
--- /dev/null
+++ b/assets/ui/button_top_bot_borders_flat.png
Binary files differ
diff --git a/brice.dat b/brice.dat
index 3b090ad..2653f9c 100644
--- a/brice.dat
+++ b/brice.dat
@@ -1,7 +1,7 @@
3
-canSprint
-0
-canJump
-0
Slow
1
+canJump
+0
+canSprint
+0
diff --git a/include/ui.hpp b/include/ui.hpp
index 7d9b9f5..507a211 100644
--- a/include/ui.hpp
+++ b/include/ui.hpp
@@ -108,6 +108,7 @@ namespace ui {
*/
void drawBox(vec2 c1, vec2 c2);
+ void drawNiceBox(vec2 c1, vec2 c2, float z);
void dialogBox(std::string name, std::string opt, bool passive, std::string text, ...);
void merchantBox(const char *name,Trade trade,const char *opt,bool passive,const char *text,...);
void merchantBox();
diff --git a/shaders/world.frag b/shaders/world.frag
index 617cbb1..87d86ca 100644
--- a/shaders/world.frag
+++ b/shaders/world.frag
@@ -26,7 +26,6 @@ void main()
if (dist < light[i].w) {
float attenuation = clamp(1.0f - dist*dist/(light[i].w*light[i].w), 0.0f, 1.0f);
attenuation *= attenuation;
-
shadeColor += (vec4(attenuation, attenuation, attenuation, 0.0f) * vec4(lightColor[i])) * lightImpact;
}
}
diff --git a/src/ui.cpp b/src/ui.cpp
index c5d134e..8f234df 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -731,6 +731,163 @@ namespace ui {
glUseProgram(0);
}
+ void drawNiceBox(vec2 c1, vec2 c2, float z) {
+ // the textures for the box corners
+ static GLuint box_corner = Texture::loadTexture("assets/ui/button_corners.png");
+ static GLuint box_side_top = Texture::loadTexture("assets/ui/button_top_bot_borders.png");
+ static GLuint box_side = Texture::loadTexture("assets/ui/button_side_borders.png");
+
+ // the dimensions of the corner textures
+ static dim2 box_corner_dim_t = Texture::imageDim("assets/ui/button_corners.png");
+ static vec2 box_corner_dim = vec2(box_corner_dim_t.x / 2.0, box_corner_dim_t.y / 2.0);
+
+ // the amount of bytes to skip in the OpenGL arrays (see below)
+ auto stride = 5 * sizeof(GLfloat);
+
+ // we always want to make sure c1 is lower left and c2 is upper right
+ if (c1.x > c2.x) std::swap(c1.x, c2.y);
+ if (c1.y > c2.y) std::swap(c1.y, c2.y);
+
+ // if the box is too small, we will not be able to draw it
+ if (c2.x - c1.x < (box_corner_dim_t.x)) return;
+ if (c2.y - c1.y < (box_corner_dim_t.y)) return;
+
+
+ GLfloat box_ul[] = {c1.x, c2.y - box_corner_dim.y, z, 0.0f, 0.5f,
+ c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f,
+ c1.x + box_corner_dim.x, c2.y, z, 0.5f, 1.0f,
+
+ c1.x + box_corner_dim.x, c2.y, z, 0.5f, 1.0f,
+ c1.x, c2.y, z, 0.0f, 1.0f,
+ c1.x, c2.y - box_corner_dim.y, z, 0.0f, 0.5f};
+
+ GLfloat box_ll[] = {c1.x, c1.y, z, 0.0f, 0.0f,
+ c1.x + box_corner_dim.x, c1.y, z, 0.5f, 0.0f,
+ c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.5f,
+
+ c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.5f,
+ c1.x, c1.y + box_corner_dim.y, z, 0.0f, 0.5f,
+ c1.x, c1.y, z, 0.0f, 0.0f};
+
+ GLfloat box_ur[] = {c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f,
+ c2.x, c2.y - box_corner_dim.y, z, 1.0f, 0.5f,
+ c2.x, c2.y, z, 1.0f, 1.0f,
+
+ c2.x, c2.y, z, 1.0f, 1.0f,
+ c2.x - box_corner_dim.x, c2.y, z, 0.5f, 1.0f,
+ c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f};
+
+ GLfloat box_lr[] = {c2.x - box_corner_dim.x, c1.y, z, 0.5f, 0.0f,
+ c2.x, c1.y, z, 1.0f, 0.0f,
+ c2.x, c1.y + box_corner_dim.y, z, 1.0f, 0.5f,
+
+ c2.x, c1.y + box_corner_dim.y, z, 1.0f, 0.5f,
+ c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.0f, 0.5f,
+ c2.x - box_corner_dim.x, c1.y, z, 0.5f, 0.0f};
+
+ GLfloat box_l[] = {c1.x, c1.y + box_corner_dim.y, z, 0.0f, 0.0f,
+ c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.0f,
+ c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 1.0f,
+
+ c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 1.0f,
+ c1.x, c2.y - box_corner_dim.y, z, 0.0f, 1.0f,
+ c1.x, c1.y + box_corner_dim.y, z, 0.0f, 0.0f};
+
+ GLfloat box_r[] = {c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.0f,
+ c2.x, c1.y + box_corner_dim.y, z, 1.0f, 0.0f,
+ c2.x, c2.y - box_corner_dim.y, z, 1.0f, 1.0f,
+
+ c2.x, c2.y - box_corner_dim.y, z, 1.0f, 1.0f,
+ c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 1.0f,
+ c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.0f};
+
+ GLfloat box_b[] = {c1.x + box_corner_dim.x, c1.y, z, 0.0f, 0.0f,
+ c2.x - box_corner_dim.x, c1.y, z, 1.0f, 0.0f,
+ c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 1.0f, 0.5f,
+
+ c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 1.0f, 0.5f,
+ c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.0f, 0.5f,
+ c1.x + box_corner_dim.x, c1.y, z, 0.0f, 0.0f};
+
+ GLfloat box_t[] = {c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.0f, 0.5f,
+ c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 1.0f, 0.5f,
+ c2.x - box_corner_dim.x, c2.y, z, 1.0f, 1.0f,
+
+ c2.x - box_corner_dim.x, c2.y, z, 1.0f, 1.0f,
+ c1.x + box_corner_dim.x, c2.y, z, 0.0f, 1.0f,
+ c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.0f, 0.5f};
+
+ GLfloat box_f[] = {c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.5f,
+ c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.5f,
+ c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f,
+
+ c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f,
+ c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f,
+ c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.5f};
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, box_corner);
+ glUniform1f(textShader_uniform_texture, 0);
+ glUseProgram(textShader);
+
+ glEnableVertexAttribArray(textShader_attribute_coord);
+ glEnableVertexAttribArray(textShader_attribute_tex);
+
+ // draw upper left corner
+ glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_ul[0]);
+ glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_ul[3]);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ // lower left corner
+ glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_ll[0]);
+ glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_ll[3]);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ // upper right corner
+ glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_ur[0]);
+ glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_ur[3]);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ // lower right corner
+ glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_lr[0]);
+ glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_lr[3]);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ // draw the middle of the box
+ glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_f[0]);
+ glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_f[3]);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ glBindTexture(GL_TEXTURE_2D, box_side);
+
+ // draw the left edge of the box
+ glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_l[0]);
+ glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_l[3]);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ // draw right edge of the box
+ glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_r[0]);
+ glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_r[3]);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ glBindTexture(GL_TEXTURE_2D, box_side_top);
+
+ // draw bottom of the box
+ glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_b[0]);
+ glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_b[3]);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ // draw top of the box
+ glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_t[0]);
+ glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_t[3]);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ glDisableVertexAttribArray(textShader_attribute_coord);
+ glDisableVertexAttribArray(textShader_attribute_tex);
+
+ glUseProgram(0);
+ }
+
void draw(void){
unsigned char i;
float x,y,tmp;
@@ -800,8 +957,7 @@ namespace ui {
x = offset.x - SCREEN_WIDTH / 6;
y = (offset.y + SCREEN_HEIGHT / 2) - HLINES(8);
- drawBox(vec2 {x, y}, vec2 {x + SCREEN_WIDTH / 3, y - SCREEN_HEIGHT * 0.6f});
-
+ drawNiceBox(vec2(x, y), vec2(x + (SCREEN_WIDTH / 3.0f), y - (SCREEN_HEIGHT * 0.6f)), -7.0f);
// draw typeOut'd text
putString(x + game::HLINE, y - fontSize - game::HLINE, (rtext = typeOut(dialogBoxText)));
@@ -934,7 +1090,7 @@ namespace ui {
x = offset.x - SCREEN_WIDTH / 2 + HLINES(8);
y = offset.y + SCREEN_HEIGHT / 2 - HLINES(8);
- drawBox(vec2 {x, y}, vec2 {x + SCREEN_WIDTH - HLINES(16), y - SCREEN_HEIGHT / 4});
+ drawNiceBox(vec2 {x, y}, vec2 {x + SCREEN_WIDTH - HLINES(16), y - SCREEN_HEIGHT / 4}, -7.0);
rtext = typeOut(dialogBoxText);
putString(x + game::HLINE, y - fontSize - game::HLINE, rtext);
diff --git a/xml/000.xml b/xml/000.xml
index 9996cec..1779b0c 100644
--- a/xml/000.xml
+++ b/xml/000.xml
@@ -8,7 +8,7 @@
<time>3400</time>
<spawnx>-880</spawnx>
<trigger spawnx="-850" id="first" notext="1"/>
- <npc name="Guy" hasDialog="true" spawnx="0" canMove="false" health="1" x="-582.05096" y="65.998985" dindex="9999"/>
+ <npc name="Guy" hasDialog="true" spawnx="0" canMove="false" health="1" x="-582.05096" y="66.298981" dindex="9999"/>
</World>
<Trigger id="first">Guy</Trigger>
diff --git a/xml/playerSpawnHill1_Building1.xml b/xml/playerSpawnHill1_Building1.xml
index 0b51b55..b86fd9f 100644
--- a/xml/playerSpawnHill1_Building1.xml
+++ b/xml/playerSpawnHill1_Building1.xml
@@ -10,7 +10,7 @@
<Dialog name="Bob">
<text id="0" nextid="1" pause="true">
Hey. Have a Dank MayMay :)
- <give id="Dank MayMay" count="1"/></text>
+ <give id="Dank MayMay" count="1"/></text>
<text id="1" nextid="2">
What? You want another Dank MayMay?
</text>