Add a update block warning screen

This commit is contained in:
GaryOderNichts 2022-09-04 21:19:54 +02:00 committed by Maschell
parent 10ba1ff82c
commit 7b586309a1
3 changed files with 93 additions and 2 deletions

View File

@ -329,3 +329,74 @@ nn::act::SlotNo handleAccountSelectScreen(const std::vector<std::shared_ptr<Acco
return resultSlot;
}
void handleUpdateWarningScreen() {
FILE *f = fopen(UPDATE_SKIP_PATH, "r");
if (f) {
DEBUG_FUNCTION_LINE("Skipping update warning screen");
fclose(f);
return;
}
auto screenBuffer = DrawUtils::InitOSScreen();
if (!screenBuffer) {
OSFatal("Failed to alloc memory for screen");
}
uint32_t tvBufferSize = OSScreenGetBufferSizeEx(SCREEN_TV);
uint32_t drcBufferSize = OSScreenGetBufferSizeEx(SCREEN_DRC);
DrawUtils::initBuffers(screenBuffer, tvBufferSize, (void *) ((uint32_t) screenBuffer + tvBufferSize), drcBufferSize);
DrawUtils::initFont();
DrawUtils::beginDraw();
DrawUtils::clear(COLOR_BACKGROUND_WARN);
DrawUtils::setFontColor(COLOR_TEXT);
// draw top bar
DrawUtils::setFontSize(48);
const char *title = "! Warning !";
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(title) / 2, 48 + 8, title, true);
DrawUtils::drawRectFilled(8, 48 + 8 + 16, SCREEN_WIDTH - 8 * 2, 3, COLOR_WHITE);
DrawUtils::setFontSize(24);
const char *message = "The update folder currently exists.";
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(message) / 2, SCREEN_HEIGHT / 2 - 24, message, true);
message = "Your system might not be blocking updates properly!";
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(message) / 2, SCREEN_HEIGHT / 2 + 0, message, true);
message = "See https://wiiu.hacks.guide/#/block-updates for more information.";
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(message) / 2, SCREEN_HEIGHT / 2 + 24, message, true);
// draw bottom bar
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_WHITE);
DrawUtils::setFontSize(18);
const char *exitHints = "\ue000 Continue / \ue001 Don't show this again";
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(exitHints) / 2, SCREEN_HEIGHT - 8, exitHints, true);
DrawUtils::endDraw();
while (true) {
VPADStatus vpad{};
VPADRead(VPAD_CHAN_0, &vpad, 1, nullptr);
if (vpad.trigger & VPAD_BUTTON_A) {
break;
} else if (vpad.trigger & VPAD_BUTTON_B) {
f = fopen(UPDATE_SKIP_PATH, "w");
if (f) {
fputs("If this file exists, the Autoboot Module will not warn you about not blocking updates", f);
fclose(f);
}
break;
}
}
DrawUtils::clear(COLOR_BLACK);
DrawUtils::endDraw();
DrawUtils::deinitFont();
free(screenBuffer);
}

View File

@ -8,9 +8,12 @@
#include <string>
#include <vector>
#define UPDATE_SKIP_PATH "fs:/vol/external01/wiiu/environments/skipUpdateWarn"
#define COLOR_WHITE Color(0xffffffff)
#define COLOR_BLACK Color(0, 0, 0, 255)
#define COLOR_BACKGROUND COLOR_BLACK
#define COLOR_BACKGROUND_WARN Color(255, 40, 0, 255)
#define COLOR_TEXT COLOR_WHITE
#define COLOR_TEXT2 Color(0xB3ffffff)
#define COLOR_AUTOBOOT Color(0xaeea00ff)
@ -31,3 +34,5 @@ void writeAutobootOption(std::string &configPath, int32_t autobootOption);
int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, const std::map<uint32_t, std::string> &menu);
nn::act::SlotNo handleAccountSelectScreen(const std::vector<std::shared_ptr<AccountInfo>> &data);
void handleUpdateWarningScreen();

View File

@ -5,6 +5,7 @@
#include "StorageUtils.h"
#include "logger.h"
#include <coreinit/debug.h>
#include <coreinit/filesystem_fsa.h>
#include <gx2/state.h>
#include <malloc.h>
#include <mocha/mocha.h>
@ -43,6 +44,20 @@ int32_t main(int32_t argc, char **argv) {
OSFatal("AutobootModule: Mocha_InitLibrary failed");
}
FSAInit();
auto client = FSAAddClient(nullptr);
if (client > 0) {
if (Mocha_UnlockFSClientEx(client) == MOCHA_RESULT_SUCCESS) {
// test if the update folder exists
FSStat stat;
if (FSAGetStat(client, "/vol/storage_mlc01/sys/update", &stat) >= 0) {
handleUpdateWarningScreen();
}
}
FSADelClient(client);
}
bool showvHBL = getVWiiHBLTitleId() != 0;
bool showHBL = false;
std::string configPath = "fs:/vol/external01/wiiu/autoboot.cfg";