From d45ddc2ed9e1ea68a5aeefd15e20ed8bdb19eb32 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 3 Feb 2022 14:01:11 +0100 Subject: [PATCH] Update .clang-format rules --- .clang-format | 2 +- source/BootUtils.cpp | 8 +++---- source/DrawUtils.cpp | 44 +++++++++++++++++++------------------- source/MenuUtils.cpp | 38 ++++++++++++++++---------------- source/MenuUtils.h | 18 +++++++--------- source/QuickStartUtils.cpp | 6 +++--- source/StorageUtils.cpp | 8 +++---- source/logger.cpp | 6 +++--- 8 files changed, 64 insertions(+), 66 deletions(-) diff --git a/.clang-format b/.clang-format index 533ffee..56cc685 100644 --- a/.clang-format +++ b/.clang-format @@ -2,7 +2,7 @@ BasedOnStyle: LLVM AccessModifierOffset: -4 AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: None +AlignConsecutiveAssignments: Consecutive AlignConsecutiveMacros: AcrossEmptyLinesAndComments AlignOperands: Align AllowAllArgumentsOnNextLine: false diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index f0d81f1..2e985a2 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -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 = std::make_shared(); - accountInfo->slot = i; - auto result = nn::act::GetMiiNameEx(reinterpret_cast(nameOut), i); + accountInfo->slot = i; + auto result = nn::act::GetMiiNameEx(reinterpret_cast(nameOut), i); if (result.IsSuccess()) { std::u16string source; std::wstring_convert, 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; } diff --git a/source/DrawUtils.cpp b/source/DrawUtils.cpp index 6c49b8c..333b82c 100644 --- a/source/DrawUtils.cpp +++ b/source/DrawUtils.cpp @@ -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); diff --git a/source/MenuUtils.cpp b/source/MenuUtils.cpp index f047c5f..84d2136 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -34,8 +34,8 @@ const char *autoboot_config_strings[] = { template 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_s); - auto buf = std::make_unique(size); + auto size = static_cast(size_s); + auto buf = std::make_unique(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::vectormiiImageSize > 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 #include -// 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, diff --git a/source/QuickStartUtils.cpp b/source/QuickStartUtils.cpp index 10b9872..2fa840f 100644 --- a/source/QuickStartUtils.cpp +++ b/source/QuickStartUtils.cpp @@ -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); diff --git a/source/StorageUtils.cpp b/source/StorageUtils.cpp index e215cef..f2ee71a 100644 --- a/source/StorageUtils.cpp +++ b/source/StorageUtils.cpp @@ -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 diff --git a/source/logger.cpp b/source/logger.cpp index c954129..2651a71 100644 --- a/source/logger.cpp +++ b/source/logger.cpp @@ -7,15 +7,15 @@ #include 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 }