mirror of
https://github.com/wiiu-env/AutobootModule.git
synced 2024-11-21 10:29:15 +01:00
Update .clang-format rules
This commit is contained in:
parent
4512de73da
commit
c56897cc75
@ -2,7 +2,7 @@
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveAssignments: Consecutive
|
||||
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
|
||||
AlignOperands: Align
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
|
@ -28,7 +28,7 @@ void handleAccountSelection();
|
||||
|
||||
void bootWiiUMenu() {
|
||||
nn::act::Initialize();
|
||||
nn::act::SlotNo slot = nn::act::GetSlotNo();
|
||||
nn::act::SlotNo slot = nn::act::GetSlotNo();
|
||||
nn::act::SlotNo defaultSlot = nn::act::GetDefaultAccount();
|
||||
nn::act::Finalize();
|
||||
|
||||
@ -58,8 +58,8 @@ void handleAccountSelection() {
|
||||
}
|
||||
char16_t nameOut[nn::act::MiiNameSize];
|
||||
std::shared_ptr<AccountInfo> accountInfo = std::make_shared<AccountInfo>();
|
||||
accountInfo->slot = i;
|
||||
auto result = nn::act::GetMiiNameEx(reinterpret_cast<int16_t *>(nameOut), i);
|
||||
accountInfo->slot = i;
|
||||
auto result = nn::act::GetMiiNameEx(reinterpret_cast<int16_t *>(nameOut), i);
|
||||
if (result.IsSuccess()) {
|
||||
std::u16string source;
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
||||
@ -73,7 +73,7 @@ void handleAccountSelection() {
|
||||
}
|
||||
|
||||
uint32_t imageSize = 0;
|
||||
result = nn::act::GetMiiImageEx(&imageSize, accountInfo->miiImageBuffer, sizeof(accountInfo->miiImageBuffer), 0, i);
|
||||
result = nn::act::GetMiiImageEx(&imageSize, accountInfo->miiImageBuffer, sizeof(accountInfo->miiImageBuffer), 0, i);
|
||||
if (result.IsSuccess()) {
|
||||
accountInfo->miiImageSize = imageSize;
|
||||
}
|
||||
|
@ -16,20 +16,20 @@
|
||||
|
||||
bool DrawUtils::isBackBuffer;
|
||||
|
||||
uint8_t *DrawUtils::tvBuffer = nullptr;
|
||||
uint32_t DrawUtils::tvSize = 0;
|
||||
uint8_t *DrawUtils::tvBuffer = nullptr;
|
||||
uint32_t DrawUtils::tvSize = 0;
|
||||
uint8_t *DrawUtils::drcBuffer = nullptr;
|
||||
uint32_t DrawUtils::drcSize = 0;
|
||||
uint32_t DrawUtils::drcSize = 0;
|
||||
|
||||
// Don't put those into the class or we have to include ft everywhere
|
||||
static FT_Library ft_lib = nullptr;
|
||||
static FT_Face ft_face = nullptr;
|
||||
static Color font_col = {0xFFFFFFFF};
|
||||
static FT_Face ft_face = nullptr;
|
||||
static Color font_col = {0xFFFFFFFF};
|
||||
|
||||
void *DrawUtils::InitOSScreen() {
|
||||
OSScreenInit();
|
||||
|
||||
uint32_t tvBufferSize = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||
uint32_t tvBufferSize = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||
uint32_t drcBufferSize = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
||||
|
||||
auto *screenBuffer = (uint8_t *) memalign(0x100, tvBufferSize + drcBufferSize);
|
||||
@ -46,10 +46,10 @@ void *DrawUtils::InitOSScreen() {
|
||||
}
|
||||
|
||||
void DrawUtils::initBuffers(void *tvBuffer, uint32_t tvSize, void *drcBuffer, uint32_t drcSize) {
|
||||
DrawUtils::tvBuffer = (uint8_t *) tvBuffer;
|
||||
DrawUtils::tvSize = tvSize;
|
||||
DrawUtils::tvBuffer = (uint8_t *) tvBuffer;
|
||||
DrawUtils::tvSize = tvSize;
|
||||
DrawUtils::drcBuffer = (uint8_t *) drcBuffer;
|
||||
DrawUtils::drcSize = drcSize;
|
||||
DrawUtils::drcSize = drcSize;
|
||||
}
|
||||
|
||||
void DrawUtils::beginDraw() {
|
||||
@ -91,11 +91,11 @@ void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t
|
||||
i += drcSize / 2;
|
||||
}
|
||||
if (a == 0xFF) {
|
||||
drcBuffer[i] = r;
|
||||
drcBuffer[i] = r;
|
||||
drcBuffer[i + 1] = g;
|
||||
drcBuffer[i + 2] = b;
|
||||
} else {
|
||||
drcBuffer[i] = r * opacity + drcBuffer[i] * (1 - opacity);
|
||||
drcBuffer[i] = r * opacity + drcBuffer[i] * (1 - opacity);
|
||||
drcBuffer[i + 1] = g * opacity + drcBuffer[i + 1] * (1 - opacity);
|
||||
drcBuffer[i + 2] = b * opacity + drcBuffer[i + 2] * (1 - opacity);
|
||||
}
|
||||
@ -110,11 +110,11 @@ void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t
|
||||
i += tvSize / 2;
|
||||
}
|
||||
if (a == 0xFF) {
|
||||
tvBuffer[i] = r;
|
||||
tvBuffer[i] = r;
|
||||
tvBuffer[i + 1] = g;
|
||||
tvBuffer[i + 2] = b;
|
||||
} else {
|
||||
tvBuffer[i] = r * opacity + tvBuffer[i] * (1 - opacity);
|
||||
tvBuffer[i] = r * opacity + tvBuffer[i] * (1 - opacity);
|
||||
tvBuffer[i + 1] = g * opacity + tvBuffer[i + 1] * (1 - opacity);
|
||||
tvBuffer[i + 2] = b * opacity + tvBuffer[i + 2] * (1 - opacity);
|
||||
}
|
||||
@ -145,8 +145,8 @@ void DrawUtils::drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32
|
||||
}
|
||||
|
||||
uint32_t dataPos = __builtin_bswap32(*(uint32_t *) &(data[0x0A]));
|
||||
uint32_t width = __builtin_bswap32(*(uint32_t *) &(data[0x12]));
|
||||
uint32_t height = __builtin_bswap32(*(uint32_t *) &(data[0x16]));
|
||||
uint32_t width = __builtin_bswap32(*(uint32_t *) &(data[0x12]));
|
||||
uint32_t height = __builtin_bswap32(*(uint32_t *) &(data[0x16]));
|
||||
|
||||
if (dataPos == 0) {
|
||||
dataPos = 54;
|
||||
@ -187,17 +187,17 @@ void DrawUtils::drawPNG(uint32_t x, uint32_t y, const uint8_t *data) {
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
uint32_t width = 0;
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
int bitDepth = 0;
|
||||
int colorType = -1;
|
||||
int bitDepth = 0;
|
||||
int colorType = -1;
|
||||
uint32_t retval = png_get_IHDR(png_ptr, info_ptr, &width, &height, &bitDepth, &colorType, NULL, NULL, NULL);
|
||||
if (retval != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t bytesPerRow = png_get_rowbytes(png_ptr, info_ptr);
|
||||
uint8_t *rowData = new uint8_t[bytesPerRow];
|
||||
uint8_t *rowData = new uint8_t[bytesPerRow];
|
||||
|
||||
for (uint32_t yy = y; yy < y + height; yy++) {
|
||||
png_read_row(png_ptr, (png_bytep) rowData, NULL);
|
||||
@ -218,7 +218,7 @@ void DrawUtils::drawPNG(uint32_t x, uint32_t y, const uint8_t *data) {
|
||||
}
|
||||
|
||||
void DrawUtils::initFont() {
|
||||
void *font = NULL;
|
||||
void *font = NULL;
|
||||
uint32_t size = 0;
|
||||
OSGetSharedData(OS_SHAREDDATATYPE_FONT_STANDARD, 0, &font, &size);
|
||||
|
||||
@ -276,7 +276,7 @@ void DrawUtils::print(uint32_t x, uint32_t y, const char *string, bool alignRigh
|
||||
|
||||
void DrawUtils::print(uint32_t x, uint32_t y, const wchar_t *string, bool alignRight) {
|
||||
FT_GlyphSlot slot = ft_face->glyph;
|
||||
FT_Vector pen = {(int) x, (int) y};
|
||||
FT_Vector pen = {(int) x, (int) y};
|
||||
|
||||
if (alignRight) {
|
||||
pen.x -= getTextWidth(string);
|
||||
@ -319,7 +319,7 @@ uint32_t DrawUtils::getTextWidth(const char *string) {
|
||||
|
||||
uint32_t DrawUtils::getTextWidth(const wchar_t *string) {
|
||||
FT_GlyphSlot slot = ft_face->glyph;
|
||||
uint32_t width = 0;
|
||||
uint32_t width = 0;
|
||||
|
||||
for (; *string; string++) {
|
||||
FT_Load_Glyph(ft_face, FT_Get_Char_Index(ft_face, *string), FT_LOAD_BITMAP_METRICS_ONLY);
|
||||
|
@ -34,8 +34,8 @@ const char *autoboot_config_strings[] = {
|
||||
template<typename... Args>
|
||||
std::string string_format(const std::string &format, Args... args) {
|
||||
int size_s = std::snprintf(nullptr, 0, format.c_str(), args...) + 1; // Extra space for '\0'
|
||||
auto size = static_cast<size_t>(size_s);
|
||||
auto buf = std::make_unique<char[]>(size);
|
||||
auto size = static_cast<size_t>(size_s);
|
||||
auto buf = std::make_unique<char[]>(size);
|
||||
std::snprintf(buf.get(), size, format.c_str(), args...);
|
||||
return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside
|
||||
}
|
||||
@ -75,15 +75,15 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput) {
|
||||
OSFatal("Failed to alloc memory for screen");
|
||||
}
|
||||
|
||||
uint32_t tvBufferSize = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||
uint32_t tvBufferSize = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||
uint32_t drcBufferSize = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
||||
|
||||
DrawUtils::initBuffers(screenBuffer, tvBufferSize, (void *) ((uint32_t) screenBuffer + tvBufferSize), drcBufferSize);
|
||||
DrawUtils::initFont();
|
||||
|
||||
uint32_t selected = autobootOptionInput > 0 ? autobootOptionInput : 0;
|
||||
int autoboot = autobootOptionInput;
|
||||
bool redraw = true;
|
||||
int autoboot = autobootOptionInput;
|
||||
bool redraw = true;
|
||||
while (true) {
|
||||
VPADStatus vpad{};
|
||||
VPADRead(VPAD_CHAN_0, &vpad, 1, nullptr);
|
||||
@ -102,10 +102,10 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput) {
|
||||
break;
|
||||
} else if (vpad.trigger & VPAD_BUTTON_X) {
|
||||
autoboot = -1;
|
||||
redraw = true;
|
||||
redraw = true;
|
||||
} else if (vpad.trigger & VPAD_BUTTON_Y) {
|
||||
autoboot = selected;
|
||||
redraw = true;
|
||||
redraw = true;
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
@ -174,14 +174,14 @@ nn::act::SlotNo handleAccountSelectScreen(const std::vector<std::shared_ptr<Acco
|
||||
OSFatal("Failed to alloc memory for screen");
|
||||
}
|
||||
|
||||
uint32_t tvBufferSize = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||
uint32_t tvBufferSize = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||
uint32_t drcBufferSize = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
||||
|
||||
DrawUtils::initBuffers(screenBuffer, tvBufferSize, (void *) ((uint32_t) screenBuffer + tvBufferSize), drcBufferSize);
|
||||
DrawUtils::initFont();
|
||||
|
||||
int32_t selected = 0;
|
||||
bool redraw = true;
|
||||
bool redraw = true;
|
||||
while (true) {
|
||||
VPADStatus vpad{};
|
||||
VPADRead(VPAD_CHAN_0, &vpad, 1, nullptr);
|
||||
@ -206,21 +206,21 @@ nn::act::SlotNo handleAccountSelectScreen(const std::vector<std::shared_ptr<Acco
|
||||
|
||||
// draw buttons
|
||||
uint32_t index = 8 + 24 + 8 + 4;
|
||||
int32_t start = (selected / 5) * 5;
|
||||
int32_t end = (start + 5) < (int32_t) data.size() ? (start + 5) : data.size();
|
||||
int32_t start = (selected / 5) * 5;
|
||||
int32_t end = (start + 5) < (int32_t) data.size() ? (start + 5) : data.size();
|
||||
for (int i = start; i < end; i++) {
|
||||
auto &val = data[i];
|
||||
if (val->miiImageSize > 0) {
|
||||
// Draw Mii
|
||||
auto width = 128;
|
||||
auto height = 128;
|
||||
auto width = 128;
|
||||
auto height = 128;
|
||||
auto target_height = 64u;
|
||||
auto target_width = 64u;
|
||||
auto xOffset = 20;
|
||||
auto yOffset = index;
|
||||
auto target_width = 64u;
|
||||
auto xOffset = 20;
|
||||
auto yOffset = index;
|
||||
for (uint32_t y = 0; y < target_height; y++) {
|
||||
for (uint32_t x = 0; x < target_width; x++) {
|
||||
uint32_t col = (((x) *width / target_width) + ((target_height - y - 1) * height / target_height) * width) * 4;
|
||||
uint32_t col = (((x) *width / target_width) + ((target_height - y - 1) * height / target_height) * width) * 4;
|
||||
uint32_t colVal = ((uint32_t *) &val->miiImageBuffer[col + 1])[0];
|
||||
if (colVal == 0x00808080) { // Remove the green background.
|
||||
DrawUtils::drawPixel(x + xOffset, y + yOffset, COLOR_BACKGROUND.r, COLOR_BACKGROUND.g, COLOR_BACKGROUND.b, COLOR_BACKGROUND.a);
|
||||
@ -249,7 +249,7 @@ nn::act::SlotNo handleAccountSelectScreen(const std::vector<std::shared_ptr<Acco
|
||||
// draw top bar
|
||||
DrawUtils::setFontSize(24);
|
||||
DrawUtils::print(16, 6 + 24, "Select your Account");
|
||||
auto curPage = (selected / 5) + 1;
|
||||
auto curPage = (selected / 5) + 1;
|
||||
auto totalPages = data.size() % 5 == 0 ? data.size() / 5 : data.size() / 5 + 1;
|
||||
DrawUtils::print(SCREEN_WIDTH - 50, 6 + 24, string_format("%d/%d", curPage, totalPages).c_str());
|
||||
DrawUtils::drawRectFilled(8, 8 + 24 + 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_WHITE);
|
||||
@ -287,7 +287,7 @@ nn::act::SlotNo handleAccountSelectScreen(const std::vector<std::shared_ptr<Acco
|
||||
|
||||
free(screenBuffer);
|
||||
|
||||
auto i = 0;
|
||||
auto i = 0;
|
||||
nn::act::SlotNo resultSlot = 0;
|
||||
for (auto const &val : data) {
|
||||
if (i == selected) {
|
||||
|
@ -7,16 +7,14 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
#define COLOR_WHITE Color(0xffffffff)
|
||||
#define COLOR_BLACK Color(0, 0, 0, 255)
|
||||
#define COLOR_BACKGROUND COLOR_BLACK
|
||||
#define COLOR_TEXT COLOR_WHITE
|
||||
#define COLOR_TEXT2 Color(0xB3ffffff)
|
||||
#define COLOR_AUTOBOOT Color(0xaeea00ff)
|
||||
#define COLOR_BORDER Color(204, 204, 204, 255)
|
||||
#define COLOR_BORDER_HIGHLIGHTED Color(0x3478e4ff)
|
||||
// clang-format on
|
||||
#define COLOR_WHITE Color(0xffffffff)
|
||||
#define COLOR_BLACK Color(0, 0, 0, 255)
|
||||
#define COLOR_BACKGROUND COLOR_BLACK
|
||||
#define COLOR_TEXT COLOR_WHITE
|
||||
#define COLOR_TEXT2 Color(0xB3ffffff)
|
||||
#define COLOR_AUTOBOOT Color(0xaeea00ff)
|
||||
#define COLOR_BORDER Color(204, 204, 204, 255)
|
||||
#define COLOR_BORDER_HIGHLIGHTED Color(0x3478e4ff)
|
||||
|
||||
enum {
|
||||
BOOT_OPTION_WII_U_MENU,
|
||||
|
@ -22,7 +22,7 @@ static void StartAppletAndExit() {
|
||||
DEBUG_FUNCTION_LINE("Wait for applet");
|
||||
ProcUIInit(OSSavesDone_ReadyToRelease);
|
||||
|
||||
bool doProcUi = true;
|
||||
bool doProcUi = true;
|
||||
bool launchWiiUMenuOnNextForeground = false;
|
||||
while (true) {
|
||||
switch (ProcUIProcessMessages(true)) {
|
||||
@ -92,7 +92,7 @@ bool getQuickBoot() {
|
||||
FSInitCmdBlock(&cmdBlock);
|
||||
|
||||
auto fileStream = new nn::sl::FileStream;
|
||||
auto *fsClient = (FSClient *) memalign(0x40, sizeof(FSClient));
|
||||
auto *fsClient = (FSClient *) memalign(0x40, sizeof(FSClient));
|
||||
memset(fsClient, 0, sizeof(*fsClient));
|
||||
FSAddClient(fsClient, FS_ERROR_FLAG_NONE);
|
||||
|
||||
@ -211,7 +211,7 @@ bool getQuickBoot() {
|
||||
|
||||
MCPTitleListType titleInfo;
|
||||
int32_t handle = MCP_Open();
|
||||
auto err = MCP_GetTitleInfo(handle, info.titleId, &titleInfo);
|
||||
auto err = MCP_GetTitleInfo(handle, info.titleId, &titleInfo);
|
||||
MCP_Close(handle);
|
||||
if (err == 0) {
|
||||
loadConsoleAccount(data.uuid);
|
||||
|
@ -35,15 +35,15 @@ static int numberUSBStorageDevicesConnected() {
|
||||
memset(config, 0, sizeof(UhsConfig));
|
||||
|
||||
config->controller_num = 0;
|
||||
uint32_t size = 5120;
|
||||
void *buffer = memalign(0x40, size);
|
||||
uint32_t size = 5120;
|
||||
void *buffer = memalign(0x40, size);
|
||||
if (buffer == nullptr) {
|
||||
free(handle);
|
||||
free(config);
|
||||
}
|
||||
memset(buffer, 0, size);
|
||||
|
||||
config->buffer = buffer;
|
||||
config->buffer = buffer;
|
||||
config->buffer_size = size;
|
||||
|
||||
if (UhsClientOpen(handle, config) != UHS_STATUS_OK) {
|
||||
@ -102,7 +102,7 @@ void initExternalStorage() {
|
||||
nn::spm::Initialize();
|
||||
|
||||
nn::spm::StorageListItem items[0x20];
|
||||
int tries = 0;
|
||||
int tries = 0;
|
||||
bool found = false;
|
||||
|
||||
while (tries < 1200) { // Wait up to 20 seconds, like the Wii U Menu
|
||||
|
@ -7,15 +7,15 @@
|
||||
#include <whb/log_udp.h>
|
||||
|
||||
uint32_t moduleLogInit = false;
|
||||
uint32_t cafeLogInit = false;
|
||||
uint32_t udpLogInit = false;
|
||||
uint32_t cafeLogInit = false;
|
||||
uint32_t udpLogInit = false;
|
||||
#endif
|
||||
|
||||
void initLogging() {
|
||||
#ifdef DEBUG
|
||||
if (!(moduleLogInit = WHBLogModuleInit())) {
|
||||
cafeLogInit = WHBLogCafeInit();
|
||||
udpLogInit = WHBLogUdpInit();
|
||||
udpLogInit = WHBLogUdpInit();
|
||||
}
|
||||
#endif // DEBUG
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user