gamedev
ui.h
1 #ifndef UI_H
2 #define UI_H
3 
4 #include <common.h>
5 #include <cstdarg>
6 
7 #include <world.h>
8 #include <ft2build.h>
9 #include FT_FREETYPE_H
10 
11 #define DEBUG
12 
13 namespace ui {
14 
15  /*
16  * Contains the coordinates of the mouse in the window.
17  */
18 
19  extern vec2 mouse;
20 
21  /*
22  * These flags are used elsewhere.
23  */
24 
25  extern bool debug;
26  extern bool posFlag;
27  extern unsigned int fontSize;
28  extern bool dialogBoxExists;
29  extern unsigned char dialogOptChosen;
30  extern bool edown;
31 
32  /*
33  * Initializes the FreeType system.
34  */
35 
36  void initFonts(void);
37 
38  /*
39  * Sets the current font/font size.
40  */
41 
42  void setFontFace(const char *ttf);
43  void setFontSize(unsigned int size);
44 
45  /*
46  * Draw a centered string.
47  */
48 
49  float putStringCentered(const float x,const float y,const char *s);
50 
51  /*
52  * Draws a formatted string at the given coordinates.
53  */
54 
55  float putText(const float x,const float y,const char *str,...);
56 
57  /*
58  * Creates a dialogBox text string (format: `name`: `text`). This function simply sets up
59  * variables that are drawn in ui::draw(). When the dialog box exists player control is
60  * limited until a right click is given, closing the box.
61  */
62 
63  void dialogBox(const char *name,const char *opt,const char *text,...);
64  void waitForDialog(void);
65 
66  /*
67  * Draws a larger string in the center of the screen. Drawing is done inside this function.
68  */
69 
70  void importantText(const char *text,...);
71 
72  /*
73  * Draw various UI elements (dialogBox, player health)
74  */
75 
76  void draw(void);
77 
78  /*
79  * Handle keyboard/mouse events.
80  */
81  void handleEvents(void);
82 
83  /*
84  * Toggle the black overlay thing.
85  */
86 
87  void toggleBlack(void);
88 
89 }
90 
91 #endif // UI_H
Definition: ui.cpp:64
Definition: common.h:46
The world system.
float y
Definition: world.h:88