@ -1,6 +0,0 @@ | |||
[submodule "SimpleIniParser"] | |||
path = SimpleIniParser | |||
url = https://github.com/AtlasNX/SimpleIniParser.git | |||
[submodule "Swurl"] | |||
path = Swurl | |||
url = https://github.com/AtlasNX/Swurl.git |
@ -1,20 +1,3 @@ | |||
# Kosmos Updater | |||
A homebrew application for the Nintendo Switch that will automatically update your CFW with the latest from Kosmos. | |||
## settings.cfg | |||
| Config option | Description | |||
| --------------------------------------------------------------------------- | --- | |||
| `host = "http://kosmos-updater.teamatlasnx.com";` | Which server to connect to. You can host your own server using the files in the [server repository](https://github.com/AtlasNX/Kosmos-Updater-Server). | |||
| `ignore = [ "sdmc://fileToIgnore.nro", "sdmc://anotherFileToIgnore.nro" ];` | Array of files to ignore when extracting. | |||
| `autoupdate = true;` | Whether or not to auto update Kosmos Updater. | |||
| `proxy_enabled = false;` | Whether or not to use a proxy for network calls. | |||
| `proxy_url = "http://example.com:8080";` | The URL of the proxy server. | |||
| `proxy_username = "username";` | The username to use for the proxy server, if blank it will not be used. | |||
| `proxy_password = "password";` | The password to use for the proxy server, if blank it will not be used. | |||
## Credits | |||
* Thanks to vgmoose for examples on using minizip in appstorenx. | |||
* Thanks to y4my4m and natinusala in the ReSwitched discord for their discussions around libcurl. | |||
This was an attempt to clean up Kosmos Updater codebase, but keep SDL. This was code I was working on for Skyline (UI Library). Even then this UI code is out of date with the effort I put into Chocolate Doom Launcher, so I would recommend looking at that project. |
@ -0,0 +1,10 @@ | |||
auto_update = true; | |||
ignored_files = [ ]; | |||
install_es_patches = false; | |||
installed_files = [ ]; | |||
installed_version = ""; | |||
proxy_enabled = false; | |||
proxy_url = ""; | |||
proxy_username = ""; | |||
proxy_password = ""; | |||
hide_exfat_warning = false; |
@ -0,0 +1,12 @@ | |||
WarningHeader = "Warning - SD Card Corruption"; | |||
WarningBody = "Kosmos Updater may cause corruption to your SD card if it is formatted as ExFAT. This\nis due to an issue with Nintendo's ExFAT drivers built into the Switch. It is recommended\nthat you use an SD card formatted as FAT32, however if you wish to continue and you are\nusing ExFAT you do so at your own risk. This warning will not show up again."; | |||
WarningFooter = "Press any button or tap to continue."; | |||
AppTitle = "Kosmos Updater"; | |||
ActionQuit = "Quit"; | |||
CheckingKosmosUpdaterUpdate = "Checking for updates to Kosmos Updater..."; | |||
DownloadKosmosUpdaterUpdate = "Getting the latest version of Kosmos Updater..."; | |||
SuccessKosmosUpdaterUpdateText = "Kosmos Updater has been updated to version %s!"; | |||
SuccessKosmosUpdaterUpdateSubtext = "Please restart the app to update your files."; | |||
ErrorKosmosUpdaterUpdateText = "Please restart the app to try again."; |
@ -0,0 +1,244 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include <switch.h> | |||
#include <SDL2/SDL.h> | |||
#include <SDL2/SDL_image.h> | |||
#include <SDL2/SDL_ttf.h> | |||
#include "Application.hpp" | |||
#include "Constants.hpp" | |||
#include "Utils/FontManager.hpp" | |||
#include "Utils/ThemeManager.hpp" | |||
#include "Utils/VersionService.hpp" | |||
using namespace KosmosUpdater::Utils; | |||
namespace KosmosUpdater { | |||
Application::Application() { | |||
currentApplication = this; | |||
Result rc; | |||
#ifdef DEBUG | |||
nxlinkStdio(); | |||
#endif | |||
rc = romfsInit(); | |||
if (R_FAILED(rc)) | |||
return; | |||
_initializedServices |= ROMFS_SERVICE; | |||
rc = setInitialize(); | |||
if (R_FAILED(rc)) | |||
return; | |||
_initializedServices |= SET_SERVICE; | |||
rc = setsysInitialize(); | |||
if (R_FAILED(rc)) | |||
return; | |||
_initializedServices |= SETSYS_SERVICE; | |||
rc = plInitialize(); | |||
if (R_FAILED(rc)) | |||
return; | |||
_initializedServices |= PL_SERVICE; | |||
if (!SDL_Init(SDL_INIT_EVERYTHING)) | |||
return; | |||
_initializedServices |= SDL_SERVICE; | |||
if (!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)) | |||
return; | |||
_initializedServices |= SDL_IMG_SERVICE; | |||
window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_FULLSCREEN); | |||
if (!window) | |||
return; | |||
renderer = SDL_CreateRenderer(window, 0, SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE); | |||
if (!renderer) | |||
return; | |||
SDL_SetRenderDrawBlendMode(Application::renderer, SDL_BLENDMODE_BLEND); | |||
if (TTF_Init() == -1) | |||
return; | |||
_initializedServices |= SDL_TTF_SERVICE; | |||
_nowTime = _lastTime = SDL_GetPerformanceCounter(); | |||
_initialized = true; | |||
} | |||
Application::~Application() { | |||
FontManager::Instance()->dealloc(); | |||
if (_currentScene != NULL) | |||
delete _currentScene; | |||
if (_initializedServices & SDL_TTF_SERVICE) | |||
TTF_Quit(); | |||
if (renderer != NULL) | |||
SDL_DestroyRenderer(renderer); | |||
if (window != NULL) | |||
SDL_DestroyWindow(window); | |||
if (_initializedServices & SDL_IMG_SERVICE) | |||
IMG_Quit(); | |||
if (_initializedServices & SDL_SERVICE) | |||
SDL_Quit(); | |||
if (_initializedServices & PL_SERVICE) | |||
plExit(); | |||
if (_initializedServices & SETSYS_SERVICE) | |||
setsysExit(); | |||
if (_initializedServices & SET_SERVICE) | |||
setExit(); | |||
if (_initializedServices & ROMFS_SERVICE) | |||
romfsExit(); | |||
} | |||
int Application::start(Scene * scene) { | |||
if (!_initialized || !window || !renderer) | |||
return -1; | |||
_currentScene = scene; | |||
// Main Game Loop | |||
while (appletMainLoop()) | |||
{ | |||
double dTime = _getDeltaTime(); | |||
// Handle controller inputs | |||
hidScanInput(); | |||
if (modal != NULL) { | |||
_processControllerForModal(CONTROLLER_P1_AUTO, dTime); | |||
} else { | |||
_processControllerForScene(CONTROLLER_P1_AUTO, dTime); | |||
} | |||
if (_handlePossibleSceneChange()) | |||
break; | |||
_render(dTime); | |||
if (_handlePossibleSceneChange()) | |||
break; | |||
// Present our frame. | |||
SDL_RenderPresent(renderer); | |||
} | |||
return 0; | |||
} | |||
void Application::render() { | |||
double dTime = _getDeltaTime(); | |||
_render(dTime); | |||
// Present our frame. | |||
SDL_RenderPresent(renderer); | |||
} | |||
void Application::switchScene(Scene * scene) { | |||
if (_currentScene != NULL) { | |||
_previousScene = _currentScene; | |||
} | |||
_currentScene = scene; | |||
} | |||
double Application::_getDeltaTime() { | |||
_lastTime = _nowTime; | |||
_nowTime = SDL_GetPerformanceCounter(); | |||
return (double) ((_nowTime - _lastTime) * 1000 / SDL_GetPerformanceFrequency()); | |||
} | |||
void Application::_processControllerForModal(HidControllerID id, double dTime) { | |||
if (modal->enabledEvents & BUTTON_HELD_EVENT) { | |||
u32 kHeld = hidKeysHeld(id); | |||
modal->buttonsHeld(kHeld, dTime); | |||
} | |||
if (modal->enabledEvents & BUTTON_DOWN_EVENT) { | |||
u32 kDown = hidKeysDown(id); | |||
modal->buttonsDown(kDown, dTime); | |||
} | |||
if (modal->enabledEvents & BUTTON_UP_EVENT) { | |||
u32 kHeld = hidKeysUp(id); | |||
modal->buttonsUp(kHeld, dTime); | |||
} | |||
} | |||
void Application::_processControllerForScene(HidControllerID id, double dTime) { | |||
if (_currentScene != NULL && _currentScene->enabledEvents & BUTTON_HELD_EVENT) { | |||
u32 kHeld = hidKeysHeld(id); | |||
_currentScene->buttonsHeld(kHeld, dTime); | |||
} | |||
if (_currentScene != NULL && _currentScene->enabledEvents & BUTTON_DOWN_EVENT) { | |||
u32 kDown = hidKeysDown(id); | |||
_currentScene->buttonsDown(kDown, dTime); | |||
} | |||
if (_currentScene != NULL && _currentScene->enabledEvents & BUTTON_UP_EVENT) { | |||
u32 kHeld = hidKeysUp(id); | |||
_currentScene->buttonsUp(kHeld, dTime); | |||
} | |||
} | |||
bool Application::_handlePossibleSceneChange() { | |||
// We should clean up our previous scene after switching. | |||
if (_previousScene != NULL) { | |||
delete _previousScene; | |||
_previousScene = NULL; | |||
} | |||
// Kill the app when there is no scene. | |||
if (_currentScene == NULL) { | |||
return true; | |||
} | |||
return false; | |||
} | |||
void Application::_render(double dTime) { | |||
// Clear the screen. | |||
SDL_SetRenderDrawColor( | |||
renderer, | |||
_currentScene->background.r, | |||
_currentScene->background.g, | |||
_currentScene->background.b, | |||
_currentScene->background.a | |||
); | |||
SDL_RenderClear(renderer); | |||
// Call rendering routines. | |||
_currentScene->render({ 0, 0, 1280, 720 }, dTime); | |||
if (modal != NULL) { | |||
modal->render({ 0, 0, 1280, 720 }, dTime); | |||
} | |||
} | |||
} |
@ -0,0 +1,59 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include <switch.h> | |||
#include <SDL2/SDL.h> | |||
#include "Modal.hpp" | |||
#include "Scene.hpp" | |||
#pragma once | |||
namespace KosmosUpdater { | |||
class Application { | |||
public: | |||
static inline Application * currentApplication = NULL; | |||
static inline SDL_Window * window = NULL; | |||
static inline SDL_Renderer * renderer = NULL; | |||
static inline Modal * modal = NULL; | |||
Application(); | |||
~Application(); | |||
int start(Scene * scene); | |||
void render(); | |||
static void switchScene(Scene * scene); | |||
private: | |||
bool _initialized = false; | |||
u8 _initializedServices = 0; | |||
u64 _nowTime; | |||
u64 _lastTime; | |||
static inline Scene * _currentScene = NULL; | |||
static inline Scene * _previousScene = NULL; | |||
double _getDeltaTime(); | |||
void _processControllerForModal(HidControllerID id, double dTime); | |||
void _processControllerForScene(HidControllerID id, double dTime); | |||
bool _handlePossibleSceneChange(); | |||
void _render(double dTime); | |||
}; | |||
} |
@ -0,0 +1,53 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include <switch.h> | |||
#pragma once | |||
namespace KosmosUpdater { | |||
typedef enum { | |||
BUTTON_HELD_EVENT = BIT(0), | |||
BUTTON_DOWN_EVENT = BIT(1), | |||
BUTTON_UP_EVENT = BIT(2) | |||
} EventTypes; | |||
typedef enum { | |||
ROMFS_SERVICE = BIT(0), | |||
SETSYS_SERVICE = BIT(1), | |||
PL_SERVICE = BIT(2), | |||
SDL_SERVICE = BIT(3), | |||
SDL_IMG_SERVICE = BIT(4), | |||
SDL_TTF_SERVICE = BIT(5), | |||
SET_SERVICE = BIT(6) | |||
} Services; | |||
typedef enum { | |||
LEFT_ALIGN, | |||
CENTER_ALIGN, | |||
RIGHT_ALIGN | |||
} TextAlignment; | |||
typedef enum { | |||
A_BUTTON, | |||
B_BUTTON, | |||
X_BUTTON, | |||
Y_BUTTON | |||
} FooterActionButton; | |||
} |
@ -0,0 +1,50 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include "Modal.hpp" | |||
#include "Utils/ThemeManager.hpp" | |||
#include "Application.hpp" | |||
using namespace KosmosUpdater::Utils; | |||
namespace KosmosUpdater { | |||
void Modal::buttonsHeld(u32 buttons, double dTime) {} | |||
void Modal::buttonsDown(u32 buttons, double dTime) {} | |||
void Modal::buttonsUp(u32 buttons, double dTime) {} | |||
void Modal::render(SDL_Rect rect, double dTime) { | |||
// Draw Faded background. | |||
SDL_Color background = ThemeManager::Instance()->modal_faded_background; | |||
SDL_SetRenderDrawColor(Application::renderer, background.r, background.g, background.b, background.a); | |||
SDL_RenderFillRect(Application::renderer, &rect); | |||
View::render(rect, dTime); | |||
} | |||
void Modal::show() { | |||
Application::modal = this; | |||
} | |||
void Modal:: dismiss(bool success) { | |||
Application::modal = NULL; | |||
if (onDismiss) { | |||
onDismiss(this, success); | |||
} | |||
} | |||
} |
@ -0,0 +1,46 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include <functional> | |||
#include <switch.h> | |||
#include "Constants.hpp" | |||
#include "View.hpp" | |||
#pragma once | |||
namespace KosmosUpdater { | |||
class Modal : public View { | |||
public: | |||
u8 enabledEvents = BUTTON_DOWN_EVENT; | |||
std::function<void(Modal *, bool)> onDismiss; | |||
virtual void buttonsHeld(u32 buttons, double dTime); | |||
virtual void buttonsDown(u32 buttons, double dTime); | |||
virtual void buttonsUp(u32 buttons, double dTime); | |||
virtual void render(SDL_Rect rect, double dTime); | |||
void show(); | |||
void dismiss(bool success); | |||
private: | |||
}; | |||
} |
@ -0,0 +1,38 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include <SDL2/SDL.h> | |||
#include <string> | |||
#include "../Constants.hpp" | |||
#pragma once | |||
namespace KosmosUpdater::Models { | |||
class FooterAction { | |||
public: | |||
FooterActionButton button; | |||
std::string text; | |||
SDL_Texture * texture; | |||
int width; | |||
int height; | |||
}; | |||
} |
@ -0,0 +1,32 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include <SDL2/SDL.h> | |||
#pragma once | |||
namespace KosmosUpdater::Models { | |||
class TextLine { | |||
public: | |||
SDL_Texture * texture; | |||
int width; | |||
int height; | |||
}; | |||
} |
@ -0,0 +1,40 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include "Scene.hpp" | |||
namespace KosmosUpdater { | |||
void Scene::render(SDL_Rect rect, double dTime) { | |||
for (auto const& view : subviews) { | |||
if (!view->isHidden) { | |||
SDL_Rect subviewFrame = view->frame; | |||
view->render({ rect.x + subviewFrame.x, rect.y + subviewFrame.y, subviewFrame.w, subviewFrame.h }, dTime); | |||
} | |||
} | |||
} | |||
void Scene::addSubView(View * view) { | |||
view->superview = NULL; | |||
subviews.push_back(view); | |||
} | |||
void Scene::removeSubView(View * view) { | |||
view->superview = NULL; | |||
subviews.push_back(view); | |||
} | |||
} |
@ -0,0 +1,50 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include <list> | |||
#include <switch.h> | |||
#include "Constants.hpp" | |||
#include "View.hpp" | |||
#pragma once | |||
namespace KosmosUpdater { | |||
class Scene { | |||
public: | |||
SDL_Color background = { 0, 0, 0, 255 }; | |||
u8 enabledEvents = BUTTON_DOWN_EVENT; | |||
std::list<View *> subviews; | |||
Scene(){}; | |||
virtual ~Scene(){}; | |||
virtual void buttonsHeld(u32 buttons, double dTime){}; | |||
virtual void buttonsDown(u32 buttons, double dTime){}; | |||
virtual void buttonsUp(u32 buttons, double dTime){}; | |||
virtual void render(SDL_Rect rect, double dTime); | |||
void addSubView(View * view); | |||
void removeSubView(View * view); | |||
private: | |||
}; | |||
} |
@ -0,0 +1,119 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include <SDL2/SDL_image.h> | |||
#include "AppUpdateScene.hpp" | |||
#include "../Application.hpp" | |||
#include "../Utils/FontManager.hpp" | |||
#include "../Utils/StringManager.hpp" | |||
#include "../Utils/ThemeManager.hpp" | |||
#include "../Utils/VersionService.hpp" | |||
using namespace KosmosUpdater; | |||
using namespace KosmosUpdater::Utils; | |||
using namespace KosmosUpdater::Views; | |||
namespace KosmosUpdater::Scenes { | |||
AppUpdateScene::AppUpdateScene() { | |||
auto fm = FontManager::Instance(); | |||
auto sm = StringManager::Instance(); | |||
auto tm = ThemeManager::Instance(); | |||
background = tm->background; | |||
_headerView = new HeaderView(sm->getLocalizedString(AppTitle), true); | |||
_headerView->frame = { 0, 0, 1280, 88 }; | |||
addSubView(_headerView); | |||
auto path = tm->getAssetDirectory() + "/downloading.png"; | |||
auto image = IMG_Load(path.c_str()); | |||
_downloading = SDL_CreateTextureFromSurface(Application::renderer, image); | |||
SDL_FreeSurface(image); | |||
_downloadImageView = new ImageView(_downloading); | |||
_downloadImageView->frame = { 400, 200, 479, 197 }; | |||
addSubView(_downloadImageView); | |||
_progressBarView = new ProgressBarView(); | |||
_progressBarView->frame = { 437, 457, 411, 10 }; | |||
addSubView(_progressBarView); | |||
auto textColor = tm->text; | |||
auto subBodyFont = fm->getFont(StandardFont, 18); | |||
_statusTextView = new TextView(subBodyFont, sm->getLocalizedString(CheckingKosmosUpdaterUpdate), textColor); | |||
_statusTextView->frame = { 0, 491, 1280, 21 }; | |||
_statusTextView->textAlignment = CENTER_ALIGN; | |||
addSubView(_statusTextView); | |||
_footerView = new FooterView(); | |||
_footerView->frame = { 0, 647, 1280, 73 }; | |||
addSubView(_footerView); | |||
} | |||
AppUpdateScene::~AppUpdateScene() { | |||
if (_headerView != NULL) | |||
delete _headerView; | |||
if (_downloading != NULL) | |||
SDL_DestroyTexture(_downloading); | |||
if (_downloadImageView != NULL) | |||
delete _downloadImageView; | |||
if (_progressBarView != NULL) | |||
delete _progressBarView; | |||
if (_statusTextView != NULL) | |||
delete _statusTextView; | |||
if (_footerView != NULL) | |||
delete _footerView; | |||
} | |||
void AppUpdateScene::buttonsDown(u32 buttons, double dTime) { | |||
if (_state == ErrorState) { | |||
if (buttons & KEY_A) { | |||
Application::switchScene(NULL); | |||
} | |||
} else { | |||
if (buttons & KEY_A) { | |||
Application::switchScene(NULL); | |||
} | |||
} | |||
} | |||
void AppUpdateScene::render(SDL_Rect rect, double dTime) { | |||
Scene::render(rect, dTime); | |||
if (_state == InitState) { | |||
_state = DownloadingVersionNumberState; | |||
// TODO: Download Version Number. | |||
} else if (_state == DownloadedVersionNumberState) { | |||
// TODO: Check if version number is newer, then switch scense or download binary. | |||
} else if (_state == DownloadedBinaryState) { | |||
// TODO: Unload romfs, replace binary, and switch scenes. | |||
} | |||
} | |||
void AppUpdateScene::_onProgressUpdate(double progress) { | |||
_progressBarView->setProgress(progress); | |||
Application::currentApplication->render(); | |||
} | |||
} |
@ -0,0 +1,62 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include <SDL2/SDL.h> | |||
#include "../Scene.hpp" | |||
#include "../Views/FooterView.hpp" | |||
#include "../Views/HeaderView.hpp" | |||
#include "../Views/ImageView.hpp" | |||
#include "../Views/ProgressBarView.hpp" | |||
#include "../Views/TextView.hpp" | |||
#pragma once | |||
namespace KosmosUpdater::Scenes { | |||
typedef enum { | |||
InitState = 0, | |||
DownloadingVersionNumberState = 1, | |||
DownloadedVersionNumberState = 2, | |||
DownloadingBinaryState = 3, | |||
DownloadedBinaryState = 4, | |||
ErrorState = 5, | |||
} AppUpdateState; | |||
class AppUpdateScene : public KosmosUpdater::Scene { | |||
public: | |||
AppUpdateScene(); | |||
~AppUpdateScene(); | |||
void buttonsDown(u32 buttons, double dTime); | |||
void render(SDL_Rect rect, double dTime); | |||
private: | |||
SDL_Texture * _downloading = NULL; | |||
KosmosUpdater::Views::HeaderView * _headerView = NULL; | |||
KosmosUpdater::Views::ImageView * _downloadImageView = NULL; | |||
KosmosUpdater::Views::ProgressBarView * _progressBarView = NULL; | |||
KosmosUpdater::Views::TextView * _statusTextView = NULL; | |||
KosmosUpdater::Views::FooterView * _footerView = NULL; | |||
AppUpdateState _state = InitState; | |||
void _onProgressUpdate(double progress); | |||
}; | |||
} |
@ -0,0 +1,24 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include "CompletionScene.hpp" | |||
namespace KosmosUpdater::Scenes { | |||
} |
@ -0,0 +1,31 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include "../Scene.hpp" | |||
#pragma once | |||
namespace KosmosUpdater::Scenes { | |||
class CompletionScene : public KosmosUpdater::Scene { | |||
public: | |||
private: | |||
}; | |||
} |
@ -0,0 +1,24 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include "ConfirmationScene.hpp" | |||
namespace KosmosUpdater::Scenes { | |||
} |
@ -0,0 +1,31 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include "../Scene.hpp" | |||
#pragma once | |||
namespace KosmosUpdater::Scenes { | |||
class ConfirmationScene : public KosmosUpdater::Scene { | |||
public: | |||
private: | |||
}; | |||
} |
@ -0,0 +1,110 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include "AppUpdateScene.hpp" | |||
#include "ExFatWarningScene.hpp" | |||
#include "../Application.hpp" | |||
#include "../Utils/ConfigManager.hpp" | |||
#include "../Utils/FontManager.hpp" | |||
#include "../Utils/StringManager.hpp" | |||
#include "../Utils/ThemeManager.hpp" | |||
#include "../Views/TextView.hpp" | |||
using namespace KosmosUpdater; | |||
using namespace KosmosUpdater::Utils; | |||
using namespace KosmosUpdater::Views; | |||
namespace KosmosUpdater::Scenes { | |||
ExFatWarningScene::ExFatWarningScene() { | |||
auto cm = ConfigManager::Instance(); | |||
auto fm = FontManager::Instance(); | |||
auto tm = ThemeManager::Instance(); | |||
auto sm = StringManager::Instance(); | |||
if (cm->shouldHideExFatWarning()) { | |||
_skipWarning = true; | |||
return; | |||
} | |||
background = tm->background; | |||
auto textColor = tm->text; | |||
auto headerFont = fm->getFont(StandardFont, 28); | |||
auto bodyFont = fm->getFont(StandardFont, 23); | |||
_headerTextView = new TextView(headerFont, sm->getLocalizedString(WarningHeader), textColor); | |||
_headerTextView->frame = { 0, 122, 1280, 33 }; | |||
_headerTextView->textAlignment = CENTER_ALIGN; | |||
_bodyTextView = new TextView(bodyFont, sm->getLocalizedString(WarningBody), textColor); | |||
_bodyTextView->frame = { 0, 272, 1280, 178 }; | |||
_bodyTextView->textAlignment = CENTER_ALIGN; | |||
_bodyTextView->lineHeight = 50; | |||
_footerTextView = new TextView(headerFont, sm->getLocalizedString(WarningFooter), textColor); | |||
_footerTextView->frame = { 0, 567, 1280, 34 }; | |||
_footerTextView->textAlignment = CENTER_ALIGN; | |||
_footerTextView->alpha = 0; | |||
addSubView(_headerTextView); | |||
addSubView(_bodyTextView); | |||
addSubView(_footerTextView); | |||
} | |||
ExFatWarningScene::~ExFatWarningScene() { | |||
if (_headerTextView != NULL) | |||
delete _headerTextView; | |||
if (_bodyTextView != NULL) | |||
delete _bodyTextView; | |||
if (_footerTextView != NULL) | |||
delete _footerTextView; | |||
} | |||
void ExFatWarningScene::buttonsDown(u32 buttons, double dTime) { | |||
if (buttons > 0 && _footerVisible) { | |||
ConfigManager::Instance()->setHideExFatWarning(true); | |||
ConfigManager::Instance()->synchronize(); | |||
_showAppUpdateScene(); | |||
} | |||
} | |||
void ExFatWarningScene::render(SDL_Rect rect, double dTime) { | |||
if (_skipWarning) { | |||
_showAppUpdateScene(); | |||
} else if (_footerVisible == false) { | |||
_timeSpent += dTime; | |||
if (_timeSpent >= 0 && _timeSpent < 1000) { | |||
_footerTextView->alpha = _timeSpent / 1000 * 255; | |||
} else if (_timeSpent >= 1 && !_footerVisible) { | |||
_footerVisible = true; | |||
_footerTextView->alpha = 255; | |||
} | |||
} | |||
Scene::render(rect, dTime); | |||
} | |||
void ExFatWarningScene::_showAppUpdateScene() { | |||
Application::switchScene(new AppUpdateScene()); | |||
} | |||
} |
@ -0,0 +1,46 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include "../Scene.hpp" | |||
#include "../Views/TextView.hpp" | |||
#pragma once | |||
namespace KosmosUpdater::Scenes { | |||
class ExFatWarningScene : public KosmosUpdater::Scene { | |||
public: | |||
ExFatWarningScene(); | |||
~ExFatWarningScene(); | |||
void buttonsDown(u32 buttons, double dTime); | |||
void render(SDL_Rect rect, double dTime); | |||
private: | |||
double _timeSpent = -10000; | |||
bool _footerVisible = false; | |||
bool _skipWarning = false; | |||
KosmosUpdater::Views::TextView * _headerTextView = NULL; | |||
KosmosUpdater::Views::TextView * _bodyTextView = NULL; | |||
KosmosUpdater::Views::TextView * _footerTextView = NULL; | |||
void _showAppUpdateScene(); | |||
}; | |||
} |
@ -0,0 +1,24 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include "PackageInstallationScene.hpp" | |||
namespace KosmosUpdater::Scenes { | |||
} |
@ -0,0 +1,31 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include "../Scene.hpp" | |||
#pragma once | |||
namespace KosmosUpdater::Scenes { | |||
class PackageInstallationScene : public KosmosUpdater::Scene { | |||
public: | |||
private: | |||
}; | |||
} |
@ -0,0 +1,188 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
#include <fstream> | |||
#include <iostream> | |||
#include "ConfigManager.hpp" | |||
namespace KosmosUpdater::Utils { | |||
ConfigManager * ConfigManager::Instance() { | |||
if (_instance == NULL) { | |||
_instance = new ConfigManager; | |||
} | |||
return _instance; | |||
} | |||
bool ConfigManager::shouldAutoUpdate() { | |||
if (!_configLoaded || !_config.exists("auto_update")) return false; | |||
return _config.lookup("auto_update"); | |||
} | |||
void ConfigManager::setAutoUpdate(bool value) { | |||
if (!_configLoaded) return; | |||
libconfig::Setting & setting = _config.lookup("auto_update"); | |||
setting = value; | |||
} | |||
std::vector<std::string> ConfigManager::getFilesToIgnore() { | |||
std::vector<std::string> value; | |||
if (!_configLoaded || !_config.exists("ignored_files")) return value; | |||
libconfig::Setting & setting = _config.lookup("ignored_files"); | |||
for (int i = 0; i < setting.getLength(); i++) { | |||
value.push_back(setting[i]); | |||
} | |||
return value; | |||
} | |||
void ConfigManager::pushFilesToIgnore(std::string value) { | |||
if (!_configLoaded) return; | |||
libconfig::Setting & setting = _config.lookup("ignored_files"); | |||
setting.add(libconfig::Setting::TypeString); | |||
setting[setting.getLength() - 1] = value; | |||
} | |||
void ConfigManager::removeFileFromIgnore(int index) { | |||
if (!_configLoaded) return; | |||
libconfig::Setting & setting = _config.lookup("ignored_files"); | |||
if (index >= setting.getLength() || index < 0) return; | |||
setting.remove(index); | |||
} | |||
bool ConfigManager::shouldInstallESPatches() { | |||
if (!_configLoaded || !_config.exists("install_es_patches")) return false; | |||
return _config.lookup("install_es_patches"); | |||
} | |||
void ConfigManager::setInstallESPatches(bool value) { | |||
if (!_configLoaded) return; | |||
libconfig::Setting & setting = _config.lookup("install_es_patches"); | |||
setting = value; | |||
} | |||
std::string ConfigManager::getInstalledVersion() { | |||
if (!_configLoaded || !_config.exists("installed_version")) return ""; | |||
return _config.lookup("installed_version"); | |||
} | |||
void ConfigManager::setInstalledVersion(std::string value) { | |||
if (!_configLoaded) return; | |||
libconfig::Setting & setting = _config.lookup("installed_version"); | |||
setting = value; | |||
} | |||
bool ConfigManager::shouldUseProxy() { | |||
if (!_configLoaded) return false; | |||
return _config.lookup("proxy_enabled"); | |||
} | |||
void ConfigManager::setUseProxy(bool value) { | |||
if (!_configLoaded) return; | |||
libconfig::Setting & setting = _config.lookup("proxy_enabled"); | |||
setting = value; | |||
} | |||
std::string ConfigManager::getProxy() { | |||
if (!_configLoaded) return ""; | |||
return _config.lookup("proxy_url"); | |||
} | |||
void ConfigManager::setProxy(std::string value) { | |||
if (!_configLoaded) return; | |||
libconfig::Setting & setting = _config.lookup("proxy_url"); | |||
setting = value; | |||
} | |||
std::string ConfigManager::getProxyUsername() { | |||
if (!_configLoaded) return ""; | |||
return _config.lookup("proxy_username"); | |||
} | |||
void ConfigManager::setProxyUsername(std::string value) { | |||
if (!_configLoaded) return; | |||
libconfig::Setting & setting = _config.lookup("proxy_username"); | |||
setting = value; | |||
} | |||
std::string ConfigManager::getProxyPassword() { | |||
if (!_configLoaded) return ""; | |||
return _config.lookup("proxy_password"); | |||
} | |||
void ConfigManager::setProxyPassword(std::string value) { | |||
if (!_configLoaded) return; | |||
libconfig::Setting & setting = _config.lookup("proxy_password"); | |||
setting = value; | |||
} | |||
bool ConfigManager::shouldHideExFatWarning() { | |||
if (!_configLoaded || !_config.exists("hide_exfat_warning")) return false; | |||
return _config.lookup("hide_exfat_warning"); | |||
} | |||
void ConfigManager::setHideExFatWarning(bool value) { | |||
if (!_configLoaded) return; | |||
libconfig::Setting & setting = _config.lookup("hide_exfat_warning"); | |||
setting = value; | |||
} | |||
bool ConfigManager::synchronize() { | |||
try { | |||
_config.writeFile("config.cfg"); | |||
return true; | |||
} catch (...) { | |||
return false; | |||
} | |||
} | |||
ConfigManager::ConfigManager() { | |||
try { | |||
_config.readFile("config.cfg"); | |||
_configLoaded = true; | |||
} catch (...) { | |||
_createDefaultConfig(); | |||
} | |||
} | |||
void ConfigManager::_createDefaultConfig() { | |||
try { | |||
_config.readFile("romfs:/config.cfg"); | |||
_configLoaded = true; | |||
if (_kosmosToolboxConfigPath()) | |||
pushFilesToIgnore("sdmc:/switch/KosmosToolbox/config.json"); | |||
synchronize(); | |||
} catch (...) { | |||
_configLoaded = false; | |||
} | |||
} | |||
bool ConfigManager::_kosmosToolboxConfigPath() { | |||
std::ifstream file("sdmc:/switch/KosmosToolbox/config.json"); | |||
if (file.fail()) | |||
return false; | |||
file.close(); | |||
return true; | |||
} | |||
} |
@ -0,0 +1,74 @@ | |||
/* | |||
* Kosmos Updater | |||
* Copyright (c) 2020 Nichole Mattera | |||
* | |||
* 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 2 | |||
* 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, write to the Free Software | |||