Port over new RGB Selection from 3DEins!
This commit is contained in:
parent
31b65ee988
commit
fe15239ac1
5 changed files with 239 additions and 3 deletions
4
Makefile
4
Makefile
|
|
@ -76,9 +76,9 @@ endif
|
|||
TARGET := Universal-Updater
|
||||
BUILD := build
|
||||
UNIVCORE := Universal-Core
|
||||
SOURCES := $(UNIVCORE) source source/download source/gui source/lang source/screens source/utils
|
||||
SOURCES := $(UNIVCORE) source source/download source/gui source/lang source/overlays source/screens source/utils
|
||||
DATA := data
|
||||
INCLUDES := $(UNIVCORE) include include/download include/gui include/lang include/screens include/utils
|
||||
INCLUDES := $(UNIVCORE) include include/download include/gui include/lang include/overlays include/screens include/utils
|
||||
GRAPHICS := assets/gfx
|
||||
#GFXBUILD := $(BUILD)
|
||||
ROMFS := romfs
|
||||
|
|
|
|||
36
include/overlays/overlay.hpp
Normal file
36
include/overlays/overlay.hpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* This file is part of Universal-Updater
|
||||
* Copyright (C) 2019-2020 Universal-Team
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#ifndef _UNIVERSAL_UPDATER_OVERLAY_HPP
|
||||
#define _UNIVERSAL_UPDATER_OVERLAY_HPP
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
namespace Overlays {
|
||||
u32 SelectColor(u32 oldColor);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -220,5 +220,8 @@
|
|||
"SELECT_3DSX_PATH": "Select the 3DSX path.",
|
||||
"SELECT_NDS_PATH": "Select the NDS path.",
|
||||
"SELECT_ARCHIVE_PATH": "Select the Archive path.",
|
||||
"TOGGLE_PROGRESSBAR": "Toggle Progressbar"
|
||||
"TOGGLE_PROGRESSBAR": "Toggle Progressbar",
|
||||
|
||||
"SELECT_RGB_COLOR": "Select your RGB Color.",
|
||||
"UI_COLOR_BEHAVIOUR": "Press START to Select.\n\uE001 to cancel.\nTouch to control the RGB.\nD-Pad to control the RGB."
|
||||
}
|
||||
|
|
|
|||
153
source/overlays/ColorSelection.cpp
Normal file
153
source/overlays/ColorSelection.cpp
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* This file is part of Universal-Updater
|
||||
* Copyright (C) 2019-2020 Universal-Team
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "colorHelper.hpp"
|
||||
#include "config.hpp"
|
||||
#include "gui.hpp"
|
||||
#include "overlay.hpp"
|
||||
#include "structs.hpp"
|
||||
|
||||
extern std::unique_ptr<Config> config;
|
||||
extern touchPosition touch;
|
||||
|
||||
extern bool touching(Structs::ButtonPos button);
|
||||
|
||||
// Draw RGB Colors.
|
||||
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((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));
|
||||
|
||||
// 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));
|
||||
|
||||
// Display as formated string.
|
||||
char hexValues[16];
|
||||
|
||||
snprintf(hexValues, sizeof hexValues, "#%02x%02x%02x", r, g, b);
|
||||
Gui::DrawStringCentered(0, 158, 0.7f, config->textColor(), "RGB: " + std::to_string(r) + ", " + std::to_string(g) + ", " + std::to_string(b) + " - Hex: " + hexValues, 310);
|
||||
Gui::Draw_Rect(110, 180, 100, 30, C2D_Color32(r, g, b, 255));
|
||||
}
|
||||
|
||||
// Draw.
|
||||
static void Draw(u8 r, u8 g, u8 b) {
|
||||
Gui::clearTextBufs();
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
C2D_TargetClear(Top, C2D_Color32(0, 0, 0, 0));
|
||||
C2D_TargetClear(Bottom, C2D_Color32(0, 0, 0, 0));
|
||||
GFX::DrawTop();
|
||||
Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(0, 0, 0, 190));
|
||||
Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), Lang::get("SELECT_RGB_COLOR"), 400);
|
||||
Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.7f, Lang::get("UI_COLOR_BEHAVIOUR")))/2, 0.7f, config->textColor(), Lang::get("UI_COLOR_BEHAVIOUR"), 390, 70);
|
||||
Gui::ScreenDraw(Bottom);
|
||||
Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(255, 255, 255, 190));
|
||||
DrawRGBColor(r, g, b);
|
||||
C3D_FrameEnd(0);
|
||||
}
|
||||
|
||||
|
||||
u32 Overlays::SelectColor(u32 oldColor) {
|
||||
u8 r = ColorHelper::getColorValue(oldColor, 2);
|
||||
u8 g = ColorHelper::getColorValue(oldColor, 1);
|
||||
u8 b = ColorHelper::getColorValue(oldColor, 0);
|
||||
|
||||
int selection = 0;
|
||||
while(1) {
|
||||
Draw(r, g, b);
|
||||
|
||||
hidScanInput();
|
||||
hidTouchRead(&touch);
|
||||
|
||||
if (hidKeysDown() & KEY_UP) {
|
||||
if (selection > 0) selection--;
|
||||
}
|
||||
|
||||
if (hidKeysDown() & KEY_DOWN) {
|
||||
if (selection < 2) selection++;
|
||||
}
|
||||
|
||||
if (hidKeysHeld() & KEY_RIGHT) {
|
||||
switch(selection) {
|
||||
case 0: // Red.
|
||||
if (r < 255) r++;
|
||||
break;
|
||||
case 1: // Green.
|
||||
if (g < 255) g++;
|
||||
break;
|
||||
case 2:
|
||||
if (b < 255) b++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hidKeysHeld() & KEY_LEFT) {
|
||||
switch(selection) {
|
||||
case 0: // Red.
|
||||
if (r > 0) r--;
|
||||
break;
|
||||
case 1: // Green.
|
||||
if (g > 0) g--;
|
||||
break;
|
||||
case 2:
|
||||
if (b > 0) b--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hidKeysDown() & KEY_START) {
|
||||
return RGBA8(r, g, b, 255);
|
||||
}
|
||||
|
||||
if (hidKeysDown() & KEY_B) {
|
||||
return 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) {
|
||||
r = i;
|
||||
}
|
||||
|
||||
if (touch.px >= (32.5 + i) && touch.px <= (32.5 + 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) {
|
||||
b = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "keyboard.hpp"
|
||||
#include "overlay.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
|
|
@ -158,6 +159,7 @@ void Settings::DrawColorChanging(void) const {
|
|||
} else if (colorMode == 11) {
|
||||
GFX::DrawButton(100, 100, "");
|
||||
}
|
||||
|
||||
Gui::DrawStringCentered(0, 215, 0.7f, WHITE, Lang::get(colorList[colorMode]), 320);
|
||||
}
|
||||
|
||||
|
|
@ -176,6 +178,7 @@ void Settings::DrawColorChanging(void) const {
|
|||
if (screenPos + i == colorSelection) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, config->textColor(), line1, 320);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -492,6 +495,47 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
}
|
||||
|
||||
} else {
|
||||
if (hDown & KEY_A) {
|
||||
switch(this->colorMode) {
|
||||
case 0:
|
||||
config->barColor(Overlays::SelectColor(config->barColor()));
|
||||
break;
|
||||
case 1:
|
||||
config->topBG(Overlays::SelectColor(config->topBG()));
|
||||
break;
|
||||
case 2:
|
||||
config->bottomBG(Overlays::SelectColor(config->bottomBG()));
|
||||
break;
|
||||
case 3:
|
||||
config->textColor(Overlays::SelectColor(config->textColor()));
|
||||
break;
|
||||
case 4:
|
||||
config->selectedColor(Overlays::SelectColor(config->selectedColor()));
|
||||
break;
|
||||
case 5:
|
||||
config->unselectedColor(Overlays::SelectColor(config->unselectedColor()));
|
||||
break;
|
||||
case 6:
|
||||
config->progressbarColor(Overlays::SelectColor(config->progressbarColor()));
|
||||
break;
|
||||
case 7:
|
||||
config->notfoundColor(Overlays::SelectColor(config->notfoundColor()));
|
||||
break;
|
||||
case 8:
|
||||
config->outdatedColor(Overlays::SelectColor(config->outdatedColor()));
|
||||
break;
|
||||
case 9:
|
||||
config->uptodateColor(Overlays::SelectColor(config->uptodateColor()));
|
||||
break;
|
||||
case 10:
|
||||
config->futureColor(Overlays::SelectColor(config->futureColor()));
|
||||
break;
|
||||
case 11:
|
||||
config->buttonColor(Overlays::SelectColor(config->buttonColor()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) {
|
||||
colorSelection = colorMode;
|
||||
dropDownMenu = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue