aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.cpp8
-rw-r--r--src/config.cpp9
-rw-r--r--src/entities.cpp4
-rw-r--r--src/gameplay.cpp8
-rw-r--r--src/inventory.cpp39
-rw-r--r--src/quest.cpp5
-rw-r--r--src/texture.cpp2
-rw-r--r--src/threadpool.cpp2
-rw-r--r--src/ui.cpp2
-rw-r--r--src/world.cpp12
10 files changed, 52 insertions, 39 deletions
diff --git a/src/common.cpp b/src/common.cpp
index 1c9c2b5..10ff64e 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -9,7 +9,7 @@
# include <vector>
#endif // __WIN32__
-#include <common.h>
+#include <common.hpp>
#ifndef __WIN32__
@@ -80,18 +80,18 @@ const char *readFile(const char *path){
std::ifstream in (path,std::ios::in);
unsigned int size;
GLchar *buf;
-
+
if(!in.is_open()){
std::cout<<"Error reading file "<<path<<"!"<<std::endl;
abort();
}
-
+
in.seekg(0,in.end);
buf = new GLchar[(size = in.tellg()) + 1];
in.seekg(0,in.beg);
in.read(buf,size);
buf[size] = '\0';
-
+
in.close();
return buf;
}
diff --git a/src/config.cpp b/src/config.cpp
index e076528..4f4ad89 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -1,11 +1,6 @@
-#include <config.h>
+#include <config.hpp>
-#include <iostream>
-
-#include <SDL2/SDL_mixer.h>
-
-#include <tinyxml2.h>
-#include <ui.h>
+#include <ui.hpp>
using namespace tinyxml2;
diff --git a/src/entities.cpp b/src/entities.cpp
index 5a92c48..6476755 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -1,7 +1,7 @@
#include <istream>
-#include <entities.h>
-#include <ui.h>
+#include <entities.hpp>
+#include <ui.hpp>
extern std::istream *names;
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 3c98461..f398ca0 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -1,7 +1,7 @@
-#include <common.h>
-#include <entities.h>
-#include <world.h>
-#include <ui.h>
+#include <common.hpp>
+#include <entities.hpp>
+#include <world.hpp>
+#include <ui.hpp>
#include <tinyxml2.h>
using namespace tinyxml2;
diff --git a/src/inventory.cpp b/src/inventory.cpp
index d9ff756..a2723fb 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -1,6 +1,6 @@
-#include <inventory.h>
-#include <entities.h>
-#include <ui.h>
+#include <inventory.hpp>
+#include <entities.hpp>
+#include <ui.hpp>
#include <tinyxml2.h>
using namespace tinyxml2;
@@ -312,6 +312,28 @@ void Inventory::draw(void){
glVertex2i(mr.x-(itemWide/2)+itemWide,mr.y-(itemWide/2)+itemWide);
glVertex2i(mr.x-(itemWide/2), mr.y-(itemWide/2)+itemWide);
glEnd();
+ if(!items.empty() && a < items.size() && items[a+numSlot].count){
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, itemtex[items[a+numSlot].id]);
+ glColor4f(1.0f, 1.0f, 1.0f, ((float)massDfp[a]/(float)(massRange?massRange:1))*0.8f);
+ glBegin(GL_QUADS);
+ if(itemMap[items[a].id]->height > itemMap[items[a+numSlot].id]->width){
+ glTexCoord2i(0,1);glVertex2i(mr.x-((itemWide/2)*((float)itemMap[items[a+numSlot].id]->width/(float)itemMap[items[a+numSlot].id]->height)), mr.y-(itemWide/2));
+ glTexCoord2i(1,1);glVertex2i(mr.x+((itemWide/2)*((float)itemMap[items[a+numSlot].id]->width/(float)itemMap[items[a+numSlot].id]->height)), mr.y-(itemWide/2));
+ glTexCoord2i(1,0);glVertex2i(mr.x+((itemWide/2)*((float)itemMap[items[a+numSlot].id]->width/(float)itemMap[items[a+numSlot].id]->height)), mr.y+(itemWide/2));
+ glTexCoord2i(0,0);glVertex2i(mr.x-((itemWide/2)*((float)itemMap[items[a+numSlot].id]->width/(float)itemMap[items[a+numSlot].id]->height)), mr.y+(itemWide/2));
+ }else{
+ glTexCoord2i(0,1);glVertex2i(mr.x-(itemWide/2),mr.y-(itemWide/2)*((float)itemMap[items[a+numSlot].id]->height/(float)itemMap[items[a+numSlot].id]->width));
+ glTexCoord2i(1,1);glVertex2i(mr.x+(itemWide/2),mr.y-(itemWide/2)*((float)itemMap[items[a+numSlot].id]->height/(float)itemMap[items[a+numSlot].id]->width));
+ glTexCoord2i(1,0);glVertex2i(mr.x+(itemWide/2),mr.y+(itemWide/2)*((float)itemMap[items[a+numSlot].id]->height/(float)itemMap[items[a+numSlot].id]->width));
+ glTexCoord2i(0,0);glVertex2i(mr.x-(itemWide/2),mr.y+(itemWide/2)*((float)itemMap[items[a+numSlot].id]->height/(float)itemMap[items[a+numSlot].id]->width));
+ }
+ glEnd();
+ glDisable(GL_TEXTURE_2D);
+ ui::setFontColor(255,255,255,((float)massDfp[a]/(float)(massRange?massRange:1))*255);
+ ui::putText(mr.x-(itemWide/2)+(itemWide*.85),mr.y-(itemWide/2),"%d",items[a+numSlot].count);
+ ui::setFontColor(255,255,255,255);
+ }
a++;
}a=0;
@@ -362,14 +384,16 @@ void Inventory::draw(void){
}
glEnd();
glDisable(GL_TEXTURE_2D);
- ui::putText(r.end.x-(itemWide/2),r.end.y-(itemWide*.9),"%s",itemMap[items[a].id]->name.c_str());
+ ui::setFontColor(255,255,255,((float)dfp[a]/(float)(range?range:1))*255);
+ ui::putStringCentered(r.end.x,r.end.y-(itemWide*.9),itemMap[items[a].id]->name.c_str());
ui::putText(r.end.x-(itemWide/2)+(itemWide*.85),r.end.y-(itemWide/2),"%d",items[a].count);
+ ui::setFontColor(255,255,255,255);
}
if(sel == a){
static float sc = 1;
static bool up;
- up ? sc += .01 : sc -= .01;
+ up ? sc += .0005*deltaTime : sc -= .0005*deltaTime;
if(sc > 1.2){
up = false;
sc = 1.2;
@@ -378,10 +402,6 @@ void Inventory::draw(void){
up = true;
sc = 1.0;
}
- glPushMatrix();
- glLoadIdentity();
- //glTranslatef(-sc, -sc, 0);
- //glScalef(sc,sc,0.0f);
glBegin(GL_QUADS);
glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)(range?range:1)));
glVertex2f(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09);
@@ -404,7 +424,6 @@ void Inventory::draw(void){
glVertex2f(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09);
glVertex2f(r.end.x + (itemWide*sc)/2 ,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09);
glEnd();
- glPopMatrix();
}
a++;
}
diff --git a/src/quest.cpp b/src/quest.cpp
index ba35c40..4ab827f 100644
--- a/src/quest.cpp
+++ b/src/quest.cpp
@@ -1,7 +1,7 @@
#include <algorithm>
-#include <quest.h>
-#include <entities.h>
+#include <quest.hpp>
+#include <entities.hpp>
extern Player *player;
@@ -50,7 +50,6 @@ int QuestHandler::finish(std::string t){
for ( auto &n : (*c).need )
player->inv->takeItem( n.first, n.second );
-
current.erase( c );
return 1;
}
diff --git a/src/texture.cpp b/src/texture.cpp
index 35d7b80..a361f19 100644
--- a/src/texture.cpp
+++ b/src/texture.cpp
@@ -1,7 +1,7 @@
#include <algorithm>
#include <string>
-#include <texture.h>
+#include <texture.hpp>
/**
* A structure for keeping track of loaded textures.
diff --git a/src/threadpool.cpp b/src/threadpool.cpp
index 619f002..c4f1c4a 100644
--- a/src/threadpool.cpp
+++ b/src/threadpool.cpp
@@ -1,4 +1,4 @@
-#include "threadpool.h"
+#include <threadpool.hpp>
/**
* Stolen from some guy.
diff --git a/src/ui.cpp b/src/ui.cpp
index 69fe1bf..0479bd3 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -1,4 +1,4 @@
-#include <ui.h>
+#include <ui.hpp>
/*
* Create a macro to easily access SDL keypresses
diff --git a/src/world.cpp b/src/world.cpp
index 623c1c2..0cff9d4 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -1,8 +1,8 @@
#include <algorithm>
#include <sstream>
-#include <world.h>
-#include <ui.h>
+#include <world.hpp>
+#include <ui.hpp>
#include <tinyxml2.h>
using namespace tinyxml2;
@@ -432,10 +432,10 @@ void World::draw(Player *p){
safeSetColorA( 255, 255, 255, weather == WorldWeather::Snowy ? 150 : 255 - worldShade * 4);
glBegin( GL_QUADS );
- glTexCoord2i( 0, 0 ); glVertex2i( worldStart, SCREEN_HEIGHT );
- glTexCoord2i( 1, 0 ); glVertex2i( -worldStart, SCREEN_HEIGHT );
- glTexCoord2i( 1, 1 ); glVertex2i( -worldStart, 0 );
- glTexCoord2i( 0, 1 ); glVertex2i( worldStart, 0 );
+ glTexCoord2i( 0, 0 ); glVertex2i( offset.x - SCREEN_WIDTH/2, SCREEN_HEIGHT );
+ glTexCoord2i( 1, 0 ); glVertex2i( offset.x + SCREEN_WIDTH/2, SCREEN_HEIGHT );
+ glTexCoord2i( 1, 1 ); glVertex2i( offset.x + SCREEN_WIDTH/2, 0 );
+ glTexCoord2i( 0, 1 ); glVertex2i( offset.x - SCREEN_WIDTH/2, 0 );
glEnd();
bgTex->bindNext();