Remove ScreenApi
Add Sprite And Image to R2
Add Image to UI7DrawList
This commit is contained in:
tobid7 2024-06-08 21:53:25 +02:00
parent 2ff75a2969
commit 93f0ed44e8
13 changed files with 118 additions and 132 deletions

View File

@ -21,7 +21,9 @@
#include <map> #include <map>
#include <renderd7/Color.hpp> #include <renderd7/Color.hpp>
#include <renderd7/Font.hpp> #include <renderd7/Font.hpp>
#include <renderd7/Image.hpp>
#include <renderd7/R7Vec.hpp> #include <renderd7/R7Vec.hpp>
#include <renderd7/Sprite.hpp>
#include <renderd7/smart_ctor.hpp> #include <renderd7/smart_ctor.hpp>
#define MAKEFLAG(x) (1 << x) #define MAKEFLAG(x) (1 << x)
@ -53,7 +55,10 @@ class R2Base {
R7Vec2 ap; //< Additional Pos R7Vec2 ap; //< Additional Pos
unsigned int clr; //< Color unsigned int clr; //< Color
bool Screen; //< TopScreen 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 int type; //< Command Type
bool lined = false; //< Draw Lined Rect/Tri bool lined = false; //< Draw Lined Rect/Tri
// Text Specific // Text Specific
@ -88,6 +93,8 @@ class R2Base {
RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2()); RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2());
void AddText(R7Vec2 pos, const std::string& text, unsigned int clr, void AddText(R7Vec2 pos, const std::string& text, unsigned int clr,
RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2()); RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2());
void AddImage(R7Vec2 pos, Image::Ref img);
void AddSprite(Sprite::Ref spr);
private: private:
const float default_text_size = 0.5f; const float default_text_size = 0.5f;

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <citro2d.h>
#include <citro3d.h>
/// \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

View File

@ -51,6 +51,7 @@ class UI7DrawList {
RD7TextFlags flags = 0, R7Vec2 box = R7Vec2()); RD7TextFlags flags = 0, R7Vec2 box = R7Vec2());
void AddText(R7Vec2 pos, const std::string &text, unsigned int clr, void AddText(R7Vec2 pos, const std::string &text, unsigned int clr,
RD7TextFlags flags = 0, R7Vec2 box = R7Vec2()); RD7TextFlags flags = 0, R7Vec2 box = R7Vec2());
void AddImage(R7Vec2 pos, RenderD7::Image::Ref img);
void AddCall(std::shared_ptr<DrawCmd> cmd); void AddCall(std::shared_ptr<DrawCmd> cmd);
void Process(bool auto_clear = true); void Process(bool auto_clear = true);

View File

@ -36,11 +36,6 @@ extern u32 d7_hUp;
extern u32 d7_hRepeat; // Inofficial lol extern u32 d7_hRepeat; // Inofficial lol
extern touchPosition d7_touch; extern touchPosition d7_touch;
// Outdated Screens
extern C3D_RenderTarget *Top;
extern C3D_RenderTarget *TopRight;
extern C3D_RenderTarget *Bottom;
// Modern Global Api // Modern Global Api
extern int rd7_max_objects; extern int rd7_max_objects;
extern bool rd7_do_splash; extern bool rd7_do_splash;

View File

@ -57,7 +57,6 @@ extern bool rd7i_mt_screen;
extern float rd7i_mt_txtSize; extern float rd7i_mt_txtSize;
extern bool rd7i_metrikd; extern bool rd7i_metrikd;
extern bool rd7i_ftraced; extern bool rd7i_ftraced;
extern bool rd7i_current_screen;
extern u64 rd7i_delta_time; extern u64 rd7i_delta_time;
extern u64 rd7i_last_tm; extern u64 rd7i_last_tm;
extern float rd7i_dtm; extern float rd7i_dtm;

View File

