Added WidgetText. Fixed some things. Updated README
This commit is contained in:
@@ -8,7 +8,49 @@
|
||||
|
||||
#include "json.hpp"
|
||||
|
||||
std::string default_font_name = "font.ttf";
|
||||
extern std::string default_font_name;
|
||||
|
||||
enum HorizontalAlign
|
||||
{
|
||||
HALIGN_LEFT,
|
||||
HALIGN_CENTER,
|
||||
HALIGN_RIGHT
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(HorizontalAlign,
|
||||
{
|
||||
{HALIGN_LEFT, "left"},
|
||||
{HALIGN_CENTER, "center"},
|
||||
{HALIGN_RIGHT, "right"},
|
||||
})
|
||||
|
||||
enum VerticalAlign
|
||||
{
|
||||
VALIGN_TOP,
|
||||
VALIGN_CENTER,
|
||||
VALIGN_BOTTOM
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(VerticalAlign,
|
||||
{
|
||||
{VALIGN_TOP, "top"},
|
||||
{VALIGN_CENTER, "center"},
|
||||
{VALIGN_BOTTOM, "bottom"},
|
||||
})
|
||||
|
||||
enum TextFit
|
||||
{
|
||||
FIT_NONE,
|
||||
FIT_SHRINK,
|
||||
FIT_AUTO
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(TextFit,
|
||||
{
|
||||
{FIT_NONE, "none"},
|
||||
{FIT_SHRINK, "shrink"},
|
||||
{FIT_AUTO, "auto"},
|
||||
})
|
||||
|
||||
// Call this before everything
|
||||
// Prints its messages
|
||||
@@ -21,6 +63,12 @@ void clean_sdl();
|
||||
// Can return NULL
|
||||
TTF_Font* get_font(int size, const std::string& filename = default_font_name);
|
||||
|
||||
// Returns a rect to use during bliting of 2 surfaces
|
||||
// base - surface on which the other is applied to
|
||||
// applied - the surface which will be applied to the other
|
||||
SDL_Rect surface_align(const SDL_Surface* base, const SDL_Surface* applied,
|
||||
HorizontalAlign halign, VerticalAlign valign);
|
||||
|
||||
// Reads the file and tries to parse a JSON file with comments
|
||||
// cfg - output json struct
|
||||
// filename - filepath to open and read
|
||||
@@ -31,5 +79,11 @@ bool read_config_json(nlohmann::json& cfg, const std::string& filename, std::ost
|
||||
|
||||
void json_extract(const nlohmann::json& j, const std::string& key, std::string& out);
|
||||
void json_extract(const nlohmann::json& j, const std::string& key, int& out);
|
||||
void json_extract(const nlohmann::json& j, const std::string& key, bool& out);
|
||||
void json_extract(const nlohmann::json& j, const std::string& key, HorizontalAlign& out);
|
||||
void json_extract(const nlohmann::json& j, const std::string& key, VerticalAlign& out);
|
||||
void json_extract(const nlohmann::json& j, const std::string& key, TextFit& out);
|
||||
void json_extract(const nlohmann::json& j, const std::string& key, SDL_Color& out);
|
||||
void json_extract(const nlohmann::json& j, const std::string& key, Uint8& out);
|
||||
|
||||
#endif // SDL_HELPERS_H_
|
||||
|
||||
Reference in New Issue
Block a user