diff --git a/include/renderd7/Draw.hpp b/include/renderd7/Draw.hpp new file mode 100644 index 0000000..89e3b4e --- /dev/null +++ b/include/renderd7/Draw.hpp @@ -0,0 +1,25 @@ +#pragma once +#include +#include +#include <3ds.h> +#include + +namespace RenderD7 +{ + namespace Draw + { + bool Rect(float x, float y, float w, float h, u32 color); + bool NFRect(float p1x, float p1y, float w, float h, u32 color, float scale = 1); + bool Px(float x, float y, u32 color); + void TextCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr); + void Text(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr); + void TextRight(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr); + float GetTextWidth(float size, std::string Text, C2D_Font fnt = nullptr); + void GetTextSize(float size, float *width, float *height, std::string Text, C2D_Font fnt = nullptr); + float GetTextHeight(float size, std::string Text, C2D_Font fnt = nullptr); + Result LoadFont(C2D_Font &fnt, const char * Path = ""); + Result UnloadFont(C2D_Font &fnt); + bool Circle(float x, float y, float radius, u32 color); + bool Image(C2D_Image img, float x, float y, float scaleX = 1.0f, float scaleY = 1.0f); + } +} \ No newline at end of file diff --git a/include/renderd7/FileSystem.hpp b/include/renderd7/FileSystem.hpp new file mode 100644 index 0000000..64f474a --- /dev/null +++ b/include/renderd7/FileSystem.hpp @@ -0,0 +1,110 @@ +//FileSystem based on libphyfs based on https://github.com/TurtleP/3ds-examples/blob/fs/physfs/fs/physfs/include/filesystem.h +#pragma once +#include +#include + +#include + +namespace RenderD7 +{ + namespace FileSystem + { + static constexpr auto MAX_STAMP = 0x20000000000000LL; + + enum FileMode + { + FileMode_Open, + FileMode_Read, + FileMode_Write, + FileMode_Closed + }; + + enum FileType + { + FileType_File, + FileType_Directory, + FileType_SymLink, + FileType_Other + }; + + struct File + { + PHYSFS_file* handle; + FileMode mode; + + File() + { + this->handle = nullptr; + this->mode = FileMode_Closed; + } + + int64_t GetSize() + { + if (this->handle == nullptr) + return 0; + + return (int64_t)PHYSFS_fileLength(this->handle); + } + }; + + struct Info + { + int64_t size; + int64_t mod_time; + FileType type; + }; + + int Init(const char* argv); + + void Initialize(); + + /* + ** mounts a specific directory for physfs to search in + ** this is typically a main directory + */ + bool SetSource(const char* source); + + /* + ** mounts a specific directory as a "save" directory + ** if appended, it will be added to the search path + */ + bool SetIdentity(const char* name, bool append); + + static std::string savePath; + + /* gets the last physfs error */ + const char* GetPhysfsError(); + + /* strips any duplicate slashes */ + std::string Normalize(const std::string& input); + + /* gets the user directory from physfs */ + std::string GetUserDirectory(); + + /* gets the save directory */ + std::string GetSaveDirectory(); + + /* sets up the writing directory for physfs */ + bool SetupWriteDirectory(); + + /* gets a list of files in a directory */ + void GetDirectoryItems(const char* directory, std::vector& items); + + /* gets the size, mod_time, and type of a file */ + bool GetInfo(const char* filename, Info& info); + + /* creates a new directory */ + bool CreateDirectory(const char* name); + + bool CloseFile(File& file); + + /* creates a new file */ + bool OpenFile(File& file, const char* name, FileMode mode); + + /* writes to a file */ + bool WriteFile(File& file, const void* data, int64_t size); + + /* reads a file's content */ + int64_t ReadFile(File& file, void* destination, int64_t size); + } +} \ No newline at end of file diff --git a/include/renderd7/renderd7.hpp b/include/renderd7/renderd7.hpp index 22cdefa..5c90abe 100644 --- a/include/renderd7/renderd7.hpp +++ b/include/renderd7/renderd7.hpp @@ -40,6 +40,7 @@ #include #include #include +#include extern "C" { @@ -206,19 +207,7 @@ namespace RenderD7 void ClearTextBufs(void); std::string Kbd(int lenght, SwkbdType tp); - bool DrawRect(float x, float y, float w, float h, u32 color); - bool DrawNFRect(float p1x, float p1y, float w, float h, u32 color, float scale = 1); - bool DrawPx(float x, float y, u32 color); - void DrawTextCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr); - void DrawText(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr); - void DrawTextLeft(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr); - float GetTextWidth(float size, std::string Text, C2D_Font fnt = nullptr); - void GetTextSize(float size, float *width, float *height, std::string Text, C2D_Font fnt = nullptr); - float GetTextHeight(float size, std::string Text, C2D_Font fnt = nullptr); - Result loadFont(C2D_Font &fnt, const char * Path = ""); - Result unloadFont(C2D_Font &fnt); - bool DrawCircle(float x, float y, float radius, u32 color); - bool DrawImage(C2D_Image img, float x, float y, float scaleX = 1.0f, float scaleY = 1.0f); + void FrameEnd(); void ToggleRD7SR(); bool IsRD7SR(); diff --git a/source/Draw.cpp b/source/Draw.cpp new file mode 100644 index 0000000..e60aec7 --- /dev/null +++ b/source/Draw.cpp @@ -0,0 +1,177 @@ +#include + +extern C2D_TextBuf TextBuf; +extern C2D_Font Font; +extern bool currentScreen; + +bool RenderD7::Draw::Rect(float x, float y, float w, float h, u32 color) +{ + return C2D_DrawRectSolid(x, y, 0.5f, w, h, color); +} + +bool RenderD7::Draw::Px(float x, float y, u32 color) +{ + return C2D_DrawRectSolid(x, y, 0.5f, 1, 1, color); +} + +void RenderD7::Draw::TextCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt) { + float lineHeight, widthScale; + + // Check for the lineHeight. + if (fnt != nullptr) { + lineHeight = RenderD7::Draw::GetTextHeight(size, " ", fnt); + } else { + lineHeight = RenderD7::Draw::GetTextHeight(size, " "); + } + + int line = 0; + while(Text.find('\n') != Text.npos) { + if (maxWidth == 0) { + // Do the widthScale. + if (fnt != nullptr) { + widthScale = RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt); + } else { + widthScale = RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n'))); + } + } else { + // Do the widthScale 2. + if (fnt != nullptr) { + widthScale = std::min((float)maxWidth, RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt)); + } else { + widthScale = std::min((float)maxWidth, RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n')))); + } + } + if (fnt != nullptr) { + RenderD7::Draw::Text((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight, fnt); + } else { + RenderD7::Draw::Text((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight); + } + + Text = Text.substr(Text.find('\n')+1); + line++; + } + + if (maxWidth == 0) { + // Do the next WidthScale. + if (fnt != nullptr) { + widthScale = RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt); + } else { + widthScale = RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n'))); + } + } else { + // And again. + if (fnt != nullptr) { + widthScale = std::min((float)maxWidth, RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt)); + } else { + widthScale = std::min((float)maxWidth, RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n')))); + } + } + if (fnt != nullptr) { + RenderD7::Draw::Text((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight, fnt); + } else { + RenderD7::Draw::Text((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight); + } +} + +// Draw String or Text. +void RenderD7::Draw::Text(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt) { + C2D_Text c2d_text; + + if (fnt != nullptr) { + C2D_TextFontParse(&c2d_text, fnt, TextBuf, Text.c_str()); + } else { + C2D_TextFontParse(&c2d_text, Font, TextBuf, Text.c_str()); + } + + C2D_TextOptimize(&c2d_text); + + float heightScale; + if (maxHeight == 0) { + heightScale = size; + } else { + if (fnt != nullptr) { + heightScale = std::min(size, size*(maxHeight/RenderD7::Draw::GetTextHeight(size, Text, fnt))); + } else { + heightScale = std::min(size, size*(maxHeight/RenderD7::Draw::GetTextHeight(size, Text))); + } + } + + if (maxWidth == 0) { + C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, size, heightScale, color); + } else { + if (fnt != nullptr) { + C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, std::min(size, size*(maxWidth/RenderD7::Draw::GetTextWidth(size, Text, fnt))), heightScale, color); + } else { + C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, std::min(size, size*(maxWidth/RenderD7::Draw::GetTextWidth(size, Text))), heightScale, color); + } + } +} +void RenderD7::Draw::TextRight(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt) +{ + RenderD7::Draw::Text(x - RenderD7::Draw::GetTextWidth(size, Text, fnt), y, size, color, Text, maxWidth, maxHeight, fnt); +} +// Get String or Text Width. +float RenderD7::Draw::GetTextWidth(float size, std::string Text, C2D_Font fnt) { + float width = 0; + if (fnt != nullptr) { + GetTextSize(size, &width, NULL, Text, fnt); + } else { + GetTextSize(size, &width, NULL, Text); + } + return width; +} + +// Get String or Text Size. +void RenderD7::Draw::GetTextSize(float size, float *width, float *height, std::string Text, C2D_Font fnt) { + C2D_Text c2d_text; + if (fnt != nullptr) { + C2D_TextFontParse(&c2d_text, fnt, TextBuf, Text.c_str()); + } else { + C2D_TextFontParse(&c2d_text, Font, TextBuf, Text.c_str()); + } + C2D_TextGetDimensions(&c2d_text, size, size, width, height); +} + + +// Get String or Text Height. +float RenderD7::Draw::GetTextHeight(float size, std::string Text, C2D_Font fnt) { + float height = 0; + if (fnt != nullptr) { + GetTextSize(size, NULL, &height, Text.c_str(), fnt); + } else { + GetTextSize(size, NULL, &height, Text.c_str()); + } + return height; +} + +Result RenderD7::Draw::LoadFont(C2D_Font &fnt, const char* Path) { + fnt = C2D_FontLoad(Path); // Only load if found. + return 0; +} + +// Unload a Font. +Result RenderD7::Draw::UnloadFont(C2D_Font &fnt) { + if (fnt != nullptr) { + C2D_FontFree(fnt); // Make sure to only unload if not nullptr. + } + return 0; +} + +bool RenderD7::Draw::Circle(float x, float y, float radius, u32 color) +{ + return C2D_DrawCircleSolid(x, y, 0.5f, radius, color); +} + +bool RenderD7::Draw::Image(C2D_Image img, float x, float y, float scaleX, float scaleY) +{ + return C2D_DrawImageAt(img, x, y, 0.5f, nullptr, scaleX, scaleY); +} + +bool RenderD7::Draw::NFRect(float p1x, float p1y, float w, float h, u32 color, float scale) +{ + C2D_DrawLine(p1x, p1y, color,w, p1y, color, scale, 1); + C2D_DrawLine(w, p1y, color,w, h, color, scale, 1); + C2D_DrawLine(w, h, color,p1x, h, color, scale, 1); + C2D_DrawLine(p1x, h, color,p1x, p1y, color, scale, 1); + return true; +} \ No newline at end of file diff --git a/source/FileSystem.cpp b/source/FileSystem.cpp new file mode 100644 index 0000000..c290ca7 --- /dev/null +++ b/source/FileSystem.cpp @@ -0,0 +1,288 @@ +#include +#include <3ds.h> +#include + +const char* RenderD7::FileSystem::GetPhysfsError() +{ + return PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()); +} + +std::string RenderD7::FileSystem::Normalize(const std::string& input) +{ + std::string out; + bool seenSep = false, isSep = false; + + for (size_t i = 0; i < input.size(); ++i) + { + isSep = (input[i] == '/'); + + if (!isSep || !seenSep) + out += input[i]; + + seenSep = isSep; + } + + return out; +} + +void RenderD7::FileSystem::Initialize() +{ + RenderD7::FileSystem::savePath = ""; +} + +int RenderD7::FileSystem::Init(const char* argv) +{ + return PHYSFS_init(argv); +} + +bool RenderD7::FileSystem::SetSource(const char* source) +{ + if (!PHYSFS_isInit()) + return false; + + std::string searchPath = source; + if (!PHYSFS_mount(searchPath.c_str(), NULL, 1)) + return false; + + return true; +} + +bool RenderD7::FileSystem::SetIdentity(const char* name, bool append) +{ + if (!PHYSFS_isInit()) + return false; + + std::string old = RenderD7::FileSystem::savePath; + + RenderD7::FileSystem::savePath = RenderD7::FileSystem::Normalize(RenderD7::FileSystem::GetUserDirectory() + "/save/" + name); + printf("Save Path set to %s\n", savePath.c_str()); + + if (!old.empty()) + PHYSFS_unmount(old.c_str()); + + int success = PHYSFS_mount(savePath.c_str(), NULL, append); + printf("Save Path mounted %d\n", success); + + PHYSFS_setWriteDir(nullptr); + + return true; +} + +std::string RenderD7::FileSystem::GetSaveDirectory() +{ + return RenderD7::FileSystem::Normalize(RenderD7::FileSystem::GetUserDirectory() + "/save"); +} + +bool RenderD7::FileSystem::SetupWriteDirectory() +{ + if (!PHYSFS_isInit()) + return false; + + if (RenderD7::FileSystem::savePath.empty()) + return false; + + std::string tmpWritePath = RenderD7::FileSystem::savePath; + std::string tmpDirectoryPath = RenderD7::FileSystem::savePath; + + if (RenderD7::FileSystem::savePath.find(RenderD7::FileSystem::GetUserDirectory()) == 0) + { + tmpWritePath = RenderD7::FileSystem::GetUserDirectory(); + tmpDirectoryPath = savePath.substr(RenderD7::FileSystem::GetUserDirectory().length()); + + /* strip leading '/' characters from the path we want to create */ + size_t startPosition = tmpDirectoryPath.find_first_not_of('/'); + + if (startPosition != std::string::npos) + tmpDirectoryPath = tmpDirectoryPath.substr(startPosition); + } + + if (!PHYSFS_setWriteDir(tmpWritePath.c_str())) + { + printf("Failed to set write dir to %s\n", tmpWritePath.c_str()); + return false; + } + + if (!RenderD7::FileSystem::CreateDirectory(tmpDirectoryPath.c_str())) + { + printf("Failed to create dir %s\n", tmpDirectoryPath.c_str()); + /* clear the write directory in case of error */ + PHYSFS_setWriteDir(nullptr); + return false; + } + + if (!PHYSFS_setWriteDir(savePath.c_str())) + { + printf("Failed to set write dir to %s\n", savePath.c_str()); + return false; + } + + if (!PHYSFS_mount(savePath.c_str(), nullptr, 0)) + { + printf("Failed to mount write dir (%s)\n", RenderD7::FileSystem::GetPhysfsError()); + /* clear the write directory in case of error */ + PHYSFS_setWriteDir(nullptr); + return false; + } + + return true; +} + +std::string RenderD7::FileSystem::GetUserDirectory() +{ + return RenderD7::FileSystem::Normalize(PHYSFS_getPrefDir("npi-d7", "renderd7")); +} + +bool RenderD7::FileSystem::GetInfo(const char* filename, RenderD7::FileSystem::Info& info) +{ + if (!PHYSFS_isInit()) + return false; + + PHYSFS_Stat stat = {}; + + if (!PHYSFS_stat(filename, &stat)) + return false; + + info.mod_time = std::min(stat.modtime, RenderD7::FileSystem::MAX_STAMP); + info.size = std::min(stat.filesize, RenderD7::FileSystem::MAX_STAMP); + + if (stat.filetype == PHYSFS_FILETYPE_REGULAR) + info.type = RenderD7::FileSystem::FileType_File; + else if (stat.filetype == PHYSFS_FILETYPE_DIRECTORY) + info.type = RenderD7::FileSystem::FileType_Directory; + else if (stat.filetype == PHYSFS_FILETYPE_SYMLINK) + info.type = RenderD7::FileSystem::FileType_SymLink; + else + info.type = RenderD7::FileSystem::FileType_Other; + + return true; +} + +void RenderD7::FileSystem::GetDirectoryItems(const char* path, std::vector& items) +{ + if (!PHYSFS_isInit()) + return; + + char** results = PHYSFS_enumerateFiles(path); + + if (results == nullptr) + return; + + for (char** item = results; *item != 0; item++) + items.push_back(*item); + + PHYSFS_freeList(results); +} + +bool RenderD7::FileSystem::OpenFile(File& file, const char* name, FileMode mode) +{ + if (mode == FileMode_Closed) + return false; + + if (!PHYSFS_isInit()) + return false; + + if (file.handle) + RenderD7::FileSystem::CloseFile(file); + + if (mode == FileMode_Read && !PHYSFS_exists(name)) + { + printf("Could not open file %s, does not exist.\n", name); + return false; + } + + if ((mode == FileMode_Write) && + (PHYSFS_getWriteDir() == nullptr && RenderD7::FileSystem::SetupWriteDirectory())) + { + printf("Could not set write directory.\n"); + return false; + } + + PHYSFS_getLastErrorCode(); + + switch (mode) + { + case FileMode_Read: + file.handle = PHYSFS_openRead(name); + break; + case FileMode_Write: + file.handle = PHYSFS_openWrite(name); + break; + default: + break; + } + + if (!file.handle) + { + const char* error = RenderD7::FileSystem::GetPhysfsError(); + + if (error == nullptr) + error = "unknown error"; + + printf("Could not open file %s (%s)\n", name, error); + + return false; + } + + file.mode = mode; + + return true; +} + +bool RenderD7::FileSystem::CloseFile(File& file) +{ + if (file.handle == nullptr || !PHYSFS_close(file.handle)) + return false; + + file.handle = nullptr; + + return true; +} + +bool RenderD7::FileSystem::CreateDirectory(const char* name) +{ + if (!PHYSFS_isInit()) + return false; + + if (PHYSFS_getWriteDir() == nullptr && !RenderD7::FileSystem::SetupWriteDirectory()) + return false; + + if (!PHYSFS_mkdir(name)) + return false; + + return true; +} + +int64_t RenderD7::FileSystem::ReadFile(File& file, void* destination, int64_t size) +{ + if (!file.handle || file.mode != FileMode_Read) + { + printf("File is not opened for reading.\n"); + return 0; + } + + if (size > file.GetSize()) + size = file.GetSize(); + else if (size < 0) + { + printf("Invalid read size %lld\n", size); + return 0; + } + + return PHYSFS_readBytes(file.handle, destination, (PHYSFS_uint64)size); +} + +bool RenderD7::FileSystem::WriteFile(File& file, const void* data, int64_t size) +{ + if (!file.handle || file.mode != FileMode_Write) + { + printf("File is not opened for writing.\n"); + return false; + } + + int64_t written = PHYSFS_writeBytes(file.handle, data, (PHYSFS_uint64)size); + + if (written != size) + return false; + + return true; +} \ No newline at end of file diff --git a/source/Toast.cpp b/source/Toast.cpp index bc21e09..678ab39 100644 --- a/source/Toast.cpp +++ b/source/Toast.cpp @@ -1,26 +1,27 @@ #include +#include RenderD7::Toast::Toast(std::string head, std::string msg) { this->head = head; this->msg = msg; - this->toast = RenderD7::BitmapPrinter(400, 70); + /*this->toast = RenderD7::BitmapPrinter(400, 70); this->toast.ClearBlank(); this->toast.DrawRectFilled(0, 0, 400, 70, 40, 40, 40, 255); this->toast.DrawRectFilled(0, 0, 400, 25, 70, 70, 70, 255); this->toast.DrawDebugText(4, 5, 0, RenderD7::Color::Hex("#ffffff"), this->head); this->toast.DrawDebugText(4, 40, 0, RenderD7::Color::Hex("#ffffff"), this->msg); - this->toastrendered->LoadPFromBuffer(BitmapConverter::ConvertData(toast.GetBitmap().DATA())); + this->toastrendered->LoadPFromBuffer(BitmapConverter::ConvertData(toast.GetBitmap().DATA()));*/ } void RenderD7::Toast::Draw(void) const { RenderD7::OnScreen(Top); - /*RenderD7::DrawRect(0, msgposy, 400, 70, RenderD7::Color::Hex("#111111")); - RenderD7::DrawRect(0, msgposy, 400, 25, RenderD7::Color::Hex("#222222")); - RenderD7::DrawText(2, msgposy+3, 0.7f, RenderD7::Color::Hex("#ffffff"), head); - RenderD7::DrawText(2, msgposy+30, 0.6f, RenderD7::Color::Hex("#ffffff"), msg);*/ - toastrendered->Draw(0, msgposy); + RenderD7::Draw::Rect(0, msgposy, 400, 70, RenderD7::Color::Hex("#111111")); + RenderD7::Draw::Rect(0, msgposy, 400, 25, RenderD7::Color::Hex("#222222")); + RenderD7::Draw::Text(2, msgposy+3, 0.7f, RenderD7::Color::Hex("#ffffff"), head); + RenderD7::Draw::Text(2, msgposy+30, 0.6f, RenderD7::Color::Hex("#ffffff"), msg); + //toastrendered->Draw(0, msgposy); } void RenderD7::Toast::Logic() diff --git a/source/renderd7.cpp b/source/renderd7.cpp index c40cfbf..f85df6a 100644 --- a/source/renderd7.cpp +++ b/source/renderd7.cpp @@ -173,13 +173,13 @@ void RenderD7::Msg::Display(std::string titletxt, std::string subtext, C3D_Rende C2D_TargetClear(Bottom, DSEVENBLACK); RenderD7::ClearTextBufs(); RenderD7::OnScreen(Top); - RenderD7::DrawRect(0, 0, 400, 240, RenderD7::Color::Hex("#111111")); + RenderD7::Draw::Rect(0, 0, 400, 240, RenderD7::Color::Hex("#111111")); RenderD7::OnScreen(Bottom); - RenderD7::DrawRect(0, 0, 320, 240, RenderD7::Color::Hex("#111111")); + RenderD7::Draw::Rect(0, 0, 320, 240, RenderD7::Color::Hex("#111111")); RenderD7::OnScreen(target); - RenderD7::DrawRect(0, 0, 400, 26, RenderD7::Color::Hex("#333333", 200)); - RenderD7::DrawText(5, 2, 0.7f, DSEVENWHITE, titletxt); - RenderD7::DrawText(5, 30, 0.6f, DSEVENWHITE, subtext); + RenderD7::Draw::Rect(0, 0, 400, 26, RenderD7::Color::Hex("#333333", 200)); + RenderD7::Draw::Text(5, 2, 0.7f, DSEVENWHITE, titletxt); + RenderD7::Draw::Text(5, 30, 0.6f, DSEVENWHITE, subtext); C3D_FrameEnd(0); } void RenderD7::Msg::DisplayWithProgress(std::string titletext, std::string subtext, float current, float total, u32 prgbarcolor) @@ -193,15 +193,15 @@ void RenderD7::Msg::DisplayWithProgress(std::string titletext, std::string subte char str[256]; snprintf(str, sizeof(str), "(%.2f%%)", ((float)current/(float)total) * 100.0f); RenderD7::OnScreen(Top); - RenderD7::DrawRect(0, 0, 400, 240, RenderD7::Color::Hex("#111111")); - RenderD7::DrawRect(0, 0, 400, 26, RenderD7::Color::Hex("#333333", 200)); - RenderD7::DrawText(5, 2, 0.7f, DSEVENWHITE, titletext); - RenderD7::DrawText(5, 30, 0.6f, DSEVENWHITE, subtext); - RenderD7::DrawRect(30, 120, 342, 30, RenderD7::Color::Hex("#333333")); - RenderD7::DrawRect(31, 121, (int)(((float)current / (float)total) * 338.0f), 28, prgbarcolor); - RenderD7::DrawTextCentered(5, 124, 0.7f, RenderD7::Color::Hex("#111111"), str, 390); + RenderD7::Draw::Rect(0, 0, 400, 240, RenderD7::Color::Hex("#111111")); + RenderD7::Draw::Rect(0, 0, 400, 26, RenderD7::Color::Hex("#333333", 200)); + RenderD7::Draw::Text(5, 2, 0.7f, DSEVENWHITE, titletext); + RenderD7::Draw::Text(5, 30, 0.6f, DSEVENWHITE, subtext); + RenderD7::Draw::Rect(30, 120, 342, 30, RenderD7::Color::Hex("#333333")); + RenderD7::Draw::Rect(31, 121, (int)(((float)current / (float)total) * 338.0f), 28, prgbarcolor); + RenderD7::Draw::TextCentered(5, 124, 0.7f, RenderD7::Color::Hex("#111111"), str, 390); RenderD7::OnScreen(Bottom); - RenderD7::DrawRect(0, 0, 320, 240, RenderD7::Color::Hex("#111111")); + RenderD7::Draw::Rect(0, 0, 320, 240, RenderD7::Color::Hex("#111111")); C3D_FrameEnd(0); } void RenderD7::SetupLog() @@ -218,11 +218,11 @@ void RenderD7::Error::DisplayError(std::string toptext, std::string errortext, i C2D_TargetClear(Top, DSEVENBLACK); C2D_TargetClear(Bottom, DSEVENBLACK); RenderD7::OnScreen(Top); - RenderD7::DrawText(0, 0, 0.7f, DSEVENWHITE, toptext); - RenderD7::DrawText(0, 30, 0.6f, DSEVENWHITE, errortext); + RenderD7::Draw::Text(0, 0, 0.7f, DSEVENWHITE, toptext); + RenderD7::Draw::Text(0, 30, 0.6f, DSEVENWHITE, errortext); C3D_FrameEnd(0); for (int i = 0; i < 60*timesec; i++) { - RenderD7::DrawRect(0, 236, (int)(((float)i / (float)60*timesec) * 400.0f), 4, RenderD7::Color::Hex("#00ff00")); + RenderD7::Draw::Rect(0, 236, (int)(((float)i / (float)60*timesec) * 400.0f), 4, RenderD7::Color::Hex("#00ff00")); gspWaitForVBlank(); @@ -249,9 +249,9 @@ void RenderD7::Error::DisplayFatalError(std::string toptext, std::string errorte img.LoadFromBitmap(errorss.GetBitmap()); RenderD7::OnScreen(Top); img.Draw(0, 0); - /*RenderD7::DrawTextCentered(0, 0, 0.7f, DSEVENWHITE, toptext, 400); - RenderD7::DrawTextCentered(0, 100, 0.6f, DSEVENWHITE, errortext, 400); - RenderD7::DrawTextCentered(0, 200, 0.6f, DSEVENWHITE, "Press Start to Exit!", 400);*/ + /*RenderD7::Draw::TextCentered(0, 0, 0.7f, DSEVENWHITE, toptext, 400); + RenderD7::Draw::TextCentered(0, 100, 0.6f, DSEVENWHITE, errortext, 400); + RenderD7::Draw::TextCentered(0, 200, 0.6f, DSEVENWHITE, "Press Start to Exit!", 400);*/ C3D_FrameEnd(0); while (error___) { @@ -337,164 +337,6 @@ void RenderD7::ClearTextBufs(void) C2D_TextBufClear(TextBuf); } -bool RenderD7::DrawRect(float x, float y, float w, float h, u32 color) -{ - return C2D_DrawRectSolid(x, y, 0.5f, w, h, color); -} - -bool RenderD7::DrawPx(float x, float y, u32 color) -{ - return C2D_DrawRectSolid(x, y, 0.5f, 1, 1, color); -} - -void RenderD7::DrawTextCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt) { - float lineHeight, widthScale; - - // Check for the lineHeight. - if (fnt != nullptr) { - lineHeight = RenderD7::GetTextHeight(size, " ", fnt); - } else { - lineHeight = RenderD7::GetTextHeight(size, " "); - } - - int line = 0; - while(Text.find('\n') != Text.npos) { - if (maxWidth == 0) { - // Do the widthScale. - if (fnt != nullptr) { - widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt); - } else { - widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n'))); - } - } else { - // Do the widthScale 2. - if (fnt != nullptr) { - widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt)); - } else { - widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')))); - } - } - if (fnt != nullptr) { - RenderD7::DrawText((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight, fnt); - } else { - RenderD7::DrawText((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight); - } - - Text = Text.substr(Text.find('\n')+1); - line++; - } - - if (maxWidth == 0) { - // Do the next WidthScale. - if (fnt != nullptr) { - widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt); - } else { - widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n'))); - } - } else { - // And again. - if (fnt != nullptr) { - widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt)); - } else { - widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')))); - } - } - if (fnt != nullptr) { - RenderD7::DrawText((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight, fnt); - } else { - RenderD7::DrawText((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight); - } -} - -// Draw String or Text. -void RenderD7::DrawText(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt) { - C2D_Text c2d_text; - - if (fnt != nullptr) { - C2D_TextFontParse(&c2d_text, fnt, TextBuf, Text.c_str()); - } else { - C2D_TextFontParse(&c2d_text, Font, TextBuf, Text.c_str()); - } - - C2D_TextOptimize(&c2d_text); - - float heightScale; - if (maxHeight == 0) { - heightScale = size; - } else { - if (fnt != nullptr) { - heightScale = std::min(size, size*(maxHeight/RenderD7::GetTextHeight(size, Text, fnt))); - } else { - heightScale = std::min(size, size*(maxHeight/RenderD7::GetTextHeight(size, Text))); - } - } - - if (maxWidth == 0) { - C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, size, heightScale, color); - } else { - if (fnt != nullptr) { - C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, std::min(size, size*(maxWidth/RenderD7::GetTextWidth(size, Text, fnt))), heightScale, color); - } else { - C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, std::min(size, size*(maxWidth/RenderD7::GetTextWidth(size, Text))), heightScale, color); - } - } -} -void RenderD7::DrawTextLeft(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt) -{ - RenderD7::DrawText(x - RenderD7::GetTextWidth(size, Text, fnt), y, size, color, Text, maxWidth, maxHeight, fnt); -} -// Get String or Text Width. -float RenderD7::GetTextWidth(float size, std::string Text, C2D_Font fnt) { - float width = 0; - if (fnt != nullptr) { - GetTextSize(size, &width, NULL, Text, fnt); - } else { - GetTextSize(size, &width, NULL, Text); - } - return width; -} - -// Get String or Text Size. -void RenderD7::GetTextSize(float size, float *width, float *height, std::string Text, C2D_Font fnt) { - C2D_Text c2d_text; - if (fnt != nullptr) { - C2D_TextFontParse(&c2d_text, fnt, TextBuf, Text.c_str()); - } else { - C2D_TextFontParse(&c2d_text, Font, TextBuf, Text.c_str()); - } - C2D_TextGetDimensions(&c2d_text, size, size, width, height); -} - - -// Get String or Text Height. -float RenderD7::GetTextHeight(float size, std::string Text, C2D_Font fnt) { - float height = 0; - if (fnt != nullptr) { - GetTextSize(size, NULL, &height, Text.c_str(), fnt); - } else { - GetTextSize(size, NULL, &height, Text.c_str()); - } - return height; -} - -Result RenderD7::loadFont(C2D_Font &fnt, const char* Path) { - fnt = C2D_FontLoad(Path); // Only load if found. - return 0; -} - -// Unload a Font. -Result RenderD7::unloadFont(C2D_Font &fnt) { - if (fnt != nullptr) { - C2D_FontFree(fnt); // Make sure to only unload if not nullptr. - } - return 0; -} - -bool RenderD7::DrawCircle(float x, float y, float radius, u32 color) -{ - return C2D_DrawCircleSolid(x, y, 0.5f, radius, color); -} - void MetrikThread(RenderD7::Parameter param) { while (true) { RenderD7::DrawMetrikOvl(); @@ -704,15 +546,15 @@ void RenderD7::DrawTObjects(std::vector tobjects, u32 color, { if (selection == i) { - RenderD7::DrawRect(tobjects[i].x - 2, tobjects[i].y - 2, tobjects[i].w + 4, tobjects[i].h + 4, selbgcolor); - RenderD7::DrawRect(tobjects[i].x, tobjects[i].y, tobjects[i].w, tobjects[i].h, color); - RenderD7::DrawRect(tobjects[i].x, tobjects[i].y, tobjects[i].w, tobjects[i].h, selcolor); - RenderD7::DrawText(tobjects[i].x + (tobjects[i].w/2) - RenderD7::GetTextHeight(tobjects[i].txtsize , tobjects[i].text) + tobjects[i].correctx, tobjects[i].y + (tobjects[i].h/2) - RenderD7::GetTextHeight(tobjects[i].txtsize, tobjects[i].text) + tobjects[i].correcty, tobjects[i].txtsize, txtcolor, tobjects[i].text); + RenderD7::Draw::Rect(tobjects[i].x - 2, tobjects[i].y - 2, tobjects[i].w + 4, tobjects[i].h + 4, selbgcolor); + RenderD7::Draw::Rect(tobjects[i].x, tobjects[i].y, tobjects[i].w, tobjects[i].h, color); + RenderD7::Draw::Rect(tobjects[i].x, tobjects[i].y, tobjects[i].w, tobjects[i].h, selcolor); + RenderD7::Draw::Text(tobjects[i].x + (tobjects[i].w/2) - RenderD7::Draw::GetTextHeight(tobjects[i].txtsize , tobjects[i].text) + tobjects[i].correctx, tobjects[i].y + (tobjects[i].h/2) - RenderD7::Draw::GetTextHeight(tobjects[i].txtsize, tobjects[i].text) + tobjects[i].correcty, tobjects[i].txtsize, txtcolor, tobjects[i].text); } else { - RenderD7::DrawRect(tobjects[i].x, tobjects[i].y - 1, tobjects[i].w, tobjects[i].h, color); - RenderD7::DrawText(tobjects[i].x + (tobjects[i].w/2) - RenderD7::GetTextHeight(tobjects[i].txtsize , tobjects[i].text) + tobjects[i].correctx, tobjects[i].y + (tobjects[i].h/2) - RenderD7::GetTextHeight(tobjects[i].txtsize, tobjects[i].text) + tobjects[i].correcty, tobjects[i].txtsize, txtcolor, tobjects[i].text); + RenderD7::Draw::Rect(tobjects[i].x, tobjects[i].y - 1, tobjects[i].w, tobjects[i].h, color); + RenderD7::Draw::Text(tobjects[i].x + (tobjects[i].w/2) - RenderD7::Draw::GetTextHeight(tobjects[i].txtsize , tobjects[i].text) + tobjects[i].correctx, tobjects[i].y + (tobjects[i].h/2) - RenderD7::Draw::GetTextHeight(tobjects[i].txtsize, tobjects[i].text) + tobjects[i].correcty, tobjects[i].txtsize, txtcolor, tobjects[i].text); } } } @@ -723,13 +565,13 @@ void RenderD7::DrawTLBtns(std::vector btns, u32 color, int sele { if (selection == i) { - RenderD7::DrawRect(btns[i].x - 2, btns[i].y - 2, btns[i].w + 4, btns[i].h + 4, selbgcolor); - RenderD7::DrawRect(btns[i].x, btns[i].y, btns[i].w, btns[i].h, color); - RenderD7::DrawRect(btns[i].x, btns[i].y, btns[i].w, btns[i].h, selcolor); + RenderD7::Draw::Rect(btns[i].x - 2, btns[i].y - 2, btns[i].w + 4, btns[i].h + 4, selbgcolor); + RenderD7::Draw::Rect(btns[i].x, btns[i].y, btns[i].w, btns[i].h, color); + RenderD7::Draw::Rect(btns[i].x, btns[i].y, btns[i].w, btns[i].h, selcolor); } else { - RenderD7::DrawRect(btns[i].x, btns[i].y - 1, btns[i].w, btns[i].h, color); + RenderD7::Draw::Rect(btns[i].x, btns[i].y - 1, btns[i].w, btns[i].h, color); } } } @@ -761,8 +603,8 @@ int RenderD7::GetRandomInt(int b, int e) void RenderD7::DrawSTObject(std::vector tobject, int tobjectindex, u32 color, u32 txtcolor) { - RenderD7::DrawRect(tobject[tobjectindex].x, tobject[tobjectindex].y, tobject[tobjectindex].w, tobject[tobjectindex].h, color); - RenderD7::DrawText(tobject[tobjectindex].x + (tobject[tobjectindex].w/2) - RenderD7::GetTextHeight(tobject[tobjectindex].txtsize , tobject[tobjectindex].text) + tobject[tobjectindex].correctx, tobject[tobjectindex].y + (tobject[tobjectindex].h/2) - RenderD7::GetTextHeight(tobject[tobjectindex].txtsize, tobject[tobjectindex].text) + tobject[tobjectindex].correcty, tobject[tobjectindex].txtsize, txtcolor, tobject[tobjectindex].text); + RenderD7::Draw::Rect(tobject[tobjectindex].x, tobject[tobjectindex].y, tobject[tobjectindex].w, tobject[tobjectindex].h, color); + RenderD7::Draw::Text(tobject[tobjectindex].x + (tobject[tobjectindex].w/2) - RenderD7::Draw::GetTextHeight(tobject[tobjectindex].txtsize , tobject[tobjectindex].text) + tobject[tobjectindex].correctx, tobject[tobjectindex].y + (tobject[tobjectindex].h/2) - RenderD7::Draw::GetTextHeight(tobject[tobjectindex].txtsize, tobject[tobjectindex].text) + tobject[tobjectindex].correcty, tobject[tobjectindex].txtsize, txtcolor, tobject[tobjectindex].text); } bool dirEntryPredicate(const RenderD7::DirContent &lhs, const RenderD7::DirContent &rhs) { @@ -804,11 +646,6 @@ void RenderD7::GetDirContents(std::vector &dircontent) { RenderD7::GetDirContentsExt(dircontent, {}); } -bool RenderD7::DrawImage(C2D_Image img, float x, float y, float scaleX, float scaleY) -{ - return C2D_DrawImageAt(img, x, y, 0.5f, nullptr, scaleX, scaleY); -} - bool RenderD7::FS::FileExist(const std::string& path) { FILE *test = fopen(path.c_str(), "r"); @@ -837,8 +674,8 @@ bool RenderD7::IsNdspInit() void RenderD7::DrawList1(RenderD7::ScrollList1 &l, float txtsize, C3D_RenderTarget *t) { RenderD7::OnScreen(t); - RenderD7::DrawRect(0, 0, 400, 240, RenderD7::Color::Hex("#dddddd")); - RenderD7::DrawText(0, 0, 0.8f, RenderD7::Color::Hex("#ffffff"), l.Text); + RenderD7::Draw::Rect(0, 0, 400, 240, RenderD7::Color::Hex("#dddddd")); + RenderD7::Draw::Text(0, 0, 0.8f, RenderD7::Color::Hex("#ffffff"), l.Text); } @@ -858,21 +695,21 @@ void RenderD7::DrawMetrikOvl() } std::string __C = RENDERD7VSTRING; std::string info = "RenderD7 " + __C + " Debug Overlay"; - float infoy = 240 - RenderD7::GetTextHeight(mt_txtSize, info); + float infoy = 240 - RenderD7::Draw::GetTextHeight(mt_txtSize, info); mt_fps = "FPS: " + RenderD7::GetFramerate(); mt_cpu = "CPU: " + std::to_string(C3D_GetProcessingTime()*(d11framerate/10)).substr(0, 4) + "%/" + std::to_string(C3D_GetProcessingTime()).substr(0, 4) + "ms"; mt_gpu = "GPU: " + std::to_string(C3D_GetDrawingTime()*(d11framerate/10)).substr(0, 4) + "%/" + std::to_string(C3D_GetDrawingTime()).substr(0, 4) + "ms"; mt_cmd = "CMD: " + std::to_string(C3D_GetCmdBufUsage()*100.0f).substr(0, 4) + "%/" + std::to_string(C3D_GetCmdBufUsage()).substr(0, 4) + "ms"; - RenderD7::DrawRect(0, 0, RenderD7::GetTextWidth(mt_txtSize, mt_fps), RenderD7::GetTextHeight(mt_txtSize, mt_fps), mt_color); - RenderD7::DrawRect(0, 50, RenderD7::GetTextWidth(mt_txtSize, mt_cpu), RenderD7::GetTextHeight(mt_txtSize, mt_cpu), mt_color); - RenderD7::DrawRect(0, 70, RenderD7::GetTextWidth(mt_txtSize, mt_gpu), RenderD7::GetTextHeight(mt_txtSize, mt_gpu), mt_color); - RenderD7::DrawRect(0, 90, RenderD7::GetTextWidth(mt_txtSize, mt_cmd), RenderD7::GetTextHeight(mt_txtSize, mt_cmd), mt_color); - RenderD7::DrawRect(0, infoy, RenderD7::GetTextWidth(mt_txtSize, info), RenderD7::GetTextHeight(mt_txtSize, info), mt_color); - RenderD7::DrawText(0, 0, mt_txtSize, mt_txtcolor, mt_fps); - RenderD7::DrawText(0, 50, mt_txtSize, mt_txtcolor, mt_cpu); - RenderD7::DrawText(0, 70, mt_txtSize, mt_txtcolor, mt_gpu); - RenderD7::DrawText(0, 90, mt_txtSize, mt_txtcolor, mt_cmd); - RenderD7::DrawText(0, infoy, mt_txtSize, mt_txtcolor, info); + RenderD7::Draw::Rect(0, 0, RenderD7::Draw::GetTextWidth(mt_txtSize, mt_fps), RenderD7::Draw::GetTextHeight(mt_txtSize, mt_fps), mt_color); + RenderD7::Draw::Rect(0, 50, RenderD7::Draw::GetTextWidth(mt_txtSize, mt_cpu), RenderD7::Draw::GetTextHeight(mt_txtSize, mt_cpu), mt_color); + RenderD7::Draw::Rect(0, 70, RenderD7::Draw::GetTextWidth(mt_txtSize, mt_gpu), RenderD7::Draw::GetTextHeight(mt_txtSize, mt_gpu), mt_color); + RenderD7::Draw::Rect(0, 90, RenderD7::Draw::GetTextWidth(mt_txtSize, mt_cmd), RenderD7::Draw::GetTextHeight(mt_txtSize, mt_cmd), mt_color); + RenderD7::Draw::Rect(0, infoy, RenderD7::Draw::GetTextWidth(mt_txtSize, info), RenderD7::Draw::GetTextHeight(mt_txtSize, info), mt_color); + RenderD7::Draw::Text(0, 0, mt_txtSize, mt_txtcolor, mt_fps); + RenderD7::Draw::Text(0, 50, mt_txtSize, mt_txtcolor, mt_cpu); + RenderD7::Draw::Text(0, 70, mt_txtSize, mt_txtcolor, mt_gpu); + RenderD7::Draw::Text(0, 90, mt_txtSize, mt_txtcolor, mt_cmd); + RenderD7::Draw::Text(0, infoy, mt_txtSize, mt_txtcolor, info); /*for (int z = 0; z < (int)mt_fpsgraph.size(); z++) { @@ -881,15 +718,6 @@ void RenderD7::DrawMetrikOvl() }*/ } -bool RenderD7::DrawNFRect(float p1x, float p1y, float w, float h, u32 color, float scale) -{ - C2D_DrawLine(p1x, p1y, color,w, p1y, color, scale, 1); - C2D_DrawLine(w, p1y, color,w, h, color, scale, 1); - C2D_DrawLine(w, h, color,p1x, h, color, scale, 1); - C2D_DrawLine(p1x, h, color,p1x, p1y, color, scale, 1); - return true; -} - RenderD7::DSP_NF::DSP_NF() { @@ -898,10 +726,10 @@ RenderD7::DSP_NF::DSP_NF() void RenderD7::DSP_NF::Draw(void) const { RenderD7::OnScreen(Top); - RenderD7::DrawRect(0, msgposy, 400, 70, RenderD7::Color::Hex("#111111")); - RenderD7::DrawRect(0, msgposy, 400, 25, RenderD7::Color::Hex("#222222")); - RenderD7::DrawText(2, msgposy+3, 0.7f, RenderD7::Color::Hex("#ffffff"), "Warning! Code: 00027"); - RenderD7::DrawText(2, msgposy+30, 0.6f, RenderD7::Color::Hex("#ffffff"), "You can't use Sound effects because the file\n<> was not found!"); + RenderD7::Draw::Rect(0, msgposy, 400, 70, RenderD7::Color::Hex("#111111")); + RenderD7::Draw::Rect(0, msgposy, 400, 25, RenderD7::Color::Hex("#222222")); + RenderD7::Draw::Text(2, msgposy+3, 0.7f, RenderD7::Color::Hex("#ffffff"), "Warning! Code: 00027"); + RenderD7::Draw::Text(2, msgposy+30, 0.6f, RenderD7::Color::Hex("#ffffff"), "You can't use Sound effects because the file\n<> was not found!"); } void RenderD7::DSP_NF::Logic() @@ -975,23 +803,23 @@ void RenderD7::RSettings::Draw(void) const if (m_state == RSETTINGS) { RenderD7::OnScreen(Top); - RenderD7::DrawRect(0, 0, 400, 21, RenderD7::Color::Hex("#111111")); - RenderD7::DrawRect(0, 21, 400, 220, RenderD7::Color::Hex("#eeeeee")); - RenderD7::DrawText(0, 0, 0.7f, DSEVENWHITE, "RenderD7->Settings"); - RenderD7::DrawTextLeft(400, 0, 0.7f, RenderD7::Color::Hex("#ffffff"), RENDERD7VSTRING); - RenderD7::DrawText(0, 30, 0.7f, DSEVENBLACK, "RD7SR: " + rd7srstate); - RenderD7::DrawText(0, 50, 0.7f, DSEVENBLACK, "Metrik to Csv: " + csvstate); - RenderD7::DrawText(0, 70, 0.7f, DSEVENBLACK, "Metrik Overlay: " + mtovlstate); - RenderD7::DrawText(0, 90, 0.7f, DSEVENBLACK, "Force FPS: " + fpsstate); - RenderD7::DrawText(0, 110, 0.7f, DSEVENBLACK, "Metrik Screen: " + mtscreenstate); - /*RenderD7::DrawText(0, 130, 0.7f, DSEVENBLACK, "Metrik Text RGB: " + mttxtcolstate); - RenderD7::DrawText(0, 150, 0.7f, DSEVENBLACK, "Metrik Alpha: " + mtcola); - RenderD7::DrawText(0, 170, 0.7f, DSEVENBLACK, "Metrik Text Alpha: " + mttxtcola);*/ + RenderD7::Draw::Rect(0, 0, 400, 21, RenderD7::Color::Hex("#111111")); + RenderD7::Draw::Rect(0, 21, 400, 220, RenderD7::Color::Hex("#eeeeee")); + RenderD7::Draw::Text(0, 0, 0.7f, DSEVENWHITE, "RenderD7->Settings"); + RenderD7::Draw::TextRight(400, 0, 0.7f, RenderD7::Color::Hex("#ffffff"), RENDERD7VSTRING); + RenderD7::Draw::Text(0, 30, 0.7f, DSEVENBLACK, "RD7SR: " + rd7srstate); + RenderD7::Draw::Text(0, 50, 0.7f, DSEVENBLACK, "Metrik to Csv: " + csvstate); + RenderD7::Draw::Text(0, 70, 0.7f, DSEVENBLACK, "Metrik Overlay: " + mtovlstate); + RenderD7::Draw::Text(0, 90, 0.7f, DSEVENBLACK, "Force FPS: " + fpsstate); + RenderD7::Draw::Text(0, 110, 0.7f, DSEVENBLACK, "Metrik Screen: " + mtscreenstate); + /*RenderD7::Draw::Text(0, 130, 0.7f, DSEVENBLACK, "Metrik Text RGB: " + mttxtcolstate); + RenderD7::Draw::Text(0, 150, 0.7f, DSEVENBLACK, "Metrik Alpha: " + mtcola); + RenderD7::Draw::Text(0, 170, 0.7f, DSEVENBLACK, "Metrik Text Alpha: " + mttxtcola);*/ RenderD7::OnScreen(Bottom); std::string verc = "Config Version: "; verc += CFGVER; - RenderD7::DrawRect(0, 0, 320, 240, RenderD7::Color::Hex("#eeeeee")); - RenderD7::DrawText(0, 0, 0.7f, RenderD7::Color::Hex("#111111"), verc); + RenderD7::Draw::Rect(0, 0, 320, 240, RenderD7::Color::Hex("#eeeeee")); + RenderD7::Draw::Text(0, 0, 0.7f, RenderD7::Color::Hex("#111111"), verc); RenderD7::DrawTObjects(buttons, RenderD7::Color::Hex("#111111"), RenderD7::Color::Hex("#eeeeee")); } @@ -1003,24 +831,24 @@ void RenderD7::RSettings::Draw(void) const std::string buildtime = V_TIME; std::string commit = V_STRING; RenderD7::OnScreen(Top); - RenderD7::DrawRect(0, 0, 400, 21, RenderD7::Color::Hex("#111111")); - RenderD7::DrawRect(0, 21, 400, 220, RenderD7::Color::Hex("#eeeeee")); - RenderD7::DrawText(0, 0, 0.7f, DSEVENWHITE, "RenderD7->Info"); - RenderD7::DrawTextLeft(400, 0, 0.7f, RenderD7::Color::Hex("#ffffff"), RENDERD7VSTRING); - RenderD7::DrawText(0, 30, 0.7f, DSEVENBLACK, "App: " + D_app_name); - RenderD7::DrawText(0, 50, 0.7f, DSEVENBLACK, "RenderD7: " + rd7ver); - RenderD7::DrawText(0, 70, 0.7f, DSEVENBLACK, "Config-Version: " + rd7cfgver); - RenderD7::DrawText(0, 90, 0.7f, DSEVENBLACK, "Citra: " + citras); - RenderD7::DrawText(0, 110, 0.7f, DSEVENBLACK, "RenderD7-Build-Time: \n" + buildtime); - RenderD7::DrawText(0, 150, 0.7f, DSEVENBLACK, "RenderD7-Commit: " + commit); - /*RenderD7::DrawText(0, 130, 0.7f, DSEVENBLACK, "Metrik Text RGB: " + mttxtcolstate); - RenderD7::DrawText(0, 150, 0.7f, DSEVENBLACK, "Metrik Alpha: " + mtcola); - RenderD7::DrawText(0, 170, 0.7f, DSEVENBLACK, "Metrik Text Alpha: " + mttxtcola);*/ + RenderD7::Draw::Rect(0, 0, 400, 21, RenderD7::Color::Hex("#111111")); + RenderD7::Draw::Rect(0, 21, 400, 220, RenderD7::Color::Hex("#eeeeee")); + RenderD7::Draw::Text(0, 0, 0.7f, DSEVENWHITE, "RenderD7->Info"); + RenderD7::Draw::TextRight(400, 0, 0.7f, RenderD7::Color::Hex("#ffffff"), RENDERD7VSTRING); + RenderD7::Draw::Text(0, 30, 0.7f, DSEVENBLACK, "App: " + D_app_name); + RenderD7::Draw::Text(0, 50, 0.7f, DSEVENBLACK, "RenderD7: " + rd7ver); + RenderD7::Draw::Text(0, 70, 0.7f, DSEVENBLACK, "Config-Version: " + rd7cfgver); + RenderD7::Draw::Text(0, 90, 0.7f, DSEVENBLACK, "Citra: " + citras); + RenderD7::Draw::Text(0, 110, 0.7f, DSEVENBLACK, "RenderD7-Build-Time: \n" + buildtime); + RenderD7::Draw::Text(0, 150, 0.7f, DSEVENBLACK, "RenderD7-Commit: " + commit); + /*RenderD7::Draw::Text(0, 130, 0.7f, DSEVENBLACK, "Metrik Text RGB: " + mttxtcolstate); + RenderD7::Draw::Text(0, 150, 0.7f, DSEVENBLACK, "Metrik Alpha: " + mtcola); + RenderD7::Draw::Text(0, 170, 0.7f, DSEVENBLACK, "Metrik Text Alpha: " + mttxtcola);*/ RenderD7::OnScreen(Bottom); std::string verc = "Config Version: "; verc += CFGVER; - RenderD7::DrawRect(0, 0, 320, 240, RenderD7::Color::Hex("#eeeeee")); - RenderD7::DrawText(0, 0, 0.7f, RenderD7::Color::Hex("#111111"), verc); + RenderD7::Draw::Rect(0, 0, 320, 240, RenderD7::Color::Hex("#eeeeee")); + RenderD7::Draw::Text(0, 0, 0.7f, RenderD7::Color::Hex("#111111"), verc); RenderD7::DrawTObjects(buttons, RenderD7::Color::Hex("#111111"), RenderD7::Color::Hex("#eeeeee")); }