cui_menu menu_credits(cui_game* p_game) { cui_menu next_state = CUI_MENU_MAIN; bool done=false; GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); UI_button button_return; UI_InitBtn(&button_return, 400, 400, "Return"); button_return.img = GRRLIB_LoadTexture(button_png); button_return.font = font; while(!done){ cui_game_update_cursor(p_game->cursor); u32 pressed = WPAD_ButtonsDown(0); UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); GRRLIB_PrintfTTF2 (20, 60, font, 20, 0xFFFFFFFF, "%s", "ChessUi -- a chess interface for Wii --"); GRRLIB_PrintfTTF2 (20, 80, font, 20, 0xFFFFFFFF, "%s", "Presented & programmed by TheDrev"); GRRLIB_PrintfTTF2 (20, 100, font, 20, 0xFFFFFFFF, "%s", "Using the FirstChess engine by Pham Hong Nguyen "); GRRLIB_PrintfTTF2 (20, 120, font, 20, 0xFFFFFFFF, "%s", "and piece graphismes by Wapcaplet"); GRRLIB_PrintfTTF2 (20, 140, font, 20, 0xFFFFFFFF, "%s", "and also the GRRLIB graphic library"); GRRLIB_PrintfTTF2 (20, 160, font, 20, 0xFFFFFFFF, "%s", "see http://wiibrew.org/wiki/Chessui for more details"); if(button_return.click){ done=true; next_state=CUI_MENU_MAIN; } if ( pressed & WPAD_BUTTON_HOME ){ if(!p_game->is_mute)AESND_Pause(true); if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;} if(!p_game->is_mute)AESND_Pause(false); } UI_DrawBtn(&button_return); cui_cursor_display(p_game->cursor); GRRLIB_Render(); } GRRLIB_FreeTTF(font); free(button_return.text); GRRLIB_FreeTexture(button_return.img); return next_state; }
//------------------------------------------------------------------------------ //! \brief Remove the sound driver //------------------------------------------------------------------------------ void CAudioDrv::RemoveDriver(void) { if (!m_AudioValidFlag) return; StopModule(); AESND_Pause(true); m_AudioValidFlag = 0; }
int main(int argc, char* argv[]) { u8 *tex_ptrone=GRRLIB_LoadTexture(handpointerred_png); u8 *tex_ptrtwo=GRRLIB_LoadTexture(handpointergreen_png); u8 *tex_back=GRRLIB_LoadJPG(bigmenuback_jpg, bigmenuback_jpg_size); u8 *tex_fore=GRRLIB_LoadTexture(credits_png); fatInitDefault(); GRRLIB_InitVideo(); WPAD_Init(); SYS_SetResetCallback(WiiResetPressed); SYS_SetPowerCallback(WiiPowerPressed); WPAD_SetPowerButtonCallback(WiimotePowerPressed); rmode = VIDEO_GetPreferredMode(NULL); AESND_Init(NULL); MODPlay_Init(&mod_track); Init_Voice(); AESND_Pause(0); // the sound loop is running now // set the MOD song if (MODPlay_SetMOD (&mod_track, dojo_dan_oriental_mod) < 0 ) { MODPlay_Unload (&mod_track); } else { // set the music volume to the minimum so we don't hear the music before saved volume is known MODPlay_SetVolume( &mod_track, 0,0); MODPlay_Start (&mod_track);// Play the MOD } WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL, rmode->fbWidth, rmode->xfbHeight); initMain(); MODPlay_SetVolume( &mod_track, opt_music, opt_music); while( HWButton == 0) { WPAD_ScanPads(); u32 wpad_one_down = WPAD_ButtonsDown(0); u32 wpad_two_down = WPAD_ButtonsDown(1); u32 type; WPADData *wd_one, *wd_two; WPAD_ReadPending(WPAD_CHAN_ALL, countevs); WPAD_Probe(WPAD_CHAN_ALL, &type); wd_one = WPAD_Data(0); wd_two = WPAD_Data(1); switch(main_mode) { case STARTUP : GRRLIB_FillScreen(0xFF000000); GRRLIB_DrawImg(0, 0, 640, 480, tex_back, 0, 1, 1, alpha>255?255:alpha); GRRLIB_DrawImg(68,308, 256, 80, tex_fore, 0, 1, 1, alpha>255?255:alpha); if(alpha++>394 || wpad_one_down > 0) { main_mode=MENU; if(tex_back) free(tex_back); if(tex_fore) free(tex_fore); initMenu(); } break; case MENU : GRRLIB_FillScreen(0xFF000000); int menuopt = menuWiimote(wd_one,wpad_one_down); if(menuopt==EXIT) { if(tex_ptrone) free(tex_ptrone); if(tex_ptrtwo) free(tex_ptrtwo); } if(menuopt>NOTHING) { processMenuOption(menuopt); if(main_mode==GAME) { MODPlay_Unload (&mod_track); if(opt_tileset==SPOOKY) MODPlay_SetMOD (&mod_track, graveyard_mod); else if(opt_tileset==EGYPTIAN) MODPlay_SetMOD (&mod_track, egypt_crap_mod); else if(opt_tileset==SIMPLE) MODPlay_SetMOD (&mod_track, childhood_mod); else if(opt_tileset==SPACE) MODPlay_SetMOD (&mod_track, nebulos_mod); else MODPlay_SetMOD (&mod_track, sushi_mod); MODPlay_SetVolume( &mod_track, opt_music, opt_music); MODPlay_Start (&mod_track); } else drawMenu(wd_one); } else drawMenu(wd_one); break; case GAME : if(gameWiimote(wd_one,wpad_one_down,wd_two,wpad_two_down)) { // we are exiting the game back to the menu main_mode=MENU; MODPlay_Unload (&mod_track); MODPlay_SetMOD (&mod_track, dojo_dan_oriental_mod); MODPlay_SetVolume( &mod_track, opt_music, opt_music); MODPlay_Start (&mod_track); killGame(); initMenu(); } else { drawGame(); } break; } // alternate which pointer is on top every frame to not give the advantage to player one in two player mode static int ticktock=0; ticktock++; if(wd_two->ir.valid && ticktock%2==0) { if(main_mode==GAME && whatGameMode()==ONE_PLAYER_GAME) { // don't display second pointer in one player mode } else GRRLIB_DrawColImg(wd_two->ir.x - 9,wd_two->ir.y - 7,68,80,tex_ptrtwo,0,1,1,0xEEFFFFFF); } if(wd_one->ir.valid) { GRRLIB_DrawColImg(wd_one->ir.x - 9,wd_one->ir.y - 7,68,80,tex_ptrone,0,1,1,0xEEFFFFFF); } if(wd_two->ir.valid && ticktock%2!=0) { if(main_mode==GAME && whatGameMode()==ONE_PLAYER_GAME) { // don't display second pointer in one player mode } else GRRLIB_DrawColImg(wd_two->ir.x - 9,wd_two->ir.y - 7,68,80,tex_ptrtwo,0,1,1,0xEEFFFFFF); } if(wd_one->btns_h & WPAD_BUTTON_1) { GRRLIB_ScrShot("MahjonggWii_Screen_%y%m%d_%H%M%S.png",time(NULL)); } GRRLIB_Render(); } // we are exiting, free the mallocs switch( main_mode) { case GAME: killGame(); } if(tex_ptrone) free(tex_ptrone); if(tex_ptrtwo) free(tex_ptrtwo); killMenuLanguages(); MODPlay_Unload (&mod_track); Free_Voice(); WPAD_Shutdown(); GRRLIB_Stop(); saveConfig(FILE_CFG); SYS_ResetSystem(HWButton, 0, 0); return 0; }
cui_menu menu_play(cui_game* p_game) { cui_menu next_state = CUI_MENU_MAIN; bool done=false; GRRLIB_texImg *tex_pieces = GRRLIB_LoadTexture(chess_classic_png); GRRLIB_texImg *tex_tile = GRRLIB_LoadTexture(keyboard_key_png); GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); bool is_debug = false; char coords[5]; char calculated_coords[5]; strcpy(coords, "d2d20"); strcpy(calculated_coords, "d2d20"); while(!done){ WPAD_IR(0, &ir); WPAD_ScanPads(); u32 pressed = WPAD_ButtonsDown(0); u32 released = WPAD_ButtonsUp(0); if(egg_check_s1_code(pressed, released)){ is_debug = true; p_game->board->tile_color1 = 0xc66300FF; p_game->board->tile_color2 = 0x632100FF; p_game->board->piece_color1 = 0x4242CCFF; p_game->board->piece_color2 = 0x444411FF; cui_board_init(p_game->board); if(voice) AESND_PlayVoice(voice, VOICE_STEREO8, warp, warp_size, VOICE_FREQ32KHZ, 1, false); } if ( pressed & WPAD_BUTTON_HOME ){ if(!p_game->is_mute)AESND_Pause(true); if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;} if(!p_game->is_mute)AESND_Pause(false); } if ( pressed & WPAD_BUTTON_MINUS){ switch(menu_option(p_game)){ case CUI_MENU_OPTION_GFX:menu_option_gfx(p_game);break; case CUI_MENU_OPTION_SND:menu_option_snd(p_game);break; default:break; } } int index_offset_x = (p_game->cursor->hotspot_x - 40 / 2)/ 40 - 140 / 40; int index_offset_y = p_game->cursor->hotspot_y / 40 - 80 / 40; if (pressed & WPAD_BUTTON_B) { p_game->cursor->is_grabbing = true; if(index_offset_x >= 0 && index_offset_x < 8 && index_offset_y >= 0 && index_offset_y < 8){ coords[0] = 'a' + index_offset_x; coords[1] = '8' - index_offset_y; } } else if(released & WPAD_BUTTON_B){ p_game->cursor->is_grabbing = false; if(index_offset_x >= 0 && index_offset_x < 8 && index_offset_y >= 0 && index_offset_y < 8){ coords[2] = 'a' + index_offset_x; coords[3] = '8' - index_offset_y; coords[4] = 0; if(voice) AESND_PlayVoice(voice, VOICE_STEREO16, move_pcm, move_pcm_size, VOICE_FREQ48KHZ, 1, false); if(calculate_coords(coords, calculated_coords, p_game->engine)){ cui_board_read_core(p_game->board, p_game->engine); } } } cui_cursor_update(p_game->cursor, ir.x, ir.y, ir.angle); if(p_game->tex_wallpaper)GRRLIB_DrawImg(0, -50, p_game->tex_wallpaper, 1, 1, 1, 0XFFFFFFFF); cui_board_display(p_game->board, tex_pieces, tex_tile, font, index_offset_x, index_offset_y); cui_cursor_display(p_game->cursor); if(is_debug){ GRRLIB_PrintfTTF (20, 00, font, coords, 16, 0x424242FF); GRRLIB_PrintfTTF2 (20, 20, font, 16, 0xFFFFFFFF, "x:%.2f y:%.2f", ir.x, ir.y); GRRLIB_PrintfTTF2 (20, 40, font, 16, 0xFFFFFFFF, "x:%.2f y:%.2f", ir.x/40, ir.y/40); GRRLIB_PrintfTTF2 (20, 60, font, 16, 0xFFFFFFFF, "x:%d y:%d", index_offset_x, index_offset_y); GRRLIB_PrintfTTF (20, 80, font, p_game->cursor->is_grabbing?"GRAB":"POINT", 16, 0xFFFFFFFF); GRRLIB_Rectangle(p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, 4, 4, 0xFF4242FF, 1); } GRRLIB_Render(); } GRRLIB_FreeTexture(tex_pieces); GRRLIB_FreeTexture(tex_tile); GRRLIB_FreeTTF(font); return next_state; }
cui_menu menu_main(cui_game* p_game) { cui_menu next_state = CUI_MENU_MAIN; bool done=false; GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); GRRLIB_texImg *tex_pieces = GRRLIB_LoadTexture(chess_classic_png); GRRLIB_texImg *tex_tile = GRRLIB_LoadTexture(keyboard_key_png); GRRLIB_texImg *tex_btn = GRRLIB_LoadTexture(button_png); UI_button button_newgame; UI_InitBtn(&button_newgame, 280, 120, "New game"); button_newgame.img = tex_btn; button_newgame.font = font; UI_button button_options; UI_InitBtn(&button_options, 280, 200, "Options"); button_options.img = tex_btn; button_options.font = font; UI_button button_credit; UI_InitBtn(&button_credit, 280, 280, "credit"); button_credit.img = tex_btn; button_credit.font = font; while(!done){ cui_game_update_cursor(p_game->cursor); u32 pressed = WPAD_ButtonsDown(0); GRRLIB_PrintfTTF (5, 5, font, "ChessUI", 96, 0x424242FF); UI_UpdateBtn(&button_newgame, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); UI_UpdateBtn(&button_options, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); UI_UpdateBtn(&button_credit, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); if(button_newgame.click){ done=true; next_state=CUI_MENU_PLAY; } if(button_options.click){ done=true; next_state=CUI_MENU_OPTION; } if(button_credit.click){ done=true; next_state=CUI_MENU_CREDITS; } if ( pressed & WPAD_BUTTON_HOME ){ if(!p_game->is_mute)AESND_Pause(true); if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;} if(!p_game->is_mute)AESND_Pause(false); } if ( pressed & WPAD_BUTTON_A ){ if(voice) AESND_PlayVoice(voice, VOICE_STEREO16, button_click_pcm, button_click_pcm_size, VOICE_FREQ48KHZ, 1, false); } cui_board_demo(p_game->board, tex_pieces, tex_tile, font); UI_DrawBtn(&button_newgame); UI_DrawBtn(&button_options); UI_DrawBtn(&button_credit); cui_cursor_display(p_game->cursor); GRRLIB_Render(); } GRRLIB_FreeTTF(font); GRRLIB_FreeTexture(tex_btn); free(button_newgame.text); free(button_options.text); free(button_credit.text); return next_state; }
enum e_cui_menu menu_option_gfx(cui_game* p_game) { cui_menu next_state = CUI_MENU_MAIN; bool done=false; u32 option_tile_color_1 = p_game->board->tile_color1; u32 option_tile_color_2 = p_game->board->tile_color2; u32 option_piece_color_1 = p_game->board->piece_color1; u32 option_piece_color_2 = p_game->board->piece_color2; GRRLIB_texImg *tex_tile = GRRLIB_LoadTexture(keyboard_key_png); GRRLIB_texImg *tex_pieces = GRRLIB_LoadTexture(chess_classic_png); GRRLIB_texImg *tex_up = GRRLIB_LoadTexture(scrollbar_arrowup_png); GRRLIB_texImg *tex_down = GRRLIB_LoadTexture(scrollbar_arrowdown_png); GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); int i,j; UI_button button_color[4][8]; //tile 1, tile 2, piece 1, piece 2 | R-+, G-+, B-+, A-+, for(i=0;i<4;i++){ for(j=0;j<8;j++){ UI_InitBtn(&button_color[i][j], 120 + j*64, 64 + i*80, NULL); button_color[i][j].img = j%2==0?tex_down:tex_up; } } UI_button button_return; UI_InitBtn(&button_return, 500, 400, "apply"); button_return.img = GRRLIB_LoadTexture(button_png); button_return.font = font; UI_button button_cancel; UI_InitBtn(&button_cancel, 350, 400, "cancel"); button_cancel.img = GRRLIB_LoadTexture(button_png); button_cancel.font = font; while(!done){ cui_game_update_cursor(p_game->cursor); u32 pressed = WPAD_ButtonsDown(0); u32* color_to_modify=NULL; u32 mask; for(i=0;i<4;i++){ for(j=0;j<8;j++){ UI_UpdateBtn(&button_color[i][j], p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); if(button_color[i][j].click){ switch(i){ case 0:color_to_modify = &option_tile_color_1;break; case 1:color_to_modify = &option_tile_color_2;break; case 2:color_to_modify = &option_piece_color_1;break; case 3:color_to_modify = &option_piece_color_2;break; } if(j==0 || j==1)mask=0x06000000; if(j==2 || j==3)mask=0x00060000; if(j==4 || j==5)mask=0x00000600; if(j==6 || j==7)mask=0x00000006; *color_to_modify+=j%2==0?-mask:mask; } } } UI_UpdateBtn(&button_cancel, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); if(button_return.click){ if((option_tile_color_1 != p_game->board->tile_color1) || (option_tile_color_2 != p_game->board->tile_color2)){ p_game->board->tile_color1 = option_tile_color_1; p_game->board->tile_color2 = option_tile_color_2; cui_board_init(p_game->board); } if(option_tile_color_1 != p_game->board->piece_color1)p_game->board->piece_color1=option_piece_color_1; if(option_tile_color_2 != p_game->board->piece_color2)p_game->board->piece_color2=option_piece_color_2; done=true; next_state=CUI_MENU_MAIN; } if(button_cancel.click){ done=true; next_state=CUI_MENU_MAIN; } if ( pressed & WPAD_BUTTON_HOME ){ if(!p_game->is_mute)AESND_Pause(true); if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;} if(!p_game->is_mute)AESND_Pause(false); } GRRLIB_DrawImg(380, 80+140, tex_tile, 0, 2, 2, option_tile_color_1); GRRLIB_DrawImg(380, 180+140, tex_tile, 0, 2, 2, option_tile_color_2); GRRLIB_DrawImg(380+80, 80+140, tex_tile, 0, 2, 2, option_tile_color_2); GRRLIB_DrawImg(380+80, 180+140, tex_tile, 0, 2, 2, option_tile_color_1); GRRLIB_DrawImg(380+160, 80+140, tex_tile, 0, 2, 2, option_tile_color_1); GRRLIB_DrawImg(380+160, 180+140, tex_tile, 0, 2, 2, option_tile_color_2); GRRLIB_DrawImg(380, 80, tex_pieces, 0, 2, 2, option_piece_color_2); GRRLIB_DrawImg(380, 180, tex_pieces, 0, 2, 2, option_piece_color_1); GRRLIB_PrintfTTF (145, 0, font, "RED GREEN BLUE ALPHA", 20, 0xFFFFFFFF); GRRLIB_PrintfTTF (15, 40, font, "Tiles color #1", 20, 0xFFFFFFFF); GRRLIB_PrintfTTF (15, 40+80, font, "Tiles color #2", 20, 0xFFFFFFFF); GRRLIB_PrintfTTF (15, 40+80*2, font, "Pieces color #1", 20, 0xFFFFFFFF); GRRLIB_PrintfTTF (15, 40+80*3, font, "Pieces color #2", 20, 0xFFFFFFFF); for(i=0;i<4;i++){ for(j=0;j<8;j++){ UI_DrawBtn(&button_color[i][j]); } } UI_DrawBtn(&button_return); UI_DrawBtn(&button_cancel); GRRLIB_Line(235, 25, 235, 350, 0xFFFFFFFF); GRRLIB_Line(235+64*2, 25, 235+64*2, 350, 0xFFFFFFFF); GRRLIB_Line(235+64*4, 25, 235+64*4, 350, 0xFFFFFFFF); GRRLIB_Line(235+64*6, 25, 235+64*6, 350, 0xFFFFFFFF); cui_cursor_display(p_game->cursor); GRRLIB_Render(); } GRRLIB_FreeTexture(tex_tile); GRRLIB_FreeTexture(tex_pieces); GRRLIB_FreeTexture(tex_up); GRRLIB_FreeTexture(tex_down); GRRLIB_FreeTTF(font); free(button_return.text); free(button_cancel.text); return next_state; }
enum e_cui_menu menu_option(cui_game* p_game) { cui_menu next_state = CUI_MENU_MAIN; bool done=false; GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); /* UI_button button_general; UI_InitBtn(&button_general, 280, 120, "General"); button_general.img = GRRLIB_LoadTexture(button_png); button_general.font = font; */ UI_button button_graphics; UI_InitBtn(&button_graphics, 280, 200, "Graphics"); button_graphics.img = GRRLIB_LoadTexture(button_png); button_graphics.font = font; UI_button button_sounds; UI_InitBtn(&button_sounds, 280, 280, "Sounds"); button_sounds.img = GRRLIB_LoadTexture(button_png); button_sounds.font = font; UI_button button_return; UI_InitBtn(&button_return, 400, 400, "Return"); button_return.img = GRRLIB_LoadTexture(button_png); button_return.font = font; while(!done){ cui_game_update_cursor(p_game->cursor); u32 pressed = WPAD_ButtonsDown(0); //UI_UpdateBtn(&button_general, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); UI_UpdateBtn(&button_graphics, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); UI_UpdateBtn(&button_sounds, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); /*if(button_general.click){ done=true; next_state=CUI_MENU_OPTION_GENERAL; }*/ if(button_graphics.click){ done=true; next_state=CUI_MENU_OPTION_GFX; } if(button_sounds.click){ done=true; next_state=CUI_MENU_OPTION_SND; } if(button_return.click){ done=true; next_state=CUI_MENU_MAIN; } if ( pressed & WPAD_BUTTON_HOME ){ if(!p_game->is_mute)AESND_Pause(true); if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;} if(!p_game->is_mute)AESND_Pause(false); } //UI_DrawBtn(&button_general); UI_DrawBtn(&button_graphics); UI_DrawBtn(&button_sounds); UI_DrawBtn(&button_return); cui_cursor_display(p_game->cursor); GRRLIB_Render(); } GRRLIB_FreeTexture(button_graphics.img);free(button_graphics.text); GRRLIB_FreeTexture(button_sounds.img);free(button_sounds.text); GRRLIB_FreeTexture(button_return.img);free(button_return.text); GRRLIB_FreeTTF(font); //GRRLIB_F(font); return next_state; }
enum e_cui_menu menu_option_snd(cui_game* p_game) { cui_menu next_state = CUI_MENU_MAIN; bool done=false; GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); GRRLIB_texImg *tex_btn = GRRLIB_LoadTexture(button_png); UI_button button_sounds; UI_InitBtn(&button_sounds, 200, 280, "Mute"); button_sounds.img = tex_btn; button_sounds.font = font; UI_button button_return; UI_InitBtn(&button_return, 400, 400, "Return"); button_return.img = tex_btn; button_return.font = font; int i; UI_button button_type[4]; for(i=0;i<4;i++){ char text[7]; sprintf(text, "TYPE %c", 'A'+i); UI_InitBtn(&button_type[i], 50+150*i, 100, text); button_type[i].img = tex_btn; button_type[i].font = font; } while(!done){ cui_game_update_cursor(p_game->cursor); u32 pressed = WPAD_ButtonsDown(0); for(i=0;i<4;i++){ UI_UpdateBtn(&button_type[i], p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); } UI_UpdateBtn(&button_sounds, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A); for(i=0;i<4;i++){ if(button_type[i].click){ switch(i){ case 0:MODPlay_SetMOD(&play,bg_music);MODPlay_Start(&play);break; case 1:MODPlay_SetMOD(&play,bg_music_b);MODPlay_Start(&play);break; case 2:MODPlay_SetMOD(&play,bg_music_c);MODPlay_Start(&play);break; case 3:MODPlay_SetMOD(&play,bg_music_d);MODPlay_Start(&play);break; } } } if(button_sounds.click){ p_game->is_mute = !p_game->is_mute; AESND_Pause(p_game->is_mute); } if(button_return.click){ done=true; next_state=CUI_MENU_MAIN; } if ( pressed & WPAD_BUTTON_HOME ){ if(!p_game->is_mute)AESND_Pause(true); if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;} if(!p_game->is_mute)AESND_Pause(false); } for(i=0;i<4;i++){ UI_DrawBtn(&button_type[i]); } UI_DrawBtn(&button_sounds); UI_DrawBtn(&button_return); cui_cursor_display(p_game->cursor); GRRLIB_Render(); } free(button_sounds.text); free(button_return.text); free(button_type[0].text); free(button_type[1].text); free(button_type[2].text); free(button_type[3].text); GRRLIB_FreeTexture(tex_btn); GRRLIB_FreeTTF(font); return next_state; }