예제 #1
0
파일: codec.cpp 프로젝트: paulcmal/wiitest
void draw_dialogue(char* tab)
{
   GRRLIB_ttfFont *myFont = GRRLIB_LoadTTF(fontCodec_ttf, fontCodec_ttf_size);
   
   //char tab[200] = texte;  // 90 caracteres max (3 lignes)
   char ligne1[31];
   char ligne2[31];
   char ligne3[31];
   char ligne4[31];
   
        // recherche des espaces pour éviter de couper un mot en 2
        // et division du dialogue sur 3 lignes
        int i; int j=0; int k=0; int l=0; int m=0; int z=0;
        while(tab[z]!='\0')  z++;  // n= nombre total de caracteres
        for(i=z; i<199; i++)
           tab[i]=' ';
        tab[199]='\n';
        
        for(i=0; i<30; i++)  // LIGNE 1
        {
           if(tab[i]==' ')
              j=i;  // recup du dernier espace pour savoir où couper
        }
        for(i=0; i<j; i++)  // on crée la ligne 1
           ligne1[i]=tab[i];
        ligne1[j]='\0';
        for(i=j+1; i<j+31; i++)  // REBELOTE LIGNE 2
        {
           if(tab[i]==' ')
              k=i;
        }
        for(i=0; i<(k-j); i++)
           ligne2[i]=tab[j+1+i];  // j+1 car on saute l'espace
        ligne2[k-j]='\0';
        for(i=k+1; i<k+31; i++)  // REBELOTE LIGNE 3
        {
           if(tab[i]==' ')
              l=i;
        }
        for(i=0; i<(l-k); i++)
           ligne3[i]=tab[k+1+i];  // k+1 car on saute l'espace
        ligne3[l-k]='\0';
        for(i=k+1; i<l+31; i++)  // REBELOTE LIGNE 4
        {
           if(tab[i]==' ')
              m=i;
        }
        for(i=0; i<(m-l); i++)
           ligne4[i]=tab[l+1+i];  // k+1 car on saute l'espace
        ligne4[m-l]='\0';
        
        
        GRRLIB_PrintfTTF(75, 265, myFont , ligne1, 28 , CLR_WHITE);
        GRRLIB_PrintfTTF(75, 295, myFont , ligne2, 28 , CLR_WHITE);
        GRRLIB_PrintfTTF(75, 325, myFont , ligne3, 28 , CLR_WHITE);
        GRRLIB_PrintfTTF(75, 355, myFont , ligne4, 28 , CLR_WHITE);
        
        
        GRRLIB_FreeTTF(myFont);
}
예제 #2
0
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;
}
예제 #3
0
파일: Game.cpp 프로젝트: PowerKiKi/polukili
   Game::~Game()
   {
      Console::log(LOG_INFO, "Game::~Game()");
      while (!this->levels.empty())
      {
         delete this->levels.top();
         this->levels.pop();
      }

      if (this->font)
      {
         GRRLIB_FreeTTF(this->font);
      }

      GRRLIB_Exit();
   }
예제 #4
0
void gfxdeinit(){
	GRRLIB_FreeTexture(img_unicorn);
	GRRLIB_FreeTexture(img_skittles);
	GRRLIB_FreeTexture(img_cheese);
	GRRLIB_FreeTexture(img_burrito);
	GRRLIB_FreeTTF(terraria);
	GRRLIB_FreeTexture(img_background);
	GRRLIB_FreeTexture(img_donut);
	GRRLIB_FreeTexture(img_parachute);
	GRRLIB_FreeTexture(img_bird);
	GRRLIB_FreeTexture(img_title);
	GRRLIB_FreeTexture(img_credits);
	GRRLIB_FreeTexture(img_tutorial);
	GRRLIB_FreeTexture(img_p1);
	GRRLIB_FreeTexture(img_p2);
}
예제 #5
0
int main(int argc, char **argv)
{
    SYS_SetResetCallback(WiiResetPressed);
    SYS_SetPowerCallback(WiiPowerPressed);
    usleep(250*1000);
    GRRLIB_Init();
    GRRLIB_ttfFont *font = GRRLIB_LoadTTF(verdana_ttf, verdana_ttf_size);
    
    
    WPAD_Init();
    USB_Initialize();
    USB_DeviceChangeNotifyAsync(USB_CLASS_HID, change_notify_cb, NULL);    
    int dev_id = get_device_id();
    int fd = open_device(dev_id);
    
    struct ds4_input data;
    memset(&data, 0, sizeof(data));
    fetch_data(fd, &data);
    random_leds(fd);
    
    int screenW = rmode->fbWidth, screenH = rmode->efbHeight;
    float pos_x = screenW/2, pos_y = screenH/2;
    while (run) {
        WPAD_ScanPads();
        u32 pressed = WPAD_ButtonsDown(0);
        if (pressed & WPAD_BUTTON_B) {
            dev_id = get_device_id();
            fd = open_device(dev_id);
        }
        if (pressed & WPAD_BUTTON_A) {
            random_leds(fd);
        }
        GRRLIB_FillScreen(0x0);
        GRRLIB_PrintfTTF(15, 15, font, "ds4wii by xerpi | L1: center | R1: random color", 15, 0xFFFFFFFF);
        
        u32 color = (r<<24)|(g<<16)|(b<<8)|0xFF;
        GRRLIB_Circle(pos_x, pos_y, 15, color, 0);
        GRRLIB_Circle(pos_x, pos_y, 14, color, 0);
        
        memset(&data, 0, sizeof(data));
        fetch_data(fd, &data);
        if (data.L1) {pos_x = screenW/2, pos_y = screenH/2;}
        if (data.R1) {random_leds(fd);}
        //1920x940
        if (data.finger1active) {
            GRRLIB_Circle((screenW/1920.0f)*data.finger1X, (screenH/940.0f)*data.finger1Y, 10, 0x00FF00FF, 1);
        }
        if (data.finger2active) {
            GRRLIB_Circle((screenW/1920.0f)*data.finger2X, (screenH/940.0f)*data.finger2Y, 10, 0x0000FFFF, 1);
        }
        
        
        /*char buf1[256];
        sprintf(buf1, "aX: %8hi  aY: %8hi  aZ: %8hi", data.accelX, data.accelY, data.accelZ);
        char buf2[256];
        sprintf(buf2, "gyroX: %8hi  gyroY: %8hi  gyroZ: %8hi", data.gyroX, data.gyroY, data.gyroZ);
        GRRLIB_PrintfTTF(15, 30, font, buf1, 14, 0xFFFFFFFF);
        GRRLIB_PrintfTTF(15, 45, font, buf2, 14, 0xFFFFFFFF);
        */
        
        #define THRESHOLD 50.0f
        if (fabs(data.accelX) > THRESHOLD)
            pos_y -= data.accelX/55.0f;
        if (fabs(data.accelY) > THRESHOLD)
            pos_x -= data.accelY/55.0f;
        
        if (pressed & WPAD_BUTTON_HOME) run = 0;
        GRRLIB_Render();
    }
    
    USB_CloseDevice(&fd);
    USB_Deinitialize();
    GRRLIB_FreeTTF (font);
    GRRLIB_Exit();
    exit(0);
    return 0;
}
예제 #6
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;
}
예제 #7
0
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;
}
예제 #8
0
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;	
}
예제 #9
0
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;
}
예제 #10
0
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;
}