aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/common.hpp2
-rw-r--r--include/ui.hpp3
-rw-r--r--include/ui_action.hpp21
-rw-r--r--include/ui_menu.hpp11
-rw-r--r--include/world.hpp95
5 files changed, 52 insertions, 80 deletions
diff --git a/include/common.hpp b/include/common.hpp
index 65ac47b..a7ad6ec 100644
--- a/include/common.hpp
+++ b/include/common.hpp
@@ -160,6 +160,8 @@ extern std::mutex mtx;
*
*/
+#define HLINES(n) (HLINE * n)
+
extern unsigned int HLINE;
extern float VOLUME_MASTER;
diff --git a/include/ui.hpp b/include/ui.hpp
index 5281d31..5ddf165 100644
--- a/include/ui.hpp
+++ b/include/ui.hpp
@@ -11,7 +11,9 @@
#include <config.hpp>
#include <world.hpp>
+
#include <ui_menu.hpp>
+#include <ui_action.hpp>
#include <ft2build.h>
#include <SDL2/SDL_opengl.h>
@@ -109,6 +111,7 @@ namespace ui {
* limited until a right click is given, closing the box.
*/
+ void drawBox(vec2 c1, vec2 c2);
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();
diff --git a/include/ui_action.hpp b/include/ui_action.hpp
new file mode 100644
index 0000000..a275ab3
--- /dev/null
+++ b/include/ui_action.hpp
@@ -0,0 +1,21 @@
+#ifndef ACTION_H_
+#define ACTION_H_
+
+#include <common.hpp>
+#include <ui.hpp>
+
+namespace ui {
+ namespace action {
+ extern bool make;
+
+ // enables the action ui
+ void enable(void);
+ // disables the action ui
+ void disable(void);
+
+ // draws the action ui
+ void draw(vec2 loc);
+ }
+}
+
+#endif // ACTION_H_
diff --git a/include/ui_menu.hpp b/include/ui_menu.hpp
index bfeecba..621676a 100644
--- a/include/ui_menu.hpp
+++ b/include/ui_menu.hpp
@@ -3,6 +3,7 @@
#include <common.hpp>
#include <config.hpp>
+#include <ui.hpp>
typedef void (*menuFunc)(void);
@@ -13,7 +14,7 @@ struct menuItem {
vec2 loc;
dim2 dim;
Color color;
-
+
const char *text;
menuFunc func;
} button;
@@ -21,11 +22,11 @@ struct menuItem {
vec2 loc;
dim2 dim;
Color color;
-
+
float minValue;
float maxValue;
float sliderLoc;
-
+
const char *text;
float *var;
} slider;
@@ -36,7 +37,7 @@ class Menu {
public:
std::vector<menuItem> items;
Menu *child, *parent;
-
+
~Menu() {
// TODO you CANNOT delete null pointers!
/*child = NULL;
@@ -55,7 +56,7 @@ namespace ui {
menuItem createChildButton(vec2 l, dim2 d, Color c, const char* t);
menuItem createParentButton(vec2 l, dim2 d, Color c, const char* t);
menuItem createSlider(vec2 l, dim2 d, Color c, float min, float max, const char* t, float* v);
-
+
void draw(void);
}
}
diff --git a/include/world.hpp b/include/world.hpp
index bee2bcf..5608acc 100644
--- a/include/world.hpp
+++ b/include/world.hpp
@@ -134,7 +134,6 @@ public:
vec2 start;
vec2 end;
bool in;
- std::vector<Structures *> build;
Village(const char *meme, World *w);
~Village(void){}
@@ -251,16 +250,19 @@ protected:
std::vector<std::string> sTexLoc;
- std::vector<Light> light;
- std::vector<Village> village;
- std::vector<Particles> particles;
- std::vector<Object> object;
- std::vector<Mob> mob;
+ std::vector<Light> light;
+ std::vector<Village> village;
+ std::vector<Particles> particles;
+ std::vector<Object> object;
+ std::vector<Mob *> mob;
+ std::vector<Structures *> build;
public:
Light *getLastLight(void);
Mob *getLastMob(void);
+ Entity *getNearInteractable(Entity e);
+ vec2 getStructurePos(int index);
std::string getSTextureLocation(unsigned int index) const;
@@ -280,20 +282,9 @@ public:
* world.
*/
- std::vector<Entity *> entity;
-
- /**
- * A vector of all NPCs in this world.
- */
-
- std::vector<NPC *> npc;
- std::vector<Merchant *> merchant;
-
- /**
- * A vector of all Structures in this world.
- */
-
- std::vector<Structures *> build;
+ std::vector<Entity *> entity;
+ std::vector<NPC *> npc;
+ std::vector<Merchant *> merchant;
/**
* NULLifies pointers and allocates necessary memory. This should be
@@ -309,64 +300,18 @@ public:
virtual ~World(void);
- /**
- * Adds a structure to the world, with the specified subtype and
- * coordinates. `inside` is a file name for the IndoorWorld XML file that
- * this structure will lead to; if NULL the player won't be able to enter
- * the structure.
- */
-
- void addStructure(BUILD_SUB subtype,float x,float y, std::string tex, std::string inside);
+ void addLight(vec2 xy, Color color);
+ void addMerchant(float x, float y, bool housed);
+ void addMob(int type,float x,float y);
+ void addMob(int t,float x,float y,void (*hey)(Mob *));
+ void addNPC(float x,float y);
+ void addObject(std::string in, std::string pickupDialog, float x, float y);
+ void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d);
+ void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, unsigned char flags);
+ void addStructure(BUILD_SUB subtype,float x,float y, std::string tex, std::string inside);
Village *addVillage(std::string name, World *world);
/**
- * Adds a Mob to the world with the specified type and coordinates.
- */
-
- void addMob(int type,float x,float y);
-
- /**
- * Adds a Mob to the world with a handler function that can be called by
- * certain mobs to trigger events.
- */
-
- void addMob(int t,float x,float y,void (*hey)(Mob *));
-
- /**
- * Adds an NPC to the world with the specified coordinates.
- */
-
- void addNPC(float x,float y);
-
- /**
- * Adds a Merchant to the world at the specified coordinates.
- */
-
- void addMerchant(float x, float y);
-
- /**
- * Adds an object to the world with the specified item id and coordinates.
- * If `pickupDialog` is not NULL, that string will display in a dialog box
- * upon object interaction.
- */
-
- void addObject(std::string in, std::string pickupDialog, float x, float y);
-
- /**
- * Adds a particle to the world with the specified coordinates, dimensions,
- * velocity, color and duration (time to live).
- */
-
- void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d);
- void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, unsigned char flags);
-
- /**
- * Adds a light to the world with the specified coordinates and color.
- */
-
- void addLight(vec2 xy, Color color);
-
- /**
* Updates the coordinates of everything in the world that has coordinates
* and a velocity. The provided delta time is used for smoother updating.
*/