Make Timer SmartCtor
ClangFormat
Reactivate Graphical Error Screen
Fix Logger
Fix Image Rendering
This commit is contained in:
tobid7 2024-06-15 15:12:06 +02:00
parent f7c0c83ac2
commit ec8743417d
17 changed files with 287 additions and 234 deletions

View File

@ -29,7 +29,7 @@
namespace RenderD7 {
class Image {
public:
Image();
Image() = default;
~Image() = default;
RD7_SMART_CTOR(Image)
void Load(const std::string& path);

View File

@ -64,6 +64,7 @@ class R2Base {
// Text Specific
RD7TextFlags flags; // Text Flags
std::string text; // Text
RD7_SMART_CTOR(R2Cmd)
};
R2Base();
~R2Base() = default;
@ -83,7 +84,7 @@ class R2Base {
// Processing
void Process();
R7Vec2 GetTextDimensions(const std::string& text);
std::string WrapText(const std ::string& in, int maxlen);
// Draw Functions
void AddRect(R7Vec2 pos, R7Vec2 size, RD7Color clr);
void AddRect(R7Vec2 pos, R7Vec2 size, unsigned int clr);
@ -103,7 +104,7 @@ class R2Base {
std::map<std::string, float> ts;
std::map<std::string, int> mln;
bool next_lined = false;
std::vector<R2Cmd> commands;
std::vector<R2Cmd::Ref> commands;
R2Screen current_screen = R2Screen_Bottom;
};
} // namespace RenderD7

View File

@ -21,8 +21,8 @@
#include <citro2d.h>
#include <citro3d.h>
#include <renderd7/smart_ctor.hpp>
#include <renderd7/Image.hpp>
#include <renderd7/smart_ctor.hpp>
#include <string>
namespace RenderD7 {
@ -44,6 +44,7 @@ class Sheet {
void Free();
Image::Ref GetImage(int idx);
C2D_SpriteSheet Get() { return this->spritesheet; }
private:
/// \param spritesheet The Sheet
C2D_SpriteSheet spritesheet;

View File

@ -20,18 +20,21 @@
#include <3ds.h>
#include <renderd7/smart_ctor.hpp>
namespace RenderD7 {
class Timer {
public:
Timer(bool autostart = true);
~Timer() {}
void reset();
void tick();
void pause();
void resume();
float get();
float get_live();
bool running();
RD7_SMART_CTOR(Timer)
void Reset();
void Tick();
void Pause();
void Resume();
float Get();
float GetLive();
bool Running();
private:
uint64_t last = 0;

View File

@ -102,6 +102,12 @@ void SetCursorPos(R7Vec2 cp);
void RestoreCursor();
void SameLine();
float GetScrollingOffset();
namespace Menu {
// All of them return the Main BG DrawList if Menu is null
UI7DrawList::Ref GetBackgroundList();
UI7DrawList::Ref GetList();
UI7DrawList::Ref GetForegroundList();
}
// DrawLists
UI7DrawList::Ref GetForegroundList();
UI7DrawList::Ref GetBackgroundList();

View File

@ -26,12 +26,9 @@ int main() {
RD7::FadeIn();
// RD7::Init::NdspFirm();
RD7::Scene::Load(std::make_unique<Sample>());
auto img = RD7::Image::New();
img->Load("romfs:/icons/icon.png");
RD7::Ftrace::End("app", "app_init");
while (RD7::MainLoop()) {
RD7::R2()->OnScreen(R2Screen_Top);
UI7::GetForegroundList()->AddImage(R7Vec2(), img);
RD7::R2()->OnScreen(R2Screen_Bottom);
RD7::Ftrace::Beg("app", "app_mainloop");
if (d7_hDown & KEY_START) {
RD7::FadeOut();

View File

@ -60,7 +60,9 @@ void DrawWave(R7Vec2 position, R7Vec2 size, float time, bool dbg) {
R7Vec2 testv2 = R7Vec2(48, 48);
std::vector<int*> img;
void display_icon(void* v, R7Vec2 p) { RD7::R2()->AddRect(p, testv2, 0xff00ffff); }
void display_icon(void* v, R7Vec2 p) {
UI7::Menu::GetList()->AddRectangle(p, testv2, 0xff00ffff);
}
Sample::Sample() {
auto ti = new int;

View File

@ -37,27 +37,28 @@ void rd7i_save_report(const std::string& msg) {
namespace RenderD7 {
void Error(const std::string& msg) {
rd7i_save_report(msg);
/*if (rd7i_graphics_on) {
C3D_FrameEnd(0);
if (rd7i_graphics_on) {
while (aptMainLoop()) {
hidScanInput();
if (hidKeysDown() & KEY_START) break;
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
RenderD7::ClearTextBufs();
C2D_TargetClear(Top, 0x00000000);
C2D_TargetClear(Bottom, 0x00000000);
RenderD7::OnScreen(Top);
C2D_TargetClear(rd7_top, 0x00000000);
C2D_TargetClear(rd7_bottom, 0x00000000);
RenderD7::R2()->OnScreen(R2Screen_Top);
if (UI7::BeginMenu("RenderD7 - Error Manager", R7Vec2(),
UI7MenuFlags_TitleMid)) {
UI7::Label(msg, RD7TextFlags_Wrap);
UI7::Label("Press Start to Exit!");
UI7::EndMenu();
}
RenderD7::OnScreen(Bottom);
RenderD7::R2()->OnScreen(R2Screen_Bottom);
UI7::Update();
RenderD7::R2()->Process();
C3D_FrameEnd(0);
}
exit(0);
} else {*/
} else {
gfxInitDefault();
consoleInit(GFX_TOP, NULL);
printf("RENDERD7 - ERROR MANAGER\n\n%s\n", msg.c_str());
@ -70,6 +71,6 @@ void Error(const std::string& msg) {
}
gfxExit();
exit(0);
// }
}
}
} // namespace RenderD7

View File

@ -19,9 +19,8 @@
#include <renderd7/external/stb_image.h>
#include <renderd7/Image.hpp>
#include <vector>
#include <renderd7/internal_db.hpp>
#include <vector>
static u32 __rd7i_gp2o__(u32 v) {
v--;
@ -50,9 +49,9 @@ static void __rd7i_r24r32(std::vector<uint8_t> &out,
}
}
static void __rd7i_maketex__(C3D_Tex* tex, Tex3DS_SubTexture* sub, std::vector<unsigned char>& buf, int w, int h) {
if(!tex || !sub)
{
static void __rd7i_maketex__(C3D_Tex *tex, Tex3DS_SubTexture *sub,
std::vector<unsigned char> &buf, int w, int h) {
if (!tex || !sub) {
_rd7i_logger()->Write("Invalid Inpit (objects have no adress!)");
return;
}
@ -72,8 +71,8 @@ static void __rd7i_maketex__(C3D_Tex* tex, Tex3DS_SubTexture* sub, std::vector<u
}
// Pow2
int wp2 = __rd7i_gp2o__(w);
int hp2 = __rd7i_gp2o__(h);
int wp2 = __rd7i_gp2o__((unsigned int)w);
int hp2 = __rd7i_gp2o__((unsigned int)h);
sub->width = (u16)w;
sub->height = (u16)h;
@ -106,10 +105,6 @@ static void __rd7i_maketex__(C3D_Tex* tex, Tex3DS_SubTexture* sub, std::vector<u
}
namespace RenderD7 {
Image::Image() {
img.tex = nullptr;
img.subtex = nullptr;
}
void Image::Load(const std::string &path) {
// Make sure to cleanup
@ -118,24 +113,25 @@ void Image::Load(const std::string &path) {
int w, h, c = 0;
unsigned char *image = stbi_load(path.c_str(), &w, &h, &c, 4);
if (image == nullptr) {
_rd7i_logger()->Write("Failed to Load Image: " + path);
//_rd7i_logger()->Write("Failed to Load Image: " + path);
return;
}
// Size/Fmt Check
if (w > 1024 || h > 1024) {
// Reason: Image to Large
_rd7i_logger()->Write("Image too Large!");
//_rd7i_logger()->Write("Image too Large!");
stbi_image_free(image);
return;
}
std::vector<unsigned char> wimg;
if (c == 3) {
_rd7i_logger()->Write("Convert Image to RGBA");
//_rd7i_logger()->Write("Convert Image to RGBA");
stbi_image_free(image);
image = stbi_load(path.c_str(), &w, &h, &c, 3);
wimg.resize(w * h * 4);
__rd7i_r24r32(wimg, std::vector<unsigned char>(image, image + (w * h * 3)), w, h);
__rd7i_r24r32(wimg, std::vector<unsigned char>(image, image + (w * h * 3)),
w, h);
} else {
wimg.assign(&image[0], &image[(w * h * 4) - 1]);
stbi_image_free(image);
@ -144,8 +140,9 @@ void Image::Load(const std::string &path) {
C3D_Tex* tex = new C3D_Tex;
Tex3DS_SubTexture* subtex = new Tex3DS_SubTexture;
__rd7i_maketex__(tex, subtex, wimg, w, h);
img.tex = tex;
img.subtex = subtex;
_rd7i_logger()->Write(RenderD7::FormatString("Created Texture (%d, %d)",
tex->width, tex->height));
img = {tex, subtex};
}
void Image::From_NIMG(const nimg &image) {
@ -156,8 +153,7 @@ void Image::From_NIMG(const nimg &image) {
Tex3DS_SubTexture* subtex = new Tex3DS_SubTexture;
std::vector<unsigned char> mdpb = image.pixel_buffer;
__rd7i_maketex__(tex, subtex, mdpb, image.width, image.height);
img.tex = tex;
img.subtex = subtex;
img = {tex, subtex};
}
C2D_Image Image::Get() {
@ -189,6 +185,7 @@ void Image::Delete() {
img.subtex = nullptr;
}
if (img.tex != nullptr) {
C3D_TexDelete(img.tex);
delete img.tex;
img.tex = nullptr;
}

View File

@ -51,10 +51,10 @@ void LoggerBase::Write(const std::string& debug_text, int lvl) {
if (this->_log.is_open() && lvl <= writelvl) {
this->_log << msg << std::endl;
}
while (msg.find_first_of('\n') != 0) {
/*while (msg.find_first_of('\n') != 0) {
lines.push_back(msg.substr(0, msg.find_first_of('\n')));
msg = msg.substr(msg.find_first_of('\n'));
}
}*/
lines.push_back(msg);
}

View File

@ -434,16 +434,16 @@ void Ovl_Keyboard::Draw(void) const {
R2()->AddText(R7Vec2(5, 114), "> " + *typed_text,
RenderD7::ThemeActive()->AutoText(RD7Color_Header));
for (auto const& it : key_table) {
R7Vec2 szs = it.size;
R7Vec2 pos = it.pos;
R7Vec2 txtdim = R2()->GetTextDimensions(it.disp);
R7Vec2 txtpos = R7Vec2(it.pos.x + it.size.x * 0.5 - txtdim.x * 0.5,
it.pos.y + it.size.y * 0.5 - txtdim.y * 0.5);
RD7Color btn = RD7Color_Button;
if (RenderD7::Hid::IsEvent("cancel", RenderD7::Hid::Up)) {
RenderD7::Hid::Clear();
shared_data[0x05] = 1;
}
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
UI7_InBox(RenderD7::Hid::GetLastTouchPosition(), it.pos, it.size)) {
UI7_InBox(RenderD7::Hid::GetLastTouchPosition(), pos, szs)) {
if (mode == 2) // Request Disable Shift
shared_data[0x02] = 1;
@ -468,8 +468,12 @@ void Ovl_Keyboard::Draw(void) const {
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
UI7_InBox(RenderD7::Hid::GetTouchPosition(), it.pos, it.size)) {
btn = RD7Color_ButtonHovered;
pos -= R7Vec2(1, 1);
szs += R7Vec2(2, 2);
}
R2()->AddRect(it.pos, it.size, btn);
R7Vec2 txtpos = R7Vec2(pos.x + szs.x * 0.5 - txtdim.x * 0.5,
pos.y + szs.y * 0.5 - txtdim.y * 0.5);
R2()->AddRect(pos, szs, btn);
R2()->AddText(txtpos, it.disp, RenderD7::ThemeActive()->AutoText(btn));
}
if (ft3 > 5) RenderD7::Hid::Lock();

View File

@ -57,73 +57,96 @@ R7Vec2 R2Base::GetTextDimensions(const std::string& text) {
return R7Vec2(w, h);
}
std::string R2Base::WrapText(const std ::string& in, int maxlen) {
std::string out;
std::string line;
int line_x = 0;
std::istringstream istream(in);
std::string temp;
while (istream >> temp) {
R7Vec2 dim = this->GetTextDimensions(line + temp);
if (line_x + dim.x <= maxlen) {
line += temp + ' ';
line_x += dim.x;
} else {
out += line + '\n';
line = temp + ' ';
line_x = dim.x;
}
}
out += line;
return out;
}
// Main Processing of Draw Calls
void R2Base::Process() {
for (auto& it : this->commands) {
if (it.type <= 0 || it.type > 3) {
if (it->type <= 0 || it->type > 5) {
// Skip
continue;
}
C2D_SceneBegin(it.Screen ? rd7_top : rd7_bottom);
if (it.type == 1) {
C2D_SceneBegin(it->Screen ? rd7_top : rd7_bottom);
if (it->type == 1) {
// Rect
if (it.lined) {
C2D_DrawLine(it.pos.x, it.pos.y, it.clr, it.pos.x + it.pszs.x, it.pos.y,
it.clr, 1.f, 0.5f);
C2D_DrawLine(it.pos.x, it.pos.y, it.clr, it.pos.x, it.pos.y + it.pszs.y,
it.clr, 1.f, 0.5f);
C2D_DrawLine(it.pos.x + it.pszs.x, it.pos.y, it.clr,
it.pos.x + it.pszs.x, it.pos.y + it.pszs.y, it.clr, 1.f,
if (it->lined) {
C2D_DrawLine(it->pos.x, it->pos.y, it->clr, it->pos.x + it->pszs.x, it->pos.y,
it->clr, 1.f, 0.5f);
C2D_DrawLine(it->pos.x, it->pos.y, it->clr, it->pos.x, it->pos.y + it->pszs.y,
it->clr, 1.f, 0.5f);
C2D_DrawLine(it->pos.x + it->pszs.x, it->pos.y, it->clr,
it->pos.x + it->pszs.x, it->pos.y + it->pszs.y, it->clr, 1.f,
0.5f);
C2D_DrawLine(it.pos.x, it.pos.y + it.pszs.y, it.clr,
it.pos.x + it.pszs.x, it.pos.y + it.pszs.y, it.clr, 1.f,
C2D_DrawLine(it->pos.x, it->pos.y + it->pszs.y, it->clr,
it->pos.x + it->pszs.x, it->pos.y + it->pszs.y, it->clr, 1.f,
0.5f);
} else {
C2D_DrawRectSolid(it.pos.x, it.pos.y, 0.5, it.pszs.x, it.pszs.y,
it.clr);
C2D_DrawRectSolid(it->pos.x, it->pos.y, 0.5, it->pszs.x, it->pszs.y,
it->clr);
}
} else if (it.type == 2) {
} else if (it->type == 2) {
// Triangle
if (it.lined) {
C2D_DrawLine(it.pos.x, it.pos.y, it.clr, it.pszs.x, it.pszs.y, it.clr,
if (it->lined) {
C2D_DrawLine(it->pos.x, it->pos.y, it->clr, it->pszs.x, it->pszs.y, it->clr,
1, 0.5f);
C2D_DrawLine(it.pos.x, it.pos.y, it.clr, it.ap.x, it.ap.y, it.clr, 1,
C2D_DrawLine(it->pos.x, it->pos.y, it->clr, it->ap.x, it->ap.y, it->clr, 1,
0.5f);
C2D_DrawLine(it.pszs.x, it.pszs.y, it.clr, it.ap.x, it.ap.y, it.clr, 1,
C2D_DrawLine(it->pszs.x, it->pszs.y, it->clr, it->ap.x, it->ap.y, it->clr, 1,
0.5f);
} else {
C2D_DrawTriangle(it.pos.x, it.pos.y, it.clr, it.pszs.x, it.pszs.y,
it.clr, it.ap.x, it.ap.y, it.clr, 0.5);
C2D_DrawTriangle(it->pos.x, it->pos.y, it->clr, it->pszs.x, it->pszs.y,
it->clr, it->ap.x, it->ap.y, it->clr, 0.5);
}
} else if (it.type == 3) {
} else if (it->type == 3) {
// Text
// little patch for a freeze
if (it.text.length() < 1) continue;
if (it.pszs.x == 0.0f) {
it.pszs.x = it.Screen == R2Screen_Top ? 400 : 320;
if (it->text.length() < 1) continue;
if (it->pszs.x == 0.0f) {
it->pszs.x = it->Screen == R2Screen_Top ? 400 : 320;
}
if (it.pszs.y == 0.0f) {
it.pszs.y = 240;
if (it->pszs.y == 0.0f) {
it->pszs.y = 240;
}
std::string edit_text = it.text;
if (edit_text.substr(it.text.length() - 1) != "\n")
std::string edit_text = it->text;
if (edit_text.substr(it->text.length() - 1) != "\n")
edit_text.append("\n"); // Add \n to end if not exist
int line = 0;
// if (it.flags & RD7TextFlags_Wrap)
// edit_text = WrapText(text, rd7i_d7_mwh.x - pos.x);
if (it->flags & RD7TextFlags_Wrap) {
edit_text = WrapText(it->text, it->pszs.x - it->pos.x);
}
while (edit_text.find('\n') != edit_text.npos) {
std::string current_line = edit_text.substr(0, edit_text.find('\n'));
// if (it.flags & RD7TextFlags_Short)
// current_line = GetShortedText(current_line, it.pszs.x - it.pos.x);
R7Vec2 newpos = it.pos;
// if (it->flags & RD7TextFlags_Short)
// current_line = GetShortedText(current_line, it->pszs.x - it->pos.x);
R7Vec2 newpos = it->pos;
// Check Flags
R7Vec2 dim = this->GetTextDimensions(current_line);
if (it.flags & RD7TextFlags_AlignRight) newpos.x = newpos.x - dim.x;
if (it.flags & RD7TextFlags_AlignMid) // Offset by inpos
newpos.x = (it.pszs.x * 0.5) - (dim.x * 0.5) + it.pos.x;
if (it.flags & RD7TextFlags_Scroll) { // Scroll Text
if (it->flags & RD7TextFlags_AlignRight) newpos.x = newpos.x - dim.x;
if (it->flags & RD7TextFlags_AlignMid) // Offset by inpos
newpos.x = (it->pszs.x * 0.5) - (dim.x * 0.5) + it->pos.x;
if (it->flags & RD7TextFlags_Scroll) { // Scroll Text
// Look into Old Draw2 Code
// TODO: Create Code for this
}
@ -136,73 +159,73 @@ void R2Base::Process() {
current_line.c_str());
C2D_TextOptimize(&c2dtext);
if (it.flags & RD7TextFlags_Shaddow) // performance Killer xd
if (it->flags & RD7TextFlags_Shaddow) // performance Killer xd
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x + 1 + (dim.y * line),
newpos.y + 1, 0.5, this->text_size, this->text_size,
RenderD7::ThemeActive()->Get(RD7Color_TextDisabled));
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x,
newpos.y + (dim.y * line), 0.5, this->text_size,
this->text_size, it.clr);
this->text_size, it->clr);
edit_text = edit_text.substr(edit_text.find('\n') + 1);
line++;
}
} else if (it.type == 4) {
if(it.img->Loadet()) {
C2D_DrawImageAt(it.img->Get(), it.pos.x, it.pos.y, 0.5f);
} else if (it->type == 4) {
if (it->img->Loadet()) {
C2D_DrawImageAt(it->img->Get(), it->pos.x, it->pos.y, 0.5f);
}
} else if (it.type == 5) {
} else if (it->type == 5) {
// TODO: Move the Draw Func into this API
it.spr->Draw();
it->spr->Draw();
}
}
this->commands.clear();
}
void R2Base::AddRect(R7Vec2 pos, R7Vec2 size, RD7Color clr) {
R2Cmd cmd;
cmd.pos = pos;
cmd.pszs = size;
cmd.clr = RenderD7::ThemeActive()->Get(clr);
cmd.type = 1; // Rect
auto cmd = R2Cmd::New();
cmd->pos = pos;
cmd->pszs = size;
cmd->clr = RenderD7::ThemeActive()->Get(clr);
cmd->type = 1; // Rect
// Just assign current screen as bottom is 0 (false)
// and Top and TopRight are !0 (true)
cmd.Screen = current_screen;
cmd->Screen = current_screen;
if (this->next_lined) {
cmd.lined = true;
cmd->lined = true;
this->next_lined = false;
}
this->commands.push_back(cmd);
}
void R2Base::AddRect(R7Vec2 pos, R7Vec2 size, unsigned int clr) {
R2Cmd cmd;
cmd.pos = pos;
cmd.pszs = size;
cmd.clr = clr;
cmd.type = 1; // Rect
auto cmd = R2Cmd::New();
cmd->pos = pos;
cmd->pszs = size;
cmd->clr = clr;
cmd->type = 1; // Rect
// Just assign current screen as bottom is 0 (false)
// and Top and TopRight are !0 (true)
cmd.Screen = current_screen;
cmd->Screen = current_screen;
if (this->next_lined) {
cmd.lined = true;
cmd->lined = true;
this->next_lined = false;
}
this->commands.push_back(cmd);
}
void R2Base::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, RD7Color clr) {
R2Cmd cmd;
cmd.pos = pos0;
cmd.pszs = pos1;
cmd.ap = pos2;
cmd.clr = RenderD7::ThemeActive()->Get(clr);
cmd.type = 2; // Triangle
auto cmd = R2Cmd::New();
cmd->pos = pos0;
cmd->pszs = pos1;
cmd->ap = pos2;
cmd->clr = RenderD7::ThemeActive()->Get(clr);
cmd->type = 2; // Triangle
// Just assign current screen as bottom is 0 (false)
// and Top and TopRight are !0 (true)
cmd.Screen = current_screen;
cmd->Screen = current_screen;
if (this->next_lined) {
cmd.lined = true;
cmd->lined = true;
this->next_lined = false;
}
this->commands.push_back(cmd);
@ -210,17 +233,17 @@ void R2Base::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, RD7Color clr) {
void R2Base::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2,
unsigned int clr) {
R2Cmd cmd;
cmd.pos = pos0;
cmd.pszs = pos1;
cmd.ap = pos2;
cmd.clr = clr;
cmd.type = 2; // Triangle
auto cmd = R2Cmd::New();
cmd->pos = pos0;
cmd->pszs = pos1;
cmd->ap = pos2;
cmd->clr = clr;
cmd->type = 2; // Triangle
// Just assign current screen as bottom is 0 (false)
// and Top and TopRight are !0 (true)
cmd.Screen = current_screen;
cmd->Screen = current_screen;
if (this->next_lined) {
cmd.lined = true;
cmd->lined = true;
this->next_lined = false;
}
this->commands.push_back(cmd);
@ -228,18 +251,18 @@ void R2Base::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2,
void R2Base::AddText(R7Vec2 pos, const std::string& text, RD7Color clr,
RD7TextFlags flags, R7Vec2 tmb) {
R2Cmd cmd;
cmd.pos = pos;
cmd.pszs = tmb;
cmd.clr = RenderD7::ThemeActive()->Get(clr);
cmd.flags = flags;
cmd.text = text;
cmd.type = 3; // Text
auto cmd = R2Cmd::New();
cmd->pos = pos;
cmd->pszs = tmb;
cmd->clr = RenderD7::ThemeActive()->Get(clr);
cmd->flags = flags;
cmd->text = text;
cmd->type = 3; // Text
// Just assign current screen as bottom is 0 (false)
// and Top and TopRight are !0 (true)
cmd.Screen = current_screen;
cmd->Screen = current_screen;
if (this->next_lined) {
cmd.lined = true;
cmd->lined = true;
this->next_lined = false;
}
this->commands.push_back(cmd);
@ -247,47 +270,47 @@ void R2Base::AddText(R7Vec2 pos, const std::string& text, RD7Color clr,
void R2Base::AddText(R7Vec2 pos, const std::string& text, unsigned int clr,
RD7TextFlags flags, R7Vec2 tmb) {
R2Cmd cmd;
cmd.pos = pos;
cmd.pszs = tmb;
cmd.clr = clr;
cmd.flags = flags;
cmd.text = text;
cmd.type = 3; // Text
auto cmd = R2Cmd::New();
cmd->pos = pos;
cmd->pszs = tmb;
cmd->clr = clr;
cmd->flags = flags;
cmd->text = text;
cmd->type = 3; // Text
// Just assign current screen as bottom is 0 (false)
// and Top and TopRight are !0 (true)
cmd.Screen = current_screen;
cmd->Screen = current_screen;
if (this->next_lined) {
cmd.lined = true;
cmd->lined = true;
this->next_lined = false;
}
this->commands.push_back(cmd);
}
void R2Base::AddImage(R7Vec2 pos, Image::Ref img) {
R2Cmd cmd;
cmd.pos = pos;
cmd.img = img;
cmd.type = 4; // Image
auto cmd = R2Cmd::New();
cmd->pos = pos;
cmd->img = img;
cmd->type = 4; // Image
// Just assign current screen as bottom is 0 (false)
// and Top and TopRight are !0 (true)
cmd.Screen = current_screen;
cmd->Screen = current_screen;
if (this->next_lined) {
cmd.lined = true;
cmd->lined = true;
this->next_lined = false;
}
this->commands.push_back(cmd);
}
void R2Base::AddSprite(Sprite::Ref spr) {
R2Cmd cmd;
cmd.spr = spr;
cmd.type = 5; // Sprite
auto cmd = R2Cmd::New();
cmd->spr = spr;
cmd->type = 5; // Sprite
// Just assign current screen as bottom is 0 (false)
// and Top and TopRight are !0 (true)
cmd.Screen = current_screen;
cmd->Screen = current_screen;
if (this->next_lined) {
cmd.lined = true;
cmd->lined = true;
this->next_lined = false;
}
this->commands.push_back(cmd);

View File

@ -28,22 +28,22 @@ Timer::Timer(bool autostart) {
current = last;
}
void Timer::reset() {
void Timer::Reset() {
last = svcGetSystemTick();
current = last;
}
void Timer::tick() {
void Timer::Tick() {
if (is_running) current = svcGetSystemTick();
}
void Timer::pause() { is_running = false; }
void Timer::Pause() { is_running = false; }
void Timer::resume() { is_running = true; }
void Timer::Resume() { is_running = true; }
bool Timer::running() { return is_running; }
bool Timer::Running() { return is_running; }
float Timer::get() { return (float)((current - last) / TPMS); }
float Timer::Get() { return (float)((current - last) / TPMS); }
float Timer::get_live() { return (float)((svcGetSystemTick() - last) / TPMS); }
float Timer::GetLive() { return (float)((svcGetSystemTick() - last) / TPMS); }
} // namespace RenderD7

View File

@ -1181,4 +1181,22 @@ UI7DrawList::Ref GetBackgroundList() {
if (!UI7CtxValidate()) return nullptr;
return ui7_ctx->bdl;
}
UI7DrawList::Ref Menu::GetBackgroundList() {
if (!UI7CtxValidate()) return nullptr;
if(!UI7CtxInMenu()) return ui7_ctx->bdl;
return ui7_ctx->cm->background;
}
UI7DrawList::Ref Menu::GetList() {
if (!UI7CtxValidate()) return nullptr;
if(!UI7CtxInMenu()) return ui7_ctx->bdl;
return ui7_ctx->cm->main;
}
UI7DrawList::Ref Menu::GetForegroundList() {
if (!UI7CtxValidate()) return nullptr;
if(!UI7CtxInMenu()) return ui7_ctx->bdl;
return ui7_ctx->cm->front;
}
} // namespace UI7

View File

@ -808,7 +808,7 @@ void RenderD7::RSettings::Draw(void) const {
RenderD7::R2()->OnScreen(R2Screen_Bottom);
if (UI7::BeginMenu("Press \uE001 to go back!", R7Vec2(),
UI7MenuFlags_Scrolling)) {
for (auto &it : rd7i_logger->Lines()) UI7::Label(it);
for (auto &it : rd7i_logger->Lines()) UI7::Label(it, RD7TextFlags_Wrap);
UI7::EndMenu();
}
}