Changes:
New Logger Add NTCtrl Base to UI7
This commit is contained in:
		| @@ -28,7 +28,6 @@ | ||||
| #include <renderd7/Net.hpp> | ||||
| #include <renderd7/Overlays.hpp> | ||||
| #include <renderd7/Sound.hpp> | ||||
| #include <renderd7/StealConsole.hpp> | ||||
| #include <renderd7/Timer.hpp> | ||||
| #include <renderd7/UI7.hpp> | ||||
| #include <renderd7/global_db.hpp> | ||||
|   | ||||
| @@ -35,15 +35,19 @@ class LoggerBase { | ||||
|   /// @brief Init the Logger
 | ||||
|   /// @param filename name[_date_time.txt]
 | ||||
|   void Init(const std::string& name, bool fileless = false); | ||||
|   /// @brief Write a String to the File
 | ||||
|   /// @brief Write a String
 | ||||
|   /// @param debug_text string
 | ||||
|   void Write(const std::string& debug_text); | ||||
|   /// @param lvl Logger LVL 0 = ERR, 1  =WARNING, >=2= Default
 | ||||
|   void Write(const std::string& debug_text, int lvl = 2); | ||||
|   void SetLvl(int lvl) { writelvl = lvl; } | ||||
|   const std::vector<std::string>& Lines(); | ||||
| 
 | ||||
|  private: | ||||
|   /// \param filename the name of the logfile
 | ||||
|   std::string filename; | ||||
|   std::string log_path; | ||||
|   std::ofstream _log; | ||||
|   int writelvl = 1;  // Only log errors/Warnings
 | ||||
|   std::vector<std::string> lines; | ||||
| }; | ||||
| }  // namespace RenderD7
 | ||||
