3
4
5
6
7
8
9
10
11
12
15#include <pu/ui/ui_Types.hpp>
16#include <pu/ui/render/render_SDL2.hpp>
17#include <pu/ttf/ttf_Font.hpp>
28 constexpr double ScreenFactor = (
double)ScreenWidth / (
double)BaseScreenWidth;
47 RendererInitOptions(
const u32 sdl_flags,
const u32 sdl_render_flags,
const u32 w = ScreenWidth,
const u32 h = ScreenHeight) :
sdl_flags(
sdl_flags),
sdl_render_flags(
sdl_render_flags),
width(
w),
height(
h),
default_shared_fonts(),
default_font_paths(),
extra_default_font_sizes(),
init_mixer(
false),
audio_mixer_flags(0),
init_img(
false),
sdl_img_flags(0),
init_romfs(
false),
pad_player_count(1),
pad_id_mask(0),
pad_style_tag(0) {}
50 this->default_shared_fonts.push_back(type);
54 for(u32 i = 0; i < PlSharedFontType_Total; i++) {
55 this->default_shared_fonts.push_back(
static_cast<PlSharedFontType>(i));
60 this->default_font_paths.push_back(font_path);
64 this->extra_default_font_sizes.push_back(font_size);
67 inline void UseAudio(
const u32 audio_mixer_flags) {
69 this->audio_mixer_flags = audio_mixer_flags;
72 inline void UseImage(
const u32 sdl_img_flags) {
74 this->sdl_img_flags = sdl_img_flags;
82 this->pad_player_count = count;
86 this->pad_id_mask |= BITL(type);
90 this->pad_style_tag |= tag;
111 return { NoAlpha, NoWidth, NoHeight,
NoRotation };
115 return { alpha, NoWidth, NoHeight,
NoRotation };
119 return { NoAlpha, width, height,
NoRotation };
139 inline u8 GetActualAlpha(
const u8 input_a) {
140 if(
this->base_a >= 0) {
141 return static_cast<u8>(
this->base_a);
156 return this->initialized;
160 return this->ok_romfs;
170 this->RenderRectangleFill(clr, x - border_width, y - border_width, width + (border_width * 2), height + (border_width * 2));
177 void RenderShadowSimple(
const i32 x,
const i32 y,
const i32 width,
const i32 height,
const i32 base_alpha,
const u8 main_alpha = 0xFF);
185 this->SetBaseRenderPosition(0, 0);
189 this->base_a = alpha;
197 padUpdate(&
this->input_pad);
201 return padGetButtonsDown(&
this->input_pad);
205 return padGetButtonsUp(&
this->input_pad);
209 return padGetButtons(&
this->input_pad);
229 AddFont(MakeDefaultFontName(font->GetFontSize()), font);
234 bool GetTextDimensions(
const std::string &font_name,
const std::string &text, i32 &out_width, i32 &out_height);
237 sdl2::Texture
RenderText(
const std::string &font_name,
const std::string &text,
const Color clr,
const u32 max_width = 0,
const u32 max_height = 0);
Definition ttf_Font.hpp:9
Definition render_Renderer.hpp:127
u64 GetButtonsUp()
Definition render_Renderer.hpp:204
void ResetBaseRenderAlpha()
Definition render_Renderer.hpp:192
void RenderCircle(const Color clr, const i32 x, const i32 y, const i32 radius)
void RenderRectangleOutline(const Color clr, const i32 x, const i32 y, const i32 width, const i32 height, const i32 border_width)
Definition render_Renderer.hpp:169
void RenderRectangle(const Color clr, const i32 x, const i32 y, const i32 width, const i32 height)
Renderer(const RendererInitOptions init_opts)
Definition render_Renderer.hpp:149
void RenderShadowSimple(const i32 x, const i32 y, const i32 width, const i32 height, const i32 base_alpha, const u8 main_alpha=0xFF)
void RenderRoundedRectangle(const Color clr, const i32 x, const i32 y, const i32 width, const i32 height, const i32 radius)
bool HasRomFs()
Definition render_Renderer.hpp:159
void SetBaseRenderAlpha(const u8 alpha)
Definition render_Renderer.hpp:188
void RenderRectangleFill(const Color clr, const i32 x, const i32 y, const i32 width, const i32 height)
void RenderRoundedRectangleFill(const Color clr, const i32 x, const i32 y, const i32 width, const i32 height, const i32 radius)
u64 GetButtonsDown()
Definition render_Renderer.hpp:200
u64 GetButtonsHeld()
Definition render_Renderer.hpp:208
void RenderTexture(sdl2::Texture texture, const i32 x, const i32 y, const TextureRenderOptions opts=TextureRenderOptions::Default())
void RenderCircleFill(const Color clr, const i32 x, const i32 y, const i32 radius)
void ResetBaseRenderPosition()
Definition render_Renderer.hpp:184
void UpdateInput()
Definition render_Renderer.hpp:196
void SetBaseRenderPosition(const i32 x, const i32 y)
Definition render_Renderer.hpp:179
void InitializeRender(const Color clr)
bool HasInitialized()
Definition render_Renderer.hpp:155
Definition sdl2_Types.hpp:10
Definition ttf_Font.hpp:7
Definition render_Renderer.hpp:20
constexpr u32 MixerAllFlags
Definition render_Renderer.hpp:94
bool LoadAllSharedFontsInFont(std::shared_ptr< ttf::Font > &font)
sdl2::Window GetMainWindow()
bool AddFont(const std::string &font_name, std::shared_ptr< ttf::Font > &font)
bool LoadSingleSharedFontInFont(std::shared_ptr< ttf::Font > &font, const PlSharedFontType type)
sdl2::Texture RenderText(const std::string &font_name, const std::string &text, const Color clr, const u32 max_width=0, const u32 max_height=0)
bool GetTextDimensions(const std::string &font_name, const std::string &text, i32 &out_width, i32 &out_height)
constexpr u32 BaseScreenWidth
Definition render_Renderer.hpp:22
sdl2::Surface GetMainSurface()
constexpr u32 BaseScreenHeight
Definition render_Renderer.hpp:23
constexpr u32 RendererSoftwareFlags
Definition render_Renderer.hpp:96
i32 GetTextWidth(const std::string &font_name, const std::string &text)
std::pair< u32, u32 > GetDimensions()
sdl2::Renderer GetMainRenderer()
constexpr u32 IMGAllFlags
Definition render_Renderer.hpp:95
i32 GetTextHeight(const std::string &font_name, const std::string &text)
void AddDefaultFont(std::shared_ptr< ttf::Font > &font)
Definition render_Renderer.hpp:228
constexpr double ScreenFactor
Definition render_Renderer.hpp:28
constexpr u32 ScreenWidth
Definition render_Renderer.hpp:25
constexpr u32 RendererHardwareFlags
Definition render_Renderer.hpp:97
constexpr u32 ScreenHeight
Definition render_Renderer.hpp:26
#define PU_SMART_CTOR(type)
Definition pu_Include.hpp:20
Definition ui_Types.hpp:44
Definition render_Renderer.hpp:30
u32 height
Definition render_Renderer.hpp:34
std::vector< u32 > extra_default_font_sizes
Definition render_Renderer.hpp:37
u32 pad_style_tag
Definition render_Renderer.hpp:45
void UseImage(const u32 sdl_img_flags)
Definition render_Renderer.hpp:72
void SetInputPlayerCount(const u32 count)
Definition render_Renderer.hpp:81
std::vector< std::string > default_font_paths
Definition render_Renderer.hpp:36
void AddExtraDefaultFontSize(const u32 font_size)
Definition render_Renderer.hpp:63
u32 sdl_render_flags
Definition render_Renderer.hpp:32
u32 audio_mixer_flags
Definition render_Renderer.hpp:39
u64 pad_id_mask
Definition render_Renderer.hpp:44
void AddDefaultFontPath(const std::string &font_path)
Definition render_Renderer.hpp:59
u32 pad_player_count
Definition render_Renderer.hpp:43
bool init_mixer
Definition render_Renderer.hpp:38
RendererInitOptions(const u32 sdl_flags, const u32 sdl_render_flags, const u32 w=ScreenWidth, const u32 h=ScreenHeight)
Definition render_Renderer.hpp:47
bool init_romfs
Definition render_Renderer.hpp:42
void AddInputNpadIdType(const u64 type)
Definition render_Renderer.hpp:85
bool init_img
Definition render_Renderer.hpp:40
std::vector< PlSharedFontType > default_shared_fonts
Definition render_Renderer.hpp:35
u32 width
Definition render_Renderer.hpp:33
u32 sdl_img_flags
Definition render_Renderer.hpp:41
void UseAudio(const u32 audio_mixer_flags)
Definition render_Renderer.hpp:67
void UseRomfs()
Definition render_Renderer.hpp:77
void AddDefaultAllSharedFonts()
Definition render_Renderer.hpp:53
void AddDefaultSharedFont(const PlSharedFontType type)
Definition render_Renderer.hpp:49
void AddInputNpadStyleTag(const u32 tag)
Definition render_Renderer.hpp:89
u32 sdl_flags
Definition render_Renderer.hpp:31
Definition render_Renderer.hpp:99
float rot_angle
Definition render_Renderer.hpp:103
static constexpr i32 NoWidth
Definition render_Renderer.hpp:106
static constexpr TextureRenderOptions Default()
Definition render_Renderer.hpp:110
i32 alpha_mod
Definition render_Renderer.hpp:100
static constexpr i32 NoAlpha
Definition render_Renderer.hpp:105
i32 width
Definition render_Renderer.hpp:101
static constexpr TextureRenderOptions WithCustomDimensions(const i32 width, const i32 height)
Definition render_Renderer.hpp:118
static constexpr TextureRenderOptions WithCustomAlpha(const u8 alpha)
Definition render_Renderer.hpp:114
i32 height
Definition render_Renderer.hpp:102
static constexpr float NoRotation
Definition render_Renderer.hpp:108
static constexpr i32 NoHeight
Definition render_Renderer.hpp:107
static constexpr TextureRenderOptions WithCustomAlphaAndDimensions(const u8 alpha, const i32 width, const i32 height)
Definition render_Renderer.hpp:122