Changes:
Remove MEMTRACK Flag Replace Draw2 with Render2 Rename sound and font to uppercase Add SMART_CTOR to Image Sprite Sound Port Everything to R2
This commit is contained in:
parent
07ed5af300
commit
5636205002
@ -12,14 +12,12 @@ RENDERD7_INC := RenderD7/include
|
||||
# Libraries used for RenderD7
|
||||
# if you already use -lm, -lctru etc place a # before -lm
|
||||
RENDERD7_LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lz -lm -lcitro2dd -lcitro3d -lctru
|
||||
RENDERD7_FLAGS := -DRENDERD7_MEMTRACK=1
|
||||
```
|
||||
Now you need to add it to your sources and includes
|
||||
```
|
||||
SOURCES := source $(RENDERD7_SRC)
|
||||
INCLUDES := source $(RENDERD7_INC)
|
||||
```
|
||||
Finally append `$(RENDERD7_FLAGS)` to your `CFLAGS`
|
||||
|
||||
Example from rd7tf
|
||||
### Installation (0.8.0-0.9.4) (OUTDATED)
|
||||
|
@ -19,7 +19,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/Allocator.hpp>
|
||||
#include <renderd7/DrawV2.hpp>
|
||||
#include <renderd7/Error.hpp>
|
||||
#include <renderd7/FileSystem.hpp>
|
||||
#include <renderd7/Hid.hpp>
|
||||
@ -28,13 +27,12 @@
|
||||
#include <renderd7/Message.hpp>
|
||||
#include <renderd7/Net.hpp>
|
||||
#include <renderd7/Overlays.hpp>
|
||||
#include <renderd7/Sound2.hpp>
|
||||
#include <renderd7/StealConsole.hpp>
|
||||
#include <renderd7/Timer.hpp>
|
||||
#include <renderd7/UI7.hpp>
|
||||
#include <renderd7/global_db.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
#include <renderd7/sound.hpp>
|
||||
#include <renderd7/swr.hpp>
|
||||
|
||||
namespace RD7 = RenderD7;
|
||||
namespace DV2 = RenderD7::Draw2;
|
@ -1,76 +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 <renderd7/Color.hpp>
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/font.hpp>
|
||||
|
||||
#define MAKEFLAG(x) (1 << x)
|
||||
|
||||
typedef unsigned int RD7TextFlags;
|
||||
|
||||
enum RD7TextFlags_ {
|
||||
RD7TextFlags_None = 0, //< Align is Left and Other things are disabled
|
||||
RD7TextFlags_AlignRight = MAKEFLAG(0),
|
||||
RD7TextFlags_AlignMid = MAKEFLAG(1),
|
||||
RD7TextFlags_Shaddow = MAKEFLAG(2), // TextBuf Killer lol (doubled Text)
|
||||
RD7TextFlags_Wrap = MAKEFLAG(3),
|
||||
RD7TextFlags_Short = MAKEFLAG(4),
|
||||
RD7TextFlags_Scroll = MAKEFLAG(5),
|
||||
};
|
||||
|
||||
namespace RenderD7 {
|
||||
R7Vec2 GetTextDimensions(const std::string& text);
|
||||
void CustomTextSize(float size);
|
||||
void TextDefaultSize();
|
||||
float TextGetSize();
|
||||
std::string TextShort(const std::string& in, int max_len);
|
||||
// Overrite TextBox Size (by default Screenwidth x Text.h)
|
||||
void TextMaxBox(R7Vec2 size);
|
||||
void TextDefaultBox();
|
||||
void TextFont(Font::Ref fnt);
|
||||
void TextFontRestore();
|
||||
void TextDefaultFont();
|
||||
namespace Draw2 {
|
||||
void Scissor(R7Vec2 pos, R7Vec2 size);
|
||||
void ScissorReset();
|
||||
void Rect(R7Vec2 pos, R7Vec2 size, unsigned int color, int t = 1);
|
||||
void RectFilled(R7Vec2 pos, R7Vec2 size, Color4 colors);
|
||||
void RectFilledSolid(R7Vec2 pos, R7Vec2 size, unsigned int color);
|
||||
// Wrapper of RectFilledSolid
|
||||
inline void RFS(R7Vec2 pos, R7Vec2 size, unsigned int color) {
|
||||
RectFilledSolid(pos, size, color);
|
||||
}
|
||||
void Line(R7Vec2 pos0, R7Vec2 pos1, unsigned int color, int t = 1);
|
||||
void Triangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, Color3 colors);
|
||||
void TriangleSolid(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color);
|
||||
// Beta and Very unstable
|
||||
void TriangleLined(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color,
|
||||
int t = 1);
|
||||
void Text(R7Vec2 pos, const std::string& text, RD7TextFlags flags = 0);
|
||||
void TextClr(R7Vec2 pos, const std::string& text, unsigned int color,
|
||||
RD7TextFlags flags = 0);
|
||||
void Image(RenderD7::Image* img, const R7Vec2& pos = R7Vec2(0, 0),
|
||||
const R7Vec2& scale = R7Vec2(1, 1));
|
||||
} // namespace Draw2
|
||||
} // namespace RenderD7
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/nimg.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
@ -30,14 +31,15 @@ class Image {
|
||||
public:
|
||||
Image();
|
||||
~Image();
|
||||
void load(const std::string& path);
|
||||
void from_nimg(const nimg& image);
|
||||
RD7_SMART_CTOR(Image)
|
||||
void Load(const std::string& path);
|
||||
void From_NIMG(const nimg& image);
|
||||
|
||||
C2D_Image get();
|
||||
C2D_Image& get_ref();
|
||||
void set(const C2D_Image& i);
|
||||
R7Vec2 get_size();
|
||||
bool loaded();
|
||||
C2D_Image Get();
|
||||
C2D_Image& GetRef();
|
||||
void Set(const C2D_Image& i);
|
||||
R7Vec2 GetSize();
|
||||
bool Loadet();
|
||||
|
||||
private:
|
||||
void safe_del();
|
||||
|
@ -67,6 +67,7 @@ class Ovl_Metrik : public RenderD7::Ovl {
|
||||
mutable std::string mt_cmd;
|
||||
mutable std::string mt_lfr;
|
||||
mutable std::string mt_tbs;
|
||||
mutable std::string mt_mem;
|
||||
|
||||
// Importand Adresses
|
||||
bool* i_is_enabled;
|
||||
|
@ -20,25 +20,83 @@
|
||||
|
||||
#include <map>
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/Font.hpp>
|
||||
#include <renderd7/Font2.hpp>
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
#define MAKEFLAG(x) (1 << x)
|
||||
|
||||
typedef unsigned int RD7TextFlags;
|
||||
|
||||
enum RD7TextFlags_ {
|
||||
RD7TextFlags_None = 0, //< Align is Left and Other things are disabled
|
||||
RD7TextFlags_AlignRight = MAKEFLAG(0),
|
||||
RD7TextFlags_AlignMid = MAKEFLAG(1),
|
||||
RD7TextFlags_Shaddow = MAKEFLAG(2), // TextBuf Killer lol (doubled Text)
|
||||
RD7TextFlags_Wrap = MAKEFLAG(3),
|
||||
RD7TextFlags_Short = MAKEFLAG(4),
|
||||
RD7TextFlags_Scroll = MAKEFLAG(5),
|
||||
};
|
||||
|
||||
enum R2Screen {
|
||||
R2Screen_Bottom,
|
||||
R2Screen_Top,
|
||||
// TopRight,
|
||||
};
|
||||
|
||||
namespace RenderD7 {
|
||||
class R2Base {
|
||||
public:
|
||||
struct R2Cmd {
|
||||
R7Vec2 pos; //< Position
|
||||
R7Vec2 pszs; //< Position or (TextBox) Size
|
||||
R7Vec2 ap; //< Additional Pos
|
||||
unsigned int clr; //< Color
|
||||
bool Screen; //< TopScreen
|
||||
// 0 = skip, 1 = rect, 2 = tri, 3 = text, 4 = image
|
||||
int type; //< Command Type
|
||||
bool lined = false; //< Draw Lined Rect/Tri
|
||||
// Text Specific
|
||||
RD7TextFlags flags; // Text Flags
|
||||
std::string text; // Text
|
||||
};
|
||||
R2Base();
|
||||
~R2Base() = default;
|
||||
void SetFont();
|
||||
RD7_SMART_CTOR(R2Base)
|
||||
|
||||
// Settings
|
||||
void SetFont(Font::Ref fnt);
|
||||
Font::Ref GetFont();
|
||||
void DefaultFont();
|
||||
void DrawNextLined();
|
||||
void OnScreen(R2Screen screen);
|
||||
R2Screen GetCurrentScreen();
|
||||
void SetTextSize(float szs);
|
||||
void DefaultTextSize();
|
||||
float GetTextSize();
|
||||
|
||||
// Processing
|
||||
void Process();
|
||||
R7Vec2 GetTextDimensions(const std::string& text);
|
||||
|
||||
// Draw Functions
|
||||
void AddRect(R7Vec2 pos, R7Vec2 size, RD7Color clr);
|
||||
void AddRect(R7Vec2 pos, R7Vec2 size, unsigned int clr);
|
||||
void AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, RD7Color clr);
|
||||
void AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int clr);
|
||||
void AddText(R7Vec2 pos, const std::string& text, RD7Color clr,
|
||||
RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2());
|
||||
void AddText(R7Vec2 pos, const std::string& text, unsigned int clr,
|
||||
RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2());
|
||||
|
||||
private:
|
||||
const float default_text_size = 0.5f;
|
||||
float text_size = 0.5;
|
||||
Font::Ref font[2];
|
||||
R7Vec2 max_wh;
|
||||
Font::Ref font;
|
||||
std::map<std::string, float> ts;
|
||||
std::map<std::string, int> mln;
|
||||
bool next_lined = false;
|
||||
std::vector<R2Cmd> commands;
|
||||
R2Screen current_screen = R2Screen_Bottom;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -20,22 +20,24 @@
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
#include <string>
|
||||
|
||||
/** Sound Class */
|
||||
class sound {
|
||||
class Sound {
|
||||
public:
|
||||
/// \brief Construct new Soundeffect
|
||||
/// \param path Path to the .wav file
|
||||
/// \param channel the channel 1-23
|
||||
/// \param toloop true:loop the sound, false: don't loop
|
||||
sound(const std::string &path, int channel = 1, bool toloop = false);
|
||||
Sound(const std::string &path, int channel = 1, bool toloop = false);
|
||||
/// @brief Deconstructor
|
||||
~sound();
|
||||
~Sound();
|
||||
RD7_SMART_CTOR(Sound)
|
||||
/// @brief Play the sound
|
||||
void play();
|
||||
void Play();
|
||||
/// @brief Stop the sound
|
||||
void stop();
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
/// \param dataSize Size of the filedata
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/Sheet.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// @brief Sprite Class
|
||||
@ -32,13 +33,14 @@ class Sprite {
|
||||
Sprite() = default;
|
||||
/// \brief Deconstruct Sprite
|
||||
~Sprite() = default;
|
||||
RD7_SMART_CTOR(Sprite)
|
||||
/// \brief Load a Sprite From SpriteSheet
|
||||
/// \param sheet the Sheet to load from.(RenderD7::Sheet)
|
||||
/// \param index the number of the Sprite in the Sheet
|
||||
void FromSheet(RenderD7::Sheet *sheet, size_t index);
|
||||
/// \brief Load a Sprite From SpriteSheet
|
||||
/// \param img the Image to load from.(RenderD7::Image)
|
||||
void FromImage(RenderD7::Image *img);
|
||||
void FromImage(RenderD7::Image::Ref img);
|
||||
/// @brief Draw the Sprite
|
||||
/// @return success ?
|
||||
bool Draw();
|
||||
@ -62,16 +64,21 @@ class Sprite {
|
||||
void Rotate(float speed);
|
||||
/// @brief Get Tje Sprite's Width
|
||||
/// @return Width
|
||||
float getWidth();
|
||||
float GetWidth();
|
||||
/// @brief Get the Sprite's Height
|
||||
/// @return Height
|
||||
float getHeight();
|
||||
float GetHeight();
|
||||
/// @brief Get The Sprite's X Position
|
||||
/// @return X Position
|
||||
float getPosX();
|
||||
float GetPosX();
|
||||
/// @brief Get the Sprite's Y Position
|
||||
/// @return Y Position
|
||||
float getPosY();
|
||||
float GetPosY();
|
||||
R7Vec2 GetSize();
|
||||
R7Vec2 GetPos();
|
||||
void SetPos(R7Vec2 pos);
|
||||
void SetScale(R7Vec2 scale);
|
||||
void SetRotCenter(R7Vec2 percentage);
|
||||
|
||||
private:
|
||||
/// @param tint ImageTint (unused)
|
||||
|
@ -18,8 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/DrawV2.hpp>
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/Render2.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
// UI7: The new RenderD7 UI Standart based on
|
||||
@ -80,7 +81,7 @@ void Label(const std::string &label, RD7TextFlags flags = 0);
|
||||
void Progressbar(float value);
|
||||
/// @brief Draw Image in Menu
|
||||
/// @param img Pointer f.e to RenderD7::Image2
|
||||
void Image(RenderD7::Image *img);
|
||||
void Image(RenderD7::Image::Ref img);
|
||||
void BrowserList(const std::vector<std::string> &entrys, int &selection,
|
||||
RD7TextFlags txtflags = 0, R7Vec2 size = R7Vec2(0, 0),
|
||||
int max_entrys = 13);
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <renderd7/Memory.hpp>
|
||||
#include <renderd7/Overlays.hpp>
|
||||
#include <renderd7/Ovl.hpp>
|
||||
#include <renderd7/Render2.hpp>
|
||||
#include <renderd7/ResultDecoder.hpp>
|
||||
#include <renderd7/Screen.hpp>
|
||||
#include <renderd7/Sheet.hpp>
|
||||
@ -67,6 +68,8 @@ extern int rd7_max_objects;
|
||||
extern bool rd7_enable_scene_system;
|
||||
|
||||
namespace RenderD7 {
|
||||
// Reference to the New Renderer
|
||||
R2Base::Ref R2();
|
||||
/// @brief Get Deltatime
|
||||
/// @return Deltatime
|
||||
float GetDeltaTime();
|
||||
|
@ -1,288 +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 <citro2d.h>
|
||||
|
||||
#include <renderd7/DrawV2.hpp>
|
||||
#include <renderd7/global_db.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
const float rd7i_d7_dts = 0.5f;
|
||||
float rd7i_d2_txt_size = rd7i_d7_dts;
|
||||
C2D_Font rd7i_d2_fnt = nullptr;
|
||||
C2D_Font rd7i_d2_fntb = nullptr;
|
||||
R7Vec2 rd7i_d7_mwh = R7Vec2(0, 0);
|
||||
std::map<std::string, float> rd7i_d2_ts;
|
||||
std::map<std::string, int> rd7i_d2_mln;
|
||||
|
||||
bool rd7i_txt_init = false;
|
||||
|
||||
std::string GetShortedText(const std::string &in, int maxlen) {
|
||||
auto textdim = RenderD7::GetTextDimensions(in);
|
||||
if (textdim.x < (float)maxlen) return in;
|
||||
std::string ft = "";
|
||||
std::string worker = in;
|
||||
if (in.find_last_of('.') != in.npos) {
|
||||
ft = in.substr(in.find_last_of('.'));
|
||||
worker = in.substr(0, in.find_last_of('.'));
|
||||
}
|
||||
|
||||
maxlen -= RenderD7::GetTextDimensions(ft).x -
|
||||
RenderD7::GetTextDimensions("(...)").x;
|
||||
float len_mod = (float)maxlen / textdim.x;
|
||||
int pos = (in.length() * len_mod) / rd7_draw2_tsm;
|
||||
std::string out;
|
||||
|
||||
out = in.substr(0, pos);
|
||||
|
||||
for (size_t i = pos; i < worker.length(); i++) {
|
||||
out += worker[i];
|
||||
if (RenderD7::GetTextDimensions(out + "(...)" + ft).x > (float)maxlen) {
|
||||
out += "(...)";
|
||||
out += ft;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return ""; // Impossible to reach
|
||||
}
|
||||
|
||||
std::string WrapText(const std ::string &in, int maxlen) {
|
||||
std::string out;
|
||||
std::string line;
|
||||
int line_x = 0;
|
||||
std::istringstream istream(in);
|
||||
std::string temp;
|
||||
|
||||
while (istream >> temp) {
|
||||
R7Vec2 dim = RenderD7::GetTextDimensions(line + temp);
|
||||
if (line_x + dim.x <= maxlen) {
|
||||
line += temp + ' ';
|
||||
line_x += dim.x;
|
||||
} else {
|
||||
out += line + '\n';
|
||||
line = temp + ' ';
|
||||
line_x = dim.x;
|
||||
}
|
||||
}
|
||||
out += line;
|
||||
return out;
|
||||
}
|
||||
|
||||
bool RD7I_FNT_VALID() {
|
||||
if (rd7i_d2_fnt != nullptr && !rd7i_txt_init) {
|
||||
rd7i_txt_init = true;
|
||||
}
|
||||
if (!rd7i_txt_init) {
|
||||
if (rd7i_base_font != nullptr) {
|
||||
rd7i_d2_fnt = rd7i_base_font;
|
||||
rd7i_txt_init = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (rd7i_d2_fnt != nullptr) {
|
||||
return true;
|
||||
} else {
|
||||
rd7i_d2_fnt = rd7i_base_font;
|
||||
return true;
|
||||
}
|
||||
// Schould never be reached
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
// TODO: Fix wrong Width/Height on other fonts
|
||||
R7Vec2 GetTextDimensions(const std::string &text) {
|
||||
C2D_TextBufClear(rd7i_d2_dimbuf);
|
||||
float w = 0, h = 0;
|
||||
if (!RD7I_FNT_VALID()) return R7Vec2(w, h);
|
||||
C2D_Text c2dtext;
|
||||
C2D_TextFontParse(&c2dtext, rd7i_d2_fnt, rd7i_d2_dimbuf, text.c_str());
|
||||
C2D_TextGetDimensions(&c2dtext, rd7i_d2_txt_size, rd7i_d2_txt_size, &w, &h);
|
||||
return R7Vec2(w, h);
|
||||
}
|
||||
|
||||
void CustomTextSize(float size) { rd7i_d2_txt_size = size; }
|
||||
|
||||
void TextDefaultSize() { rd7i_d2_txt_size = rd7i_d7_dts; }
|
||||
|
||||
void TextMaxBox(R7Vec2 size) { rd7i_d7_mwh = size; }
|
||||
|
||||
void TextDefaultBox() { rd7i_d7_mwh = R7Vec2(0, 0); }
|
||||
|
||||
void TextFont(Font::Ref fnt) {
|
||||
rd7i_d2_fntb = rd7i_d2_fnt;
|
||||
rd7i_d2_fnt = fnt->Ptr();
|
||||
}
|
||||
|
||||
void TextFontRestore() {
|
||||
// Create temp copy
|
||||
// Restore other font
|
||||
// Set other to temp
|
||||
auto tmp = rd7i_d2_fnt;
|
||||
rd7i_d2_fnt = rd7i_d2_fntb;
|
||||
rd7i_d2_fntb = tmp;
|
||||
}
|
||||
|
||||
void TextDefaultFont() {
|
||||
rd7i_d2_fntb = rd7i_d2_fnt;
|
||||
rd7i_d2_fnt = rd7i_base_font;
|
||||
}
|
||||
|
||||
float TextGetSize() { return rd7i_d2_txt_size; }
|
||||
|
||||
std::string TextShort(const std::string &in, int max_len) {
|
||||
return GetShortedText(in, max_len);
|
||||
}
|
||||
|
||||
namespace Draw2 {
|
||||
void Scissor(R7Vec2 pos, R7Vec2 size) {
|
||||
// TODO: Seems not correct yet
|
||||
C3D_SetScissor(GPU_SCISSOR_NORMAL, GSP_SCREEN_WIDTH - pos.y - size.y, pos.x,
|
||||
GSP_SCREEN_WIDTH - pos.y, pos.x + size.x);
|
||||
}
|
||||
void ScissorReset() { C3D_SetScissor(GPU_SCISSOR_DISABLE, 0, 0, 0, 0); }
|
||||
void Rect(R7Vec2 pos, R7Vec2 size, unsigned int color, int t) {
|
||||
// 4 DrawLine Calls Lol
|
||||
C2D_DrawLine(pos.x, pos.y, color, pos.x + size.x, pos.y, color, t, 1.f);
|
||||
C2D_DrawLine(pos.x, pos.y, color, pos.x, pos.y + size.y, color, t, 1.f);
|
||||
C2D_DrawLine(pos.x + size.x, pos.y, color, pos.x + size.x, pos.y + size.y,
|
||||
color, t, 1.f);
|
||||
C2D_DrawLine(pos.x, pos.y + size.y, color, pos.x + size.x, pos.y + size.y,
|
||||
color, t, 1.f);
|
||||
}
|
||||
|
||||
void RectFilled(R7Vec2 pos, R7Vec2 size, Color4 colors) {
|
||||
C2D_DrawRectangle(pos.x, pos.y, 0.5f, size.x, size.y, colors.color0,
|
||||
colors.color1, colors.color2, colors.color3);
|
||||
}
|
||||
|
||||
void RectFilledSolid(R7Vec2 pos, R7Vec2 size, unsigned int color) {
|
||||
C2D_DrawRectSolid(pos.x, pos.y, 0.5f, size.x, size.y, color);
|
||||
}
|
||||
|
||||
void Line(R7Vec2 pos0, R7Vec2 pos1, unsigned int color, int t) {
|
||||
C2D_DrawLine(pos0.x, pos0.y, color, pos1.x, pos1.y, color, t, 1.f);
|
||||
}
|
||||
|
||||
void Triangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, Color3 colors) {
|
||||
C2D_DrawTriangle(pos0.x, pos0.y, colors.color0, pos1.x, pos1.y, colors.color1,
|
||||
pos2.x, pos2.y, colors.color2, 0.5f);
|
||||
}
|
||||
|
||||
void TriangleSolid(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color) {
|
||||
C2D_DrawTriangle(pos0.x, pos0.y, color, pos1.x, pos1.y, color, pos2.x, pos2.y,
|
||||
color, 0.5f);
|
||||
}
|
||||
|
||||
void TriangleLined(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color,
|
||||
int t) {
|
||||
// 3 Line Cqalls lol more efficient than Rect
|
||||
C2D_DrawLine(pos0.x, pos0.y, color, pos1.x, pos1.y, color, t, 1.f);
|
||||
C2D_DrawLine(pos0.x, pos0.y, color, pos2.x, pos2.y, color, t, 1.f);
|
||||
C2D_DrawLine(pos1.x, pos1.y, color, pos2.x, pos2.y, color, t, 1.f);
|
||||
}
|
||||
|
||||
void Text(R7Vec2 pos, const std::string &text, RD7TextFlags flags) {
|
||||
TextClr(pos, text, RenderD7::ThemeActive()->Get(RD7Color_Text), flags);
|
||||
}
|
||||
|
||||
void TextClr(R7Vec2 pos, const std::string &text, unsigned int color,
|
||||
RD7TextFlags flags) {
|
||||
// The Start of the C2D Text Hell
|
||||
if (!RD7I_FNT_VALID()) return;
|
||||
// Check if Theme Loadet
|
||||
if (!ThemeActive()) return;
|
||||
// little patch for a freeze
|
||||
if (text.length() < 1) return;
|
||||
// Variables
|
||||
bool updated_mwh = false;
|
||||
if (rd7i_d7_mwh.x == 0.0f) {
|
||||
rd7i_d7_mwh.x = rd7i_current_screen ? 400 : 320;
|
||||
updated_mwh = true;
|
||||
}
|
||||
if (rd7i_d7_mwh.y == 0.0f) {
|
||||
rd7i_d7_mwh.y = 240;
|
||||
updated_mwh = true;
|
||||
}
|
||||
std::string edit_text = text;
|
||||
if (edit_text.substr(text.length() - 1) != "\n")
|
||||
edit_text.append("\n"); // Add \n to end if not exist
|
||||
int line = 0;
|
||||
|
||||
if (flags & RD7TextFlags_Wrap)
|
||||
edit_text = WrapText(text, rd7i_d7_mwh.x - pos.x);
|
||||
|
||||
while (edit_text.find('\n') != edit_text.npos) {
|
||||
std::string current_line = edit_text.substr(0, edit_text.find('\n'));
|
||||
if (flags & RD7TextFlags_Short)
|
||||
current_line = GetShortedText(current_line, rd7i_d7_mwh.x - pos.x);
|
||||
R7Vec2 newpos = pos;
|
||||
// Check Flags
|
||||
R7Vec2 dim = GetTextDimensions(current_line);
|
||||
if (flags & RD7TextFlags_AlignRight)
|
||||
newpos.x = newpos.x - GetTextDimensions(current_line).x;
|
||||
if (flags & RD7TextFlags_AlignMid) // Offset by inpos
|
||||
newpos.x = (rd7i_d7_mwh.x * 0.5) - (dim.x * 0.5) + pos.x;
|
||||
if (flags & RD7TextFlags_Scroll) { // Scroll Text
|
||||
if (newpos.x + dim.x > rd7i_d7_mwh.x - newpos.x - 10) {
|
||||
if (rd7i_d2_ts.find(current_line) == rd7i_d2_ts.end())
|
||||
rd7i_d2_ts[current_line] = 0;
|
||||
if (rd7i_d2_mln.find(current_line) == rd7i_d2_mln.end())
|
||||
rd7i_d2_mln[current_line] =
|
||||
GetShortedText(current_line, rd7i_d7_mwh.x - newpos.x).length();
|
||||
rd7i_d2_ts[current_line] += rd7i_dtm * 6;
|
||||
if ((int)rd7i_d2_ts[current_line] >= (int)current_line.length()) {
|
||||
rd7i_d2_ts[current_line] = 0.0f;
|
||||
}
|
||||
std::string bcl = current_line;
|
||||
current_line = current_line.substr((int)rd7i_d2_ts[current_line],
|
||||
rd7i_d2_mln[current_line]);
|
||||
if (newpos.x + GetTextDimensions(current_line).x <
|
||||
rd7i_d7_mwh.x - newpos.x)
|
||||
current_line +=
|
||||
"|" + bcl.substr(0, rd7i_d2_ts[bcl] - (int)current_line.length());
|
||||
}
|
||||
}
|
||||
if (rd7_debugging) {
|
||||
RenderD7::Draw2::Rect(newpos, dim, RenderD7::Color::Hex("#ff0000"));
|
||||
}
|
||||
C2D_Text c2dtext;
|
||||
C2D_TextFontParse(&c2dtext, rd7i_d2_fnt, rd7i_text_buffer,
|
||||
current_line.c_str());
|
||||
C2D_TextOptimize(&c2dtext);
|
||||
|
||||
if (flags & RD7TextFlags_Shaddow) // performance Killer xd
|
||||
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x + 1 + (dim.y * line),
|
||||
newpos.y + 1, 0.5, rd7i_d2_txt_size, rd7i_d2_txt_size,
|
||||
RenderD7::ThemeActive()->Get(RD7Color_TextDisabled));
|
||||
|
||||
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x, newpos.y + (dim.y * line),
|
||||
0.5, rd7i_d2_txt_size, rd7i_d2_txt_size, color);
|
||||
edit_text = edit_text.substr(edit_text.find('\n') + 1);
|
||||
line++;
|
||||
}
|
||||
|
||||
if (updated_mwh) rd7i_d7_mwh = R7Vec2(0, 0);
|
||||
}
|
||||
|
||||
void Image(RenderD7::Image *img, const R7Vec2 &pos, const R7Vec2 &scale) {
|
||||
if (img->loaded())
|
||||
C2D_DrawImageAt(img->get(), pos.x, pos.y, 0.5f, nullptr, scale.x, scale.y);
|
||||
}
|
||||
} // namespace Draw2
|
||||
} // namespace RenderD7
|
@ -111,7 +111,7 @@ Image::Image() {
|
||||
|
||||
Image::~Image() { safe_del(); }
|
||||
|
||||
void Image::load(const std::string &path) {
|
||||
void Image::Load(const std::string &path) {
|
||||
// Make sure to cleanup
|
||||
safe_del();
|
||||
ld = false;
|
||||
@ -149,7 +149,7 @@ void Image::load(const std::string &path) {
|
||||
ld = true;
|
||||
}
|
||||
|
||||
void Image::from_nimg(const nimg &image) {
|
||||
void Image::From_NIMG(const nimg &image) {
|
||||
// Make sure to cleanup
|
||||
safe_del();
|
||||
ld = false;
|
||||
@ -164,15 +164,15 @@ void Image::from_nimg(const nimg &image) {
|
||||
ld = true;
|
||||
}
|
||||
|
||||
C2D_Image Image::get() { return img; }
|
||||
C2D_Image &Image::get_ref() { return img; }
|
||||
C2D_Image Image::Get() { return img; }
|
||||
C2D_Image &Image::GetRef() { return img; }
|
||||
|
||||
void Image::set(const C2D_Image &i) {
|
||||
void Image::Set(const C2D_Image &i) {
|
||||
safe_del();
|
||||
img = i;
|
||||
}
|
||||
|
||||
R7Vec2 Image::get_size() {
|
||||
R7Vec2 Image::GetSize() {
|
||||
if (!img.subtex) return R7Vec2(0, 0);
|
||||
return R7Vec2(img.subtex->width, img.subtex->height);
|
||||
}
|
||||
@ -182,5 +182,5 @@ void Image::safe_del() {
|
||||
if (img.tex != nullptr) delete img.tex;
|
||||
}
|
||||
|
||||
bool Image::loaded() { return ld; }
|
||||
bool Image::Loadet() { return ld; }
|
||||
} // namespace RenderD7
|
@ -24,7 +24,6 @@ static RenderD7::Memory::memory_metrics metrics;
|
||||
|
||||
bool rd7_enable_memtrack;
|
||||
|
||||
#ifdef RENDERD7_MEMTRACK
|
||||
void *operator new(size_t size) {
|
||||
void *ptr = malloc(size);
|
||||
if (rd7_enable_memtrack) metrics.t_TotalAllocated += size;
|
||||
@ -41,24 +40,27 @@ int total_size = 0;
|
||||
std::map<void *, size_t> sizes;
|
||||
|
||||
void *operator new[](size_t size) {
|
||||
if (rd7_enable_memtrack) allocations++;
|
||||
if (rd7_enable_memtrack) total_size += size;
|
||||
void *ptr = malloc(size);
|
||||
if (rd7_enable_memtrack) sizes[ptr] = size;
|
||||
if (rd7_enable_memtrack) metrics.t_TotalAllocated += size;
|
||||
if (rd7_enable_memtrack) {
|
||||
allocations++;
|
||||
total_size += size;
|
||||
sizes[ptr] = size;
|
||||
metrics.t_TotalAllocated += size;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void operator delete[](void *ptr) {
|
||||
if (rd7_enable_memtrack) allocations--;
|
||||
if (rd7_enable_memtrack) total_size -= sizes[ptr];
|
||||
if (rd7_enable_memtrack) metrics.t_TotalFreed += sizes[ptr];
|
||||
if (rd7_enable_memtrack) sizes.erase(ptr);
|
||||
if (rd7_enable_memtrack) {
|
||||
allocations--;
|
||||
total_size -= sizes[ptr];
|
||||
metrics.t_TotalFreed += sizes[ptr];
|
||||
sizes.erase(ptr);
|
||||
}
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace RenderD7 {
|
||||
|
||||
namespace Memory {
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/DrawV2.hpp> // Update to Draw2
|
||||
#include <renderd7/Message.hpp>
|
||||
#include <renderd7/Screen.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
#include <vector>
|
||||
|
||||
extern bool rd7_debugging;
|
||||
@ -45,10 +45,10 @@ namespace RenderD7 {
|
||||
float GetDeltaTime(); // Extern from renderd7.cpp
|
||||
|
||||
void ProcessMessages() {
|
||||
float tmp_txt = RenderD7::TextGetSize();
|
||||
RenderD7::TextDefaultSize();
|
||||
float tmp_txt = R2()->GetTextSize();
|
||||
R2()->DefaultTextSize();
|
||||
// Draw in ovl mode
|
||||
RenderD7::OnScreen(Top);
|
||||
R2()->OnScreen(R2Screen_Top);
|
||||
float fol = anim_len - fade_outs;
|
||||
std::reverse(msg_lst.begin(), msg_lst.end());
|
||||
for (size_t i = 0; i < msg_lst.size(); i++) {
|
||||
@ -65,23 +65,17 @@ void ProcessMessages() {
|
||||
200 - (float(msg_lst[i]->animationframe - fade_outs) / fol) * 200;
|
||||
}
|
||||
// Wtf is this function lol
|
||||
RenderD7::ThemeActive()->Set(
|
||||
RD7Color_MessageBackground,
|
||||
RenderD7::Color::RGBA(RD7Color_MessageBackground)
|
||||
.changeA(new_alpha)
|
||||
.toRGBA());
|
||||
RenderD7::ThemeActive()->Set(
|
||||
RD7Color_Text,
|
||||
RenderD7::Color::RGBA(RD7Color_Text2).changeA(new_alpha).toRGBA());
|
||||
RenderD7::Draw2::RFS(
|
||||
pos, R7Vec2(150, 50),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_MessageBackground));
|
||||
RenderD7::Draw2::Text(pos + R7Vec2(5, 1), msg_lst[i]->title);
|
||||
RenderD7::Draw2::Text(pos + R7Vec2(5, 17), msg_lst[i]->message);
|
||||
auto bgc = RenderD7::Color::RGBA(RD7Color_MessageBackground)
|
||||
.changeA(new_alpha)
|
||||
.toRGBA();
|
||||
auto tc =
|
||||
RenderD7::Color::RGBA(RD7Color_Text2).changeA(new_alpha).toRGBA();
|
||||
R2()->AddRect(pos, R7Vec2(150, 50), bgc);
|
||||
R2()->AddText(pos + R7Vec2(5, 1), msg_lst[i]->title, tc);
|
||||
R2()->AddText(pos + R7Vec2(5, 17), msg_lst[i]->message, tc);
|
||||
if (rd7_debugging)
|
||||
RenderD7::Draw2::Text(pos + R7Vec2(155, 1),
|
||||
std::to_string(msg_lst[i]->animationframe));
|
||||
RenderD7::ThemeActive()->UndoAll();
|
||||
R2()->AddText(pos + R7Vec2(155, 1),
|
||||
std::to_string(msg_lst[i]->animationframe), tc);
|
||||
// Why Frameadd? because Message uses int as frame and
|
||||
// It seems that lower 0.5 will be rounded to 0
|
||||
// Why not replace int with float ?
|
||||
@ -103,7 +97,7 @@ void ProcessMessages() {
|
||||
// ReReverse ?? lol
|
||||
// Cause otherwise the Toasts will swap
|
||||
std::reverse(msg_lst.begin(), msg_lst.end());
|
||||
RenderD7::CustomTextSize(tmp_txt);
|
||||
R2()->SetTextSize(tmp_txt);
|
||||
}
|
||||
|
||||
void PushMessage(const Message &msg) {
|
||||
|
@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <renderd7/DrawV2.hpp>
|
||||
#include <renderd7/FunctionTrace.hpp>
|
||||
#include <renderd7/Hid.hpp>
|
||||
#include <renderd7/Overlays.hpp>
|
||||
@ -286,22 +285,22 @@ namespace RenderD7 {
|
||||
Ovl_Ftrace::Ovl_Ftrace(bool* is_enabled) { i_is_enabled = is_enabled; }
|
||||
|
||||
void Ovl_Ftrace::Draw(void) const {
|
||||
float tmp_txt = RenderD7::TextGetSize();
|
||||
RenderD7::TextDefaultSize();
|
||||
RenderD7::OnScreen(Top);
|
||||
float tmp_txt = R2()->GetTextSize();
|
||||
R2()->DefaultTextSize();
|
||||
R2()->OnScreen(R2Screen_Top);
|
||||
RenderD7::Color::RGBA bg(RD7Color_Background);
|
||||
bg.changeA(150);
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 20), bg.toRGBA());
|
||||
R2()->AddRect(R7Vec2(0, 0), R7Vec2(400, 20), bg.toRGBA());
|
||||
|
||||
std::vector<RenderD7::Ftrace::FTRes> dt;
|
||||
for (auto const& it : RenderD7::Ftrace::rd7_traces)
|
||||
if (it.second.is_ovl && dt.size() < 10) dt.push_back(it.second);
|
||||
for (size_t i = 0; i < (dt.size() < 10 ? dt.size() : 10); i++) {
|
||||
RenderD7::Draw2::Text(R7Vec2(5, 30 + i * 15), dt[i].func_name);
|
||||
RenderD7::Draw2::Text(R7Vec2(295, 30 + i * 15),
|
||||
RenderD7::MsTimeFmt(dt[i].time_of));
|
||||
R2()->AddText(R7Vec2(5, 30 + i * 15), dt[i].func_name, RD7Color_Text);
|
||||
R2()->AddText(R7Vec2(295, 30 + i * 15), RenderD7::MsTimeFmt(dt[i].time_of),
|
||||
RD7Color_Text);
|
||||
}
|
||||
RenderD7::CustomTextSize(tmp_txt);
|
||||
R2()->SetTextSize(tmp_txt);
|
||||
}
|
||||
|
||||
void Ovl_Ftrace::Logic() {
|
||||
@ -318,16 +317,12 @@ Ovl_Metrik::Ovl_Metrik(bool* is_enabled, bool* screen, uint32_t* mt_color,
|
||||
}
|
||||
|
||||
void Ovl_Metrik::Draw(void) const {
|
||||
float tmp_txt = RenderD7::TextGetSize();
|
||||
RenderD7::TextDefaultSize();
|
||||
if (i_screen[0]) {
|
||||
RenderD7::OnScreen(Bottom);
|
||||
} else {
|
||||
RenderD7::OnScreen(Top);
|
||||
}
|
||||
float tmp_txt = R2()->GetTextSize();
|
||||
R2()->DefaultTextSize();
|
||||
R2()->OnScreen(i_screen[0] ? R2Screen_Bottom : R2Screen_Top);
|
||||
std::string info =
|
||||
"RenderD7 " + std::string(RENDERD7VSTRING) + " Debug Overlay";
|
||||
float dim_y = RenderD7::GetTextDimensions(info).y;
|
||||
float dim_y = R2()->GetTextDimensions(info).y;
|
||||
float infoy = 240 - dim_y;
|
||||
mt_fps = "FPS: " + RenderD7::GetFramerate();
|
||||
if (rd7i_idb_running) mt_fps += " IDB -> ON";
|
||||
@ -346,41 +341,54 @@ void Ovl_Metrik::Draw(void) const {
|
||||
mt_tbs =
|
||||
"TextBuf: " + std::to_string(C2D_TextBufGetNumGlyphs(rd7i_text_buffer)) +
|
||||
"/4096";
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 0), RenderD7::GetTextDimensions(mt_fps),
|
||||
i_mt_color[0]);
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 50), RenderD7::GetTextDimensions(mt_cpu),
|
||||
i_mt_color[0]);
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 50 + dim_y * 1),
|
||||
RenderD7::GetTextDimensions(mt_gpu), i_mt_color[0]);
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 50 + dim_y * 2),
|
||||
RenderD7::GetTextDimensions(mt_cmd), i_mt_color[0]);
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 50 + dim_y * 3),
|
||||
RenderD7::GetTextDimensions(mt_lfr), i_mt_color[0]);
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 50 + dim_y * 4),
|
||||
RenderD7::GetTextDimensions(mt_tbs), i_mt_color[0]);
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, infoy), RenderD7::GetTextDimensions(info),
|
||||
i_mt_color[0]);
|
||||
RenderD7::ThemeActive()->Set(RD7Color_Text, i_txt_color[0]);
|
||||
RenderD7::Draw2::Text(R7Vec2(0, 0), mt_fps);
|
||||
RenderD7::Draw2::Text(R7Vec2(0, 50), mt_cpu);
|
||||
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 1), mt_gpu);
|
||||
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 2), mt_cmd);
|
||||
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 3), mt_lfr);
|
||||
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 4), mt_tbs);
|
||||
RenderD7::Draw2::Text(R7Vec2(0, infoy), info);
|
||||
RenderD7::ThemeActive()->Undo();
|
||||
if (rd7_enable_memtrack)
|
||||
mt_mem = "Mem: " + RenderD7::FormatBytes(RenderD7::Memory::GetCurrent()) +
|
||||
" | " +
|
||||
RenderD7::FormatBytes(RenderD7::Memory::GetTotalAllocated()) +
|
||||
" | " + RenderD7::FormatBytes(RenderD7::Memory::GetTotalFreed());
|
||||
R2()->AddRect(R7Vec2(0, 0), R2()->GetTextDimensions(mt_fps),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2()->AddRect(R7Vec2(0, 50), R2()->GetTextDimensions(mt_cpu),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2()->AddRect(R7Vec2(0, 50 + dim_y * 1), R2()->GetTextDimensions(mt_gpu),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2()->AddRect(R7Vec2(0, 50 + dim_y * 2), R2()->GetTextDimensions(mt_cmd),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2()->AddRect(R7Vec2(0, 50 + dim_y * 3), R2()->GetTextDimensions(mt_lfr),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2()->AddRect(R7Vec2(0, 50 + dim_y * 4), R2()->GetTextDimensions(mt_tbs),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
if (rd7_enable_memtrack)
|
||||
R2()->AddRect(R7Vec2(0, 50 + dim_y * 5), R2()->GetTextDimensions(mt_mem),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2()->AddRect(R7Vec2(0, infoy), R2()->GetTextDimensions(info),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2()->AddText(R7Vec2(0, 0), mt_fps, (unsigned int)i_txt_color[0]);
|
||||
R2()->AddText(R7Vec2(0, 50), mt_cpu, (unsigned int)i_txt_color[0]);
|
||||
R2()->AddText(R7Vec2(0, 50 + dim_y * 1), mt_gpu,
|
||||
(unsigned int)i_txt_color[0]);
|
||||
R2()->AddText(R7Vec2(0, 50 + dim_y * 2), mt_cmd,
|
||||
(unsigned int)i_txt_color[0]);
|
||||
R2()->AddText(R7Vec2(0, 50 + dim_y * 3), mt_lfr,
|
||||
(unsigned int)i_txt_color[0]);
|
||||
R2()->AddText(R7Vec2(0, 50 + dim_y * 4), mt_tbs,
|
||||
(unsigned int)i_txt_color[0]);
|
||||
if (rd7_enable_memtrack)
|
||||
R2()->AddText(R7Vec2(0, 50 + dim_y * 5), mt_mem,
|
||||
(unsigned int)i_txt_color[0]);
|
||||
R2()->AddText(R7Vec2(0, infoy), info, (unsigned int)i_txt_color[0]);
|
||||
|
||||
// Force Bottom (Debug Touchpos)
|
||||
RenderD7::OnScreen(Bottom);
|
||||
R2()->OnScreen(R2Screen_Bottom);
|
||||
if (Hid::IsEvent("touch", Hid::Held)) {
|
||||
RenderD7::Draw2::Line(R7Vec2(Hid::GetTouchPosition().x, 0),
|
||||
R7Vec2(Hid::GetTouchPosition().x, 240),
|
||||
RenderD7::Color::Hex("#ff0000"));
|
||||
RenderD7::Draw2::Line(R7Vec2(0, Hid::GetTouchPosition().y),
|
||||
R7Vec2(320, Hid::GetTouchPosition().y),
|
||||
RenderD7::Color::Hex("#ff0000"));
|
||||
/*R2()->AddLine(R7Vec2(Hid::GetTouchPosition().x, 0),
|
||||
R7Vec2(Hid::GetTouchPosition().x, 240),
|
||||
RenderD7::Color::Hex("#ff0000"));
|
||||
R2()->AddLine(R7Vec2(0, Hid::GetTouchPosition().y),
|
||||
R7Vec2(320, Hid::GetTouchPosition().y),
|
||||
RenderD7::Color::Hex("#ff0000"));*/
|
||||
}
|
||||
RenderD7::CustomTextSize(tmp_txt);
|
||||
R2()->SetTextSize(tmp_txt);
|
||||
}
|
||||
|
||||
void Ovl_Metrik::Logic() {
|
||||
@ -406,8 +414,8 @@ Ovl_Keyboard::~Ovl_Keyboard() {
|
||||
}
|
||||
|
||||
void Ovl_Keyboard::Draw(void) const {
|
||||
float tmp_txt = RenderD7::TextGetSize();
|
||||
RenderD7::TextDefaultSize();
|
||||
float tmp_txt = R2()->GetTextSize();
|
||||
R2()->DefaultTextSize();
|
||||
if (ft3 > 5) RenderD7::Hid::Unlock();
|
||||
auto key_table =
|
||||
(type == RD7Keyboard_Numpad) ? keyboard_layout_num : keyboard_layout;
|
||||
@ -415,23 +423,18 @@ void Ovl_Keyboard::Draw(void) const {
|
||||
key_table = keyboard_layout_caps;
|
||||
else if (mode == 2)
|
||||
key_table = keyboard_layout_shift;
|
||||
RenderD7::OnScreen(Top);
|
||||
RenderD7::Draw2::RFS(
|
||||
R7Vec2(0, 0), R7Vec2(400, 240),
|
||||
RenderD7::Color::RGBA(RD7Color_FrameBg).changeA(150).toRGBA());
|
||||
RenderD7::OnScreen(Bottom);
|
||||
RenderD7::Draw2::RFS(
|
||||
R7Vec2(0, 0), R7Vec2(320, 112),
|
||||
RenderD7::Color::RGBA(RD7Color_FrameBg).changeA(150).toRGBA());
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 112), R7Vec2(320, 128),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_FrameBg));
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 112), R7Vec2(320, 20),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_Header));
|
||||
RenderD7::ThemeActive()->TextBy(RD7Color_Header);
|
||||
RenderD7::Draw2::Text(R7Vec2(5, 114), "> " + *typed_text);
|
||||
RenderD7::ThemeActive()->Undo();
|
||||
R2()->OnScreen(R2Screen_Top);
|
||||
R2()->AddRect(R7Vec2(0, 0), R7Vec2(400, 240),
|
||||
RenderD7::Color::RGBA(RD7Color_FrameBg).changeA(150).toRGBA());
|
||||
R2()->OnScreen(R2Screen_Bottom);
|
||||
R2()->AddRect(R7Vec2(0, 0), R7Vec2(320, 112),
|
||||
RenderD7::Color::RGBA(RD7Color_FrameBg).changeA(150).toRGBA());
|
||||
R2()->AddRect(R7Vec2(0, 112), R7Vec2(320, 128), RD7Color_FrameBg);
|
||||
R2()->AddRect(R7Vec2(0, 112), R7Vec2(320, 20), RD7Color_Header);
|
||||
R2()->AddText(R7Vec2(5, 114), "> " + *typed_text,
|
||||
RenderD7::ThemeActive()->AutoText(RD7Color_Header));
|
||||
for (auto const& it : key_table) {
|
||||
R7Vec2 txtdim = RenderD7::GetTextDimensions(it.disp);
|
||||
R7Vec2 txtdim = R2()->GetTextDimensions(it.disp);
|
||||
R7Vec2 txtpos = R7Vec2(it.pos.x + it.size.x * 0.5 - txtdim.x * 0.5,
|
||||
it.pos.y + it.size.y * 0.5 - txtdim.y * 0.5);
|
||||
RD7Color btn = RD7Color_Button;
|
||||
@ -466,13 +469,11 @@ void Ovl_Keyboard::Draw(void) const {
|
||||
UI7_InBox(RenderD7::Hid::GetTouchPosition(), it.pos, it.size)) {
|
||||
btn = RD7Color_ButtonHovered;
|
||||
}
|
||||
RenderD7::Draw2::RFS(it.pos, it.size, RenderD7::ThemeActive()->Get(btn));
|
||||
RenderD7::ThemeActive()->TextBy(btn);
|
||||
RenderD7::Draw2::Text(txtpos, it.disp);
|
||||
RenderD7::ThemeActive()->Undo();
|
||||
R2()->AddRect(it.pos, it.size, btn);
|
||||
R2()->AddText(txtpos, it.disp, RenderD7::ThemeActive()->AutoText(btn));
|
||||
}
|
||||
if (ft3 > 5) RenderD7::Hid::Lock();
|
||||
RenderD7::CustomTextSize(tmp_txt);
|
||||
R2()->SetTextSize(tmp_txt);
|
||||
}
|
||||
|
||||
void Ovl_Keyboard::Logic() {
|
||||
|
@ -1,7 +1,260 @@
|
||||
/**
|
||||
* 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 <citro2d.h>
|
||||
|
||||
#include <renderd7/Render2.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
R2Base::R2Base() {
|
||||
for (int i = 0; i < 2; i++) this->font[i] = Font::New();
|
||||
R2Base::R2Base() { this->font = Font::New(); }
|
||||
|
||||
void R2Base::SetFont(Font::Ref fnt) {
|
||||
if (!fnt) return;
|
||||
this->font = fnt;
|
||||
}
|
||||
|
||||
Font::Ref R2Base::GetFont() { return this->font; }
|
||||
|
||||
void R2Base::DefaultFont() { this->font->Unload(); }
|
||||
|
||||
void R2Base::DrawNextLined() { this->next_lined = true; }
|
||||
|
||||
void R2Base::OnScreen(R2Screen screen) {
|
||||
if (screen < 0 || screen > R2Screen_Top) return;
|
||||
this->current_screen = screen;
|
||||
}
|
||||
|
||||
void R2Base::SetTextSize(float szs) { text_size = szs; }
|
||||
|
||||
void R2Base::DefaultTextSize() { text_size = default_text_size; }
|
||||
|
||||
float R2Base::GetTextSize() { return text_size; }
|
||||
|
||||
R2Screen R2Base::GetCurrentScreen() { return current_screen; }
|
||||
|
||||
R7Vec2 R2Base::GetTextDimensions(const std::string& text) {
|
||||
C2D_TextBufClear(rd7i_d2_dimbuf);
|
||||
float w = 0, h = 0;
|
||||
C2D_Text c2dtext;
|
||||
C2D_TextFontParse(&c2dtext, font->Ptr(), rd7i_d2_dimbuf, text.c_str());
|
||||
C2D_TextGetDimensions(&c2dtext, this->text_size, this->text_size, &w, &h);
|
||||
return R7Vec2(w, h);
|
||||
}
|
||||
|
||||
// Main Processing of Draw Calls
|
||||
void R2Base::Process() {
|
||||
for (auto& it : this->commands) {
|
||||
if (it.type <= 0 || it.type > 3) {
|
||||
// Skip
|
||||
continue;
|
||||
}
|
||||
C2D_SceneBegin(it.Screen ? rd7_top : rd7_bottom);
|
||||
if (it.type == 1) {
|
||||
// Rect
|
||||
if (it.lined) {
|
||||
C2D_DrawLine(it.pos.x, it.pos.y, it.clr, it.pos.x + it.pszs.x, it.pos.y,
|
||||
it.clr, 1.f, 0.5f);
|
||||
C2D_DrawLine(it.pos.x, it.pos.y, it.clr, it.pos.x, it.pos.y + it.pszs.y,
|
||||
it.clr, 1.f, 0.5f);
|
||||
C2D_DrawLine(it.pos.x + it.pszs.x, it.pos.y, it.clr,
|
||||
it.pos.x + it.pszs.x, it.pos.y + it.pszs.y, it.clr, 1.f,
|
||||
0.5f);
|
||||
C2D_DrawLine(it.pos.x, it.pos.y + it.pszs.y, it.clr,
|
||||
it.pos.x + it.pszs.x, it.pos.y + it.pszs.y, it.clr, 1.f,
|
||||
0.5f);
|
||||
} else {
|
||||
C2D_DrawRectSolid(it.pos.x, it.pos.y, 0.5, it.pszs.x, it.pszs.y,
|
||||
it.clr);
|
||||
}
|
||||
} else if (it.type == 2) {
|
||||
// Triangle
|
||||
if (it.lined) {
|
||||
C2D_DrawLine(it.pos.x, it.pos.y, it.clr, it.pszs.x, it.pszs.y, it.clr,
|
||||
1, 0.5f);
|
||||
C2D_DrawLine(it.pos.x, it.pos.y, it.clr, it.ap.x, it.ap.y, it.clr, 1,
|
||||
0.5f);
|
||||
C2D_DrawLine(it.pszs.x, it.pszs.y, it.clr, it.ap.x, it.ap.y, it.clr, 1,
|
||||
0.5f);
|
||||
} else {
|
||||
C2D_DrawTriangle(it.pos.x, it.pos.y, it.clr, it.pszs.x, it.pszs.y,
|
||||
it.clr, it.ap.x, it.ap.y, it.clr, 0.5);
|
||||
}
|
||||
} else if (it.type == 3) {
|
||||
// Text
|
||||
// little patch for a freeze
|
||||
if (it.text.length() < 1) continue;
|
||||
if (it.pszs.x == 0.0f) {
|
||||
it.pszs.x = it.Screen == R2Screen_Top ? 400 : 320;
|
||||
}
|
||||
if (it.pszs.y == 0.0f) {
|
||||
it.pszs.y = 240;
|
||||
}
|
||||
std::string edit_text = it.text;
|
||||
if (edit_text.substr(it.text.length() - 1) != "\n")
|
||||
edit_text.append("\n"); // Add \n to end if not exist
|
||||
int line = 0;
|
||||
|
||||
// if (it.flags & RD7TextFlags_Wrap)
|
||||
// edit_text = WrapText(text, rd7i_d7_mwh.x - pos.x);
|
||||
|
||||
while (edit_text.find('\n') != edit_text.npos) {
|
||||
std::string current_line = edit_text.substr(0, edit_text.find('\n'));
|
||||
// if (it.flags & RD7TextFlags_Short)
|
||||
// current_line = GetShortedText(current_line, it.pszs.x - it.pos.x);
|
||||
R7Vec2 newpos = it.pos;
|
||||
// Check Flags
|
||||
R7Vec2 dim = this->GetTextDimensions(current_line);
|
||||
if (it.flags & RD7TextFlags_AlignRight) newpos.x = newpos.x - dim.x;
|
||||
if (it.flags & RD7TextFlags_AlignMid) // Offset by inpos
|
||||
newpos.x = (it.pszs.x * 0.5) - (dim.x * 0.5) + it.pos.x;
|
||||
if (it.flags & RD7TextFlags_Scroll) { // Scroll Text
|
||||
// Look into Old Draw2 Code
|
||||
// TODO: Create Code for this
|
||||
}
|
||||
if (rd7_debugging) {
|
||||
this->DrawNextLined();
|
||||
this->AddRect(newpos, dim, 0xff0000ff);
|
||||
}
|
||||
C2D_Text c2dtext;
|
||||
C2D_TextFontParse(&c2dtext, font->Ptr(), rd7i_text_buffer,
|
||||
current_line.c_str());
|
||||
C2D_TextOptimize(&c2dtext);
|
||||
|
||||
if (it.flags & RD7TextFlags_Shaddow) // performance Killer xd
|
||||
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x + 1 + (dim.y * line),
|
||||
newpos.y + 1, 0.5, this->text_size, this->text_size,
|
||||
RenderD7::ThemeActive()->Get(RD7Color_TextDisabled));
|
||||
|
||||
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x,
|
||||
newpos.y + (dim.y * line), 0.5, this->text_size,
|
||||
this->text_size, it.clr);
|
||||
edit_text = edit_text.substr(edit_text.find('\n') + 1);
|
||||
line++;
|
||||
}
|
||||
}
|
||||
}
|
||||
this->commands.clear();
|
||||
}
|
||||
|
||||
void R2Base::AddRect(R7Vec2 pos, R7Vec2 size, RD7Color clr) {
|
||||
R2Cmd cmd;
|
||||
cmd.pos = pos;
|
||||
cmd.pszs = size;
|
||||
cmd.clr = RenderD7::ThemeActive()->Get(clr);
|
||||
cmd.type = 1; // Rect
|
||||
// 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::AddRect(R7Vec2 pos, R7Vec2 size, unsigned int clr) {
|
||||
R2Cmd cmd;
|
||||
cmd.pos = pos;
|
||||
cmd.pszs = size;
|
||||
cmd.clr = clr;
|
||||
cmd.type = 1; // Rect
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd.Screen = current_screen;
|
||||
if (this->next_lined) {
|
||||
cmd.lined = true;
|
||||
this->next_lined = false;
|
||||
}
|
||||
this->commands.push_back(cmd);
|
||||
}
|
||||
|
||||
void R2Base::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, RD7Color clr) {
|
||||
R2Cmd cmd;
|
||||
cmd.pos = pos0;
|
||||
cmd.pszs = pos1;
|
||||
cmd.ap = pos2;
|
||||
cmd.clr = RenderD7::ThemeActive()->Get(clr);
|
||||
cmd.type = 2; // Triangle
|
||||
// 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::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2,
|
||||
unsigned int clr) {
|
||||
R2Cmd cmd;
|
||||
cmd.pos = pos0;
|
||||
cmd.pszs = pos1;
|
||||
cmd.ap = pos2;
|
||||
cmd.clr = clr;
|
||||
cmd.type = 2; // Triangle
|
||||
// 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::AddText(R7Vec2 pos, const std::string& text, RD7Color clr,
|
||||
RD7TextFlags flags, R7Vec2 tmb) {
|
||||
R2Cmd cmd;
|
||||
cmd.pos = pos;
|
||||
cmd.pszs = tmb;
|
||||
cmd.clr = RenderD7::ThemeActive()->Get(clr);
|
||||
cmd.flags = flags;
|
||||
cmd.text = text;
|
||||
cmd.type = 3; // Text
|
||||
// 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::AddText(R7Vec2 pos, const std::string& text, unsigned int clr,
|
||||
RD7TextFlags flags, R7Vec2 tmb) {
|
||||
R2Cmd cmd;
|
||||
cmd.pos = pos;
|
||||
cmd.pszs = tmb;
|
||||
cmd.clr = clr;
|
||||
cmd.flags = flags;
|
||||
cmd.text = text;
|
||||
cmd.type = 3; // Text
|
||||
// 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
|
@ -18,9 +18,10 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <renderd7/Sound2.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
#include <renderd7/sound.hpp>
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
||||
// Reference: http://yannesposito.com/Scratch/en/blog/2010-10-14-Fun-with-wav/
|
||||
@ -40,7 +41,7 @@ typedef struct _WavHeader {
|
||||
} WavHeader;
|
||||
static_assert(sizeof(WavHeader) == 44, "WavHeader size is not 44 bytes.");
|
||||
|
||||
sound::sound(const string &path, int channel, bool toloop) {
|
||||
Sound::Sound(const string &path, int channel, bool toloop) {
|
||||
if (rd7i_is_ndsp) {
|
||||
ndspSetOutputMode(NDSP_OUTPUT_STEREO);
|
||||
ndspSetOutputCount(2); // Num of buffers
|
||||
@ -119,7 +120,7 @@ sound::sound(const string &path, int channel, bool toloop) {
|
||||
}
|
||||
}
|
||||
|
||||
sound::~sound() {
|
||||
Sound::~Sound() {
|
||||
if (rd7i_is_ndsp) {
|
||||
waveBuf.data_vaddr = 0;
|
||||
waveBuf.nsamples = 0;
|
||||
@ -133,7 +134,7 @@ sound::~sound() {
|
||||
}
|
||||
}
|
||||
|
||||
void sound::play() {
|
||||
void Sound::Play() {
|
||||
if (rd7i_is_ndsp) {
|
||||
if (!data) return;
|
||||
DSP_FlushDataCache(data, dataSize);
|
||||
@ -141,7 +142,7 @@ void sound::play() {
|
||||
}
|
||||
}
|
||||
|
||||
void sound::stop() {
|
||||
void Sound::Stop() {
|
||||
if (rd7i_is_ndsp) {
|
||||
if (!data) return;
|
||||
ndspChnWaveBufClear(chnl);
|
@ -38,13 +38,32 @@ void RenderD7::Sprite::SetRotation(float rotation) {
|
||||
void RenderD7::Sprite::Rotate(float speed) {
|
||||
C2D_SpriteRotateDegrees(&this->sprite, speed);
|
||||
}
|
||||
float RenderD7::Sprite::getHeight() { return this->sprite.params.pos.h; }
|
||||
float RenderD7::Sprite::getWidth() { return this->sprite.params.pos.w; }
|
||||
float RenderD7::Sprite::getPosX() { return this->sprite.params.pos.x; }
|
||||
float RenderD7::Sprite::getPosY() { return this->sprite.params.pos.y; }
|
||||
float RenderD7::Sprite::GetHeight() { return GetSize().x; }
|
||||
float RenderD7::Sprite::GetWidth() { return GetSize().y; }
|
||||
float RenderD7::Sprite::GetPosX() { return GetPos().x; }
|
||||
float RenderD7::Sprite::GetPosY() { return GetPos().y; }
|
||||
|
||||
void RenderD7::Sprite::FromImage(RenderD7::Image *img) {
|
||||
C2D_SpriteFromImage(&this->sprite, img->get());
|
||||
R7Vec2 RenderD7::Sprite::GetPos() {
|
||||
return R7Vec2(this->sprite.params.pos.x, this->sprite.params.pos.y);
|
||||
}
|
||||
|
||||
R7Vec2 RenderD7::Sprite::GetSize() {
|
||||
return R7Vec2(this->sprite.params.pos.w, this->sprite.params.pos.h);
|
||||
}
|
||||
|
||||
void RenderD7::Sprite::SetPos(R7Vec2 pos) {
|
||||
C2D_SpriteSetPos(&this->sprite, pos.x, pos.y);
|
||||
}
|
||||
|
||||
void RenderD7::Sprite::SetScale(R7Vec2 scale) {
|
||||
C2D_SpriteScale(&this->sprite, scale.x, scale.y);
|
||||
}
|
||||
void RenderD7::Sprite::SetRotCenter(R7Vec2 percentage) {
|
||||
C2D_SpriteSetCenter(&this->sprite, percentage.x, percentage.y);
|
||||
}
|
||||
|
||||
void RenderD7::Sprite::FromImage(RenderD7::Image::Ref img) {
|
||||
C2D_SpriteFromImage(&this->sprite, img->Get());
|
||||
}
|
||||
|
||||
void RenderD7::Sprite::SetScale(float x, float y) {
|
||||
|
102
source/UI7.cpp
102
source/UI7.cpp
@ -18,12 +18,12 @@
|
||||
|
||||
#include <ctime>
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/DrawV2.hpp>
|
||||
#include <renderd7/Hid.hpp>
|
||||
#include <renderd7/Message.hpp>
|
||||
#include <renderd7/Overlays.hpp>
|
||||
#include <renderd7/UI7.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
template <typename T>
|
||||
@ -39,9 +39,7 @@ inline T d7min(T a, T b) {
|
||||
// As the 3ds doesn't support std::chrono
|
||||
#ifdef __3DS__
|
||||
/// @brief 3ds System Ticks per milli second
|
||||
/// Already defined in FTrace ik but
|
||||
/// I Want to make UI7 and Draw2 more
|
||||
/// Independent of the main RenderD7 api
|
||||
/// Already defined in FTrace ik
|
||||
#define TICKS_PER_MSEC 268111.856
|
||||
#include <3ds.h>
|
||||
#define __get_time() (float)svcGetSystemTick() / (float)TICKS_PER_MSEC
|
||||
@ -106,20 +104,16 @@ class DrawCmd {
|
||||
if (type == DrawCmdType_Skip) {
|
||||
return;
|
||||
}
|
||||
RenderD7::OnScreen(screen ? Top : Bottom);
|
||||
RenderD7::R2()->OnScreen(screen ? R2Screen_Top : R2Screen_Bottom);
|
||||
if (type == DrawCmdType_Rect) {
|
||||
RenderD7::Draw2::RFS(R7Vec2(rect.x, rect.y), R7Vec2(rect.z, rect.w), clr);
|
||||
RenderD7::R2()->AddRect(R7Vec2(rect.x, rect.y), R7Vec2(rect.z, rect.w),
|
||||
clr);
|
||||
} else if (type == DrawCmdType_Triangle) {
|
||||
RenderD7::Draw2::TriangleSolid(R7Vec2(rect.x, rect.y),
|
||||
R7Vec2(rect.z, rect.w), add_coords, clr);
|
||||
RenderD7::R2()->AddTriangle(R7Vec2(rect.x, rect.y),
|
||||
R7Vec2(rect.z, rect.w), add_coords, clr);
|
||||
} else if (type == DrawCmdType_Text) {
|
||||
if (text_box.x || text_box.y) {
|
||||
RenderD7::TextMaxBox(text_box);
|
||||
}
|
||||
RenderD7::Draw2::TextClr(R7Vec2(rect.x, rect.y), text, clr, text_flags);
|
||||
if (text_box.x || text_box.y) {
|
||||
RenderD7::TextDefaultBox();
|
||||
}
|
||||
RenderD7::R2()->AddText(R7Vec2(rect.x, rect.y), text, clr, text_flags,
|
||||
text_box);
|
||||
} else if (type == DrawCmdType_Debug) {
|
||||
Debug();
|
||||
}
|
||||
@ -127,31 +121,33 @@ class DrawCmd {
|
||||
void Debug() {
|
||||
RenderD7::OnScreen(screen ? Top : Bottom);
|
||||
if (stype == DrawCmdType_Skip && type != DrawCmdType_Debug) return;
|
||||
// auto color = (clr == -1 ? ovr_clr : RenderD7::ThemeActive()->Get(clr));
|
||||
if (stype == DrawCmdType_Rect) {
|
||||
RenderD7::Draw2::TriangleLined(
|
||||
R7Vec2(rect.x, rect.y), R7Vec2(rect.x + rect.z, rect.y),
|
||||
R7Vec2(rect.x, rect.y + rect.w), 0xff0000ff);
|
||||
RenderD7::Draw2::TriangleLined(R7Vec2(rect.x + rect.z, rect.y + rect.w),
|
||||
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.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);
|
||||
} else if (stype == DrawCmdType_Triangle) {
|
||||
RenderD7::Draw2::TriangleLined(R7Vec2(rect.x, rect.y),
|
||||
R7Vec2(rect.z, rect.w), add_coords,
|
||||
0xff00ff00);
|
||||
RenderD7::R2()->DrawNextLined();
|
||||
RenderD7::R2()->AddTriangle(R7Vec2(rect.x, rect.y),
|
||||
R7Vec2(rect.z, rect.w), add_coords,
|
||||
0xff00ff00);
|
||||
} else if (stype == DrawCmdType_Text) {
|
||||
auto szs = RenderD7::GetTextDimensions(text);
|
||||
auto szs = RenderD7::R2()->GetTextDimensions(text);
|
||||
if (text_flags & RD7TextFlags_AlignRight) {
|
||||
rect.x -= szs.x;
|
||||
}
|
||||
RenderD7::Draw2::TriangleLined(
|
||||
R7Vec2(rect.x, rect.y), R7Vec2(rect.x + szs.x, rect.y),
|
||||
R7Vec2(rect.x, rect.y + szs.y), 0xff00ffff);
|
||||
RenderD7::Draw2::TriangleLined(R7Vec2(rect.x + szs.x, rect.y + szs.y),
|
||||
R7Vec2(rect.x + szs.x, rect.y),
|
||||
R7Vec2(rect.x, rect.y + szs.y),
|
||||
0xff00ffff);
|
||||
RenderD7::R2()->DrawNextLined();
|
||||
RenderD7::R2()->AddTriangle(R7Vec2(rect.x, rect.y),
|
||||
R7Vec2(rect.x + szs.x, rect.y),
|
||||
R7Vec2(rect.x, rect.y + szs.y), 0xff00ffff);
|
||||
RenderD7::R2()->DrawNextLined();
|
||||
RenderD7::R2()->AddTriangle(R7Vec2(rect.x + szs.x, rect.y + szs.y),
|
||||
R7Vec2(rect.x + szs.x, rect.y),
|
||||
R7Vec2(rect.x, rect.y + szs.y), 0xff00ffff);
|
||||
}
|
||||
}
|
||||
RD7_SMART_CTOR(DrawCmd)
|
||||
@ -469,7 +465,7 @@ float GetDeltaTime() {
|
||||
bool Button(const std::string &label, R7Vec2 size) {
|
||||
bool ret = false;
|
||||
if (!UI7CtxValidate()) return ret;
|
||||
R7Vec2 textdim = RenderD7::GetTextDimensions(label);
|
||||
R7Vec2 textdim = RenderD7::R2()->GetTextDimensions(label);
|
||||
if (size.x == 0) {
|
||||
size.x = textdim.x + 8;
|
||||
}
|
||||
@ -509,9 +505,9 @@ bool Button(const std::string &label, R7Vec2 size) {
|
||||
|
||||
void Checkbox(const std::string &label, bool &c) {
|
||||
if (!UI7CtxValidate()) return;
|
||||
float sv = (RenderD7::TextGetSize() * 40) * 0.9;
|
||||
float sv = (RenderD7::R2()->GetTextSize() * 40) * 0.9;
|
||||
R7Vec2 cbs = R7Vec2(sv, sv);
|
||||
R7Vec2 txtdim = RenderD7::GetTextDimensions(label);
|
||||
R7Vec2 txtdim = RenderD7::R2()->GetTextDimensions(label);
|
||||
R7Vec2 inp = cbs + R7Vec2(txtdim.x + 5, 0);
|
||||
RD7Color bg = RD7Color_FrameBg;
|
||||
|
||||
@ -550,7 +546,7 @@ void Checkbox(const std::string &label, bool &c) {
|
||||
|
||||
void Label(const std::string &label, RD7TextFlags flags) {
|
||||
if (!UI7CtxValidate()) return;
|
||||
R7Vec2 textdim = RenderD7::GetTextDimensions(label);
|
||||
R7Vec2 textdim = RenderD7::R2()->GetTextDimensions(label);
|
||||
R7Vec2 pos = GetCursorPos();
|
||||
auto upos = pos;
|
||||
// Remove some y offset cause texts have some offset
|
||||
@ -564,7 +560,7 @@ void Label(const std::string &label, RD7TextFlags flags) {
|
||||
return;
|
||||
}
|
||||
|
||||
float tbh = RenderD7::TextGetSize() * 40;
|
||||
float tbh = RenderD7::R2()->GetTextSize() * 40;
|
||||
auto &list =
|
||||
(upos.y + textdim.y < tbh) ? ui7_ctx->cm->front : ui7_ctx->cm->main;
|
||||
|
||||
@ -601,28 +597,28 @@ void Progressbar(float value) {
|
||||
}
|
||||
}
|
||||
|
||||
void Image(RenderD7::Image *img) {
|
||||
void Image(RenderD7::Image::Ref img) {
|
||||
if (!UI7CtxValidate()) return;
|
||||
R7Vec2 pos = GetCursorPos();
|
||||
UI7CtxCursorMove(R7Vec2(img->get_size().x, img->get_size().y));
|
||||
UI7CtxCursorMove(R7Vec2(img->GetSize().x, img->GetSize().y));
|
||||
|
||||
if (ui7_ctx->cm->enable_scrolling) {
|
||||
R7Vec2 pb = pos;
|
||||
pos -= R7Vec2(0, ui7_ctx->cm->scrolling_offset);
|
||||
if (pos.y > 240 || (pos.y + img->get_size().y < ui7_ctx->cm->tbh - 5 &&
|
||||
if (pos.y > 240 || (pos.y + img->GetSize().y < ui7_ctx->cm->tbh - 5 &&
|
||||
pb.y > ui7_ctx->cm->tbh))
|
||||
return;
|
||||
}
|
||||
|
||||
RenderD7::Draw2::Image(img, pos);
|
||||
// RenderD7::Draw2::Image(img, pos);
|
||||
}
|
||||
|
||||
void BrowserList(const std::vector<std::string> &entrys, int &selection,
|
||||
RD7TextFlags txtflags, R7Vec2 size, int max_entrys) {
|
||||
if (!UI7CtxValidate()) return;
|
||||
if (selection < 0) return;
|
||||
float tmp_txt = RenderD7::TextGetSize();
|
||||
RenderD7::TextDefaultSize();
|
||||
float tmp_txt = RenderD7::R2()->GetTextSize();
|
||||
RenderD7::R2()->DefaultTextSize();
|
||||
R7Vec2 pos = GetCursorPos();
|
||||
if (pos.y + 15 * max_entrys > 230) max_entrys = (int)((230 - pos.y) / 15);
|
||||
if (size.x == 0) size.x = (rd7i_current_screen ? 400 : 320) - (pos.x * 2);
|
||||
@ -656,15 +652,15 @@ void BrowserList(const std::vector<std::string> &entrys, int &selection,
|
||||
: (i % 2 == 0 ? RD7Color_List0 : RD7Color_List1)),
|
||||
txtflags | RD7TextFlags_Short, R7Vec2(size.x, 15));
|
||||
}
|
||||
RenderD7::CustomTextSize(tmp_txt);
|
||||
RenderD7::R2()->SetTextSize(tmp_txt);
|
||||
}
|
||||
|
||||
void InputText(const std::string &label, std::string &text,
|
||||
const std::string &hint) {
|
||||
if (!UI7CtxValidate()) return;
|
||||
float sv = (RenderD7::TextGetSize() * 40) * 0.9;
|
||||
float sv = (RenderD7::R2()->GetTextSize() * 40) * 0.9;
|
||||
R7Vec2 cbs = R7Vec2(144, sv);
|
||||
R7Vec2 txtdim = RenderD7::GetTextDimensions(label);
|
||||
R7Vec2 txtdim = RenderD7::R2()->GetTextDimensions(label);
|
||||
R7Vec2 inp = cbs + R7Vec2(txtdim.x + 5, 0);
|
||||
RD7Color bg = RD7Color_FrameBg;
|
||||
auto id = UI7ID(label);
|
||||
@ -715,7 +711,7 @@ bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) {
|
||||
size.y = 240;
|
||||
}
|
||||
RD7TextFlags txtflags = 0;
|
||||
float tbh = RenderD7::TextGetSize() * 40;
|
||||
float tbh = RenderD7::R2()->GetTextSize() * 40;
|
||||
ui7_ctx->cm->tbh = tbh;
|
||||
|
||||
if (flags & UI7MenuFlags_NoTitlebar) {
|
||||
@ -840,8 +836,8 @@ void Grid(const std::string &name, const R7Vec2 &size, const R7Vec2 &entry_size,
|
||||
pos += igoff;
|
||||
for (size_t i = 0; i < num_entrys; i++) {
|
||||
display_func(data_array[i], pos);
|
||||
if (ui7_ctx->debugging)
|
||||
RenderD7::Draw2::Text(pos + R7Vec2(4, 4), std::to_string(i));
|
||||
// if (ui7_ctx->debugging)
|
||||
// RenderD7::Draw2::Text(pos + R7Vec2(4, 4), std::to_string(i));
|
||||
if (pos.x + (entry_size.x * 2) > (cpos.x + size.x) &&
|
||||
pos.y + (entry_size.y * 2) > cpos.y + size.y) {
|
||||
break;
|
||||
@ -858,9 +854,9 @@ void Grid(const std::string &name, const R7Vec2 &size, const R7Vec2 &entry_size,
|
||||
|
||||
void ColorSelector(const std::string &label, unsigned int &color) {
|
||||
if (!UI7CtxValidate()) return;
|
||||
float sv = (RenderD7::TextGetSize() * 40) * 0.9;
|
||||
float sv = (RenderD7::R2()->GetTextSize() * 40) * 0.9;
|
||||
R7Vec2 cbs = R7Vec2(sv, sv);
|
||||
R7Vec2 txtdim = RenderD7::GetTextDimensions(label);
|
||||
R7Vec2 txtdim = RenderD7::R2()->GetTextDimensions(label);
|
||||
R7Vec2 inp = cbs + R7Vec2(txtdim.x + 5, 0);
|
||||
auto outline =
|
||||
RenderD7::Color::RGBA(color).is_light() ? 0xff000000 : 0xffffffff;
|
||||
|
@ -16,8 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <renderd7/DrawV2.hpp> // Switch to Draw2
|
||||
#include <renderd7/Hid.hpp> // Integate HidApi
|
||||
#include <renderd7/Hid.hpp> // Integate HidApi
|
||||
#include <renderd7/Message.hpp>
|
||||
#include <renderd7/Overlays.hpp>
|
||||
#include <renderd7/ThemeEditor.hpp>
|
||||
@ -34,6 +33,8 @@
|
||||
#include <filesystem>
|
||||
#include <random>
|
||||
|
||||
RenderD7::R2Base::Ref rd7i_render2;
|
||||
|
||||
static void RD7i_ExitHook() {
|
||||
C2D_TextBufDelete(rd7i_text_buffer);
|
||||
C2D_TextBufDelete(rd7i_d2_dimbuf);
|
||||
@ -53,13 +54,21 @@ std::vector<std::string> string_to_lines(std::string input_str) {
|
||||
void Npifade() {
|
||||
if (rd7i_fadein) {
|
||||
if (rd7i_fadealpha < 255) {
|
||||
rd7i_fadealpha += 3;
|
||||
if ((int)rd7i_fadealpha + 3 > 255) {
|
||||
rd7i_fadealpha = 255;
|
||||
} else {
|
||||
rd7i_fadealpha += 3;
|
||||
}
|
||||
} else {
|
||||
rd7i_fadein = false;
|
||||
}
|
||||
} else if (rd7i_fadeout) {
|
||||
if (rd7i_fadealpha > 0) {
|
||||
rd7i_fadealpha -= 3;
|
||||
if ((int)rd7i_fadealpha - 3 < 0) {
|
||||
rd7i_fadealpha = 0;
|
||||
} else {
|
||||
rd7i_fadealpha -= 3;
|
||||
}
|
||||
} else {
|
||||
rd7i_fadeout = false;
|
||||
}
|
||||
@ -73,12 +82,14 @@ void Npifade() {
|
||||
}
|
||||
// No fade
|
||||
}
|
||||
RenderD7::OnScreen(Top);
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 240),
|
||||
((rd7i_fadealpha << 24) | 0x00000000));
|
||||
RenderD7::OnScreen(Bottom);
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(320, 240),
|
||||
((rd7i_fadealpha << 24) | 0x00000000));
|
||||
/*if (rd7i_fadein || rd7i_fadeout) {
|
||||
RenderD7::R2()->OnScreen(RenderD7::R2Screen_Top);
|
||||
RenderD7::R2()->AddRect(R7Vec2(0, 0), R7Vec2(400, 240),
|
||||
((rd7i_fadealpha << 24) | 0x00000000));
|
||||
RenderD7::R2()->OnScreen(RenderD7::R2Screen_Bottom);
|
||||
RenderD7::R2()->AddRect(R7Vec2(0, 0), R7Vec2(320, 240),
|
||||
((rd7i_fadealpha << 24) | 0x00000000));
|
||||
}*/
|
||||
}
|
||||
|
||||
void PushSplash() {
|
||||
@ -220,6 +231,14 @@ void rd7i_init_theme() {
|
||||
}
|
||||
}
|
||||
|
||||
RenderD7::R2Base::Ref RenderD7::R2() {
|
||||
if (!rd7i_render2) {
|
||||
RenderD7::Error("Render2 Was Called before being Init!");
|
||||
// return schould not be reached then
|
||||
}
|
||||
return rd7i_render2;
|
||||
}
|
||||
|
||||
float RenderD7::GetDeltaTime() { return (float)rd7i_dtm; }
|
||||
|
||||
bool RenderD7::DrawImageFromSheet(RenderD7::Sheet *sheet, size_t index, float x,
|
||||
@ -324,9 +343,13 @@ void RenderD7::Init::Graphics() {
|
||||
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
||||
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
|
||||
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
|
||||
rd7_top = Top;
|
||||
rd7_bottom = Bottom;
|
||||
rd7_top_right = TopRight;
|
||||
rd7i_text_buffer = C2D_TextBufNew(4096);
|
||||
rd7i_d2_dimbuf = C2D_TextBufNew(4096);
|
||||
rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA);
|
||||
rd7i_render2 = R2Base::New();
|
||||
}
|
||||
|
||||
Result RenderD7::Init::Main(std::string app_name) {
|
||||
@ -371,6 +394,9 @@ Result RenderD7::Init::Main(std::string app_name) {
|
||||
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
||||
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
|
||||
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
|
||||
rd7_top = Top;
|
||||
rd7_bottom = Bottom;
|
||||
rd7_top_right = TopRight;
|
||||
rd7i_text_buffer = C2D_TextBufNew(4096);
|
||||
rd7i_d2_dimbuf = C2D_TextBufNew(4096);
|
||||
rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA);
|
||||
@ -379,6 +405,7 @@ Result RenderD7::Init::Main(std::string app_name) {
|
||||
rd7i_last_tm = svcGetSystemTick();
|
||||
if (rd7_do_splash) PushSplash();
|
||||
|
||||
rd7i_render2 = R2Base::New();
|
||||
rd7i_init_config();
|
||||
rd7i_init_input();
|
||||
rd7i_init_theme();
|
||||
@ -421,6 +448,9 @@ Result RenderD7::Init::Minimal(std::string app_name) {
|
||||
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
||||
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
|
||||
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
|
||||
rd7_top = Top;
|
||||
rd7_bottom = Bottom;
|
||||
rd7_top_right = TopRight;
|
||||
rd7i_text_buffer = C2D_TextBufNew(4096);
|
||||
rd7i_d2_dimbuf = C2D_TextBufNew(4096);
|
||||
rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA);
|
||||
@ -432,6 +462,7 @@ Result RenderD7::Init::Minimal(std::string app_name) {
|
||||
svcGetSystemInfo(&citracheck, 0x20000, 0);
|
||||
rd7i_is_citra = citracheck ? true : false;
|
||||
|
||||
rd7i_render2 = R2Base::New();
|
||||
rd7i_init_config();
|
||||
rd7i_init_input();
|
||||
rd7i_init_theme();
|
||||
@ -444,6 +475,7 @@ Result RenderD7::Init::Minimal(std::string app_name) {
|
||||
Result RenderD7::Init::Reload() {
|
||||
rd7i_graphics_on = false;
|
||||
C2D_TextBufDelete(rd7i_text_buffer);
|
||||
rd7i_render2 = nullptr; // Delete Render2
|
||||
C2D_Fini();
|
||||
C3D_Fini();
|
||||
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||
@ -452,8 +484,12 @@ Result RenderD7::Init::Reload() {
|
||||
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
||||
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
|
||||
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
|
||||
rd7_top = Top;
|
||||
rd7_bottom = Bottom;
|
||||
rd7_top_right = TopRight;
|
||||
rd7i_text_buffer = C2D_TextBufNew(4096);
|
||||
rd7i_base_font = C2D_FontLoadSystem(CFG_REGION_USA);
|
||||
rd7i_render2 = R2Base::New();
|
||||
rd7i_graphics_on = true;
|
||||
|
||||
return 0;
|
||||
@ -504,15 +540,16 @@ void RenderD7::FrameEnd() {
|
||||
RenderD7::ProcessMessages();
|
||||
OvlHandler();
|
||||
Npifade();
|
||||
R2()->Process();
|
||||
C3D_FrameEnd(0);
|
||||
}
|
||||
|
||||
RenderD7::RSettings::RSettings() {
|
||||
// RenderD7 Settings is designed for
|
||||
// System Font
|
||||
RenderD7::TextDefaultFont();
|
||||
tmp_txt = RenderD7::TextGetSize();
|
||||
RenderD7::TextDefaultSize();
|
||||
R2()->DefaultFont();
|
||||
tmp_txt = R2()->GetTextSize();
|
||||
R2()->DefaultTextSize();
|
||||
RenderD7::FadeIn();
|
||||
std::fstream cfg_ldr(rd7i_config_path + "/config.rc7", std::ios::in);
|
||||
cfg_ldr >> rd7i_config;
|
||||
@ -522,10 +559,7 @@ RenderD7::RSettings::RSettings() {
|
||||
stateftold = rd7i_ftraced;
|
||||
}
|
||||
|
||||
RenderD7::RSettings::~RSettings() {
|
||||
RenderD7::TextFontRestore();
|
||||
RenderD7::CustomTextSize(tmp_txt);
|
||||
}
|
||||
RenderD7::RSettings::~RSettings() { R2()->SetTextSize(tmp_txt); }
|
||||
|
||||
std::vector<std::string> StrHelper(std::string input) {
|
||||
std::string ss(input);
|
||||
@ -609,39 +643,44 @@ void RenderD7::RSettings::Draw(void) const {
|
||||
|
||||
} else if (m_state == RFTRACE) {
|
||||
RenderD7::OnScreen(Top);
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 240),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_Background));
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 20),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_Header));
|
||||
RenderD7::ThemeActive()->TextBy(RD7Color_Header);
|
||||
RenderD7::Draw2::Text(R7Vec2(5, 2), "RenderD7 -> FTrace");
|
||||
RenderD7::Draw2::Text(R7Vec2(395, 2), RENDERD7VSTRING,
|
||||
RD7TextFlags_AlignRight);
|
||||
RenderD7::ThemeActive()->Undo();
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 220), R7Vec2(400, 20),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_Header));
|
||||
RenderD7::ThemeActive()->TextBy(RD7Color_Header);
|
||||
RenderD7::Draw2::Text(
|
||||
// Draw Top Screen Into Background DrawList
|
||||
UI7::GetBackgroundList()->AddRectangle(R7Vec2(0, 0), R7Vec2(400, 240),
|
||||
RD7Color_Background);
|
||||
UI7::GetBackgroundList()->AddRectangle(R7Vec2(0, 0), R7Vec2(400, 20),
|
||||
RD7Color_Header);
|
||||
UI7::GetBackgroundList()->AddText(
|
||||
R7Vec2(5, 2), "RenderD7 -> FTrace",
|
||||
RenderD7::ThemeActive()->AutoText(RD7Color_Header));
|
||||
UI7::GetBackgroundList()->AddText(
|
||||
R7Vec2(395, 2), RENDERD7VSTRING,
|
||||
RenderD7::ThemeActive()->AutoText(RD7Color_Header),
|
||||
RD7TextFlags_AlignRight);
|
||||
UI7::GetBackgroundList()->AddRectangle(
|
||||
R7Vec2(0, 220), R7Vec2(400, 20),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_Header));
|
||||
UI7::GetBackgroundList()->AddText(
|
||||
R7Vec2(5, 222),
|
||||
"Traces: " + std::to_string(ftrace_index + 1) + "/" +
|
||||
std::to_string(RenderD7::Ftrace::rd7_traces.size()));
|
||||
RenderD7::ThemeActive()->Undo();
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 20), R7Vec2(400, 20),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_TextDisabled));
|
||||
RenderD7::ThemeActive()->TextBy(RD7Color_TextDisabled);
|
||||
RenderD7::Draw2::Text(R7Vec2(5, 22), "Function:");
|
||||
RenderD7::Draw2::Text(R7Vec2(395, 22),
|
||||
"Time (ms):", RD7TextFlags_AlignRight);
|
||||
RenderD7::ThemeActive()->Undo();
|
||||
std::to_string(RenderD7::Ftrace::rd7_traces.size()),
|
||||
RenderD7::ThemeActive()->AutoText(RD7Color_Header));
|
||||
UI7::GetBackgroundList()->AddRectangle(R7Vec2(0, 20), R7Vec2(400, 20),
|
||||
RD7Color_TextDisabled);
|
||||
UI7::GetBackgroundList()->AddText(
|
||||
R7Vec2(5, 22),
|
||||
"Function:", RenderD7::ThemeActive()->AutoText(RD7Color_TextDisabled));
|
||||
UI7::GetBackgroundList()->AddText(
|
||||
R7Vec2(395, 22),
|
||||
"Time (ms):", RenderD7::ThemeActive()->AutoText(RD7Color_TextDisabled),
|
||||
RD7TextFlags_AlignRight);
|
||||
|
||||
// List Bg
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if ((i % 2 == 0))
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (i) * 15), R7Vec2(400, 15),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_List0));
|
||||
UI7::GetBackgroundList()->AddRectangle(R7Vec2(0, 40 + (i)*15),
|
||||
R7Vec2(400, 15), RD7Color_List0);
|
||||
else
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (i) * 15), R7Vec2(400, 15),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_List1));
|
||||
UI7::GetBackgroundList()->AddRectangle(R7Vec2(0, 40 + (i)*15),
|
||||
R7Vec2(400, 15), RD7Color_List1);
|
||||
}
|
||||
|
||||
RenderD7::Ftrace::Beg("rd7ft", "display_traces");
|
||||
@ -655,27 +694,20 @@ void RenderD7::RSettings::Draw(void) const {
|
||||
ix < start_index + 10 && it != RenderD7::Ftrace::rd7_traces.end()) {
|
||||
if (ix == ftrace_index) {
|
||||
_fkey__ = it->first;
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (ix - start_index) * 15),
|
||||
R7Vec2(400, 15),
|
||||
RenderD7::ThemeActive()->Get(RD7Color_Selector));
|
||||
RenderD7::ThemeActive()->TextBy(RD7Color_Header);
|
||||
RenderD7::Draw2::Text(R7Vec2(5, 40 + (ix - start_index) * 15),
|
||||
it->second.func_name);
|
||||
RenderD7::Draw2::Text(R7Vec2(395, 40 + (ix - start_index) * 15),
|
||||
RenderD7::MsTimeFmt(it->second.time_of),
|
||||
RD7TextFlags_AlignRight);
|
||||
RenderD7::ThemeActive()->Undo();
|
||||
|
||||
} else {
|
||||
// Use List 0 cause no reference for screenpos
|
||||
RenderD7::ThemeActive()->TextBy(RD7Color_List0);
|
||||
RenderD7::Draw2::Text(R7Vec2(5, 40 + (ix - start_index) * 15),
|
||||
it->second.func_name);
|
||||
RenderD7::Draw2::Text(R7Vec2(395, 40 + (ix - start_index) * 15),
|
||||
RenderD7::MsTimeFmt(it->second.time_of),
|
||||
RD7TextFlags_AlignRight);
|
||||
RenderD7::ThemeActive()->Undo();
|
||||
UI7::GetBackgroundList()->AddRectangle(
|
||||
R7Vec2(0, 40 + (ix - start_index) * 15), R7Vec2(400, 15),
|
||||
RD7Color_Selector);
|
||||
}
|
||||
auto clr = ix == ftrace_index
|
||||
? RD7Color_Selector
|
||||
: (ix % 2 == 0 ? RD7Color_List0 : RD7Color_List1);
|
||||
UI7::GetBackgroundList()->AddText(R7Vec2(5, 40 + (ix - start_index) * 15),
|
||||
it->second.func_name,
|
||||
RenderD7::ThemeActive()->AutoText(clr));
|
||||
UI7::GetBackgroundList()->AddText(
|
||||
R7Vec2(395, 40 + (ix - start_index) * 15),
|
||||
RenderD7::MsTimeFmt(it->second.time_of),
|
||||
RenderD7::ThemeActive()->AutoText(clr), RD7TextFlags_AlignRight);
|
||||
++it;
|
||||
++ix;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user