diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 25 | ||||
-rw-r--r-- | include/inventory.h | 14 | ||||
-rw-r--r-- | include/ui.h | 44 |
3 files changed, 51 insertions, 32 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/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 f933a37..a4fed3e 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> @@ -99,12 +100,12 @@ namespace ui { /* * These flags are used elsewhere. */ - + extern unsigned int fontSize; - + extern bool debug; extern bool posFlag; - + extern unsigned char dialogOptChosen; extern unsigned char merchOptChosen; extern bool dialogBoxExists; @@ -112,59 +113,62 @@ namespace ui { extern bool dialogPassive; extern unsigned int textWrapLimit; + extern int fontTransInv; /* * Initializes the FreeType system. */ void initFonts(void); - + void destroyFonts(void); - + /* * Sets the current font/font size. */ - + 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. */ - + float putStringCentered(const float x,const float y,const char *s); - + /* * Draws a formatted string at the given coordinates. */ - + float putText(const float x,const float y,const char *str,...); - + /* * Creates a dialogBox text string (format: `name`: `text`). This function simply sets up * variables that are drawn in ui::draw(). When the dialog box exists player control is * limited until a right click is given, closing the box. */ - + 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); - + /* * Draws a larger string in the center of the screen. Drawing is done inside this function. */ - + void importantText(const char *text,...); void passiveImportantText(int duration,const char *text,...); - + /* * Draw various UI elements (dialogBox, player health) */ - + void draw(void); - + /* * Draw various menu items @@ -177,17 +181,17 @@ namespace ui { * Handle keyboard/mouse events. */ void handleEvents(void); - + /* * Toggle the black overlay thing. */ - + void toggleBlack(void); void toggleBlackFast(void); void toggleWhite(void); void toggleWhiteFast(void); void waitForCover(void); - + } #endif // UI_H |