aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-03-21 08:49:48 -0400
committerClyne Sullivan <tullivan99@gmail.com>2016-03-21 08:49:48 -0400
commitafdbe5de31c9ae1009d36710eb2b1c31ec44a9f5 (patch)
tree58812c528ea6d4995a6acad83a156c6fd5bd0407 /include
parent3432a970912dac94d9ba527f10f0354dcc396bf4 (diff)
parent51c6e601c3d6451294506b72213244e3aee9822f (diff)
cleaning up ui code
Diffstat (limited to 'include')
-rw-r--r--include/common.h25
-rw-r--r--include/entities.h1
-rw-r--r--include/inventory.h14
-rw-r--r--include/ui.h6
-rw-r--r--include/world.h1
5 files changed, 34 insertions, 13 deletions
diff --git a/include/common.h b/include/common.h
index 58d561f..6f453b0 100644
--- a/include/common.h
+++ b/include/common.h
@@ -1,6 +1,6 @@
/** @file common.h
* @brief Common items needed by most other files.
- *
+ *
* This file contains headers, variables and functions that are needed in
* most other files included in this project.
*/
@@ -14,12 +14,13 @@
#include <string>
#include <vector>
#include <string>
-#include <fstream>
+#include <fstream>
#include <thread>
#include <mutex>
#include <future>
#include <math.h>
#include <threadpool.h>
+#include <algorithm>
#define GLEW_STATIC
#include <GL/glew.h>
@@ -48,6 +49,17 @@ N abso(N v){
return v;
}
+template<class A>
+float averagef(A v){
+ float avg = 0;
+ for(auto &a : v){
+ avg += a;
+ }
+ avg /= v.size();
+ return avg;
+}
+
+
extern GLuint colorIndex; // Texture.cpp?
/**
@@ -130,7 +142,7 @@ extern std::mutex mtx;
* definition was made. Every item being drawn to the screen and most object detection/physic
* handling is done based off of this number. Increasing it will give the game a zoomed-in
* feel, while decreasing it will do the opposite.
- *
+ *
*/
extern unsigned int HLINE;
@@ -159,7 +171,7 @@ extern float VOLUME_SFX;
* Included in common.h is a prototype for DEBUG_prints, which writes a formatted
* string to the console containing the callee's file and line number. This macro simplifies
* it to a simple printf call.
- *
+ *
* DEBUG must be defined for this macro to function.
*/
@@ -181,7 +193,7 @@ extern unsigned int deltaTime;
/**
* References the variable in main.cpp, used for drawing with the player.
*/
-
+
extern vec2 offset;
/**
@@ -211,11 +223,12 @@ void safeSetColor(int r,int g,int b);
void safeSetColorA(int r,int g,int b,int a);
+
/**
* We've encountered many problems when attempting to create delays for triggering
* the logic function. As a result, we decided on using the timing libraries given
* by <chrono> in the standard C++ library. This function simply returns the amount
- * of milliseconds that have passed sine the epoch.
+ * of milliseconds that have passed since the epoch.
*/
#ifdef __WIN32__
diff --git a/include/entities.h b/include/entities.h
index ef421f5..450975f 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -219,6 +219,7 @@ public:
class Merchant : public NPC{
public:
std::vector<Trade>trade;
+ uint currTrade;
void interact();
diff --git a/include/inventory.h b/include/inventory.h
index 69cf073..7369642 100644
--- a/include/inventory.h
+++ b/include/inventory.h
@@ -11,11 +11,11 @@
class Item{
public:
std::string name,type;
-
+
float width;
float height;
int maxStackSize;
-
+
std::string texloc;
Texturec *tex;
@@ -45,16 +45,18 @@ public:
Inventory(unsigned int s); // Creates an inventory of size 's'
~Inventory(void); // Free's allocated memory
-
+
int addItem(std::string name,uint count);
int takeItem(std::string name,uint count);
int hasItem(std::string name);
-
+
int useItem(void);
bool detectCollision(vec2,vec2);
-
+
void setSelection(unsigned int s);
-
+ void setSelectionUp();
+ void setSelectionDown();
+
void draw(void); // Draws a text list of items in this inventory (should only be called for the player for now)
};
diff --git a/include/ui.h b/include/ui.h
index 072d418..2a7518f 100644
--- a/include/ui.h
+++ b/include/ui.h
@@ -6,6 +6,7 @@
#define UI_H
#include <common.h>
+#include <inventory.h>
#include <cstdarg>
#include <config.h>
@@ -106,11 +107,13 @@ namespace ui {
extern bool posFlag;
extern unsigned char dialogOptChosen;
+ extern unsigned char merchOptChosen;
extern bool dialogBoxExists;
extern bool dialogImportant;
extern bool dialogPassive;
extern unsigned int textWrapLimit;
+ extern int fontTransInv;
/*
* Initializes the FreeType system.
@@ -126,6 +129,7 @@ namespace ui {
void setFontFace(const char *ttf);
void setFontSize(unsigned int size);
+ void setFontColor(unsigned char r,unsigned char g,unsigned char b, unsigned char a);
/*
* Draw a centered string.
@@ -148,10 +152,10 @@ namespace ui {
void dialogBox(const char *name,const char *opt,bool passive,const char *text,...);
void merchantBox(const char *name,Trade trade,const char *opt,bool passive,const char *text,...);
void merchantBox();
+ void closeBox();
void waitForDialog(void);
void drawPage( std::string path );
-
/*
* Draws a larger string in the center of the screen. Drawing is done inside this function.
*/
diff --git a/include/world.h b/include/world.h
index 3a2d445..152d654 100644
--- a/include/world.h
+++ b/include/world.h
@@ -53,6 +53,7 @@ enum class WorldWeather : unsigned char {
typedef struct {
vec2 loc; /**< Light location */
Color color; /**< Light color */
+ float radius;
} Light;
/**