- Add RD7 and DV2 namespace
- Restructer Default Theme System - Rename NIMG_Engine to swr (SoftwareRender) - Begin Adding Debug Lines to UI7 - Remove GUI ErrorSystem
This commit is contained in:
@ -5,10 +5,8 @@
|
||||
#include <renderd7/external/json.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
// This is btw the default theme setup
|
||||
// RenderD7 StyleColor Api
|
||||
// not const cause const = error lol
|
||||
std::map<RD7Color, unsigned int> rd7i_color_map = {
|
||||
// Default Theme
|
||||
const std::map<RD7Color, unsigned int> rd7i_default_theme = {
|
||||
{RD7Color_Text, RGBA8(0, 0, 0, 255)},
|
||||
{RD7Color_Text2, RGBA8(255, 255, 255, 255)}, // For Background change or so
|
||||
{RD7Color_TextDisabled, RGBA8(170, 170, 170, 255)},
|
||||
@ -29,6 +27,10 @@ std::map<RD7Color, unsigned int> rd7i_color_map = {
|
||||
{RD7Color_Progressbar, RGBA8(0, 255, 0, 255)},
|
||||
};
|
||||
|
||||
// RenderD7 StyleColor Api
|
||||
// not const cause const = error lol
|
||||
std::map<RD7Color, unsigned int> rd7i_color_map = rd7i_default_theme;
|
||||
|
||||
std::map<RD7Color, unsigned int> rd7i_color_swap_map;
|
||||
|
||||
unsigned int RenderD7::StyleColor(RD7Color color) {
|
||||
@ -175,26 +177,7 @@ void RenderD7::ThemeSave(const std::string& path) {
|
||||
file.close();
|
||||
}
|
||||
|
||||
void RenderD7::ThemeDefault() {
|
||||
rd7i_color_map[RD7Color_Text] = RGBA8(0, 0, 0, 255);
|
||||
rd7i_color_map[RD7Color_Text2] = RGBA8(255, 255, 255, 255);
|
||||
rd7i_color_map[RD7Color_TextDisabled] = RGBA8(170, 170, 170, 255);
|
||||
rd7i_color_map[RD7Color_Background] = RGBA8(238, 238, 238, 255);
|
||||
rd7i_color_map[RD7Color_Header] = RGBA8(17, 17, 17, 255);
|
||||
rd7i_color_map[RD7Color_Selector] = RGBA8(34, 34, 34, 255);
|
||||
rd7i_color_map[RD7Color_SelectorFade] = RGBA8(90, 90, 90, 255);
|
||||
rd7i_color_map[RD7Color_List0] = RGBA8(204, 204, 204, 255);
|
||||
rd7i_color_map[RD7Color_List1] = RGBA8(187, 187, 187, 255);
|
||||
rd7i_color_map[RD7Color_MessageBackground] = RGBA8(51, 51, 51, 255);
|
||||
rd7i_color_map[RD7Color_Button] = RGBA8(17, 17, 17, 255);
|
||||
rd7i_color_map[RD7Color_ButtonHovered] = RGBA8(34, 34, 34, 255);
|
||||
rd7i_color_map[RD7Color_ButtonDisabled] = RGBA8(8, 8, 8, 255);
|
||||
rd7i_color_map[RD7Color_ButtonActive] = RGBA8(42, 42, 42, 255);
|
||||
rd7i_color_map[RD7Color_Checkmark] = RGBA8(42, 42, 42, 255);
|
||||
rd7i_color_map[RD7Color_FrameBg] = RGBA8(85, 85, 85, 255);
|
||||
rd7i_color_map[RD7Color_FrameBgHovered] = RGBA8(119, 119, 119, 255);
|
||||
rd7i_color_map[RD7Color_Progressbar] = RGBA8(0, 255, 0, 255);
|
||||
}
|
||||
void RenderD7::ThemeDefault() { rd7i_color_map = rd7i_default_theme; }
|
||||
|
||||
uint32_t RenderD7::Color::Hex(const std::string& color, uint8_t a) {
|
||||
if (color.length() < 7 ||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
namespace RenderD7 {
|
||||
void Error(const std::string& msg) {
|
||||
if (rd7i_graphics_on) {
|
||||
/*if (rd7i_graphics_on) {
|
||||
C3D_FrameEnd(0);
|
||||
while (aptMainLoop()) {
|
||||
hidScanInput();
|
||||
@ -27,18 +27,18 @@ void Error(const std::string& msg) {
|
||||
C3D_FrameEnd(0);
|
||||
}
|
||||
exit(0);
|
||||
} else {
|
||||
gfxInitDefault();
|
||||
consoleInit(GFX_TOP, NULL);
|
||||
printf("RENDERD7 - ERROR MANAGER\n\n%s\n", msg.c_str());
|
||||
printf("Press Start to Exit\n");
|
||||
while (aptMainLoop()) {
|
||||
hidScanInput();
|
||||
if (hidKeysDown() & KEY_START) break;
|
||||
gfxSwapBuffers();
|
||||
}
|
||||
gfxExit();
|
||||
exit(0);
|
||||
} else {*/
|
||||
gfxInitDefault();
|
||||
consoleInit(GFX_TOP, NULL);
|
||||
printf("RENDERD7 - ERROR MANAGER\n\n%s\n", msg.c_str());
|
||||
printf("Press Start to Exit\n");
|
||||
while (aptMainLoop()) {
|
||||
hidScanInput();
|
||||
if (hidKeysDown() & KEY_START) break;
|
||||
gfxSwapBuffers();
|
||||
}
|
||||
gfxExit();
|
||||
exit(0);
|
||||
// }
|
||||
}
|
||||
} // namespace RenderD7
|
@ -65,6 +65,31 @@ struct UI7ID {
|
||||
int lt;
|
||||
};
|
||||
|
||||
struct UI7OBJ {
|
||||
UI7OBJ() {}
|
||||
UI7OBJ(const R7Vec4 &i0, const int &i1) {
|
||||
box = i0;
|
||||
type = i1;
|
||||
s = rd7i_current_screen;
|
||||
}
|
||||
void Debug() {
|
||||
RenderD7::OnScreen(s ? Top : Bottom);
|
||||
RenderD7::Draw2::TriangleLined(R7Vec2(box.x, box.y),
|
||||
R7Vec2(box.x + box.z, box.y),
|
||||
R7Vec2(box.x, box.y + box.w), 0xff0000ff);
|
||||
RenderD7::Draw2::TriangleLined(
|
||||
R7Vec2(box.x, box.y + box.w), R7Vec2(box.x + box.z, box.y),
|
||||
R7Vec2(box.x + box.z, box.y + box.w), 0xff0000ff);
|
||||
}
|
||||
R7Vec4 box;
|
||||
int type;
|
||||
bool s = false;
|
||||
};
|
||||
|
||||
std::vector<unsigned int> ui7i_debug_colors{
|
||||
0x00000000,
|
||||
};
|
||||
|
||||
struct UI7_Ctx {
|
||||
UI7_Ctx() {
|
||||
delta = 0.0f;
|
||||
@ -76,6 +101,7 @@ struct UI7_Ctx {
|
||||
cbackup = R7Vec2();
|
||||
in_menu = false;
|
||||
current_menu = UI7ID("");
|
||||
debugging = true;
|
||||
}
|
||||
float delta;
|
||||
float time;
|
||||
@ -85,9 +111,11 @@ struct UI7_Ctx {
|
||||
R7Vec2 cbackup;
|
||||
R7Vec2 slc;
|
||||
bool in_menu;
|
||||
bool debugging;
|
||||
UI7ID current_menu;
|
||||
std::map<std::string, R7Vec2> grid_mapping;
|
||||
std::unordered_map<std::string, UI7ID *> ids;
|
||||
std::vector<UI7OBJ> objects;
|
||||
};
|
||||
|
||||
UI7_Ctx *ui7_ctx;
|
||||
@ -127,6 +155,12 @@ void UI7CtxCursorMove(R7Vec2 size) {
|
||||
ui7_ctx->slc += R7Vec2(size.x, 0);
|
||||
}
|
||||
|
||||
void UI7CtxRegObj(const UI7OBJ &obj) {
|
||||
if (!UI7CtxValidate()) return;
|
||||
if (!ui7_ctx->debugging) return;
|
||||
ui7_ctx->objects.push_back(obj);
|
||||
}
|
||||
|
||||
UI7ID *UI7CtxNewID(const std::string &i) {
|
||||
std::string t = i;
|
||||
std::transform(t.begin(), t.end(), t.begin(),
|
||||
@ -195,6 +229,7 @@ void Update() {
|
||||
ui7_ctx->time += ui7_ctx->delta;
|
||||
ui7_ctx->cursor = R7Vec2();
|
||||
UI7CtxClearIDs();
|
||||
if (ui7_ctx->debugging) ui7_ctx->objects.clear();
|
||||
}
|
||||
|
||||
float GetTime() {
|
||||
@ -219,8 +254,7 @@ bool Button(const std::string &label, R7Vec2 size) {
|
||||
}
|
||||
RD7Color btn = RD7Color_Button;
|
||||
R7Vec2 pos = GetCursorPos();
|
||||
|
||||
UI7CtxCursorMove(size);
|
||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, size), 0));
|
||||
|
||||
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, size)) {
|
||||
@ -237,6 +271,7 @@ bool Button(const std::string &label, R7Vec2 size) {
|
||||
RenderD7::TextColorByBg(btn);
|
||||
RenderD7::Draw2::Text(pos, label);
|
||||
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||
UI7CtxCursorMove(size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -265,8 +300,11 @@ void Checkbox(const std::string &label, bool &c) {
|
||||
if (c == true) {
|
||||
RenderD7::Draw2::RFS(pos + R7Vec2(2, 2), cbs - R7Vec2(4, 4),
|
||||
RenderD7::StyleColor(RD7Color_Checkmark));
|
||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos + R7Vec2(2, 2), cbs - R7Vec2(4, 4)), 2));
|
||||
}
|
||||
RenderD7::Draw2::Text(pos + R7Vec2(cbs.x + 5, 1), label);
|
||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, cbs + R7Vec2(txtdim.x + 5, 0)), 0));
|
||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, cbs), 1));
|
||||
}
|
||||
|
||||
void Label(const std::string &label, RD7TextFlags flags) {
|
||||
@ -274,6 +312,11 @@ void Label(const std::string &label, RD7TextFlags flags) {
|
||||
R7Vec2 textdim = RenderD7::GetTextDimensions(label);
|
||||
R7Vec2 pos = GetCursorPos();
|
||||
float tbh = RenderD7::TextGetSize() * 40;
|
||||
if (flags & RD7TextFlags_AlignRight) {
|
||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos - R7Vec2(textdim.x, 0), textdim), 0));
|
||||
} else {
|
||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, textdim), 0));
|
||||
}
|
||||
// Remove some y offset cause texts have some offset
|
||||
UI7CtxCursorMove(textdim - R7Vec2(0, 4));
|
||||
RenderD7::TextColorByBg(
|
||||
@ -301,6 +344,7 @@ void Image(RenderD7::Image *img) {
|
||||
if (!UI7CtxValidate()) return;
|
||||
R7Vec2 pos = GetCursorPos();
|
||||
UI7CtxCursorMove(R7Vec2(img->get_size().x, img->get_size().y));
|
||||
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, img->get_size()), 0));
|
||||
|
||||
RenderD7::Draw2::Image(img, pos);
|
||||
}
|
||||
@ -414,6 +458,7 @@ bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) {
|
||||
}
|
||||
|
||||
SetCursorPos(R7Vec2(5, tbh + 5));
|
||||
|
||||
return UI7CtxBeginMenu(title);
|
||||
}
|
||||
|
||||
@ -488,4 +533,13 @@ void SameLine() {
|
||||
ui7_ctx->cursor = ui7_ctx->slc;
|
||||
}
|
||||
|
||||
void Debug() {
|
||||
if (!UI7CtxValidate()) return;
|
||||
if (ui7_ctx->debugging) {
|
||||
for (size_t i = 0; i < ui7_ctx->objects.size(); i++) {
|
||||
ui7_ctx->objects[i].Debug();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace UI7
|
@ -7,9 +7,9 @@
|
||||
// Use an Npi simplifier cause I am lazy
|
||||
#define reca_cc(x) reinterpret_cast<const char*>(x)
|
||||
#define reca_c(x) reinterpret_cast<char*>(x)
|
||||
#define pak32(q, w, e, r) \
|
||||
((((q)&0xff) << 0) | (((w)&0xff) << 8) | (((e)&0xff) << 16) | \
|
||||
(((r)&0xff) << 24))
|
||||
#define pak32(q, w, e, r) \
|
||||
((((q) & 0xff) << 0) | (((w) & 0xff) << 8) | (((e) & 0xff) << 16) | \
|
||||
(((r) & 0xff) << 24))
|
||||
|
||||
// Stupid RLE Algorithm
|
||||
void npi_compress(std::vector<unsigned char>& ret,
|
||||
|
@ -448,6 +448,7 @@ void RenderD7::FrameEnd() {
|
||||
RenderD7::Ftrace::Beg("rd7oh", f2s(OvlHandler));
|
||||
OvlHandler();
|
||||
RenderD7::Ftrace::End("rd7oh", f2s(OvlHandler));
|
||||
UI7::Debug();
|
||||
Npifade();
|
||||
RenderD7::Ftrace::End("rd7-core", "frame");
|
||||
C3D_FrameEnd(0);
|
||||
@ -593,10 +594,10 @@ void RenderD7::RSettings::Draw(void) const {
|
||||
// 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::Draw2::RFS(R7Vec2(0, 40 + (i) * 15), R7Vec2(400, 15),
|
||||
RenderD7::StyleColor(RD7Color_List0));
|
||||
else
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (i)*15), R7Vec2(400, 15),
|
||||
RenderD7::Draw2::RFS(R7Vec2(0, 40 + (i) * 15), R7Vec2(400, 15),
|
||||
RenderD7::StyleColor(RD7Color_List1));
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
#include <renderd7/external/stb_image.h>
|
||||
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/nimg_engine.hpp>
|
||||
#include <renderd7/swr.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
NIMG_Engine::NIMG_Engine(int w, int h) { image = RenderD7::nimg(w, h); }
|
||||
NIMG_Engine::NIMG_Engine() { image = RenderD7::nimg(1, 1); }
|
||||
swr::swr(int w, int h) { image = RenderD7::nimg(w, h); }
|
||||
swr::swr() { image = RenderD7::nimg(1, 1); }
|
||||
|
||||
NIMG_Engine::~NIMG_Engine() {
|
||||
swr::~swr() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void NIMG_Engine::load_file(const std::string& path) {
|
||||
void swr::load_file(const std::string& path) {
|
||||
int w, h, c;
|
||||
uint8_t* dat = stbi_load(path.c_str(), &w, &h, &c, 4);
|
||||
image = nimg(w, h);
|
||||
@ -27,11 +27,11 @@ void NIMG_Engine::load_file(const std::string& path) {
|
||||
stbi_image_free(dat);
|
||||
}
|
||||
|
||||
void NIMG_Engine::load_nimg(const std::string& path) {
|
||||
void swr::load_nimg(const std::string& path) {
|
||||
image = RenderD7::NIMG_Load(path);
|
||||
}
|
||||
|
||||
void NIMG_Engine::draw_pixel(int x, int y, unsigned int color) {
|
||||
void swr::draw_pixel(int x, int y, unsigned int color) {
|
||||
if (x > image.width || x < 0 || y > image.height || y < 0) return;
|
||||
RenderD7::Color::RGBA splitter(color);
|
||||
image.pixel_buffer[((y * image.width + x) * 4) + 0] = splitter.m_r;
|
||||
@ -40,11 +40,14 @@ void NIMG_Engine::draw_pixel(int x, int y, unsigned int color) {
|
||||
image.pixel_buffer[((y * image.width + x) * 4) + 3] = splitter.m_a;
|
||||
}
|
||||
|
||||
void NIMG_Engine::draw_rect(int x, int y, int w, int h, unsigned int color,
|
||||
int t) {}
|
||||
void swr::draw_rect(int x, int y, int w, int h, unsigned int color, int t) {
|
||||
draw_line(x, y, x + w, y, color, t);
|
||||
draw_line(x, y, x, y + h, color, t);
|
||||
draw_line(x, y + h, x + w, y + h, color, t);
|
||||
draw_line(x + w, y + h, x + w, y + h, color, t);
|
||||
}
|
||||
|
||||
void NIMG_Engine::draw_rect_solid(int x, int y, int w, int h,
|
||||
unsigned int color) {
|
||||
void swr::draw_rect_solid(int x, int y, int w, int h, unsigned int color) {
|
||||
for (int ix = x; ix < x + w; ix++) {
|
||||
for (int iy = y; iy < y + h; iy++) {
|
||||
draw_pixel(ix, iy, color);
|
||||
@ -52,7 +55,15 @@ void NIMG_Engine::draw_rect_solid(int x, int y, int w, int h,
|
||||
}
|
||||
}
|
||||
|
||||
void NIMG_Engine::flip(bool h, bool v) {
|
||||
void swr::draw_line(int x1, int y1, int x2, int y2, unsigned int color, int t) {
|
||||
for (int ix = x1; ix < x2 * t; ix++) {
|
||||
for (int iy = y1; iy < y2 * t; iy++) {
|
||||
draw_pixel(ix, iy, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void swr::flip(bool h, bool v) {
|
||||
const nimg _bak = image;
|
||||
if (h) {
|
||||
for (int x = 0; x < image.width; x++) {
|
Reference in New Issue
Block a user