@ -42,7 +42,6 @@
#include <renderd7/Ovl.hpp> #include <renderd7/Ovl.hpp>
#include <renderd7/Render2.hpp> #include <renderd7/Render2.hpp>
#include <renderd7/ResultDecoder.hpp> #include <renderd7/ResultDecoder.hpp>
#include <renderd7/Screen.hpp>
#include <renderd7/Sheet.hpp> #include <renderd7/Sheet.hpp>
#include <renderd7/Sprite.hpp> #include <renderd7/Sprite.hpp>
#include <renderd7/SpriteAnimation.hpp> #include <renderd7/SpriteAnimation.hpp>

View File

@ -20,7 +20,6 @@
#include <memory> #include <memory>
#include <renderd7/Color.hpp> #include <renderd7/Color.hpp>
#include <renderd7/Message.hpp> #include <renderd7/Message.hpp>
#include <renderd7/Screen.hpp>
#include <renderd7/renderd7.hpp> #include <renderd7/renderd7.hpp>
#include <vector> #include <vector>

View File

@ -147,6 +147,11 @@ void R2Base::Process() {
edit_text = edit_text.substr(edit_text.find('\n') + 1); edit_text = edit_text.substr(edit_text.find('\n') + 1);
line++; 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(); this->commands.clear();
@ -257,4 +262,33 @@ void R2Base::AddText(R7Vec2 pos, const std::string& text, unsigned int clr,
this->commands.push_back(cmd); 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 } // namespace RenderD7

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <renderd7/Screen.hpp>
#include <renderd7/internal_db.hpp>
void RenderD7::OnScreen(C3D_RenderTarget *target) {
C2D_SceneBegin(target);
rd7i_current_screen = (target == Top || target == TopRight) ? 1 : 0;
}

View File

@ -57,7 +57,7 @@ RenderD7::ThemeEditor::~ThemeEditor() {
} }
void RenderD7::ThemeEditor::Draw() const { void RenderD7::ThemeEditor::Draw() const {
RenderD7::OnScreen(Top); RenderD7::R2()->OnScreen(R2Screen_Top);
if (UI7::BeginMenu("RenderD7 -> Theme Editor")) { if (UI7::BeginMenu("RenderD7 -> Theme Editor")) {
UI7::Label("Sample Text"); UI7::Label("Sample Text");
UI7::Checkbox("Checkbox", cm); UI7::Checkbox("Checkbox", cm);
@ -68,7 +68,7 @@ void RenderD7::ThemeEditor::Draw() const {
edit_theme->GetTableRef()[RD7Color_Progressbar]); edit_theme->GetTableRef()[RD7Color_Progressbar]);
UI7::EndMenu(); UI7::EndMenu();
} }
RenderD7::OnScreen(Bottom); RenderD7::R2()->OnScreen(R2Screen_Bottom);
if (UI7::BeginMenu("Theme", R7Vec2(), UI7MenuFlags_Scrolling)) { if (UI7::BeginMenu("Theme", R7Vec2(), UI7MenuFlags_Scrolling)) {
if (menu == 0) { if (menu == 0) {
if (UI7::Button("Create New")) { if (UI7::Button("Create New")) {

View File

@ -89,6 +89,7 @@ enum DrawCmdType_ {
DrawCmdType_Rect, DrawCmdType_Rect,
DrawCmdType_Triangle, DrawCmdType_Triangle,
DrawCmdType_Text, DrawCmdType_Text,
DrawCmdType_Image,
DrawCmdType_Debug, DrawCmdType_Debug,
}; };
@ -114,12 +115,14 @@ class DrawCmd {
} else if (type == DrawCmdType_Text) { } else if (type == DrawCmdType_Text) {
RenderD7::R2()->AddText(R7Vec2(rect.x, rect.y), text, clr, text_flags, RenderD7::R2()->AddText(R7Vec2(rect.x, rect.y), text, clr, text_flags,
text_box); text_box);
} else if (type == DrawCmdType_Image) {
RenderD7::R2()->AddImage(R7Vec2(rect.x, rect.y), img);
} else if (type == DrawCmdType_Debug) { } else if (type == DrawCmdType_Debug) {
Debug(); Debug();
} }
} }
void 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_Skip && type != DrawCmdType_Debug) return;
if (stype == DrawCmdType_Rect) { if (stype == DrawCmdType_Rect) {
RenderD7::R2()->DrawNextLined(); RenderD7::R2()->DrawNextLined();
@ -148,6 +151,17 @@ class DrawCmd {
RenderD7::R2()->AddTriangle(R7Vec2(rect.x + szs.x, rect.y + szs.y), RenderD7::R2()->AddTriangle(R7Vec2(rect.x + szs.x, rect.y + szs.y),
R7Vec2(rect.x + szs.x, rect.y), R7Vec2(rect.x + szs.x, rect.y),
R7Vec2(rect.x, rect.y + szs.y), 0xff00ffff); 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) RD7_SMART_CTOR(DrawCmd)
@ -156,6 +170,7 @@ class DrawCmd {
R7Vec2 add_coords = R7Vec2(); // Additional Coords R7Vec2 add_coords = R7Vec2(); // Additional Coords
unsigned int clr = 0; // Color unsigned int clr = 0; // Color
std::string text = ""; // Text std::string text = ""; // Text
RenderD7::Image::Ref img; // Image
DrawCmdType type = DrawCmdType_Skip; // DrawCmd Type DrawCmdType type = DrawCmdType_Skip; // DrawCmd Type
DrawCmdType stype = DrawCmdType_Skip; // Second Type DrawCmdType stype = DrawCmdType_Skip; // Second Type
RD7TextFlags text_flags = 0; // Flags for Text Rendering RD7TextFlags text_flags = 0; // Flags for Text Rendering
@ -165,7 +180,7 @@ class DrawCmd {
void UI7DrawList::AddRectangle(R7Vec2 pos, R7Vec2 szs, RD7Color clr) { void UI7DrawList::AddRectangle(R7Vec2 pos, R7Vec2 szs, RD7Color clr) {
auto cmd = DrawCmd::New(); auto cmd = DrawCmd::New();
cmd->screen = rd7i_current_screen; cmd->screen = RenderD7::R2()->GetCurrentScreen();
cmd->rect.x = pos.x; cmd->rect.x = pos.x;
cmd->rect.y = pos.y; cmd->rect.y = pos.y;
cmd->rect.z = szs.x; 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) { void UI7DrawList::AddRectangle(R7Vec2 pos, R7Vec2 szs, unsigned int clr) {
auto cmd = DrawCmd::New(); auto cmd = DrawCmd::New();
cmd->screen = rd7i_current_screen; cmd->screen = RenderD7::R2()->GetCurrentScreen();
cmd->rect.x = pos.x; cmd->rect.x = pos.x;
cmd->rect.y = pos.y; cmd->rect.y = pos.y;
cmd->rect.z = szs.x; 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, void UI7DrawList::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2,
RD7Color clr) { RD7Color clr) {
auto cmd = DrawCmd::New(); auto cmd = DrawCmd::New();
cmd->screen = rd7i_current_screen; cmd->screen = RenderD7::R2()->GetCurrentScreen();
cmd->rect.x = pos0.x; cmd->rect.x = pos0.x;
cmd->rect.y = pos0.y; cmd->rect.y = pos0.y;
cmd->rect.z = pos1.x; 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, void UI7DrawList::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2,
unsigned int clr) { unsigned int clr) {
auto cmd = DrawCmd::New(); auto cmd = DrawCmd::New();
cmd->screen = rd7i_current_screen; cmd->screen = RenderD7::R2()->GetCurrentScreen();
cmd->rect.x = pos0.x; cmd->rect.x = pos0.x;
cmd->rect.y = pos0.y; cmd->rect.y = pos0.y;
cmd->rect.z = pos1.x; 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, void UI7DrawList::AddText(R7Vec2 pos, const std::string &text, RD7Color clr,
RD7TextFlags flags, R7Vec2 box) { RD7TextFlags flags, R7Vec2 box) {
auto cmd = DrawCmd::New(); auto cmd = DrawCmd::New();
cmd->screen = rd7i_current_screen; cmd->screen = RenderD7::R2()->GetCurrentScreen();
cmd->rect.x = pos.x; cmd->rect.x = pos.x;
cmd->rect.y = pos.y; cmd->rect.y = pos.y;
cmd->text = text; 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, void UI7DrawList::AddText(R7Vec2 pos, const std::string &text, unsigned int clr,
RD7TextFlags flags, R7Vec2 box) { RD7TextFlags flags, R7Vec2 box) {
auto cmd = DrawCmd::New(); auto cmd = DrawCmd::New();
cmd->screen = rd7i_current_screen; cmd->screen = RenderD7::R2()->GetCurrentScreen();
cmd->rect.x = pos.x; cmd->rect.x = pos.x;
cmd->rect.y = pos.y; cmd->rect.y = pos.y;
cmd->text = text; cmd->text = text;
@ -249,6 +264,17 @@ void UI7DrawList::AddText(R7Vec2 pos, const std::string &text, unsigned int clr,
AddCall(cmd); 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<DrawCmd> cmd) { void UI7DrawList::AddCall(std::shared_ptr<DrawCmd> cmd) {
this->list.push_back(cmd); this->list.push_back(cmd);
} }
@ -272,7 +298,7 @@ void UI7DrawList::AddDebugCall(std::shared_ptr<DrawCmd> cmd) {
dcmd->text_box = cmd->text_box; dcmd->text_box = cmd->text_box;
dcmd->text_flags = cmd->text_flags; dcmd->text_flags = cmd->text_flags;
dcmd->type = DrawCmdType_Debug; dcmd->type = DrawCmdType_Debug;
dcmd->screen = rd7i_current_screen; dcmd->screen = RenderD7::R2()->GetCurrentScreen();
UI7CtxPushDebugCmd(dcmd); UI7CtxPushDebugCmd(dcmd);
} }
@ -354,7 +380,7 @@ bool UI7CtxBeginMenu(const std::string &lb) {
ui7_ctx->cm = ui7_ctx->menus[id.ID()]; ui7_ctx->cm = ui7_ctx->menus[id.ID()];
ui7_ctx->cm->menuid = id; ui7_ctx->cm->menuid = id;
ui7_ctx->cm->cursor = R7Vec2(0, 0); 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->background) ui7_ctx->cm->background = UI7DrawList::New();
if (!ui7_ctx->cm->main) ui7_ctx->cm->main = UI7DrawList::New(); if (!ui7_ctx->cm->main) ui7_ctx->cm->main = UI7DrawList::New();
if (!ui7_ctx->cm->front) ui7_ctx->cm->front = 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"); RenderD7::Ftrace::ScopedTrace tr("ui7", "EndMenu");
// Draw Scrollbar // Draw Scrollbar
if (ui7_ctx->cm->enable_scrolling) { 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 tsp = 5 + ui7_ctx->cm->tbh;
int szs = 240 - tsp - 5; int szs = 240 - tsp - 5;
int lszs = 20; // Lowest Slider size int lszs = 20; // Lowest Slider size
@ -574,7 +600,8 @@ void Label(const std::string &label, RD7TextFlags flags) {
void Progressbar(float value) { void Progressbar(float value) {
if (!UI7CtxValidate()) return; if (!UI7CtxValidate()) return;
R7Vec2 pos = GetCursorPos(); 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) if (ui7_ctx->cm->show_scroolbar && ui7_ctx->cm->enable_scrolling)
size.x -= 16; size.x -= 16;
UI7CtxCursorMove(size); UI7CtxCursorMove(size);
@ -610,7 +637,7 @@ void Image(RenderD7::Image::Ref img) {
return; return;
} }
// RenderD7::Draw2::Image(img, pos); ui7_ctx->cm->main->AddImage(pos, img);
} }
void BrowserList(const std::vector<std::string> &entrys, int &selection, void BrowserList(const std::vector<std::string> &entrys, int &selection,
@ -621,7 +648,8 @@ void BrowserList(const std::vector<std::string> &entrys, int &selection,
RenderD7::R2()->DefaultTextSize(); RenderD7::R2()->DefaultTextSize();
R7Vec2 pos = GetCursorPos(); R7Vec2 pos = GetCursorPos();
if (pos.y + 15 * max_entrys > 230) max_entrys = (int)((230 - pos.y) / 15); 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); if (size.y == 0) size.y = (max_entrys * 15);
UI7CtxCursorMove(size); UI7CtxCursorMove(size);
int selindex = (selection < max_entrys ? selection : (max_entrys - 1)); 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; if (!ret) return ret;
bool titlebar = true; bool titlebar = true;
if (size.x == 0) { if (size.x == 0) {
size.x = rd7i_current_screen ? 400 : 320; size.x = RenderD7::R2()->GetCurrentScreen() ? 400 : 320;
} }
if (size.y == 0) { if (size.y == 0) {
size.y = 240; size.y = 240;
@ -720,7 +748,7 @@ bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) {
} }
if (flags & UI7MenuFlags_TitleMid) txtflags = RD7TextFlags_AlignMid; if (flags & UI7MenuFlags_TitleMid) txtflags = RD7TextFlags_AlignMid;
ui7_ctx->cm->enable_scrolling = (flags & UI7MenuFlags_Scrolling); 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 // 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) { if (ui7_ctx->cm->scrolling_offset != 0.f && ui7_ctx->cm->ms.y < 235) {
ui7_ctx->cm->scrolling_offset = 0.f; ui7_ctx->cm->scrolling_offset = 0.f;

View File

@ -56,7 +56,6 @@ bool rd7i_mt_screen;
float rd7i_mt_txtSize; float rd7i_mt_txtSize;
bool rd7i_metrikd = false; bool rd7i_metrikd = false;
bool rd7i_ftraced = false; bool rd7i_ftraced = false;
bool rd7i_current_screen = false;
u64 rd7i_delta_time; u64 rd7i_delta_time;
u64 rd7i_last_tm; u64 rd7i_last_tm;
float rd7i_dtm; float rd7i_dtm;
@ -84,11 +83,6 @@ u32 d7_hUp;
u32 d7_hRepeat; // Inofficial lol u32 d7_hRepeat; // Inofficial lol
touchPosition d7_touch; touchPosition d7_touch;
// Outdated Screens
C3D_RenderTarget *Top;
C3D_RenderTarget *TopRight;
C3D_RenderTarget *Bottom;
// Modern Global Api // Modern Global Api
int rd7_max_objects = C2D_DEFAULT_MAX_OBJECTS; int rd7_max_objects = C2D_DEFAULT_MAX_OBJECTS;
bool rd7_do_splash = false; bool rd7_do_splash = false;

View File

@ -99,10 +99,11 @@ void PushSplash() {
// Display for 2 Sec // Display for 2 Sec
for (int x = 0; x < 120; x++) { for (int x = 0; x < 120; x++) {
C3D_FrameBegin(C3D_FRAME_SYNCDRAW); C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(Top, 0xff000000); C2D_TargetClear(rd7_top, 0xff000000);
C2D_TargetClear(Bottom, 0xff000000); C2D_TargetClear(rd7_bottom, 0xff000000);
RenderD7::ClearTextBufs(); RenderD7::ClearTextBufs();
RenderD7::OnScreen(Top); C2D_SceneBegin(rd7_top);
RenderD7::R2()->OnScreen(R2Screen_Top);
C2D_DrawImageAt(C2D_SpriteSheetGetImage(sheet, 0), 400 / 2 - 300 / 2, C2D_DrawImageAt(C2D_SpriteSheetGetImage(sheet, 0), 400 / 2 - 300 / 2,
240 / 2 - 100 / 2, 0.5); 240 / 2 - 100 / 2, 0.5);
C3D_FrameEnd(0); C3D_FrameEnd(0);
@ -324,8 +325,8 @@ bool RenderD7::MainLoop() {
RenderD7::ClearTextBufs(); RenderD7::ClearTextBufs();
C3D_FrameBegin(C3D_FRAME_SYNCDRAW); C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(Top, C2D_Color32(0, 0, 0, 0)); C2D_TargetClear(rd7_top, C2D_Color32(0, 0, 0, 0));
C2D_TargetClear(Bottom, C2D_Color32(0, 0, 0, 0)); C2D_TargetClear(rd7_bottom, C2D_Color32(0, 0, 0, 0));
frameloop(); frameloop();
if (rd7_enable_scene_system) { if (rd7_enable_scene_system) {
RenderD7::Scene::doDraw(); RenderD7::Scene::doDraw();
@ -340,12 +341,9 @@ void RenderD7::Init::Graphics() {
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
C2D_Init((size_t)rd7_max_objects); C2D_Init((size_t)rd7_max_objects);
C2D_Prepare(); C2D_Prepare();
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); rd7_top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); rd7_top_right = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); rd7_bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
rd7_top = Top;
rd7_bottom = Bottom;
rd7_top_right = TopRight;
rd7i_text_buffer = C2D_TextBufNew(4096); rd7i_text_buffer = C2D_TextBufNew(4096);
rd7i_d2_dimbuf = C2D_TextBufNew(4096); rd7i_d2_dimbuf = C2D_TextBufNew(4096);
rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA); rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA);
@ -391,21 +389,18 @@ Result RenderD7::Init::Main(std::string app_name) {
atexit(C2D_Fini); atexit(C2D_Fini);
atexit(RD7i_ExitHook); atexit(RD7i_ExitHook);
C2D_Prepare(); C2D_Prepare();
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); rd7_top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); rd7_top_right = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); rd7_bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
rd7_top = Top;
rd7_bottom = Bottom;
rd7_top_right = TopRight;
rd7i_text_buffer = C2D_TextBufNew(4096); rd7i_text_buffer = C2D_TextBufNew(4096);
rd7i_d2_dimbuf = C2D_TextBufNew(4096); rd7i_d2_dimbuf = C2D_TextBufNew(4096);
rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA); rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA);
rd7i_render2 = R2Base::New();
rd7i_graphics_on = true; rd7i_graphics_on = true;
rd7i_last_tm = svcGetSystemTick(); rd7i_last_tm = svcGetSystemTick();
if (rd7_do_splash) PushSplash(); if (rd7_do_splash) PushSplash();
rd7i_render2 = R2Base::New();
rd7i_init_config(); rd7i_init_config();
rd7i_init_input(); rd7i_init_input();
rd7i_init_theme(); rd7i_init_theme();
@ -445,15 +440,13 @@ Result RenderD7::Init::Minimal(std::string app_name) {
atexit(C2D_Fini); atexit(C2D_Fini);
atexit(RD7i_ExitHook); atexit(RD7i_ExitHook);
C2D_Prepare(); C2D_Prepare();
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); rd7_top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); rd7_top_right = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); rd7_bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
rd7_top = Top;
rd7_bottom = Bottom;
rd7_top_right = TopRight;
rd7i_text_buffer = C2D_TextBufNew(4096); rd7i_text_buffer = C2D_TextBufNew(4096);
rd7i_d2_dimbuf = C2D_TextBufNew(4096); rd7i_d2_dimbuf = C2D_TextBufNew(4096);
rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA); rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA);
rd7i_render2 = R2Base::New();
rd7i_graphics_on = true; rd7i_graphics_on = true;
if (rd7_do_splash) PushSplash(); if (rd7_do_splash) PushSplash();
@ -462,7 +455,6 @@ Result RenderD7::Init::Minimal(std::string app_name) {
svcGetSystemInfo(&citracheck, 0x20000, 0); svcGetSystemInfo(&citracheck, 0x20000, 0);
rd7i_is_citra = citracheck ? true : false; rd7i_is_citra = citracheck ? true : false;
rd7i_render2 = R2Base::New();
rd7i_init_config(); rd7i_init_config();
rd7i_init_input(); rd7i_init_input();
rd7i_init_theme(); rd7i_init_theme();
@ -481,12 +473,9 @@ Result RenderD7::Init::Reload() {
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
C2D_Init((size_t)rd7_max_objects); C2D_Init((size_t)rd7_max_objects);
C2D_Prepare(); C2D_Prepare();
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); rd7_top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT); rd7_top_right = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); rd7_bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
rd7_top = Top;
rd7_bottom = Bottom;
rd7_top_right = TopRight;
rd7i_text_buffer = C2D_TextBufNew(4096); rd7i_text_buffer = C2D_TextBufNew(4096);
rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA); rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA);
rd7i_render2 = R2Base::New(); rd7i_render2 = R2Base::New();
@ -573,7 +562,7 @@ std::vector<std::string> StrHelper(std::string input) {
void RenderD7::RSettings::Draw(void) const { void RenderD7::RSettings::Draw(void) const {
if (m_state == RSETTINGS) { if (m_state == RSETTINGS) {
RenderD7::OnScreen(Top); RenderD7::R2()->OnScreen(R2Screen_Top);
if (UI7::BeginMenu("RenderD7 -> Settings")) { if (UI7::BeginMenu("RenderD7 -> Settings")) {
UI7::SetCursorPos(R7Vec2(395, 2)); UI7::SetCursorPos(R7Vec2(395, 2));
UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight); UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight);
@ -588,7 +577,7 @@ void RenderD7::RSettings::Draw(void) const {
UI7::Label("Kbd test: " + kbd_test); UI7::Label("Kbd test: " + kbd_test);
UI7::EndMenu(); UI7::EndMenu();
} }
RenderD7::OnScreen(Bottom); RenderD7::R2()->OnScreen(R2Screen_Bottom);
if (UI7::BeginMenu("Press \uE001 to go back!")) { if (UI7::BeginMenu("Press \uE001 to go back!")) {
if (UI7::Button("FTrace")) { if (UI7::Button("FTrace")) {
shared_request[0x00000001] = RFTRACE; shared_request[0x00000001] = RFTRACE;
@ -615,7 +604,7 @@ void RenderD7::RSettings::Draw(void) const {
} }
} else if (m_state == RIDB) { } else if (m_state == RIDB) {
RenderD7::OnScreen(Top); RenderD7::R2()->OnScreen(R2Screen_Top);
if (UI7::BeginMenu("RenderD7 -> Debugger")) { if (UI7::BeginMenu("RenderD7 -> Debugger")) {
UI7::SetCursorPos(R7Vec2(395, 2)); UI7::SetCursorPos(R7Vec2(395, 2));
UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight); UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight);
@ -624,7 +613,7 @@ void RenderD7::RSettings::Draw(void) const {
std::string(rd7i_idb_running ? "true" : "false")); std::string(rd7i_idb_running ? "true" : "false"));
UI7::EndMenu(); UI7::EndMenu();
} }
RenderD7::OnScreen(Bottom); RenderD7::R2()->OnScreen(R2Screen_Bottom);
if (UI7::BeginMenu("Press \uE001 to go back!")) { if (UI7::BeginMenu("Press \uE001 to go back!")) {
if (UI7::Button("Start Server")) { if (UI7::Button("Start Server")) {
RenderD7::IDB::Start(); RenderD7::IDB::Start();
@ -642,7 +631,7 @@ void RenderD7::RSettings::Draw(void) const {
} }
} else if (m_state == RFTRACE) { } else if (m_state == RFTRACE) {
RenderD7::OnScreen(Top); RenderD7::R2()->OnScreen(R2Screen_Top);
// Draw Top Screen Into Background DrawList // Draw Top Screen Into Background DrawList
UI7::GetBackgroundList()->AddRectangle(R7Vec2(0, 0), R7Vec2(400, 240), UI7::GetBackgroundList()->AddRectangle(R7Vec2(0, 0), R7Vec2(400, 240),
RD7Color_Background); RD7Color_Background);
@ -714,7 +703,7 @@ void RenderD7::RSettings::Draw(void) const {
RenderD7::Ftrace::End("rd7ft", "display_traces"); RenderD7::Ftrace::End("rd7ft", "display_traces");
RenderD7::OnScreen(Bottom); RenderD7::R2()->OnScreen(R2Screen_Bottom);
if (UI7::BeginMenu("Press \uE001 to go back!")) { if (UI7::BeginMenu("Press \uE001 to go back!")) {
auto jt = RenderD7::Ftrace::rd7_traces.begin(); auto jt = RenderD7::Ftrace::rd7_traces.begin();
std::advance(jt, ftrace_index); std::advance(jt, ftrace_index);
@ -729,7 +718,7 @@ void RenderD7::RSettings::Draw(void) const {
UI7::EndMenu(); UI7::EndMenu();
} }
} else if (m_state == RUI7) { } else if (m_state == RUI7) {
RenderD7::OnScreen(Top); RenderD7::R2()->OnScreen(R2Screen_Top);
if (UI7::BeginMenu("RenderD7 -> UI7")) { if (UI7::BeginMenu("RenderD7 -> UI7")) {
UI7::SetCursorPos(R7Vec2(395, 2)); UI7::SetCursorPos(R7Vec2(395, 2));
UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight); UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight);
@ -753,7 +742,7 @@ void RenderD7::RSettings::Draw(void) const {
UI7::EndMenu(); UI7::EndMenu();
} }
RenderD7::OnScreen(Bottom); RenderD7::R2()->OnScreen(R2Screen_Bottom);
if (UI7::BeginMenu("Press \uE001 to go back!", R7Vec2(), if (UI7::BeginMenu("Press \uE001 to go back!", R7Vec2(),
UI7MenuFlags_Scrolling)) { UI7MenuFlags_Scrolling)) {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
@ -769,7 +758,7 @@ void RenderD7::RSettings::Draw(void) const {
UI7::EndMenu(); UI7::EndMenu();
} }
} else if (m_state == ROVERLAYS) { } else if (m_state == ROVERLAYS) {
RenderD7::OnScreen(Top); RenderD7::R2()->OnScreen(R2Screen_Top);
if (UI7::BeginMenu("RenderD7 -> Overlays")) { if (UI7::BeginMenu("RenderD7 -> Overlays")) {
UI7::SetCursorPos(R7Vec2(395, 2)); UI7::SetCursorPos(R7Vec2(395, 2));
UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight); UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight);
@ -779,7 +768,7 @@ void RenderD7::RSettings::Draw(void) const {
UI7::EndMenu(); UI7::EndMenu();
} }
RenderD7::OnScreen(Bottom); RenderD7::R2()->OnScreen(R2Screen_Bottom);
if (UI7::BeginMenu("Press \uE001 to go back!")) { if (UI7::BeginMenu("Press \uE001 to go back!")) {
UI7::Label("Metrik:"); UI7::Label("Metrik:");
UI7::Checkbox("Enable Overlay", rd7i_metrikd); UI7::Checkbox("Enable Overlay", rd7i_metrikd);