Fully rewrite config.

This commit is contained in:
StackZ
2020-06-20 15:22:50 +02:00
parent 7972fd483a
commit 50e4aa99e0
22 changed files with 1372 additions and 1274 deletions
+20 -19
View File
@@ -27,6 +27,7 @@
#include "common.hpp"
#include "gfx.hpp"
extern std::unique_ptr<Config> config;
extern bool isScriptSelected;
extern u32 barColor;
extern u32 bgTopColor;
@@ -36,10 +37,10 @@ extern u32 TextColor;
void GFX::DrawTop(void) {
Gui::ScreenDraw(Top);
if (isScriptSelected == false) {
Gui::Draw_Rect(0, 0, 400, 25, Config::Color1);
Gui::Draw_Rect(0, 25, 400, 190, Config::Color2);
Gui::Draw_Rect(0, 215, 400, 25, Config::Color1);
if (Config::UseBars == true) {
Gui::Draw_Rect(0, 0, 400, 25, config->barColor());
Gui::Draw_Rect(0, 25, 400, 190, config->topBG());
Gui::Draw_Rect(0, 215, 400, 25, config->barColor());
if (config->useBars() == true) {
DrawSprite(sprites_top_screen_top_idx, 0, 0);
DrawSprite(sprites_top_screen_bot_idx, 0, 215);
}
@@ -47,7 +48,7 @@ void GFX::DrawTop(void) {
Gui::Draw_Rect(0, 0, 400, 30, barColor);
Gui::Draw_Rect(0, 25, 400, 190, bgBottomColor);
Gui::Draw_Rect(0, 215, 400, 25, barColor);
if (Config::UseBars == true) {
if (config->useBars() == true) {
DrawSprite(sprites_top_screen_top_idx, 0, 0);
DrawSprite(sprites_top_screen_bot_idx, 0, 215);
}
@@ -57,10 +58,10 @@ void GFX::DrawTop(void) {
void GFX::DrawBottom(void) {
Gui::ScreenDraw(Bottom);
if (isScriptSelected == false) {
Gui::Draw_Rect(0, 0, 320, 25, Config::Color1);
Gui::Draw_Rect(0, 25, 320, 190, Config::Color3);
Gui::Draw_Rect(0, 215, 320, 25, Config::Color1);
if (Config::UseBars == true) {
Gui::Draw_Rect(0, 0, 320, 25, config->barColor());
Gui::Draw_Rect(0, 25, 320, 190, config->bottomBG());
Gui::Draw_Rect(0, 215, 320, 25, config->barColor());
if (config->useBars() == true) {
DrawSprite(sprites_bottom_screen_top_idx, 0, 0);
DrawSprite(sprites_bottom_screen_bot_idx, 0, 215);
}
@@ -68,7 +69,7 @@ void GFX::DrawBottom(void) {
Gui::Draw_Rect(0, 0, 320, 30, barColor);
Gui::Draw_Rect(0, 25, 320, 190, bgBottomColor);
Gui::Draw_Rect(0, 215, 320, 25, barColor);
if (Config::UseBars == true) {
if (config->useBars() == true) {
DrawSprite(sprites_bottom_screen_top_idx, 0, 0);
DrawSprite(sprites_bottom_screen_bot_idx, 0, 215);
}
@@ -89,10 +90,10 @@ void GFX::DrawSpriteBlend(int img, int x, int y, float ScaleX, float ScaleY) {
C2D_SetImageTint(&tint, C2D_BotLeft, TextColor, 0.5);
C2D_SetImageTint(&tint, C2D_BotRight, TextColor, 0.5);
} else {
C2D_SetImageTint(&tint, C2D_TopLeft, Config::TxtColor, 0.5);
C2D_SetImageTint(&tint, C2D_TopRight, Config::TxtColor, 0.5);
C2D_SetImageTint(&tint, C2D_BotLeft, Config::TxtColor, 0.5);
C2D_SetImageTint(&tint, C2D_BotRight, Config::TxtColor, 0.5);
C2D_SetImageTint(&tint, C2D_TopLeft, config->textColor(), 0.5);
C2D_SetImageTint(&tint, C2D_TopRight, config->textColor(), 0.5);
C2D_SetImageTint(&tint, C2D_BotLeft, config->textColor(), 0.5);
C2D_SetImageTint(&tint, C2D_BotRight, config->textColor(), 0.5);
}
C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, img), x, y, 0.5f, &tint, ScaleX, ScaleY);
@@ -107,10 +108,10 @@ void GFX::DrawArrow(int x, int y, float rotation, int arrowSprite) {
C2D_SetImageTint(&tint, C2D_BotLeft, TextColor, 0.5);
C2D_SetImageTint(&tint, C2D_BotRight, TextColor, 0.5);
} else {
C2D_SetImageTint(&tint, C2D_TopLeft, Config::TxtColor, 0.5);
C2D_SetImageTint(&tint, C2D_TopRight, Config::TxtColor, 0.5);
C2D_SetImageTint(&tint, C2D_BotLeft, Config::TxtColor, 0.5);
C2D_SetImageTint(&tint, C2D_BotRight, Config::TxtColor, 0.5);
C2D_SetImageTint(&tint, C2D_TopLeft, config->textColor(), 0.5);
C2D_SetImageTint(&tint, C2D_TopRight, config->textColor(), 0.5);
C2D_SetImageTint(&tint, C2D_BotLeft, config->textColor(), 0.5);
C2D_SetImageTint(&tint, C2D_BotRight, config->textColor(), 0.5);
}
if (arrowSprite == 0) {
@@ -138,6 +139,6 @@ void GFX::DrawButton(int x, int y, std::string ButtonText, u32 color) {
if (isScriptSelected) {
Gui::DrawStringCentered(- (158/2) + x, y + (61/2) - (Gui::GetStringHeight(0.6f, ButtonText) / 2), 0.6f, TextColor, ButtonText, 145, 30);
} else {
Gui::DrawStringCentered(- (158/2) + x, y + (61/2) - (Gui::GetStringHeight(0.6f, ButtonText) / 2), 0.6f, Config::TxtColor, ButtonText, 145, 30);
Gui::DrawStringCentered(- (158/2) + x, y + (61/2) - (Gui::GetStringHeight(0.6f, ButtonText) / 2), 0.6f, config->textColor(), ButtonText, 145, 30);
}
}
+18 -17
View File
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <ctype.h>
extern std::unique_ptr<Config> config;
extern C3D_RenderTarget* Top;
extern C3D_RenderTarget* Bottom;
@@ -80,21 +81,21 @@ extern bool touching(touchPosition touch, Structs::ButtonPos button);
void Input::DrawNumpad() {
for(uint i=0;i<(sizeof(NumpadStruct)/sizeof(NumpadStruct[0]));i++) {
Gui::Draw_Rect(NumpadStruct[i].x, NumpadStruct[i].y, 60, 50, Config::Color1);
Gui::Draw_Rect(NumpadStruct[i].x, NumpadStruct[i].y, 60, 50, config->barColor());
char c[2] = {NumpadStruct[i].character[0]};
Gui::DrawString(NumpadStruct[i].x+25, NumpadStruct[i].y+15, 0.72f, Config::TxtColor, c, 50);
Gui::DrawString(NumpadStruct[i].x+25, NumpadStruct[i].y+15, 0.72f, config->textColor(), c, 50);
}
}
void Input::drawKeyboard() {
for(uint i=0;i<(sizeof(keysQWERTY)/sizeof(keysQWERTY[0]));i++) {
C2D_DrawRectSolid(keysQWERTY[i].x, keysQWERTY[i].y+103, 0.5f, 20, 20, Config::Color1 & C2D_Color32(255, 255, 255, 200));
C2D_DrawRectSolid(keysQWERTY[i].x, keysQWERTY[i].y+103, 0.5f, 20, 20, config->barColor() & C2D_Color32(255, 255, 255, 200));
if (shift) {
char c[2] = {caps ? (char)toupper(keysQWERTYShift[i].character[0]) : keysQWERTYShift[i].character[0]};
Gui::DrawString(keysQWERTYShift[i].x+(10-(Gui::GetStringWidth(0.50, c)/2)), keysQWERTYShift[i].y+103+(10-(Gui::GetStringHeight(0.50, c)/2)), 0.50, Config::TxtColor, c);
Gui::DrawString(keysQWERTYShift[i].x+(10-(Gui::GetStringWidth(0.50, c)/2)), keysQWERTYShift[i].y+103+(10-(Gui::GetStringHeight(0.50, c)/2)), 0.50, config->textColor(), c);
} else {
char c[2] = {caps ? (char)toupper(keysQWERTY[i].character[0]) : keysQWERTY[i].character[0]};
Gui::DrawString(keysQWERTY[i].x+(10-(Gui::GetStringWidth(0.50, c)/2)), keysQWERTY[i].y+103+(10-(Gui::GetStringHeight(0.50, c)/2)), 0.50, Config::TxtColor, c);
Gui::DrawString(keysQWERTY[i].x+(10-(Gui::GetStringWidth(0.50, c)/2)), keysQWERTY[i].y+103+(10-(Gui::GetStringHeight(0.50, c)/2)), 0.50, config->textColor(), c);
}
}
@@ -104,13 +105,13 @@ void Input::drawKeyboard() {
std::string backSpace = modifierKeys[0].character;
std::string caps = modifierKeys[1].character;
C2D_DrawRectSolid(modifierKeys[i].x, modifierKeys[i].y+103, 0.5f, modifierKeys[i].w, 20, Config::Color1 & C2D_Color32(255, 255, 255, 200));
Gui::DrawString(modifierKeys[2].x+5, modifierKeys[2].y+105, 0.50, Config::TxtColor, enter);
Gui::DrawString(modifierKeys[3].x+7, modifierKeys[3].y+105, 0.45, Config::TxtColor, arrowUp);
Gui::DrawString(modifierKeys[4].x+10, modifierKeys[4].y+105, 0.45, Config::TxtColor, arrowUp);
C2D_DrawRectSolid(modifierKeys[i].x, modifierKeys[i].y+103, 0.5f, modifierKeys[i].w, 20, config->barColor() & C2D_Color32(255, 255, 255, 200));
Gui::DrawString(modifierKeys[2].x+5, modifierKeys[2].y+105, 0.50, config->textColor(), enter);
Gui::DrawString(modifierKeys[3].x+7, modifierKeys[3].y+105, 0.45, config->textColor(), arrowUp);
Gui::DrawString(modifierKeys[4].x+10, modifierKeys[4].y+105, 0.45, config->textColor(), arrowUp);
Gui::DrawString(modifierKeys[0].x+5, modifierKeys[0].y+105, 0.45, Config::TxtColor, backSpace);
Gui::DrawString(modifierKeys[1].x+5, modifierKeys[1].y+105, 0.45, Config::TxtColor, caps);
Gui::DrawString(modifierKeys[0].x+5, modifierKeys[0].y+105, 0.45, config->textColor(), backSpace);
Gui::DrawString(modifierKeys[1].x+5, modifierKeys[1].y+105, 0.45, config->textColor(), caps);
}
}
@@ -130,11 +131,11 @@ std::string Input::Numpad(uint maxLength, std::string Text) {
C2D_TargetClear(Top, BLACK);
C2D_TargetClear(Bottom, BLACK);
GFX::DrawTop();
Gui::DrawString((400-Gui::GetStringWidth(0.55f, Text))/2, 2, 0.55f, Config::TxtColor, Text, 400);
Gui::DrawString(180, 217, 0.8, Config::TxtColor, (string+(cursorBlink-- > 0 ? "_" : "")).c_str(), 400);
Gui::DrawString((400-Gui::GetStringWidth(0.55f, Text))/2, 2, 0.55f, config->textColor(), Text, 400);
Gui::DrawString(180, 217, 0.8, config->textColor(), (string+(cursorBlink-- > 0 ? "_" : "")).c_str(), 400);
if (cursorBlink < -20) cursorBlink = 20;
Gui::ScreenDraw(Bottom);
Gui::Draw_Rect(0, 0, 320, 240, Config::Color3);
Gui::Draw_Rect(0, 0, 320, 240, config->bottomBG());
DrawNumpad();
scanKeys();
hDown = keysDown();
@@ -211,11 +212,11 @@ std::string Input::getString(uint maxLength, std::string Text, float inputTextSi
Gui::clearTextBufs();
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
GFX::DrawTop();
Gui::DrawString((400-Gui::GetStringWidth(0.55f, Text))/2, 2, 0.55f, Config::TxtColor, Text, 400);
Gui::DrawString((400-Gui::GetStringWidth(0.55f, Text))/2, 2, 0.55f, config->textColor(), Text, 400);
GFX::DrawBottom();
drawKeyboard();
C2D_DrawRectSolid(0, 81, 0.5f, 320, 20, Config::Color1 & C2D_Color32(200, 200, 200, 200));
Gui::DrawString(2, 82, inputTextSize, Config::TxtColor, (string+(cursorBlink-- > 0 ? "_" : "")).c_str(), 316);
C2D_DrawRectSolid(0, 81, 0.5f, 320, 20, config->barColor() & C2D_Color32(200, 200, 200, 200));
Gui::DrawString(2, 82, inputTextSize, config->textColor(), (string+(cursorBlink-- > 0 ? "_" : "")).c_str(), 316);
if (cursorBlink < -20) cursorBlink = 20;
scanKeys();
hDown = keysDown();
+16 -15
View File
@@ -27,6 +27,7 @@
#include "common.hpp"
#include "msg.hpp"
extern std::unique_ptr<Config> config;
extern bool isScriptSelected;
extern u32 barColor;
@@ -41,15 +42,15 @@ void Msg::DisplayStartMSG() {
C2D_TargetClear(Top, BLACK);
C2D_TargetClear(Bottom, BLACK);
Gui::ScreenDraw(Top);
Gui::Draw_Rect(0, 0, 400, 25, Config::Color1);
Gui::Draw_Rect(0, 25, 400, 190, Config::Color2);
Gui::Draw_Rect(0, 215, 400, 25, Config::Color1);
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("STARTING_UNIVERSAL_UPDATER"));
Gui::Draw_Rect(0, 0, 400, 25, config->barColor());
Gui::Draw_Rect(0, 25, 400, 190, config->topBG());
Gui::Draw_Rect(0, 215, 400, 25, config->barColor());
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("STARTING_UNIVERSAL_UPDATER"));
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
Gui::ScreenDraw(Bottom);
Gui::Draw_Rect(0, 0, 320, 25, Config::Color1);
Gui::Draw_Rect(0, 25, 320, 190, Config::Color2);
Gui::Draw_Rect(0, 215, 320, 25, Config::Color1);
Gui::Draw_Rect(0, 0, 320, 25, config->barColor());
Gui::Draw_Rect(0, 25, 320, 190, config->topBG());
Gui::Draw_Rect(0, 215, 320, 25, config->barColor());
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
C3D_FrameEnd(0);
}
@@ -61,7 +62,7 @@ void Msg::DisplayMsg(std::string text) {
C2D_TargetClear(Bottom, BLACK);
GFX::DrawTop();
if (isScriptSelected == false) {
Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, text))/2, 0.6f, Config::TxtColor, text, 395, 70);
Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, text))/2, 0.6f, config->textColor(), text, 395, 70);
} else if (isScriptSelected == true) {
Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, text))/2, 0.6f, TextColor, text, 395, 70);
}
@@ -77,7 +78,7 @@ void Msg::DisplayWarnMsg(std::string Text) {
C2D_TargetClear(Bottom, BLACK);
GFX::DrawTop();
if (isScriptSelected == false) {
Gui::DrawStringCentered(0, 1, 0.6f, Config::TxtColor, Text, 400);
Gui::DrawStringCentered(0, 1, 0.6f, config->textColor(), Text, 400);
} else if (isScriptSelected == true) {
Gui::DrawStringCentered(0, 1, 0.6f, TextColor, Text, 400);
}
@@ -106,8 +107,8 @@ bool Msg::promptMsg(std::string promptMsg) {
C2D_TargetClear(Bottom, BLACK);
GFX::DrawTop();
if (isScriptSelected == false) {
Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, promptMsg))/2, 0.6f, Config::TxtColor, promptMsg, 395, 70);
Gui::DrawStringCentered(0, 217, 0.72f, Config::TxtColor, Lang::get("CONFIRM_OR_CANCEL"), 400);
Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, promptMsg))/2, 0.6f, config->textColor(), promptMsg, 395, 70);
Gui::DrawStringCentered(0, 217, 0.72f, config->textColor(), Lang::get("CONFIRM_OR_CANCEL"), 400);
} else if (isScriptSelected == true) {
Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, promptMsg))/2, 0.6f, TextColor, promptMsg, 395, 70);
Gui::DrawStringCentered(0, 217, 0.72f, TextColor, Lang::get("CONFIRM_OR_CANCEL"), 400);
@@ -115,10 +116,10 @@ bool Msg::promptMsg(std::string promptMsg) {
GFX::DrawBottom();
if (isScriptSelected == false) {
Gui::Draw_Rect(10, 100, 140, 35, Config::Color1);
Gui::Draw_Rect(170, 100, 140, 35, Config::Color1);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("YES")))/2-150+70, 110, 0.6f, Config::TxtColor, Lang::get("YES"), 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("NO")))/2+150-70, 110, 0.6f, Config::TxtColor, Lang::get("NO"), 140);
Gui::Draw_Rect(10, 100, 140, 35, config->barColor());
Gui::Draw_Rect(170, 100, 140, 35, config->barColor());
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("YES")))/2-150+70, 110, 0.6f, config->textColor(), Lang::get("YES"), 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("NO")))/2+150-70, 110, 0.6f, config->textColor(), Lang::get("NO"), 140);
} else if (isScriptSelected == true) {
Gui::Draw_Rect(10, 100, 140, 35, barColor);
Gui::Draw_Rect(170, 100, 140, 35, barColor);