mirror of
https://github.com/wiiu-env/AromaUpdater.git
synced 2024-12-02 17:44:17 +01:00
98 lines
2.5 KiB
C++
98 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include "schrift.h"
|
|
#include <cstdint>
|
|
#include <map>
|
|
|
|
// visible screen sizes
|
|
#define SCREEN_WIDTH 854
|
|
#define SCREEN_HEIGHT 480
|
|
|
|
union Color {
|
|
explicit Color(uint32_t color) {
|
|
this->color = color;
|
|
}
|
|
|
|
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
|
this->r = r;
|
|
this->g = g;
|
|
this->b = b;
|
|
this->a = a;
|
|
}
|
|
|
|
uint32_t color{};
|
|
struct {
|
|
uint8_t r;
|
|
uint8_t g;
|
|
uint8_t b;
|
|
uint8_t a;
|
|
};
|
|
};
|
|
|
|
#define COLOR_GRAY Color(128, 128, 128, 255)
|
|
#define COLOR_WHITE Color(255, 255, 255, 255)
|
|
#define COLOR_BLACK Color(0, 0, 0, 255)
|
|
#define COLOR_YELLOW Color(255, 255, 0, 255)
|
|
#define COLOR_GREEN Color(128, 255, 0, 255)
|
|
#define COLOR_RED Color(255, 0, 0, 255)
|
|
#define COLOR_BLUE Color(0, 0, 170, 255)
|
|
|
|
class DrawUtils {
|
|
public:
|
|
static uint32_t ProcCallbackAcquired([[maybe_unused]] void *context);
|
|
|
|
static uint32_t ProcCallbackReleased([[maybe_unused]] void *context);
|
|
|
|
static bool Init();
|
|
static void DeInit();
|
|
|
|
static void beginDraw();
|
|
|
|
static void endDraw();
|
|
|
|
static void clear(Color col);
|
|
|
|
static void drawPixel(uint32_t x, uint32_t y, Color col) { drawPixel(x, y, col.r, col.g, col.b, col.a); }
|
|
|
|
static void drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
|
|
|
static void drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color col);
|
|
|
|
static void drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t borderSize, Color col);
|
|
|
|
static void drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t *data);
|
|
|
|
static void drawPNG(uint32_t x, uint32_t y, const uint8_t *data);
|
|
|
|
static bool initFont();
|
|
|
|
static void deinitFont();
|
|
|
|
static void setFontSize(uint32_t size);
|
|
|
|
static void setFontColor(Color col);
|
|
|
|
static void printf(uint32_t x, uint32_t y, bool alignRight, const char *fmt, ...);
|
|
|
|
static void print(uint32_t x, uint32_t y, const char *string, bool alignRight = false);
|
|
|
|
static void print(uint32_t x, uint32_t y, const wchar_t *string, bool alignRight = false);
|
|
|
|
static uint32_t getTextWidth(const char *string);
|
|
|
|
static uint32_t getTextWidth(const wchar_t *string);
|
|
|
|
private:
|
|
static bool isBackBuffer;
|
|
|
|
static uint8_t *tvBuffer;
|
|
static uint32_t tvSize;
|
|
static uint8_t *drcBuffer;
|
|
static uint32_t drcSize;
|
|
static bool hasForeground;
|
|
|
|
|
|
static uint32_t fontSize;
|
|
static std::map<uint32_t, std::map<uint32_t, SFT_Image>> glyphCache;
|
|
};
|