Patch Overlays and RSettings to default txt size + cf

This commit is contained in:
tobid7 2024-02-20 20:56:14 +01:00
parent 33bb37be06
commit 688570b3cd
8 changed files with 29 additions and 21 deletions

View File

@ -71,8 +71,8 @@ void CustomizeColor(RD7Color color, unsigned int custom);
void ColorNew(RD7Color color, unsigned int new_color);
void UndoColorEdit(RD7Color color);
void UndoAllColorEdits();
void ThemeLoad(const std::string& path);
void ThemeSave(const std::string& path);
void ThemeLoad(const std::string &path);
void ThemeSave(const std::string &path);
void ThemeDefault();
namespace Color {
/// @brief RGBA Class

View File

@ -45,7 +45,7 @@ void EndMenu();
void Grid(const std::string &name, const R7Vec2 &size,
R7Vec2 (*display_func)(void *, R7Vec2), void **data_array,
size_t num_entrys);
bool BeginTree(const std::string& text);
bool BeginTree(const std::string &text);
void EndTree();
R7Vec2 GetCursorPos();
void SetCursorPos(R7Vec2 cp);

View File

@ -114,6 +114,7 @@ class RSettings : public RenderD7::Scene {
std::string kbd_test;
bool statemtold = false;
bool stateftold = false;
float tmp_txt;
public:
/// @brief Constructor

View File

@ -105,11 +105,11 @@ void Sample::Draw() const {
UI7::Checkbox("RD7-Debug", rd7_debugging);
UI7::InputText("Search", search__, "Tap Here");
UI7::Label("Text Control:");
if(UI7::Button("text++")) txt_size+=0.01;
if (UI7::Button("text++")) txt_size += 0.01;
UI7::SameLine();
if(UI7::Button("text--")) txt_size -= 0.01;
if (UI7::Button("text--")) txt_size -= 0.01;
UI7::SameLine();
if(UI7::Button("def")) txt_size = 0.5;
if (UI7::Button("def")) txt_size = 0.5;
}
UI7::EndMenu();
}

View File

@ -27,6 +27,8 @@ namespace RenderD7 {
float GetDeltaTime(); // Extern from renderd7.cpp
void ProcessMessages() {
float tmp_txt = RenderD7::TextGetSize();
RenderD7::TextDefaultSize();
// Draw in ovl mode
RenderD7::OnScreen(Top);
float fol = anim_len - fade_outs;
@ -82,6 +84,7 @@ void ProcessMessages() {
// ReReverse ?? lol
// Cause otherwise the Toasts will swap
std::reverse(msg_lst.begin(), msg_lst.end());
RenderD7::CustomTextSize(tmp_txt);
}
void PushMessage(const Message &msg) {

View File

@ -244,6 +244,8 @@ 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);
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 20),
RenderD7::StyleColor(RD7Color_Background));
@ -256,6 +258,7 @@ void Ovl_Ftrace::Draw(void) const {
RenderD7::Draw2::Text(R7Vec2(295, 30 + i * 15),
RenderD7::MsTimeFmt(dt[i].time_of));
}
RenderD7::CustomTextSize(tmp_txt);
}
void Ovl_Ftrace::Logic() {
@ -357,6 +360,8 @@ Ovl_Keyboard::~Ovl_Keyboard() {
}
void Ovl_Keyboard::Draw(void) const {
float tmp_txt = RenderD7::TextGetSize();
RenderD7::TextDefaultSize();
if (ft3 > 5) RenderD7::Hid::Unlock();
auto key_table = keyboard_layout;
if (mode == 1)
@ -416,6 +421,7 @@ void Ovl_Keyboard::Draw(void) const {
RenderD7::UndoColorEdit(RD7Color_Text);
}
if (ft3 > 5) RenderD7::Hid::Lock();
RenderD7::CustomTextSize(tmp_txt);
}
void Ovl_Keyboard::Logic() {

View File

@ -242,7 +242,7 @@ 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::TextGetSize() * 40) * 0.9;
R7Vec2 cbs = R7Vec2(sv, sv);
R7Vec2 txtdim = RenderD7::GetTextDimensions(label);
R7Vec2 inp = cbs + R7Vec2(txtdim.x + 5, 0);
@ -273,10 +273,11 @@ void Label(const std::string &label, RD7TextFlags flags) {
if (!UI7CtxValidate()) return;
R7Vec2 textdim = RenderD7::GetTextDimensions(label);
R7Vec2 pos = GetCursorPos();
float tbh = RenderD7::TextGetSize() * 40;
// Remove some y offset cause texts have some offset
UI7CtxCursorMove(textdim - R7Vec2(0, 4));
RenderD7::TextColorByBg(
(pos.y + textdim.y < 20 ? RD7Color_Header : RD7Color_Background));
(pos.y + textdim.y < tbh ? RD7Color_Header : RD7Color_Background));
RenderD7::Draw2::Text(pos, label, flags);
RenderD7::UndoColorEdit(RD7Color_Text);
}
@ -361,7 +362,7 @@ void BrowserList(const std::vector<std::string> &entrys, int &selection,
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::TextGetSize() * 40) * 0.9;
R7Vec2 cbs = R7Vec2(144, sv);
R7Vec2 txtdim = RenderD7::GetTextDimensions(label);
R7Vec2 inp = cbs + R7Vec2(txtdim.x + 5, 0);
@ -399,7 +400,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::TextGetSize() * 40;
if (flags & UI7MenuFlags_NoTitlebar) titlebar = false;
if (flags & UI7MenuFlags_TitleMid) txtflags = RD7TextFlags_AlignMid;
RenderD7::Draw2::RFS(R7Vec2(0, 0), size,
@ -412,7 +413,7 @@ bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) {
RenderD7::UndoColorEdit(RD7Color_Text);
}
SetCursorPos(R7Vec2(5, tbh+5));
SetCursorPos(R7Vec2(5, tbh + 5));
return UI7CtxBeginMenu(title);
}
@ -462,14 +463,9 @@ void Grid(const std::string &name, const R7Vec2 &size,
UI7CtxCursorMove(size);
}
bool BeginTree(const std::string& text) {
bool BeginTree(const std::string &text) { return false; }
return false;
}
void EndTree() {
}
void EndTree() {}
R7Vec2 GetCursorPos() {
if (!UI7CtxValidate()) return R7Vec2();

View File

@ -454,6 +454,8 @@ void RenderD7::FrameEnd() {
}
RenderD7::RSettings::RSettings() {
tmp_txt = RenderD7::TextGetSize();
RenderD7::TextDefaultSize();
RenderD7::FadeIn();
std::fstream cfg_ldr(rd7i_config_path + "/config.rc7", std::ios::in);
cfg_ldr >> rd7i_config;
@ -463,7 +465,7 @@ RenderD7::RSettings::RSettings() {
stateftold = rd7i_ftraced;
}
RenderD7::RSettings::~RSettings() {}
RenderD7::RSettings::~RSettings() { RenderD7::CustomTextSize(tmp_txt); }
std::vector<std::string> StrHelper(std::string input) {
std::string ss(input);
@ -591,10 +593,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));
}