Skip to content

Commit

Permalink
Add controls and text
Browse files Browse the repository at this point in the history
  • Loading branch information
noahpistilli committed Aug 10, 2024
1 parent 45445ff commit fcbb8a8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
18 changes: 11 additions & 7 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ 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})
string(REGEX REPLACE "\\.[^.]*$" "" binary_without_ext ${binary})
execute_process(
COMMAND ${BINARY_AS} -o ${binary_without_ext}.o ${binary}
)
endforeach ()
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
)
6 changes: 4 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "gui/gui.h"
#include "menu.h"
#include "qr.h"
#include "noto_sans_jp_regular.otf.h"
#include <fat.h>
#include <gccore.h>
#include <iostream>
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand Down
29 changes: 26 additions & 3 deletions menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ static void HaltGui() {
if (guiHalt) {
LWP_SuspendThread(guithread);
} else {
UpdatePads();
mainWindow->Draw();

// Run this for loop only once
Expand Down Expand Up @@ -158,11 +157,35 @@ void InitGUIThreads() {
u8 *buf = static_cast<u8 *>(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;
}
}
}

0 comments on commit fcbb8a8

Please sign in to comment.