From fcbb8a8b7e82f9f81090651a128be96340e5c7e9 Mon Sep 17 00:00:00 2001 From: Sketch <75850871+SketchMaster2001@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:04:38 -0400 Subject: [PATCH] Add controls and text --- CMakeLists.txt | 3 ++- data/CMakeLists.txt | 18 +++++++++++------- main.cpp | 6 ++++-- menu.cpp | 29 ++++++++++++++++++++++++++--- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa95f77..6104e0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,9 +39,10 @@ add_executable(dominos-account-linker qr.h ) -target_link_libraries(dominos-account-linker PRIVATE png gui `freetype-config --libs` wiiuse bte asnd ogc qrencode mbedcrypto z fat +target_link_libraries(dominos-account-linker PRIVATE png gui `freetype-config --libs` wiiuse bte asnd ogc qrencode mbedcrypto z fat bz2 # It absolutely hates glob here so we have to manually set it ourselves ${CMAKE_CURRENT_SOURCE_DIR}/data/channel_gradient_bottom.png.o ${CMAKE_CURRENT_SOURCE_DIR}/data/channel_gradient_top.png.o ${CMAKE_CURRENT_SOURCE_DIR}/data/bg_stripes.png.o + ${CMAKE_CURRENT_SOURCE_DIR}/data/noto_sans_jp_regular.otf.o ) \ No newline at end of file diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 71a707e..ae1b306 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -7,12 +7,6 @@ foreach (png ${pngs}) ) endforeach () -# Only one font here -execute_process( - COMMAND ${BIN2S} -H noto_sans_jp_regular.otf.h noto_sans_jp_regular.otf - OUTPUT_FILE noto_sans_jp_regular.otf.s -) - file(GLOB binaries "*.s") foreach (binary ${binaries}) @@ -20,4 +14,14 @@ foreach (binary ${binaries}) execute_process( COMMAND ${BINARY_AS} -o ${binary_without_ext}.o ${binary} ) -endforeach () \ No newline at end of file +endforeach () + +# Only one font here +execute_process( + COMMAND ${BIN2S} -H ${CMAKE_CURRENT_SOURCE_DIR}/noto_sans_jp_regular.otf.h ${CMAKE_CURRENT_SOURCE_DIR}/noto_sans_jp_regular.otf + OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/noto_sans_jp_regular.otf.s +) + +execute_process( + COMMAND ${BINARY_AS} -o ${CMAKE_CURRENT_SOURCE_DIR}/noto_sans_jp_regular.otf.o ${CMAKE_CURRENT_SOURCE_DIR}/noto_sans_jp_regular.otf.s +) \ No newline at end of file diff --git a/main.cpp b/main.cpp index 4f63a9f..cd16438 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,7 @@ #include "gui/gui.h" #include "menu.h" #include "qr.h" +#include "noto_sans_jp_regular.otf.h" #include #include #include @@ -61,6 +62,7 @@ int main() { InitAudio(); InitGUIThreads(); + InitFreeType((u8 *)noto_sans_jp_regular_otf, noto_sans_jp_regular_otf_size); init_fat(); // We first encode our URL to a PNG. @@ -78,8 +80,8 @@ int main() { int width, height; u8 *png_data = readPNG("fat:/qr.png", width, height); - u8 *resized = resizeImage(png_data, width, height, 300, 300); - writePNG("fat:/qr.png", resized, 300, 300); + u8 *resized = resizeImage(png_data, width, height, 200, 200); + writePNG("fat:/qr.png", resized, 200, 200); MainMenu(); return 0; diff --git a/menu.cpp b/menu.cpp index d83b471..c462d7f 100644 --- a/menu.cpp +++ b/menu.cpp @@ -70,7 +70,6 @@ static void HaltGui() { if (guiHalt) { LWP_SuspendThread(guithread); } else { - UpdatePads(); mainWindow->Draw(); // Run this for loop only once @@ -158,11 +157,35 @@ void InitGUIThreads() { u8 *buf = static_cast(malloc(sz + 1)); fread(buf, 1, sz, fp); + GuiText titleTxt("WiiLink Account Linker", 28, {70, 187, 255, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0, 25); + + GuiText msgTxt("To finish creating your WiiLink Account, scan this QR code with a mobile device and follow the instructions there.", 20, (GXColor){0xff, 0xff, 0xff, 255}); + msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + msgTxt.SetWrap(true, 500); + msgTxt.SetPosition(0, -150); + + GuiText homeTxt("Press HOME to return to the Wii Menu", 30, {70, 187, 255, 255}); + homeTxt.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + homeTxt.SetPosition(0, -30); + GuiImage *qr = new GuiImage(new GuiImageData(buf)); qr->SetAlignment(ALIGN_CENTRE, ALIGN_CENTRE); - qr->SetPosition(0, 85); + qr->SetPosition(0, 90); + + mainWindow->Append(&titleTxt); + mainWindow->Append(&msgTxt); + mainWindow->Append(&homeTxt); mainWindow->Append(qr); - while (true) + while (true) { usleep(THREAD_SLEEP); + WPAD_ScanPads(); + u32 pressed = WPAD_ButtonsDown(0); + if (pressed & WPAD_BUTTON_HOME) { + ExitRequested = true; + exitType = WII_MENU; + } + } } \ No newline at end of file