Add startup splash on first boot of U-U.

This commit is contained in:
StackZ 2020-06-21 12:46:32 +02:00
commit 984d363533
9 changed files with 155 additions and 18 deletions

View file

@ -5,6 +5,7 @@ sprites/bottom_screen_bot.png
sprites/bottom_screen_top.png
sprites/button.png
sprites/delete.png
sprites/dev_by.png
sprites/download_all.png
sprites/dropdown.png
sprites/noIcon.png
@ -15,6 +16,7 @@ sprites/selector.png
sprites/side_arrow.png
sprites/uniStore.png
sprites/uniStore_HD.png
sprites/universal-updater.png
sprites/update.png
sprites/updateStore.png
sprites/view.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View file

@ -0,0 +1,42 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
*
* 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 STARTUP_HPP
#define STARTUP_HPP
#include "common.hpp"
class Startup : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
Startup(int mode = 0, std::string file = "NOT_USED");
private:
int mode = 0, delay = 150;
std::string file = "NOT_USED";
};
#endif

View file

@ -113,6 +113,9 @@ public:
// Language.
std::string language() { return this->v_language; }
void language(std::string v) { this->v_language = v; if (!this->changesMade) this->changesMade = true; }
// First startup.
bool firstStartup() { return this->v_firstStartup; }
void firstStartup(bool v) { this->v_firstStartup = v; if (!this->changesMade) this->changesMade = true; }
// Mainly helper.
bool getBool(const std::string &key);
@ -130,7 +133,7 @@ private:
v_outdatedColor, v_uptodateColor, v_notfoundColor, v_futureColor;
std::string v_scriptPath, v_musicPath, v_storePath, v_autobootFile, v_language;
int v_langPath, v_viewMode, v_autoboot, v_keyDelay;
bool v_logging, v_useBars, v_screenFade, v_progressDisplay;
bool v_logging, v_useBars, v_screenFade, v_progressDisplay, v_firstStartup;
};
#endif

View file

@ -33,6 +33,7 @@
#include "mainMenu.hpp"
#include "screenCommon.hpp"
#include "scriptlist.hpp"
#include "startup.hpp"
#include "sound.h"
#include "unistore.hpp"
@ -95,7 +96,7 @@ Result Init::Initialize() {
mkdir("sdmc:/3ds/Universal-Updater", 0777);
mkdir("sdmc:/3ds/Universal-Updater/scripts", 0777);
mkdir("sdmc:/3ds/Universal-Updater/stores", 0777);
// We need to make sure, the file exist.
config = std::make_unique<Config>();
@ -116,26 +117,32 @@ Result Init::Initialize() {
AutobootWhat = config->autoboot();
if (config->autoboot() == 1) {
if (access(config->autobootFile().c_str(), F_OK) == 0) {
Gui::setScreen(std::make_unique<UniStore>(true, config->autobootFile()), false, true);
if (!config->firstStartup()) {
if (AutobootWhat == 1) {
if (access(config->autobootFile().c_str(), F_OK) == 0) {
Gui::setScreen(std::make_unique<UniStore>(true, config->autobootFile()), false, true);
} else {
AutobootWhat = 0;
config->autoboot(0);
Gui::setScreen(std::make_unique<MainMenu>(), false, true);
}
} else if (AutobootWhat == 2) {
if (access(config->autobootFile().c_str(), F_OK) == 0) {
Gui::setScreen(std::make_unique<ScriptList>(), false, true);
} else {
AutobootWhat = 0;
config->autoboot(0);
Gui::setScreen(std::make_unique<MainMenu>(), false, true);
}
} else {
AutobootWhat = 0;
config->autoboot(0);
Gui::setScreen(std::make_unique<MainMenu>(), false, true);
}
} else if (config->autoboot() == 2) {
if (access(config->autobootFile().c_str(), F_OK) == 0) {
Gui::setScreen(std::make_unique<ScriptList>(), false, true);
} else {
AutobootWhat = 0;
config->autoboot(0);
Gui::setScreen(std::make_unique<MainMenu>(), false, true);
}
} else {
AutobootWhat = 0;
config->autoboot(0);
Gui::setScreen(std::make_unique<MainMenu>(), false, true);
}
if (config->firstStartup()) {
Gui::setScreen(std::make_unique<Startup>(AutobootWhat, config->autobootFile()), false, true);
}
osSetSpeedupEnable(true); // Enable speed-up for New 3DS users

View file

@ -50,6 +50,7 @@ void MainMenu::Draw(void) const {
Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 237-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, config->textColor(), V_STRING);
}
GFX::DrawSprite(sprites_universal_updater_idx, 110, 30);
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
GFX::DrawBottom();
GFX::DrawArrow(0, 218, 0, 1);

View file

@ -0,0 +1,74 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
*
* 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 "mainMenu.hpp"
#include "scriptlist.hpp"
#include "startup.hpp"
#include "unistore.hpp"
#include <unistd.h>
extern bool touching(touchPosition touch, Structs::ButtonPos button);
extern int fadealpha;
extern bool fadein;
extern std::unique_ptr<Config> config;
Startup::Startup(int mode, std::string file) {
this->mode = mode; this->file = file;
}
void Startup::Draw(void) const {
GFX::DrawTop();
GFX::DrawSprite(sprites_dev_by_idx, 0, 25);
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
GFX::DrawBottom();
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
}
void Startup::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (this->delay > 0) {
this->delay -= 2;
if (this->delay <= 0) {
if (this->mode == 0) {
config->firstStartup(false);
Gui::setScreen(std::make_unique<MainMenu>(), true, true);
} else if (this->mode == 1) {
config->firstStartup(false);
if (access(this->file.c_str(), F_OK) == 0) {
Gui::setScreen(std::make_unique<UniStore>(true, this->file), true, true);
} else {
Gui::setScreen(std::make_unique<MainMenu>(), true, true);
}
} else if (this->mode == 2) {
config->firstStartup(false);
if (access(this->file.c_str(), F_OK) == 0) {
Gui::setScreen(std::make_unique<ScriptList>(), true, true);
} else {
Gui::setScreen(std::make_unique<MainMenu>(), true, true);
}
}
}
}
}

View file

@ -61,6 +61,7 @@ void Config::initialize() {
this->setBool("SCREEN_FADE", false);
this->setBool("PROGRESS_DISPLAY", true);
this->setString("LANGUAGE", "en");
this->setBool("FIRST_STARTUP", true);
// Write to file.
fwrite(this->json.dump(1, '\t').c_str(), 1, this->json.dump(1, '\t').size(), file);
@ -165,7 +166,7 @@ Config::Config() {
if (!this->json.contains("AUTOBOOT")) {
this->autoboot(0);
} else {
this->viewMode(this->getInt("AUTOBOOT"));
this->autoboot(this->getInt("AUTOBOOT"));
}
if (!this->json.contains("STOREPATH")) {
@ -228,6 +229,12 @@ Config::Config() {
this->language(this->getString("LANGUAGE"));
}
if (!this->json.contains("FIRST_STARTUP")) {
this->firstStartup(true);
} else {
this->firstStartup(this->getBool("FIRST_STARTUP"));
}
this->changesMade = false; // No changes made yet.
}
@ -261,6 +268,7 @@ void Config::save() {
this->setBool("SCREEN_FADE", this->screenFade());
this->setBool("PROGRESS_DISPLAY", this->progressDisplay());
this->setString("LANGUAGE", this->language());
this->setBool("FIRST_STARTUP", this->firstStartup());
// Write changes to file.
fwrite(this->json.dump(1, '\t').c_str(), 1, this->json.dump(1, '\t').size(), file);
fclose(file);