You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
57 lines
1.5 KiB
5 months ago
|
#include "system/ui/raylib/util.h"
|
||
6 months ago
|
|
||
|
#include <array>
|
||
|
|
||
|
#undef GREEN
|
||
|
#undef RED
|
||
|
#undef YELLOW
|
||
|
#include "common/swaglog.h"
|
||
|
#include "system/hardware/hw.h"
|
||
|
|
||
|
constexpr std::array<const char *, static_cast<int>(FontWeight::Count)> FONT_FILE_PATHS = {
|
||
|
"../../assets/fonts/Inter-Black.ttf",
|
||
|
"../../assets/fonts/Inter-Bold.ttf",
|
||
|
"../../assets/fonts/Inter-ExtraBold.ttf",
|
||
|
"../../assets/fonts/Inter-ExtraLight.ttf",
|
||
|
"../../assets/fonts/Inter-Medium.ttf",
|
||
|
"../../assets/fonts/Inter-Regular.ttf",
|
||
|
"../../assets/fonts/Inter-SemiBold.ttf",
|
||
|
"../../assets/fonts/Inter-Thin.ttf",
|
||
|
};
|
||
|
|
||
|
struct FontManager {
|
||
|
FontManager() {
|
||
|
for (int i = 0; i < fonts.size(); ++i) {
|
||
|
fonts[i] = LoadFontEx(FONT_FILE_PATHS[i], 120, nullptr, 250);
|
||
|
SetTextureFilter(fonts[i].texture, TEXTURE_FILTER_TRILINEAR);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
~FontManager() {
|
||
|
for (auto &f : fonts) UnloadFont(f);
|
||
|
}
|
||
|
|
||
|
std::array<Font, static_cast<int>(FontWeight::Count)> fonts;
|
||
|
};
|
||
|
|
||
|
const Font& getFont(FontWeight weight) {
|
||
|
static FontManager font_manager;
|
||
|
return font_manager.fonts[(int)weight];
|
||
|
}
|
||
|
|
||
|
Texture2D LoadTextureResized(const char *fileName, int size) {
|
||
|
Image img = LoadImage(fileName);
|
||
|
ImageResize(&img, size, size);
|
||
|
Texture2D texture = LoadTextureFromImage(img);
|
||
|
SetTextureFilter(texture, TEXTURE_FILTER_TRILINEAR);
|
||
|
return texture;
|
||
|
}
|
||
|
|
||
|
void initApp(const char *title, int fps) {
|
||
|
Hardware::set_display_power(true);
|
||
|
Hardware::set_brightness(65);
|
||
|
// SetTraceLogLevel(LOG_NONE);
|
||
|
InitWindow(0, 0, title);
|
||
|
SetTargetFPS(fps);
|
||
|
}
|