Some more RGB overlay stuff.

This commit is contained in:
StackZ 2020-07-15 20:40:11 +02:00
commit a145c20a91
2 changed files with 41 additions and 15 deletions

View file

@ -27,6 +27,7 @@
#include "colorHelper.hpp"
#include "config.hpp"
#include "gui.hpp"
#include "keyboard.hpp"
#include "overlay.hpp"
#include "structs.hpp"
@ -39,19 +40,24 @@ extern bool touching(Structs::ButtonPos button);
static void DrawRGBColor(u8 r, u8 g, u8 b) {
// Display RGB line.
for (int i = 0; i < 256; i++) {
Gui::Draw_Rect((32.5 + i), 30, 1, 20, C2D_Color32(i, 0, 0, 255));
Gui::Draw_Rect((32.5 + i), 80, 1, 20, C2D_Color32(0, i, 0, 255));
Gui::Draw_Rect((32.5 + i), 130, 1, 20, C2D_Color32(0, 0, i, 255));
Gui::Draw_Rect((10 + i), 30, 1, 20, C2D_Color32(i, 0, 0, 255));
Gui::Draw_Rect((10 + i), 80, 1, 20, C2D_Color32(0, i, 0, 255));
Gui::Draw_Rect((10 + i), 130, 1, 20, C2D_Color32(0, 0, i, 255));
}
Gui::Draw_Rect((32.5 + r), 30, 1, 20, C2D_Color32(255, 255, 255, 255));
Gui::Draw_Rect((32.5 + g), 80, 1, 20, C2D_Color32(255, 255, 255, 255));
Gui::Draw_Rect((32.5 + b), 130, 1, 20, C2D_Color32(255, 255, 255, 255));
Gui::Draw_Rect((10 + r), 30, 1, 20, C2D_Color32(255, 255, 255, 255));
Gui::Draw_Rect((10 + g), 80, 1, 20, C2D_Color32(255, 255, 255, 255));
Gui::Draw_Rect((10 + b), 130, 1, 20, C2D_Color32(255, 255, 255, 255));
// Display RGB Boxes.
Gui::Draw_Rect(270, 30, 40, 20, C2D_Color32(200, 200, 200, 255));
Gui::Draw_Rect(270, 80, 40, 20, C2D_Color32(200, 200, 200, 255));
Gui::Draw_Rect(270, 130, 40, 20, C2D_Color32(200, 200, 200, 255));
// Display Values.
Gui::DrawStringCentered(0, 10, 0.7f, config->textColor(), std::to_string(r));
Gui::DrawStringCentered(0, 60, 0.7f, config->textColor(), std::to_string(g));
Gui::DrawStringCentered(0, 110, 0.7f, config->textColor(), std::to_string(b));
Gui::DrawStringCentered(-(40 / 2) + 150, 30 + (20/2) - (Gui::GetStringHeight(0.6f, std::to_string(r)) / 2), 0.6f, C2D_Color32(0, 0, 0, 255), std::to_string(r), 40, 20);
Gui::DrawStringCentered(-(40 / 2) + 150, 80 + (20/2) - (Gui::GetStringHeight(0.6f, std::to_string(g)) / 2), 0.6f, C2D_Color32(0, 0, 0, 255), std::to_string(g), 40, 20);
Gui::DrawStringCentered(-(40 / 2) + 150, 130 + (20/2) - (Gui::GetStringHeight(0.6f, std::to_string(b)) / 2), 0.6f, C2D_Color32(0, 0, 0, 255), std::to_string(b), 40, 20);
// Display as formated string.
char hexValues[16];
@ -136,18 +142,38 @@ u32 Overlays::SelectColor(u32 oldColor) {
if (hidKeysHeld() & KEY_TOUCH) {
for (int i = 0; i < 256; i++) {
if (touch.px >= (32.5 + i) && touch.px <= (32.5 + i) + 1 && touch.py >= 30 && touch.py <= 30 + 20) {
if (touch.px >= (10 + i) && touch.px <= (10 + i) + 1 && touch.py >= 30 && touch.py <= 30 + 20) {
r = i;
}
if (touch.px >= (32.5 + i) && touch.px <= (32.5 + i) + 1 && touch.py >= 80 && touch.py <= 80 + 20) {
if (touch.px >= (10 + i) && touch.px <= (10 + i) + 1 && touch.py >= 80 && touch.py <= 80 + 20) {
g = i;
}
if (touch.px >= (32.5 + i) && touch.px <= (32.5 + i) + 1 && touch.py >= 130 && touch.py <= 130 + 20) {
if (touch.px >= (10 + i) && touch.px <= (10 + i) + 1 && touch.py >= 130 && touch.py <= 130 + 20) {
b = i;
}
}
}
// Change RGB Value on the next button!
if (hidKeysDown() & KEY_TOUCH) {
if (touch.px >= 270 && touch.px <= 270 + 40 && touch.py >= 30 && touch.py <= 30 + 20) {
int temp = Input::getUint(255, Lang::get("ENTER_RED_RGB"));
if (temp != -1) {
r = temp;
}
} else if (touch.px >= 270 && touch.px <= 270 + 40 && touch.py >= 80 && touch.py <= 80 + 20) {
int temp = Input::getUint(255, Lang::get("ENTER_GREEN_RGB"));
if (temp != -1) {
g = temp;
}
} else if (touch.px >= 270 && touch.px <= 270 + 40 && touch.py >= 130 && touch.py <= 130 + 20) {
int temp = Input::getUint(255, Lang::get("ENTER_BLUE_RGB"));
if (temp != -1) {
b = temp;
}
}
}
}
}

View file

@ -556,7 +556,7 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_TOUCH) {
if (touching(touch, mainButtons[0])) {
int temp = Input::getUint(255, Lang::get("ENTER_RED_RGB"));
if(temp != -1) {
if (temp != -1) {
red = temp;
if (colorMode == 0) {
config->barColor(RGBA8(red, ColorHelper::getColorValue(config->barColor(), 1), ColorHelper::getColorValue(config->barColor(), 0), 255));
@ -586,7 +586,7 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) {
}
} else if (touching(touch, mainButtons[1])) {
int temp = Input::getUint(255, Lang::get("ENTER_GREEN_RGB"));
if(temp != -1) {
if (temp != -1) {
green = temp;
if (colorMode == 0) {
config->barColor(RGBA8(ColorHelper::getColorValue(config->barColor(), 2), green, ColorHelper::getColorValue(config->barColor(), 0), 255));
@ -616,7 +616,7 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) {
}
} else if (touching(touch, mainButtons[2])) {
int temp = Input::getUint(255, Lang::get("ENTER_BLUE_RGB"));
if(temp != -1) {
if (temp != -1) {
blue = temp;
if (colorMode == 0) {
config->barColor(RGBA8(ColorHelper::getColorValue(config->barColor(), 2), ColorHelper::getColorValue(config->barColor(), 1), blue, 255));