| @@ -30,9 +30,9 @@ namespace RenderD7 { | ||||
| class SpriteSheetAnimation : public RenderD7::Sprite { | ||||
|  public: | ||||
|   /// @brief Constructor | ||||
|   SpriteSheetAnimation(); | ||||
|   SpriteSheetAnimation() = default; | ||||
|   /// @brief Deconstructor | ||||
|   ~SpriteSheetAnimation(); | ||||
|   ~SpriteSheetAnimation() = default; | ||||
|   RD7_SMART_CTOR(SpriteSheetAnimation); | ||||
|   /// @brief Setup an Animation | ||||
|   /// @param sheet Input Spritesheet | ||||
|   | ||||
| @@ -1,39 +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 <sstream> | ||||
| #include <string> | ||||
|  | ||||
| namespace RenderD7 { | ||||
| /// @brief StealConsole Class | ||||
| class StealConsole { | ||||
|  public: | ||||
|   /// @brief Constructor | ||||
|   StealConsole(); | ||||
|   /// @brief Deconstructor | ||||
|   ~StealConsole(); | ||||
|   /// @brief The Stolen Stdout | ||||
|   /// @return Stdout as string | ||||
|   std::string GetStdout(); | ||||
|  | ||||
|  private: | ||||
|   /// @param stolen_stdout Stolen Stdout | ||||
|   std::stringstream stolen_stdout; | ||||
| }; | ||||
| }  // namespace RenderD7 | ||||
| @@ -22,7 +22,7 @@ | ||||
| #include <renderd7/global_db.hpp> | ||||
| #include <renderd7/renderd7.hpp> | ||||
|  | ||||
| #define CFGVER "0" | ||||
| #define CFGVER "1" | ||||
| #define THEMEVER "0" | ||||
|  | ||||
| #ifndef V_RD7BTIME | ||||
| @@ -76,6 +76,9 @@ extern bool rd7i_amdt; | ||||
| extern void* rd7i_soc_buf; | ||||
| extern bool rd7i_is_am_init; | ||||
| extern RenderD7::Theme::Ref rd7i_active_theme; | ||||
| extern bool rd7i_lggrf; | ||||
|  | ||||
| // Use function for protection | ||||
| RenderD7::LoggerBase::Ref _rd7i_logger(); | ||||
| RenderD7::Net::Error rd7i_soc_init(); | ||||
| void rd7i_soc_deinit(); | ||||
| @@ -37,7 +37,7 @@ | ||||
| #include <renderd7/Color.hpp> | ||||
| #include <renderd7/FunctionTrace.hpp> | ||||
| #include <renderd7/Hardware.hpp> | ||||
| #include <renderd7/Log2.hpp> | ||||
| #include <renderd7/Logger.hpp> | ||||
| #include <renderd7/Memory.hpp> | ||||
| #include <renderd7/Overlays.hpp> | ||||
| #include <renderd7/Ovl.hpp> | ||||
| @@ -107,6 +107,7 @@ class RSettings : public RenderD7::Scene { | ||||
|     ROVERLAYS,  // Overlay Settings | ||||
|     RFTRACE,    // FTRace Menu | ||||
|     RUI7,       // UI7 Menu | ||||
|     RLOGS,      // Logs | ||||
|   }; | ||||
|  | ||||
|   /// @param shared_request Defines requests from Draw to Logic | ||||
|   | ||||
| @@ -19,7 +19,7 @@ | ||||
| #include <filesystem> | ||||
| #include <fstream> | ||||
| #include <memory> | ||||
| #include <renderd7/Log2.hpp> | ||||
| #include <renderd7/Logger.hpp> | ||||
| #include <renderd7/Time.hpp> | ||||
| #include <renderd7/renderd7.hpp> | ||||
| 
 | ||||
| @@ -46,9 +46,9 @@ void LoggerBase::Init(const std::string& name, bool fileless) { | ||||
|   this->Write("RenderD7 Log\n\n"); | ||||
| } | ||||
| 
 | ||||
| void LoggerBase::Write(const std::string& debug_text) { | ||||
| void LoggerBase::Write(const std::string& debug_text, int lvl) { | ||||
|   std::string msg = "[" + RenderD7::GetTimeStr() + "]: " + debug_text; | ||||
|   if (this->_log.is_open()) { | ||||
|   if (this->_log.is_open() && lvl <= writelvl) { | ||||
|     this->_log << msg << std::endl; | ||||
|   } | ||||
|   while (msg.find_first_of('\n') != 0) { | ||||
| @@ -57,4 +57,6 @@ void LoggerBase::Write(const std::string& debug_text) { | ||||
|   } | ||||
|   lines.push_back(msg); | ||||
| } | ||||
| 
 | ||||
| const std::vector<std::string>& LoggerBase::Lines() { return this->lines; } | ||||
| }  // namespace RenderD7
 | ||||
| @@ -17,13 +17,18 @@ | ||||
|  */ | ||||
|  | ||||
| #include <renderd7/Sheet.hpp> | ||||
| #include <renderd7/internal_db.hpp> | ||||
|  | ||||
| Result RenderD7::Sheet::Load(const std::string& path) { | ||||
|   this->spritesheet = C2D_SpriteSheetLoad(path.c_str()); | ||||
|   if (!this->spritesheet) { | ||||
|     _rd7i_logger()->Write("Failed to Load Spritesheet from: " + path, 0); | ||||
|   } | ||||
|   return 0; | ||||
| } | ||||
|  | ||||
| void RenderD7::Sheet::Free() { | ||||
|   if (!this->spritesheet) return; | ||||
|   C2D_SpriteSheetFree(this->spritesheet); | ||||
|   this->spritesheet = nullptr; | ||||
| } | ||||
|   | ||||
| @@ -50,7 +50,7 @@ Sound::Sound(const string &path, int channel, bool toloop) { | ||||
|     std::fstream fp(path, std::ios::in | std::ios::binary); | ||||
|  | ||||
|     if (!fp.is_open()) { | ||||
|       printf("Could not open the WAV file: %s\n", path.c_str()); | ||||
|       _rd7i_logger()->Write("Could not open WAV: " + path, 0); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
| @@ -59,7 +59,7 @@ Sound::Sound(const string &path, int channel, bool toloop) { | ||||
|     size_t read = fp.tellg(); | ||||
|     if (read != sizeof(wavHeader)) { | ||||
|       // Short read. | ||||
|       printf("WAV file header is too short: %s\n", path.c_str()); | ||||
|       _rd7i_logger()->Write("WAV Header is too short", 0); | ||||
|       fp.close(); | ||||
|       return; | ||||
|     } | ||||
| @@ -68,7 +68,7 @@ Sound::Sound(const string &path, int channel, bool toloop) { | ||||
|     static const char RIFF_magic[4] = {'R', 'I', 'F', 'F'}; | ||||
|     if (memcmp(wavHeader.magic, RIFF_magic, sizeof(wavHeader.magic)) != 0) { | ||||
|       // Incorrect magic number. | ||||
|       printf("Wrong file format.\n"); | ||||
|       _rd7i_logger()->Write("Wrong Fileformat", 0); | ||||
|       fp.close(); | ||||
|       return; | ||||
|     } | ||||
| @@ -77,7 +77,7 @@ Sound::Sound(const string &path, int channel, bool toloop) { | ||||
|         (wavHeader.channels != 1 && wavHeader.channels != 2) || | ||||
|         (wavHeader.bits_per_sample != 8 && wavHeader.bits_per_sample != 16)) { | ||||
|       // Unsupported WAV file. | ||||
|       printf("Corrupted wav file.\n"); | ||||
|       _rd7i_logger()->Write("File is invalid", 0); | ||||
|       fp.close(); | ||||
|       return; | ||||
|     } | ||||
|   | ||||
| @@ -18,13 +18,6 @@ | ||||
|  | ||||
| #include <renderd7/SpriteAnimation.hpp> | ||||
|  | ||||
| RenderD7::SpriteSheetAnimation::SpriteSheetAnimation() { | ||||
|   // | ||||
| } | ||||
| RenderD7::SpriteSheetAnimation::~SpriteSheetAnimation() { | ||||
|   // | ||||
| } | ||||
|  | ||||
| void RenderD7::SpriteSheetAnimation::Setup(RenderD7::Sheet::Ref sheet, | ||||
|                                            size_t imagecount, size_t startimage, | ||||
|                                            float frame_begin, | ||||
|   | ||||
| @@ -1,42 +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 <iostream> | ||||
| #include <renderd7/StealConsole.hpp> | ||||
|  | ||||
| namespace RenderD7 { | ||||
| StealConsole::StealConsole() { | ||||
|   std::streambuf *old = std::cout.rdbuf(this->stolen_stdout.rdbuf()); | ||||
|   if (old) { | ||||
|     // To prevent from unused error | ||||
|   } | ||||
| } | ||||
|  | ||||
| StealConsole::~StealConsole() { | ||||
|   // Do Nothing Here | ||||
| } | ||||
|  | ||||
| std::string StealConsole::GetStdout() { | ||||
|   if (this->stolen_stdout.str().length() < 400) { | ||||
|     return this->stolen_stdout.str(); | ||||
|   } else { | ||||
|     return this->stolen_stdout.str().substr(stolen_stdout.str().length() - 400); | ||||
|   } | ||||
|   return ""; | ||||
| } | ||||
| }  // namespace RenderD7 | ||||
| @@ -83,6 +83,33 @@ struct UI7ID { | ||||
|   bool has_title; | ||||
| }; | ||||
|  | ||||
| // Non Touch Control | ||||
| struct NTCtrl { | ||||
|   // 0x0 = Obj | ||||
|   // 0x1 = Selector | ||||
|   // 0x2 = fill obj | ||||
|   std::vector<unsigned char> grid; | ||||
|   std::vector<unsigned char> cgrid; | ||||
|   int hz = 0;   // Horizontal maximum obj | ||||
|   int vt = 0;   // Vertical maximum Obj | ||||
|   int chz = 0;  // current hz | ||||
|   int selection = 0; | ||||
|   void AddObj() { | ||||
|     chz++; | ||||
|     if (chz > hz) hz = chz; | ||||
|     grid.push_back(0x0); | ||||
|   } | ||||
|   void NewRow() { | ||||
|     chz = 0; | ||||
|     vt++; | ||||
|   } | ||||
|   void Clear() { | ||||
|     cgrid = grid; | ||||
|     grid.clear(); | ||||
|   } | ||||
|   RD7_SMART_CTOR(NTCtrl) | ||||
| }; | ||||
|  | ||||
| using DrawCmdType = int; | ||||
| enum DrawCmdType_ { | ||||
|   DrawCmdType_Skip, | ||||
| @@ -314,6 +341,7 @@ struct UI7Menu { | ||||
|   float tbh;                      // TabBar Height | ||||
|   bool show_scroolbar = true;     // Show Scrollbar | ||||
|   bool has_touch = false;         // To Disable touch on Top Screen | ||||
|   NTCtrl::Ref ctrl;               // NonTouchControl | ||||
|  | ||||
|   // SubMenu | ||||
|   std::string submenu; | ||||
| @@ -378,6 +406,7 @@ bool UI7CtxBeginMenu(const std::string &lb) { | ||||
|   if (ui7_ctx->menus.find(id.ID()) == ui7_ctx->menus.end()) | ||||
|     ui7_ctx->menus.insert(std::make_pair(id.ID(), UI7Menu::New())); | ||||
|   ui7_ctx->cm = ui7_ctx->menus[id.ID()]; | ||||
|   if (!ui7_ctx->cm->ctrl) ui7_ctx->cm->ctrl = NTCtrl::New(); | ||||
|   ui7_ctx->cm->menuid = id; | ||||
|   ui7_ctx->cm->cursor = R7Vec2(0, 0); | ||||
|   ui7_ctx->cm->has_touch = !RenderD7::R2()->GetCurrentScreen(); | ||||
| @@ -394,6 +423,9 @@ void UI7CtxEndMenu() { | ||||
|   RenderD7::Ftrace::ScopedTrace tr("ui7", "EndMenu"); | ||||
|   // Draw Scrollbar | ||||
|   if (ui7_ctx->cm->enable_scrolling) { | ||||
|     ui7_ctx->cm->show_scroolbar = (ui7_ctx->cm->ms.y < 235 ? false : true); | ||||
|  | ||||
|     if (ui7_ctx->cm->show_scroolbar) { | ||||
|       int sw = (RenderD7::R2()->GetCurrentScreen() ? 400 : 320); | ||||
|       int tsp = 5 + ui7_ctx->cm->tbh; | ||||
|       int szs = 240 - tsp - 5; | ||||
| @@ -403,19 +435,20 @@ void UI7CtxEndMenu() { | ||||
|       int slider_rh = d7min(d7max(slider_h, (float)lszs), (float)(szs - 4)); | ||||
|       int slider_pos = d7min( | ||||
|           static_cast<float>(tsp + szs - slider_rh - 4), | ||||
|         d7max( | ||||
|             static_cast<float>(tsp), | ||||
|           d7max(static_cast<float>(tsp), | ||||
|                 static_cast<float>(tsp) + | ||||
|                     static_cast<float>( | ||||
|                     (szs) * (static_cast<float>(ui7_ctx->cm->scrolling_offset) / | ||||
|                         (szs) * | ||||
|                         (static_cast<float>(ui7_ctx->cm->scrolling_offset) / | ||||
|                          static_cast<float>(ui7_ctx->cm->msr.y))))); | ||||
|       int slider_w = 4; | ||||
|     ui7_ctx->cm->front->AddRectangle(R7Vec2(sw - 12, tsp), | ||||
|                                      R7Vec2(slider_w * 2, szs), RD7Color_List0); | ||||
|       ui7_ctx->cm->front->AddRectangle( | ||||
|           R7Vec2(sw - 12, tsp), R7Vec2(slider_w * 2, szs), RD7Color_List0); | ||||
|       ui7_ctx->cm->front->AddRectangle(R7Vec2(sw - 10, slider_pos + 2), | ||||
|                                        R7Vec2(slider_w, slider_h), | ||||
|                                        RD7Color_Selector); | ||||
|     } | ||||
|   } | ||||
|   ui7_ctx->active_menus.push_back(ui7_ctx->cm); | ||||
|   ui7_ctx->cm = nullptr; | ||||
|   ui7_ctx->in_menu = false; | ||||
| @@ -469,6 +502,7 @@ void Update() { | ||||
|     it->background->Process(); | ||||
|     it->main->Process(); | ||||
|     it->front->Process(); | ||||
|     it->ctrl->Clear(); | ||||
|   } | ||||
|   ui7_ctx->fdl->Process(); | ||||
|   ui7_ctx->active_menus.clear(); | ||||
| @@ -502,6 +536,7 @@ bool Button(const std::string &label, R7Vec2 size) { | ||||
|   R7Vec2 pos = GetCursorPos(); | ||||
|  | ||||
|   UI7CtxCursorMove(size); | ||||
|   ui7_ctx->cm->ctrl->AddObj(); | ||||
|  | ||||
|   if (ui7_ctx->cm->enable_scrolling) { | ||||
|     R7Vec2 pb = pos; | ||||
| @@ -540,6 +575,7 @@ void Checkbox(const std::string &label, bool &c) { | ||||
|   R7Vec2 pos = GetCursorPos(); | ||||
|  | ||||
|   UI7CtxCursorMove(inp); | ||||
|   ui7_ctx->cm->ctrl->AddObj(); | ||||
|  | ||||
|   if (ui7_ctx->cm->enable_scrolling) { | ||||
|     R7Vec2 pb = pos; | ||||
| @@ -577,6 +613,7 @@ void Label(const std::string &label, RD7TextFlags flags) { | ||||
|   auto upos = pos; | ||||
|   // Remove some y offset cause texts have some offset | ||||
|   UI7CtxCursorMove(textdim - R7Vec2(0, 4)); | ||||
|   ui7_ctx->cm->ctrl->AddObj(); | ||||
|  | ||||
|   if (ui7_ctx->cm->enable_scrolling) { | ||||
|     R7Vec2 pb = pos; | ||||
| @@ -605,6 +642,7 @@ void Progressbar(float value) { | ||||
|   if (ui7_ctx->cm->show_scroolbar && ui7_ctx->cm->enable_scrolling) | ||||
|     size.x -= 16; | ||||
|   UI7CtxCursorMove(size); | ||||
|   ui7_ctx->cm->ctrl->AddObj(); | ||||
|  | ||||
|   if (ui7_ctx->cm->enable_scrolling) { | ||||
|     R7Vec2 pb = pos; | ||||
| @@ -628,6 +666,7 @@ void Image(RenderD7::Image::Ref img) { | ||||
|   if (!UI7CtxValidate()) return; | ||||
|   R7Vec2 pos = GetCursorPos(); | ||||
|   UI7CtxCursorMove(R7Vec2(img->GetSize().x, img->GetSize().y)); | ||||
|   ui7_ctx->cm->ctrl->AddObj(); | ||||
|  | ||||
|   if (ui7_ctx->cm->enable_scrolling) { | ||||
|     R7Vec2 pb = pos; | ||||
| @@ -652,6 +691,7 @@ void BrowserList(const std::vector<std::string> &entrys, int &selection, | ||||
|     size.x = (RenderD7::R2()->GetCurrentScreen() ? 400 : 320) - (pos.x * 2); | ||||
|   if (size.y == 0) size.y = (max_entrys * 15); | ||||
|   UI7CtxCursorMove(size); | ||||
|   ui7_ctx->cm->ctrl->AddObj(); | ||||
|   int selindex = (selection < max_entrys ? selection : (max_entrys - 1)); | ||||
|  | ||||
|   for (int i = 0; i < max_entrys; i++) { | ||||
| @@ -696,6 +736,7 @@ void InputText(const std::string &label, std::string &text, | ||||
|  | ||||
|   R7Vec2 pos = GetCursorPos(); | ||||
|   UI7CtxCursorMove(inp); | ||||
|   ui7_ctx->cm->ctrl->AddObj(); | ||||
|  | ||||
|   if (ui7_ctx->cm->enable_scrolling) { | ||||
|     R7Vec2 pb = pos; | ||||
| @@ -892,6 +933,7 @@ void ColorSelector(const std::string &label, unsigned int &color) { | ||||
|  | ||||
|   R7Vec2 pos = GetCursorPos(); | ||||
|   UI7CtxCursorMove(inp); | ||||
|   ui7_ctx->cm->ctrl->AddObj(); | ||||
|  | ||||
|   if (ui7_ctx->cm->enable_scrolling) { | ||||
|     R7Vec2 pb = pos; | ||||
| @@ -1103,6 +1145,7 @@ void RestoreCursor() { | ||||
| void SameLine() { | ||||
|   if (!UI7CtxValidate()) return; | ||||
|   if (!UI7CtxInMenu()) return; | ||||
|   ui7_ctx->cm->ctrl->NewRow(); | ||||
|   ui7_ctx->cm->cursor = ui7_ctx->cm->slc; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -24,6 +24,7 @@ | ||||
| #include <string.h> | ||||
| #include <unistd.h> | ||||
|  | ||||
| #include <renderd7/Error.hpp> | ||||
| #include <renderd7/FileSystem.hpp> | ||||
| #include <renderd7/external/json.hpp> | ||||
| #include <renderd7/internal_db.hpp> | ||||
| @@ -74,6 +75,16 @@ bool rd7i_amdt = false; | ||||
| void *rd7i_soc_buf = nullptr; | ||||
| bool rd7i_is_am_init = false; | ||||
| RenderD7::Theme::Ref rd7i_active_theme; | ||||
| RenderD7::LoggerBase::Ref rd7i_logger; | ||||
| bool rd7i_lggrf = false; | ||||
|  | ||||
| RenderD7::LoggerBase::Ref _rd7i_logger() { | ||||
|   if (!rd7i_logger) { | ||||
|     RenderD7::Error( | ||||
|         "You're trying to use a RenderD7 Func without Init RenderD7!"); | ||||
|   } | ||||
|   return rd7i_logger; | ||||
| } | ||||
|  | ||||
| /// Global /// | ||||
| // Outdated HidApi (HidV2Patched) | ||||
|   | ||||
| @@ -33,8 +33,8 @@ | ||||
| #include <random> | ||||
|  | ||||
| RenderD7::R2Base::Ref rd7i_render2; | ||||
| RenderD7::LoggerBase::Ref rd7i_logger; | ||||
| RenderD7::LoggerBase::Ref rd7i_glogger; | ||||
| extern RenderD7::LoggerBase::Ref rd7i_logger; | ||||
|  | ||||
| static void RD7i_ExitHook() { | ||||
|   C2D_TextBufDelete(rd7i_text_buffer); | ||||
| @@ -182,14 +182,12 @@ void rd7i_init_config() { | ||||
|     rd7i_config.clear(); | ||||
|     rd7i_config["info"]["version"] = CFGVER; | ||||
|     rd7i_config["info"]["renderd7ver"] = RENDERD7VSTRING; | ||||
|     rd7i_config["settings"]["doscreentimeout"] = 0; | ||||
|     rd7i_config["settings"]["forcetimeoutLB"] = true; | ||||
|     rd7i_config["settings"]["renderer"] = "c3d_c2d"; | ||||
|     rd7i_config["metrik-settings"]["enableoverlay"] = false; | ||||
|     rd7i_config["metrik-settings"]["show"] = false; | ||||
|     rd7i_config["metrik-settings"]["Screen"] = true; | ||||
|     rd7i_config["metrik-settings"]["txtColor"] = "#ffffffff"; | ||||
|     rd7i_config["metrik-settings"]["Color"] = "#aa000000"; | ||||
|     rd7i_config["metrik-settings"]["txtSize"] = 0.7f; | ||||
|     rd7i_config["metrik-settings"]["Text"] = "#ffffffff"; | ||||
|     rd7i_config["metrik-settings"]["Bg"] = "#aa000000"; | ||||
|     rd7i_config["metrik-settings"]["Size"] = 0.7f; | ||||
|     rd7i_config["internal_logger"]["nowritetxt"] = true; | ||||
|     std::fstream cfg_wrt(rd7i_config_path + "/config.rc7", std::ios::out); | ||||
|     cfg_wrt << rd7i_config.dump(4); | ||||
|     cfg_wrt.close(); | ||||
| @@ -198,9 +196,10 @@ void rd7i_init_config() { | ||||
|   cfg_ldr >> rd7i_config; | ||||
|   cfg_ldr.close(); | ||||
|  | ||||
|   rd7i_metrikd = rd7i_config["metrik-settings"]["enableoverlay"].get<bool>(); | ||||
|   rd7i_mt_txtSize = rd7i_config["metrik-settings"]["txtSize"].get<float>(); | ||||
|   rd7i_metrikd = rd7i_config["metrik-settings"]["show"].get<bool>(); | ||||
|   rd7i_mt_txtSize = rd7i_config["metrik-settings"]["Size"].get<float>(); | ||||
|   rd7i_mt_screen = rd7i_config["metrik-settings"]["Screen"].get<bool>(); | ||||
|   rd7i_lggrf = rd7i_config["internal_logger"]["nowritetxt"].get<bool>(); | ||||
|  | ||||
|   if (rd7i_metrikd) | ||||
|     RenderD7::AddOvl(std::make_unique<RenderD7::Ovl_Metrik>( | ||||
| @@ -363,7 +362,6 @@ Result RenderD7::Init::Main(std::string app_name) { | ||||
|   RenderD7::Ftrace::ScopedTrace st("rd7-core", f2s(Init::Main)); | ||||
|   rd7i_app_name = app_name; | ||||
|   rd7i_logger = LoggerBase::New(); | ||||
|   rd7i_logger->Init("renderd7", true); | ||||
|   rd7i_glogger = LoggerBase::New(); | ||||
|  | ||||
|   gfxInitDefault(); | ||||
| @@ -380,6 +378,9 @@ Result RenderD7::Init::Main(std::string app_name) { | ||||
|   atexit(aptExit); | ||||
|   romfsInit(); | ||||
|  | ||||
|   rd7i_init_config(); | ||||
|   _rd7i_logger()->Init("renderd7", rd7i_lggrf); | ||||
|  | ||||
|   rd7i_active_theme = Theme::New(); | ||||
|   rd7i_active_theme->Default(); | ||||
|  | ||||
| @@ -414,7 +415,6 @@ Result RenderD7::Init::Main(std::string app_name) { | ||||
|   rd7i_last_tm = svcGetSystemTick(); | ||||
|   if (rd7_do_splash) PushSplash(); | ||||
|  | ||||
|   rd7i_init_config(); | ||||
|   rd7i_init_input(); | ||||
|   rd7i_init_theme(); | ||||
|   UI7::Init(); | ||||
| @@ -427,13 +427,15 @@ Result RenderD7::Init::Minimal(std::string app_name) { | ||||
|   RenderD7::Ftrace::ScopedTrace st("rd7-core", f2s(Init::Minimal)); | ||||
|   rd7i_app_name = app_name; | ||||
|   rd7i_logger = LoggerBase::New(); | ||||
|   rd7i_logger->Init("renderd7", true); | ||||
|   rd7i_glogger = LoggerBase::New(); | ||||
|  | ||||
|   gfxInitDefault(); | ||||
|   atexit(gfxExit); | ||||
|   romfsInit(); | ||||
|  | ||||
|   rd7i_init_config(); | ||||
|   _rd7i_logger()->Init("renderd7", rd7i_lggrf); | ||||
|  | ||||
|   rd7i_active_theme = Theme::New(); | ||||
|   rd7i_active_theme->Default(); | ||||
|  | ||||
| @@ -473,7 +475,6 @@ Result RenderD7::Init::Minimal(std::string app_name) { | ||||
|   svcGetSystemInfo(&citracheck, 0x20000, 0); | ||||
|   rd7i_is_citra = citracheck ? true : false; | ||||
|  | ||||
|   rd7i_init_config(); | ||||
|   rd7i_init_input(); | ||||
|   rd7i_init_theme(); | ||||
|   UI7::Init(); | ||||
| @@ -612,6 +613,11 @@ void RenderD7::RSettings::Draw(void) const { | ||||
|       if (UI7::Button("ThemeEditor")) { | ||||
|         RenderD7::LoadThemeEditor(); | ||||
|       } | ||||
|       if (UI7::Button("Logs")) { | ||||
|         shared_request[0x00000001] = RLOGS; | ||||
|       } | ||||
|       UI7::SameLine(); | ||||
|       UI7::Checkbox("No File", rd7i_lggrf); | ||||
|       if (UI7::Button("Back")) { | ||||
|         shared_request[0x00000002] = 1U; | ||||
|       } | ||||
| @@ -800,6 +806,21 @@ void RenderD7::RSettings::Draw(void) const { | ||||
|       } | ||||
|       UI7::EndMenu(); | ||||
|     } | ||||
|   } else if (m_state == RLOGS) { | ||||
|     RenderD7::R2()->OnScreen(R2Screen_Top); | ||||
|     if (UI7::BeginMenu("RenderD7 -> Logs")) { | ||||
|       UI7::SetCursorPos(R7Vec2(395, 2)); | ||||
|       UI7::Label(RENDERD7VSTRING, RD7TextFlags_AlignRight); | ||||
|       UI7::RestoreCursor(); | ||||
|       UI7::EndMenu(); | ||||
|     } | ||||
|  | ||||
|     RenderD7::R2()->OnScreen(R2Screen_Bottom); | ||||
|     if (UI7::BeginMenu("Press \uE001 to go back!", R7Vec2(), | ||||
|                        UI7MenuFlags_Scrolling)) { | ||||
|       for (auto &it : rd7i_logger->Lines()) UI7::Label(it); | ||||
|       UI7::EndMenu(); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| @@ -813,6 +834,7 @@ void RenderD7::RSettings::Logic() { | ||||
|         std::fstream cfg_wrt(rd7i_config_path + "/config.rc7", std::ios::out); | ||||
|         rd7i_config["metrik-settings"]["enableoverlay"] = rd7i_metrikd; | ||||
|         rd7i_config["metrik-settings"]["Screen"] = rd7i_mt_screen; | ||||
|         rd7i_config["internal_logger"]["nowritetxt"] = rd7i_lggrf; | ||||
|         cfg_wrt << rd7i_config.dump(4); | ||||
|         cfg_wrt.close(); | ||||
|         rd7i_settings = false; | ||||
| @@ -843,6 +865,7 @@ void RenderD7::RSettings::Logic() { | ||||
|       std::fstream cfg_wrt(rd7i_config_path + "/config.rc7", std::ios::out); | ||||
|       rd7i_config["metrik-settings"]["enableoverlay"] = rd7i_metrikd; | ||||
|       rd7i_config["metrik-settings"]["Screen"] = rd7i_mt_screen; | ||||
|       rd7i_config["internal_logger"]["nowritetxt"] = rd7i_lggrf; | ||||
|       cfg_wrt << rd7i_config.dump(4); | ||||
|       cfg_wrt.close(); | ||||
|       rd7i_settings = false; | ||||
| @@ -862,7 +885,7 @@ void RenderD7::RSettings::Logic() { | ||||
|       m_state = RSETTINGS; | ||||
|     } | ||||
|   } | ||||
|   if (m_state == RIDB) { | ||||
|   if (m_state == RIDB || m_state == RLOGS) { | ||||
|     if (d7_hDown & KEY_B) { | ||||
|       m_state = RSETTINGS; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user