aboutsummaryrefslogtreecommitdiffstats
path: root/include/ui.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/ui.hpp')
-rw-r--r--include/ui.hpp130
1 files changed, 56 insertions, 74 deletions
diff --git a/include/ui.hpp b/include/ui.hpp
index ac415f5..456c88a 100644
--- a/include/ui.hpp
+++ b/include/ui.hpp
@@ -32,112 +32,94 @@ public:
void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
};
-namespace ui {
+struct OptionDim {
+ float x;
+ float y;
+ float width;
+};
- extern bool fadeEnable;
- extern int fadeIntensity;
+using DialogOption = std::pair<OptionDim, std::string>;
- // the pixel-coordinates of the mouse
- extern vec2 mouse;
+class UISystem : public entityx::System<UISystem> {
+private:
+ static bool fadeEnable;
+ static bool fadeFast;
+ static int fadeIntensity;
- // raw mouse values from SDL
- extern vec2 premouse;
+ static std::string dialogText;
+ static std::string importantText;
+ static std::vector<DialogOption> dialogOptions;
+ static int dialogOptionResult;
- // the currently used font size for text rendering
- extern unsigned int fontSize;
+public:
+ UISystem(void) {}
- // shows the debug overlay when set to true
- extern bool debug;
+ void update(entityx::EntityManager& en, entityx::EventManager& ev, entityx::TimeDelta dt) override;
- // shows tracers when set to true (alongside `debug`)
- extern bool posFlag;
+ static void render(void);
- extern unsigned char dialogOptChosen;
- extern bool dialogBoxExists;
- extern bool dialogImportant;
- extern bool dialogPassive;
+ /***
+ * Fade library
+ */
- extern unsigned int textWrapLimit;
- extern int fontTransInv;
+ static void fadeToggle(void);
+ static void fadeToggleFast(void);
+ static void waitForCover(void);
+ static void waitForUncover(void);
- /*
- * Initializes the FreeType system.
- */
- void initFonts(void);
- void initSounds(void);
+ static inline bool isFading(void)
+ { return fadeIntensity != 0; }
- void destroyFonts(void);
+ static inline bool isDialog(void)
+ { return !dialogText.empty() || !importantText.empty(); }
- /*
- * Sets the current font/font size.
- */
+ /**
+ * Text library
+ */
- void setFontFace(const char *ttf);
- void setFontSize(unsigned int size);
- void setFontColor(int r, int g, int b, int a);
- void setFontZ(float z);
+ static void putText(const vec2& p, const std::string& s, ...);
+ static void putString(const vec2& p, const std::string& s, float wrap = 0.12345f);
+ static float putStringCentered(const vec2& p, const std::string& s, bool print = true);
- /*
- * Draw a centered string.
- */
+ static void dialogBox(const std::string& n, const std::string& s, ...);
+ static void dialogAddOption(const std::string& o);
+ static void dialogImportant(const std::string& s);
- float putStringCentered(const float x,const float y,std::string s);
+ static void waitForDialog(void);
+ static void advanceDialog(void);
+ static int getDialogResult(void);
+};
- /*
- * Draws a formatted string at the given coordinates.
- */
+namespace ui {
+ // the pixel-coordinates of the mouse
+ extern vec2 mouse;
- float putText(const float x,const float y,const char *str,...);
+ // raw mouse values from SDL
+ extern vec2 premouse;
- /**
- * This function is a facility for logic events to draw text; the text
- * will be prepared then drawn in the render loop.
- */
- void putTextL(vec2 c,const char *str, ...);
+ // shows the debug overlay when set to true
+ extern bool debug;
- /*
- * 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.
- */
+ // shows tracers when set to true (alongside `debug`)
+ extern bool posFlag;
+
+ void initSounds(void);
- void drawBox(vec2 c1, vec2 c2);
void drawNiceBox(vec2 c1, vec2 c2, float z);
void drawNiceBoxColor(vec2 c1, vec2 c2, float z, Color c);
- void dialogBox(std::string name, std::string opt, bool passive, std::string text, ...);
- void closeBox();
- void waitForDialog(void);
bool pageExists(void);
void drawPage(const GLuint& tex);
- void dontTypeOut(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,...);
+ //void importantText(const char *text,...);
+ //void passiveImportantText(int duration,const char *text,...);
/*
* Draw various UI elements (dialogBox, player health)
*/
void draw(void);
- void drawFade(void);
- void fadeUpdate(void);
-
- /*
- * Toggle the black overlay thing.
- */
-
- void toggleBlack(void);
- void toggleBlackFast(void);
- void toggleWhite(void);
- void toggleWhiteFast(void);
- void waitForCover(void);
- void waitForUncover(void);
/*
* Takes a screenshot of the game