main(){ unsigned short base = 1; unsigned short power = 1; unsigned short menuAnswer = 0; int userInput = 0; menuAnswer = powerMenu(); while (menuAnswer != 4){//while the user has not selected "Exit Program" if (menuAnswer == 1){//if user selects change base printf("Please enter a base between 1 and 25:"); userInput = getNum(); if (checkRange(userInput, kBaseMax, kMinNum)){ base = userInput; } } else if (menuAnswer == 2){//if user selects change exponant printf("Please enter a exponent between 1 and 5:"); userInput = getNum(); if (checkRange(userInput, kPowerMax, kMinNum)){ power = userInput; } } else if (menuAnswer == 3){//if user selects "Display base raised to exponents" printf("%d to the power %d = %d", base, power, calculation(base, power)); } menuAnswer = powerMenu();//Get menu selection from user } return 0; }
int aboutMenu() { aboutBg = sf2d_create_texture_mem_RGBA8(about_img.pixel_data, about_img.width, about_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); highlight = sf2d_create_texture_mem_RGBA8(highlight_img.pixel_data, highlight_img.width, highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); sf2d_set_clear_color(RGBA8(0, 0, 0, 0)); while (aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); sf2d_start_frame(GFX_TOP, GFX_LEFT); sf2d_draw_texture(aboutBg, 0, 0); sftd_draw_textf(roboto, 20, 68, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][0]); sftd_draw_textf(roboto, 20, 83, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][1]); sftd_draw_textf(roboto, 20, 116, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][2]); //sftd_draw_textf(roboto, 20, 132, RGBA8(0, 0, 0, 255), 12, "Model = NULL"); sftd_draw_textf(roboto, 20, 168, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][5]); //sftd_draw_textf(roboto, 20, 183, RGBA8(0, 0, 0, 255), 12, "NinjaHax version: NULL"); if (touch.px >= 0 && touch.px <= 480 && touch.py >= 58 && touch.py <= 105) { sf2d_draw_texture(highlight, 0, 56); sftd_draw_textf(roboto, 20, 68, RGBA8(0, 0, 0, 255), 12, "Cyanogen3DS Updates"); sftd_draw_textf(roboto, 20, 83, RGBA8(0, 0, 0, 255), 12, "Click for, view or isntall available updates"); } else if (touch.px >= 0 && touch.px <= 480 && touch.py >= 106 && touch.py <= 157) { sf2d_draw_texture(highlight, 0, 105); sftd_draw_textf(roboto, 20, 116, RGBA8(0, 0, 0, 255), 12, "Cyanogen3DS version: 0.01-20151019-UNOFFICIAL"); sftd_draw_textf(roboto, 20, 132, RGBA8(0, 0, 0, 255), 12, "Model = NULL"); } digitalTime(350, 2); batteryStatus(316, 2); androidQuickSettings(); cursorController(); sf2d_end_frame(); navbarControls(1); if (kDown & KEY_Y) powerMenu(); if (kDown & KEY_L) lockScreen(); if (kDown & KEY_B) { sf2d_free_texture(aboutBg); sf2d_free_texture(highlight); settingsMenu(); } if ((touch.px >= 44 && touch.px <= 119 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A)) { sf2d_free_texture(aboutBg); sf2d_free_texture(highlight); settingsMenu(); } else if ((touch.px >= 120 && touch.px <= 195 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A)) { sf2d_free_texture(aboutBg); sf2d_free_texture(highlight); home(); } sf2d_swapbuffers(); } sf2d_free_texture(aboutBg); sf2d_free_texture(highlight); return 0; }
int settingsMenu() { settingsBg = sf2d_create_texture_mem_RGBA8(settings_img.pixel_data, settings_img.width, settings_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); about_highlight = sf2d_create_texture_mem_RGBA8(about_highlight_img.pixel_data, about_highlight_img.width, about_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); display_highlight = sf2d_create_texture_mem_RGBA8(display_highlight_img.pixel_data, display_highlight_img.width, display_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); developeroptions_highlight = sf2d_create_texture_mem_RGBA8(developeroptions_highlight_img.pixel_data, developeroptions_highlight_img.width, developeroptions_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); performance_highlight = sf2d_create_texture_mem_RGBA8(performance_highlight_img.pixel_data, performance_highlight_img.width, performance_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); security_highlight = sf2d_create_texture_mem_RGBA8(security_highlight_img.pixel_data, security_highlight_img.width, security_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); wifi_highlight = sf2d_create_texture_mem_RGBA8(wifi_highlight_img.pixel_data, wifi_highlight_img.width, wifi_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); sf2d_set_clear_color(RGBA8(0, 0, 0, 0)); while (aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); sf2d_start_frame(GFX_TOP, GFX_LEFT); sf2d_draw_texture(settingsBg, 0, 0); sftd_draw_textf(roboto, 48, 106, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][0]); sftd_draw_textf(roboto, 48, 153, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][1]); sftd_draw_textf(roboto, 48, 202, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][2]); sftd_draw_textf(roboto, 250, 106, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][3]); sftd_draw_textf(roboto, 250, 153, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][4]); sftd_draw_textf(roboto, 250, 202, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][5]); settingsHighlight(); digitalTime(350, 2); batteryStatus(316, 2); androidQuickSettings(); cursorController(); sf2d_end_frame(); navbarControls(1); if (kDown & KEY_Y) powerMenu(); if (kDown & KEY_L) lockScreen(); if (kDown & KEY_B) { settingsUnload(); appDrawer(); } if ((touch.px >= 44 && touch.px <= 119 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A)) { settingsUnload(); appDrawer(); } else if ((touch.px >= 120 && touch.px <= 195 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A)) { settingsUnload(); home(); } sf2d_swapbuffers(); } settingsUnload(); return 0; }
int home() { sf2d_set_clear_color(RGBA8(0, 0, 0, 0)); ic_allapps_pressed = sf2d_create_texture_mem_RGBA8(ic_allapps_pressed_img.pixel_data, ic_allapps_pressed_img.width, ic_allapps_pressed_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); ic_launcher_browser = sf2d_create_texture_mem_RGBA8(ic_launcher_browser_img.pixel_data, ic_launcher_browser_img.width, ic_launcher_browser_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); ic_launcher_messenger = sf2d_create_texture_mem_RGBA8(ic_launcher_messenger_img.pixel_data, ic_launcher_messenger_img.width, ic_launcher_messenger_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); ic_launcher_apollo = sf2d_create_texture_mem_RGBA8(ic_launcher_apollo_img.pixel_data, ic_launcher_apollo_img.width, ic_launcher_apollo_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); ic_launcher_settings = sf2d_create_texture_mem_RGBA8(ic_launcher_settings_img.pixel_data, ic_launcher_settings_img.width, ic_launcher_settings_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM); // Main loop while (aptMainLoop()) { //Scan all the inputs. This should be done once for each frame hidScanInput(); //hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame) u32 kDown = hidKeysDown(); //hidKeysUp returns information about which buttons have been just released //u32 kUp = hidKeysUp(); sf2d_start_frame(GFX_TOP, GFX_LEFT); sf2d_draw_texture(background, 0, 0); sf2d_draw_texture(ic_launcher_browser, 49, 145); sf2d_draw_texture(ic_launcher_messenger, 114, 145); sf2d_draw_texture(ic_launcher_apollo, 241, 145); sf2d_draw_texture(ic_launcher_settings, 306, 145); appDrawerIcon(); dayNightWidget(); navbarControls(0); //Displays navbar digitalTime(350, 2); //Displays digital time batteryStatus(316, 2); //Displays battery status cursorController(); sf2d_end_frame(); if ((touch.px >= 170 && touch.px <= 210 && touch.py >= 148 && touch.py <= 190) && (kDown & KEY_A)) { sf2d_free_texture(ic_allapps_pressed); appDrawer(); //Open app drawer } if ((touch.px >= 306 && touch.px <= 351 && touch.py >= 145 && touch.py <= 190) && (kDown & KEY_A)) { sf2d_free_texture(ic_allapps_pressed); settingsMenu(); //Open settings menu } if (kDown & KEY_Y) powerMenu(); //Open power menu if (kDown & KEY_L) lockScreen(); //Locks the screen // Flush and swap framebuffers sf2d_swapbuffers(); } sf2d_free_texture(ic_allapps_pressed); return 0; }