From 93f0ed44e8072cf6ee4cfd3f4a52012b46918b3d Mon Sep 17 00:00:00 2001 From: tobid7 Date: Sat, 8 Jun 2024 21:53:25 +0200 Subject: [PATCH] Changes: Remove ScreenApi Add Sprite And Image to R2 Add Image to UI7DrawList --- include/renderd7/Render2.hpp | 9 +++- include/renderd7/Screen.hpp | 34 --------------- include/renderd7/UI7.hpp | 1 + include/renderd7/global_db.hpp | 5 --- include/renderd7/internal_db.hpp | 1 - include/renderd7/renderd7.hpp | 1 - source/Message.cpp | 1 - source/Render2.cpp | 34 +++++++++++++++ source/Screen.cpp | 25 ----------- source/ThemeEditor.cpp | 4 +- source/UI7.cpp | 58 +++++++++++++++++++------- source/internal_db.cpp | 6 --- source/renderd7.cpp | 71 ++++++++++++++------------------ 13 files changed, 118 insertions(+), 132 deletions(-) delete mode 100644 include/renderd7/Screen.hpp delete mode 100644 source/Screen.cpp diff --git a/include/renderd7/Render2.hpp b/include/renderd7/Render2.hpp index 3f05a85..95d70a8 100644 --- a/include/renderd7/Render2.hpp +++ b/include/renderd7/Render2.hpp @@ -21,7 +21,9 @@ #include #include #include +#include #include +#include #include #define MAKEFLAG(x) (1 << x) @@ -53,7 +55,10 @@ class R2Base { R7Vec2 ap; //< Additional Pos unsigned int clr; //< Color bool Screen; //< TopScreen - // 0 = skip, 1 = rect, 2 = tri, 3 = text, 4 = image + Image::Ref img; //< Image Reference + Sprite::Ref spr; //< Sprite Reference + // 0 = skip, 1 = rect, 2 = tri, 3 = text, + // 4 = image, 5 = sprite int type; //< Command Type bool lined = false; //< Draw Lined Rect/Tri // Text Specific @@ -88,6 +93,8 @@ class R2Base { RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2()); void AddText(R7Vec2 pos, const std::string& text, unsigned int clr, RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2()); + void AddImage(R7Vec2 pos, Image::Ref img); + void AddSprite(Sprite::Ref spr); private: const float default_text_size = 0.5f; diff --git a/include/renderd7/Screen.hpp b/include/renderd7/Screen.hpp deleted file mode 100644 index a65dfb6..0000000 --- a/include/renderd7/Screen.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file is part of RenderD7 - * Copyright (C) 2021-2024 NPI-D7, tobid7 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include - -/// \param Top Tob-Screen Target -extern C3D_RenderTarget *Top; -/// \param TopRight Top-Right-Screen Target (Never atually used) -extern C3D_RenderTarget *TopRight; -/// \param Bottom Bottom-Screen Target -extern C3D_RenderTarget *Bottom; - -namespace RenderD7 { -/// @brief Begin Drawing On Specific Screen -/// @param target The Screen Target (Top, Bottom or TopTight) -void OnScreen(C3D_RenderTarget *target); -} // namespace RenderD7 diff --git a/include/renderd7/UI7.hpp b/include/renderd7/UI7.hpp index 98e1b59..b90988f 100644 --- a/include/renderd7/UI7.hpp +++ b/include/renderd7/UI7.hpp @@ -51,6 +51,7 @@ class UI7DrawList { RD7TextFlags flags = 0, R7Vec2 box = R7Vec2()); void AddText(R7Vec2 pos, const std::string &text, unsigned int clr, RD7TextFlags flags = 0, R7Vec2 box = R7Vec2()); + void AddImage(R7Vec2 pos, RenderD7::Image::Ref img); void AddCall(std::shared_ptr cmd); void Process(bool auto_clear = true); diff --git a/include/renderd7/global_db.hpp b/include/renderd7/global_db.hpp index 15484b4..a15c6c5 100644 --- a/include/renderd7/global_db.hpp +++ b/include/renderd7/global_db.hpp @@ -36,11 +36,6 @@ extern u32 d7_hUp; extern u32 d7_hRepeat; // Inofficial lol extern touchPosition d7_touch; -// Outdated Screens -extern C3D_RenderTarget *Top; -extern C3D_RenderTarget *TopRight; -extern C3D_RenderTarget *Bottom; - // Modern Global Api extern int rd7_max_objects; extern bool rd7_do_splash; diff --git a/include/renderd7/internal_db.hpp b/include/renderd7/internal_db.hpp index 669f668..6ca3ac8 100644 --- a/include/renderd7/internal_db.hpp +++ b/include/renderd7/internal_db.hpp @@ -57,7 +57,6 @@ extern bool rd7i_mt_screen; extern float rd7i_mt_txtSize; extern bool rd7i_metrikd; extern bool rd7i_ftraced; -extern bool rd7i_current_screen; extern u64 rd7i_delta_time; extern u64 rd7i_last_tm; extern float rd7i_dtm; diff --git a/include/renderd7/renderd7.hpp b/include/renderd7/renderd7.hpp index 26f19cf..851158e 100644 --- a/include/renderd7/renderd7.hpp +++ b/include/renderd7/renderd7.hpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include diff --git a/source/Message.cpp b/source/Message.cpp index ed656e8..85311aa 100644 --- a/source/Message.cpp +++ b/source/Message.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/source/Render2.cpp b/source/Render2.cpp index 41d3351..c71abd1 100644 --- a/source/Render2.cpp +++ b/source/Render2.cpp @@ -147,6 +147,11 @@ void R2Base::Process() { edit_text = edit_text.substr(edit_text.find('\n') + 1); line++; } + } else if (it.type == 4) { + C2D_DrawImageAt(it.img->Get(), it.pos.x, it.pos.y, 0.5f); + } else if (it.type == 5) { + // TODO: Move the Draw Func into this API + it.spr->Draw(); } } this->commands.clear(); @@ -257,4 +262,33 @@ void R2Base::AddText(R7Vec2 pos, const std::string& text, unsigned int clr, 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 + // Just assign current screen as bottom is 0 (false) + // and Top and TopRight are !0 (true) + cmd.Screen = current_screen; + if (this->next_lined) { + 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 + // Just assign current screen as bottom is 0 (false) + // and Top and TopRight are !0 (true) + cmd.Screen = current_screen; + if (this->next_lined) { + cmd.lined = true; + this->next_lined = false; + } + this->commands.push_back(cmd); +} + } // namespace RenderD7 \ No newline at end of file diff --git a/source/Screen.cpp b/source/Screen.cpp deleted file mode 100644 index 49fecb1..0000000 --- a/source/Screen.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/** - * This file is part of RenderD7 - * Copyright (C) 2021-2024 NPI-D7, tobid7 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -void RenderD7::OnScreen(C3D_RenderTarget *target) { - C2D_SceneBegin(target); - rd7i_current_screen = (target == Top || target == TopRight) ? 1 : 0; -} \ No newline at end of file diff --git a/source/ThemeEditor.cpp b/source/ThemeEditor.cpp index 29bcb72..9a4846e 100644 --- a/source/ThemeEditor.cpp +++ b/source/ThemeEditor.cpp @@ -57,7 +57,7 @@ RenderD7::ThemeEditor::~ThemeEditor() { } void RenderD7::ThemeEditor::Draw() const { - RenderD7::OnScreen(Top); + RenderD7::R2()->OnScreen(R2Screen_Top); if (UI7::BeginMenu("RenderD7 -> Theme Editor")) { UI7::Label("Sample Text"); UI7::Checkbox("Checkbox", cm); @@ -68,7 +68,7 @@ void RenderD7::ThemeEditor::Draw() const { edit_theme->GetTableRef()[RD7Color_Progressbar]); UI7::EndMenu(); } - RenderD7::OnScreen(Bottom); + RenderD7::R2()->OnScreen(R2Screen_Bottom); if (UI7::BeginMenu("Theme", R7Vec2(), UI7MenuFlags_Scrolling)) { if (menu == 0) { if (UI7::Button("Create New")) { diff --git a/source/UI7.cpp b/source/UI7.cpp index b63bd73..a8f9e7d 100644 --- a/source/UI7.cpp +++ b/source/UI7.cpp @@ -89,6 +89,7 @@ enum DrawCmdType_ { DrawCmdType_Rect, DrawCmdType_Triangle, DrawCmdType_Text, + DrawCmdType_Image, DrawCmdType_Debug, }; @@ -114,12 +115,14 @@ class DrawCmd { } else if (type == DrawCmdType_Text) { RenderD7::R2()->AddText(R7Vec2(rect.x, rect.y), text, clr, text_flags, text_box); + } else if (type == DrawCmdType_Image) { + RenderD7::R2()->AddImage(R7Vec2(rect.x, rect.y), img); } else if (type == DrawCmdType_Debug) { Debug(); } } void Debug() { - RenderD7::OnScreen(screen ? Top : Bottom); + RenderD7::R2()->OnScreen(screen ? R2Screen_Top : R2Screen_Bottom); if (stype == DrawCmdType_Skip && type != DrawCmdType_Debug) return; if (stype == DrawCmdType_Rect) { RenderD7::R2()->DrawNextLined(); @@ -148,6 +151,17 @@ class DrawCmd { RenderD7::R2()->AddTriangle(R7Vec2(rect.x + szs.x, rect.y + szs.y), R7Vec2(rect.x + szs.x, rect.y), R7Vec2(rect.x, rect.y + szs.y), 0xff00ffff); + } else if (stype == DrawCmdType_Image) { + rect.z = img->GetSize().x; + rect.w = img->GetSize().y; + RenderD7::R2()->DrawNextLined(); + RenderD7::R2()->AddTriangle(R7Vec2(rect.x, rect.y), + R7Vec2(rect.x + rect.z, rect.y), + R7Vec2(rect.x, rect.y + rect.w), 0xff0000ff); + RenderD7::R2()->DrawNextLined(); + RenderD7::R2()->AddTriangle(R7Vec2(rect.x + rect.z, rect.y + rect.w), + R7Vec2(rect.x + rect.z, rect.y), + R7Vec2(rect.x, rect.y + rect.w), 0xff0000ff); } } RD7_SMART_CTOR(DrawCmd) @@ -156,6 +170,7 @@ class DrawCmd { R7Vec2 add_coords = R7Vec2(); // Additional Coords unsigned int clr = 0; // Color std::string text = ""; // Text + RenderD7::Image::Ref img; // Image DrawCmdType type = DrawCmdType_Skip; // DrawCmd Type DrawCmdType stype = DrawCmdType_Skip; // Second Type RD7TextFlags text_flags = 0; // Flags for Text Rendering @@ -165,7 +180,7 @@ class DrawCmd { void UI7DrawList::AddRectangle(R7Vec2 pos, R7Vec2 szs, RD7Color clr) { auto cmd = DrawCmd::New(); - cmd->screen = rd7i_current_screen; + cmd->screen = RenderD7::R2()->GetCurrentScreen(); cmd->rect.x = pos.x; cmd->rect.y = pos.y; cmd->rect.z = szs.x; @@ -178,7 +193,7 @@ void UI7DrawList::AddRectangle(R7Vec2 pos, R7Vec2 szs, RD7Color clr) { void UI7DrawList::AddRectangle(R7Vec2 pos, R7Vec2 szs, unsigned int clr) { auto cmd = DrawCmd::New(); - cmd->screen = rd7i_current_screen; + cmd->screen = RenderD7::R2()->GetCurrentScreen(); cmd->rect.x = pos.x; cmd->rect.y = pos.y; cmd->rect.z = szs.x; @@ -192,7 +207,7 @@ void UI7DrawList::AddRectangle(R7Vec2 pos, R7Vec2 szs, unsigned int clr) { void UI7DrawList::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, RD7Color clr) { auto cmd = DrawCmd::New(); - cmd->screen = rd7i_current_screen; + cmd->screen = RenderD7::R2()->GetCurrentScreen(); cmd->rect.x = pos0.x; cmd->rect.y = pos0.y; cmd->rect.z = pos1.x; @@ -207,7 +222,7 @@ void UI7DrawList::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, void UI7DrawList::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int clr) { auto cmd = DrawCmd::New(); - cmd->screen = rd7i_current_screen; + cmd->screen = RenderD7::R2()->GetCurrentScreen(); cmd->rect.x = pos0.x; cmd->rect.y = pos0.y; cmd->rect.z = pos1.x; @@ -222,7 +237,7 @@ void UI7DrawList::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, void UI7DrawList::AddText(R7Vec2 pos, const std::string &text, RD7Color clr, RD7TextFlags flags, R7Vec2 box) { auto cmd = DrawCmd::New(); - cmd->screen = rd7i_current_screen; + cmd->screen = RenderD7::R2()->GetCurrentScreen(); cmd->rect.x = pos.x; cmd->rect.y = pos.y; cmd->text = text; @@ -237,7 +252,7 @@ void UI7DrawList::AddText(R7Vec2 pos, const std::string &text, RD7Color clr, void UI7DrawList::AddText(R7Vec2 pos, const std::string &text, unsigned int clr, RD7TextFlags flags, R7Vec2 box) { auto cmd = DrawCmd::New(); - cmd->screen = rd7i_current_screen; + cmd->screen = RenderD7::R2()->GetCurrentScreen(); cmd->rect.x = pos.x; cmd->rect.y = pos.y; cmd->text = text; @@ -249,6 +264,17 @@ void UI7DrawList::AddText(R7Vec2 pos, const std::string &text, unsigned int clr, AddCall(cmd); } +void UI7DrawList::AddImage(R7Vec2 pos, RenderD7::Image::Ref img) { + auto cmd = DrawCmd::New(); + cmd->screen = RenderD7::R2()->GetCurrentScreen(); + cmd->rect.x = pos.x; + cmd->rect.y = pos.y; + cmd->img = img; + cmd->type = DrawCmdType_Image; + AddDebugCall(cmd); + AddCall(cmd); +} + void UI7DrawList::AddCall(std::shared_ptr cmd) { this->list.push_back(cmd); } @@ -272,7 +298,7 @@ void UI7DrawList::AddDebugCall(std::shared_ptr cmd) { dcmd->text_box = cmd->text_box; dcmd->text_flags = cmd->text_flags; dcmd->type = DrawCmdType_Debug; - dcmd->screen = rd7i_current_screen; + dcmd->screen = RenderD7::R2()->GetCurrentScreen(); UI7CtxPushDebugCmd(dcmd); } @@ -354,7 +380,7 @@ bool UI7CtxBeginMenu(const std::string &lb) { ui7_ctx->cm = ui7_ctx->menus[id.ID()]; ui7_ctx->cm->menuid = id; ui7_ctx->cm->cursor = R7Vec2(0, 0); - ui7_ctx->cm->has_touch = !rd7i_current_screen; + ui7_ctx->cm->has_touch = !RenderD7::R2()->GetCurrentScreen(); if (!ui7_ctx->cm->background) ui7_ctx->cm->background = UI7DrawList::New(); if (!ui7_ctx->cm->main) ui7_ctx->cm->main = UI7DrawList::New(); if (!ui7_ctx->cm->front) ui7_ctx->cm->front = UI7DrawList::New(); @@ -368,7 +394,7 @@ void UI7CtxEndMenu() { RenderD7::Ftrace::ScopedTrace tr("ui7", "EndMenu"); // Draw Scrollbar if (ui7_ctx->cm->enable_scrolling) { - int sw = (rd7i_current_screen ? 400 : 320); + int sw = (RenderD7::R2()->GetCurrentScreen() ? 400 : 320); int tsp = 5 + ui7_ctx->cm->tbh; int szs = 240 - tsp - 5; int lszs = 20; // Lowest Slider size @@ -574,7 +600,8 @@ void Label(const std::string &label, RD7TextFlags flags) { void Progressbar(float value) { if (!UI7CtxValidate()) return; R7Vec2 pos = GetCursorPos(); - R7Vec2 size = R7Vec2((rd7i_current_screen ? 400 : 320) - (pos.x * 2), 20); + R7Vec2 size = R7Vec2( + (RenderD7::R2()->GetCurrentScreen() ? 400 : 320) - (pos.x * 2), 20); if (ui7_ctx->cm->show_scroolbar && ui7_ctx->cm->enable_scrolling) size.x -= 16; UI7CtxCursorMove(size); @@ -610,7 +637,7 @@ void Image(RenderD7::Image::Ref img) { return; } - // RenderD7::Draw2::Image(img, pos); + ui7_ctx->cm->main->AddImage(pos, img); } void BrowserList(const std::vector &entrys, int &selection, @@ -621,7 +648,8 @@ void BrowserList(const std::vector &entrys, int &selection, RenderD7::R2()->DefaultTextSize(); R7Vec2 pos = GetCursorPos(); if (pos.y + 15 * max_entrys > 230) max_entrys = (int)((230 - pos.y) / 15); - if (size.x == 0) size.x = (rd7i_current_screen ? 400 : 320) - (pos.x * 2); + if (size.x == 0) + size.x = (RenderD7::R2()->GetCurrentScreen() ? 400 : 320) - (pos.x * 2); if (size.y == 0) size.y = (max_entrys * 15); UI7CtxCursorMove(size); int selindex = (selection < max_entrys ? selection : (max_entrys - 1)); @@ -705,7 +733,7 @@ bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) { if (!ret) return ret; bool titlebar = true; if (size.x == 0) { - size.x = rd7i_current_screen ? 400 : 320; + size.x = RenderD7::R2()->GetCurrentScreen() ? 400 : 320; } if (size.y == 0) { size.y = 240; @@ -720,7 +748,7 @@ bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) { } if (flags & UI7MenuFlags_TitleMid) txtflags = RD7TextFlags_AlignMid; ui7_ctx->cm->enable_scrolling = (flags & UI7MenuFlags_Scrolling); - if (ui7_ctx->cm->enable_scrolling && !rd7i_current_screen) { + if (ui7_ctx->cm->enable_scrolling && !RenderD7::R2()->GetCurrentScreen()) { // Patch that sets scrolling to 0 if max pos is not out of screen if (ui7_ctx->cm->scrolling_offset != 0.f && ui7_ctx->cm->ms.y < 235) { ui7_ctx->cm->scrolling_offset = 0.f; diff --git a/source/internal_db.cpp b/source/internal_db.cpp index a8ba477..b6b5c52 100644 --- a/source/internal_db.cpp +++ b/source/internal_db.cpp @@ -56,7 +56,6 @@ bool rd7i_mt_screen; float rd7i_mt_txtSize; bool rd7i_metrikd = false; bool rd7i_ftraced = false; -bool rd7i_current_screen = false; u64 rd7i_delta_time; u64 rd7i_last_tm; float rd7i_dtm; @@ -84,11 +83,6 @@ u32 d7_hUp; u32 d7_hRepeat; // Inofficial lol touchPosition d7_touch; -// Outdated Screens -C3D_RenderTarget *Top; -C3D_RenderTarget *TopRight; -C3D_RenderTarget *Bottom; - // Modern Global Api int rd7_max_objects = C2D_DEFAULT_MAX_OBJECTS; bool rd7_do_splash = false; diff --git a/source/renderd7.cpp b/source/renderd7.cpp index 1296cce..10b9d1e 100644 --- a/source/renderd7.cpp +++ b/source/renderd7.cpp @@ -99,10 +99,11 @@ void PushSplash() { // Display for 2 Sec for (int x = 0; x < 120; x++) { C3D_FrameBegin(C3D_FRAME_SYNCDRAW); - C2D_TargetClear(Top, 0xff000000); - C2D_TargetClear(Bottom, 0xff000000); + C2D_TargetClear(rd7_top, 0xff000000); + C2D_TargetClear(rd7_bottom, 0xff000000); RenderD7::ClearTextBufs(); - RenderD7::OnScreen(Top); + C2D_SceneBegin(rd7_top); + RenderD7::R2()->OnScreen(R2Screen_Top); C2D_DrawImageAt(C2D_SpriteSheetGetImage(sheet, 0), 400 / 2 - 300 / 2, 240 / 2 - 100 / 2, 0.5); C3D_FrameEnd(0); @@ -324,8 +325,8 @@ bool RenderD7::MainLoop() { RenderD7::ClearTextBufs(); C3D_FrameBegin(C3D_FRAME_SYNCDRAW); - C2D_TargetClear(Top, C2D_Color32(0, 0, 0, 0)); - C2D_TargetClear(Bottom, C2D_Color32(0, 0, 0, 0)); + C2D_TargetClear(rd7_top, C2D_Color32(0, 0, 0, 0)); + C2D_TargetClear(rd7_bottom, C2D_Color32(0, 0, 0, 0)); frameloop(); if (rd7_enable_scene_system) { RenderD7::Scene::doDraw(); @@ -340,12 +341,9 @@ void RenderD7::Init::Graphics() { C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); C2D_Init((size_t)rd7_max_objects); C2D_Prepare(); - Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); - TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); - Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); - rd7_top = Top; - rd7_bottom = Bottom; - rd7_top_right = TopRight; + rd7_top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); + rd7_top_right = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); + rd7_bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); rd7i_text_buffer = C2D_TextBufNew(4096); rd7i_d2_dimbuf = C2D_TextBufNew(4096); rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA); @@ -391,21 +389,18 @@ Result RenderD7::Init::Main(std::string app_name) { atexit(C2D_Fini); atexit(RD7i_ExitHook); C2D_Prepare(); - Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); - TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); - Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); - rd7_top = Top; - rd7_bottom = Bottom; - rd7_top_right = TopRight; + rd7_top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); + rd7_top_right = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); + rd7_bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); rd7i_text_buffer = C2D_TextBufNew(4096); rd7i_d2_dimbuf = C2D_TextBufNew(4096); rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA); + rd7i_render2 = R2Base::New(); rd7i_graphics_on = true; rd7i_last_tm = svcGetSystemTick(); if (rd7_do_splash) PushSplash(); - rd7i_render2 = R2Base::New(); rd7i_init_config(); rd7i_init_input(); rd7i_init_theme(); @@ -445,15 +440,13 @@ Result RenderD7::Init::Minimal(std::string app_name) { atexit(C2D_Fini); atexit(RD7i_ExitHook); C2D_Prepare(); - Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); - TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); - Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); - rd7_top = Top; - rd7_bottom = Bottom; - rd7_top_right = TopRight; + rd7_top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); + rd7_top_right = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); + rd7_bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); rd7i_text_buffer = C2D_TextBufNew(4096); rd7i_d2_dimbuf = C2D_TextBufNew(4096); rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA); + rd7i_render2 = R2Base::New(); rd7i_graphics_on = true; if (rd7_do_splash) PushSplash(); @@ -462,7 +455,6 @@ Result RenderD7::Init::Minimal(std::string app_name) { svcGetSystemInfo(&citracheck, 0x20000, 0); rd7i_is_citra = citracheck ? true : false; - rd7i_render2 = R2Base::New(); rd7i_init_config(); rd7i_init_input(); rd7i_init_theme(); @@ -481,12 +473,9 @@ Result RenderD7::Init::Reload() { C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); C2D_Init((size_t)rd7_max_objects); C2D_Prepare(); - Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); - TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); - Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); - rd7_top = Top; - rd7_bottom = Bottom; - rd7_top_right = TopRight; + rd7_top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); + rd7_top_right = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); + rd7_bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); rd7i_text_buffer = C2D_TextBufNew(4096); rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA); rd7i_render2 = R2Base::New(); @@ -573,7 +562,7 @@ std::vector StrHelper(std::string input) { void RenderD7::RSettings::Draw(void) const { if (m_state == RSETTINGS) { - RenderD7::OnScreen(Top); + RenderD7::R2()->OnScreen(R2Screen_Top); if (UI7::BeginMenu("RenderD7 -> Settings")) { UI7::SetCursorPos(R7Vec2(395, 2)); UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight); @@ -588,7 +577,7 @@ void RenderD7::RSettings::Draw(void) const { UI7::Label("Kbd test: " + kbd_test); UI7::EndMenu(); } - RenderD7::OnScreen(Bottom); + RenderD7::R2()->OnScreen(R2Screen_Bottom); if (UI7::BeginMenu("Press \uE001 to go back!")) { if (UI7::Button("FTrace")) { shared_request[0x00000001] = RFTRACE; @@ -615,7 +604,7 @@ void RenderD7::RSettings::Draw(void) const { } } else if (m_state == RIDB) { - RenderD7::OnScreen(Top); + RenderD7::R2()->OnScreen(R2Screen_Top); if (UI7::BeginMenu("RenderD7 -> Debugger")) { UI7::SetCursorPos(R7Vec2(395, 2)); UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight); @@ -624,7 +613,7 @@ void RenderD7::RSettings::Draw(void) const { std::string(rd7i_idb_running ? "true" : "false")); UI7::EndMenu(); } - RenderD7::OnScreen(Bottom); + RenderD7::R2()->OnScreen(R2Screen_Bottom); if (UI7::BeginMenu("Press \uE001 to go back!")) { if (UI7::Button("Start Server")) { RenderD7::IDB::Start(); @@ -642,7 +631,7 @@ void RenderD7::RSettings::Draw(void) const { } } else if (m_state == RFTRACE) { - RenderD7::OnScreen(Top); + RenderD7::R2()->OnScreen(R2Screen_Top); // Draw Top Screen Into Background DrawList UI7::GetBackgroundList()->AddRectangle(R7Vec2(0, 0), R7Vec2(400, 240), RD7Color_Background); @@ -714,7 +703,7 @@ void RenderD7::RSettings::Draw(void) const { RenderD7::Ftrace::End("rd7ft", "display_traces"); - RenderD7::OnScreen(Bottom); + RenderD7::R2()->OnScreen(R2Screen_Bottom); if (UI7::BeginMenu("Press \uE001 to go back!")) { auto jt = RenderD7::Ftrace::rd7_traces.begin(); std::advance(jt, ftrace_index); @@ -729,7 +718,7 @@ void RenderD7::RSettings::Draw(void) const { UI7::EndMenu(); } } else if (m_state == RUI7) { - RenderD7::OnScreen(Top); + RenderD7::R2()->OnScreen(R2Screen_Top); if (UI7::BeginMenu("RenderD7 -> UI7")) { UI7::SetCursorPos(R7Vec2(395, 2)); UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight); @@ -753,7 +742,7 @@ void RenderD7::RSettings::Draw(void) const { UI7::EndMenu(); } - RenderD7::OnScreen(Bottom); + RenderD7::R2()->OnScreen(R2Screen_Bottom); if (UI7::BeginMenu("Press \uE001 to go back!", R7Vec2(), UI7MenuFlags_Scrolling)) { for (int i = 0; i < 20; i++) { @@ -769,7 +758,7 @@ void RenderD7::RSettings::Draw(void) const { UI7::EndMenu(); } } else if (m_state == ROVERLAYS) { - RenderD7::OnScreen(Top); + RenderD7::R2()->OnScreen(R2Screen_Top); if (UI7::BeginMenu("RenderD7 -> Overlays")) { UI7::SetCursorPos(R7Vec2(395, 2)); UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight); @@ -779,7 +768,7 @@ void RenderD7::RSettings::Draw(void) const { UI7::EndMenu(); } - RenderD7::OnScreen(Bottom); + RenderD7::R2()->OnScreen(R2Screen_Bottom); if (UI7::BeginMenu("Press \uE001 to go back!")) { UI7::Label("Metrik:"); UI7::Checkbox("Enable Overlay", rd7i_metrikd);