Some, uhh.. changes?

This commit is contained in:
StackZ
2020-06-27 09:15:29 +02:00
parent e3cda40b38
commit f68613ef06
63 changed files with 477 additions and 585 deletions
+3 -5
View File
@@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
* 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
@@ -26,8 +26,7 @@
#include "colorHelper.hpp"
int ColorHelper::getColorValue(int color, int bgr)
{
int ColorHelper::getColorValue(int color, int bgr) {
char colorName[10];
int i;
std::stringstream ss;
@@ -40,8 +39,7 @@ int ColorHelper::getColorValue(int color, int bgr)
return i;
}
std::string ColorHelper::getColorName(int color, int bgr)
{
std::string ColorHelper::getColorName(int color, int bgr) {
char colorName[10];
int i = getColorValue(color, bgr);
itoa(i, colorName, 10);
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
* 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
@@ -24,9 +24,9 @@
* reasonable ways as different from the original version.
*/
#include "colorHelper.hpp"
#include "common.hpp"
#include "config.hpp"
#include "colorHelper.hpp"
#include <citro2d.h>
#include <unistd.h>
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
* 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
+30 -13
View File
@@ -1,3 +1,29 @@
/*
* 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 "common.hpp"
#include "config.hpp"
#include "fileBrowse.hpp"
@@ -29,7 +55,7 @@ std::vector<DirEntry> dirContents;
extern bool touching(touchPosition touch, Structs::ButtonPos button);
extern touchPosition touch;
std::vector<Structs::ButtonPos> buttonPositions = {
const std::vector<Structs::ButtonPos> buttonPositions = {
{295, 0, 25, 25}, // Arrow Up.
{295, 215, 25, 25}, // Arrow Down.
{15, 220, 50, 15}, // Open.
@@ -178,13 +204,8 @@ std::string selectFilePath(std::string selectText, std::string initialPath, cons
GFX::DrawTop();
char path[PATH_MAX];
getcwd(path, PATH_MAX);
if (config->useBars() == true) {
Gui::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, 2, 0.60f, config->textColor(), path, 390);
Gui::DrawStringCentered(0, 220, 0.60f, config->textColor(), selectText, 390);
} else {
Gui::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, 0, 0.60f, config->textColor(), path, 390);
Gui::DrawStringCentered(0, 218, 0.60f, config->textColor(), selectText, 390);
}
Gui::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, config->useBars() ? 0 : 2, 0.60f, config->textColor(), path, 390);
Gui::DrawStringCentered(0, config->useBars() ? 220 : 218, 0.60f, config->textColor(), selectText, 390);
GFX::DrawBottom();
if (config->viewMode() == 0) {
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)dirContents.size(); i++) {
@@ -206,11 +227,7 @@ std::string selectFilePath(std::string selectText, std::string initialPath, cons
}
}
if (config->useBars() == true) {
Gui::DrawStringCentered(0, 0, 0.45f, config->textColor(), Lang::get("FILEBROWSE_MSG"), 260);
} else {
Gui::DrawStringCentered(0, 2, 0.45f, config->textColor(), Lang::get("FILEBROWSE_MSG"), 260);
}
Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.45f, config->textColor(), Lang::get("FILEBROWSE_MSG"), 260);
GFX::DrawArrow(295, -1);
GFX::DrawArrow(315, 240, 180.0);
GFX::DrawSpriteBlend(sprites_view_idx, buttonPositions[6].x, buttonPositions[6].y);
+3 -4
View File
@@ -1,6 +1,5 @@
#include "files.h"
FS_Path getPathInfo(const char * path, FS_ArchiveID * archive) {
*archive = ARCHIVE_SDMC;
FS_Path filePath = {0};
@@ -8,8 +7,7 @@ FS_Path getPathInfo(const char * path, FS_ArchiveID * archive) {
if (!strncmp(path, "sdmc:/", 6)) {
prefixlen = 5;
}
else if (*path != '/') {
} else if (*path != '/') {
//if the path is local (doesnt start with a slash), it needs to be appended to the working dir to be valid
char * actualPath = NULL;
asprintf(&actualPath, "%s%s", WORKING_DIR, path);
@@ -18,8 +16,9 @@ FS_Path getPathInfo(const char * path, FS_ArchiveID * archive) {
}
//if the filePath wasnt set above, set it
if (filePath.size == 0)
if (filePath.size == 0) {
filePath = fsMakePath(PATH_ASCII, path+prefixlen);
}
return filePath;
}
+7 -6
View File
@@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
* 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
@@ -29,16 +29,17 @@
// adapted from GM9i's byte parsing.
std::string formatBytes(int bytes) {
char out[32];
if (bytes == 1)
if (bytes == 1) {
snprintf(out, sizeof(out), "%d Byte", bytes);
else if (bytes < 1024)
} else if (bytes < 1024) {
snprintf(out, sizeof(out), "%d Bytes", bytes);
else if (bytes < 1024 * 1024)
} else if (bytes < 1024 * 1024) {
snprintf(out, sizeof(out), "%.1f KB", (float)bytes / 1024);
else if (bytes < 1024 * 1024 * 1024)
} else if (bytes < 1024 * 1024 * 1024) {
snprintf(out, sizeof(out), "%.1f MB", (float)bytes / 1024 / 1024);
else
} else {
snprintf(out, sizeof(out), "%.1f GB", (float)bytes / 1024 / 1024 / 1024);
}
return out;
}
+11 -15
View File
@@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
* 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
@@ -37,7 +37,7 @@
#include <unistd.h>
extern bool showProgressBar;
extern int progressBarType;
extern ProgressBar progressbarType;
extern char progressBarMsg[128];
extern int filesExtracted;
@@ -61,6 +61,7 @@ int ScriptHelper::getNum(nlohmann::json json, const std::string &key, const std:
if (!json.at(key).contains(key2)) return 0;
if (!json.at(key).at(key2).is_number()) return 0;
return json.at(key).at(key2).get_ref<const int64_t&>();
}
@@ -83,7 +84,7 @@ Result ScriptHelper::downloadFile(std::string file, std::string output, std::str
Result ret = NONE;
snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
showProgressBar = true;
progressBarType = 0;
progressbarType = ProgressBar::Downloading;
Threads::create((ThreadFunc)displayProgressBar);
if (downloadToFile(file, output) != 0) {
showProgressBar = false;
@@ -112,7 +113,7 @@ Result ScriptHelper::removeFile(std::string file, std::string message) {
void ScriptHelper::installFile(std::string file, bool updatingSelf, std::string message) {
snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
showProgressBar = true;
progressBarType = 2;
progressbarType = ProgressBar::Installing;
Threads::create((ThreadFunc)displayProgressBar);
installCia(file.c_str(), updatingSelf);
showProgressBar = false;
@@ -123,7 +124,7 @@ void ScriptHelper::extractFile(std::string file, std::string input, std::string
snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
showProgressBar = true;
filesExtracted = 0;
progressBarType = 1;
progressbarType = ProgressBar::Extracting;
Threads::create((ThreadFunc)displayProgressBar);
extractArchive(file, input, output);
showProgressBar = false;
@@ -170,13 +171,8 @@ void ScriptHelper::bootTitle(const std::string TitleID, bool isNAND, std::string
else MSG += Lang::get("MEDIATYPE_SD") + "\n" + TitleID;
u64 ID = std::stoull(TitleID, 0, 16);
if (Msg::promptMsg(MSG)) {
if (isNAND == true) {
Msg::DisplayMsg(message);
CIA_LaunchTitle(ID, MEDIATYPE_NAND);
} else {
Msg::DisplayMsg(message);
CIA_LaunchTitle(ID, MEDIATYPE_SD);
}
Msg::DisplayMsg(message);
CIA_LaunchTitle(ID, isNAND ? MEDIATYPE_NAND : MEDIATYPE_SD);
}
}
@@ -191,13 +187,13 @@ Result ScriptHelper::prompt(std::string message) {
Result ScriptHelper::copyFile(std::string source, std::string destination, std::string message) {
Result ret = NONE;
if (access(source.c_str(), F_OK) != 0 ) {
if (access(source.c_str(), F_OK) != 0) {
return COPY_ERROR;
}
Msg::DisplayMsg(message);
// If destination does not exist, create dirs.
if (access(destination.c_str(), F_OK) != 0 ) {
if (access(destination.c_str(), F_OK) != 0) {
makeDirs(destination.c_str());
}
@@ -207,7 +203,7 @@ Result ScriptHelper::copyFile(std::string source, std::string destination, std::
Result ScriptHelper::renameFile(std::string oldName, std::string newName, std::string message) {
Result ret = NONE;
if (access(oldName.c_str(), F_OK) != 0 ) {
if (access(oldName.c_str(), F_OK) != 0) {
return MOVE_ERROR;
}
-1
View File
@@ -25,7 +25,6 @@ typedef struct _WavHeader {
static_assert(sizeof(WavHeader) == 44, "WavHeader size is not 44 bytes.");
sound::sound(const string& path, int channel, bool toloop) {
ndspSetOutputMode(NDSP_OUTPUT_STEREO);
ndspSetOutputCount(2); // Num of buffers
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
* 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
+2 -4
View File
@@ -6,16 +6,14 @@
static std::vector<Thread> threads;
void Threads::create(ThreadFunc entrypoint)
{
void Threads::create(ThreadFunc entrypoint) {
s32 prio = 0;
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
Thread thread = threadCreate((ThreadFunc)entrypoint, NULL, 64 * 1024, prio - 1, -2, false);
threads.push_back(thread);
}
void Threads::destroy(void)
{
void Threads::destroy(void) {
for (u32 i = 0; i < threads.size(); i++) {
threadJoin(threads.at(i), U64_MAX);
threadFree(threads.at(i));