Example #1
0
void CMenu::error(const wstringEx &msg)
{
	s32 padsState;
	WPADData *wd;

	WPAD_Rumble(WPAD_CHAN_0, 0);
	_hideAbout();
	_hideCode();
	_hideConfig();
	_hideConfig2();
	_hideConfigAdv();
	_hideDownload();
	_hideGame();
	_hideMain();
	_hideWBFS();
	_hideGameSettings();
	m_btnMgr.setText(m_errorLblMessage, msg, true);
	_showError();
	do
	{
		WPAD_ScanPads();
		padsState = WPAD_ButtonsDown(0);
		wd = WPAD_Data(0);
		_mainLoopCommon(wd);
	} while ((padsState & (WPAD_BUTTON_HOME | WPAD_BUTTON_A | WPAD_BUTTON_B)) == 0);
	WPAD_Rumble(WPAD_CHAN_0, 0);
	_hideError(false);
}
Example #2
0
void ShutoffRumble()
{
	for(int i=0;i<4;i++)
	{
		WPAD_Rumble(i, 0);
		rumbleCount[i] = 0;
	}
}
Example #3
0
struct virtkey *get_key_internal()
{
	while(1)
	{
		uint32_t k;
		int x,y,xm, ym, i=0;
		int border_x = VirtualKeyboard.x;
		int border_y = VirtualKeyboard.y;

		draw_vk();
		
		SDL_ShowCursor(SDL_ENABLE);
		
		flip_VKB();

		k = menu_wait_key_press();
		
		SDL_ShowCursor(SDL_DISABLE);

		if (k & KEY_ESCAPE) return NULL;
		else if (k & KEY_SELECT)
		{
			
			SDL_GetMouseState(&xm, &ym);
			x = (xm-border_x);
			y = (ym-border_y);
			
			i = get_index(x*RATIO,y*RATIO);
			
			if (i==-1) continue;
			
			#ifdef GEKKO
			WPAD_Rumble(0, 1);
			SDL_Delay(90);
			WPAD_Rumble(0, 0);
			#endif
			
			virtkey_t *key = &keys[i];
			
			return key;
		}
	}

	return NULL;
}
Example #4
0
static void ShutoffRumble(int i, int cooloff)
{
	if(CONF_GetPadMotorMode() == 0)
		return;

	prev[i] = gettime() + cooloff;
	WPAD_Rumble(i, 0); // rumble off
	rumbleOn[i] = 0;
}
Example #5
0
bool Menu_Delete(){

	WPAD_Rumble(0,0);
	self.rumbleAmt = 0;
	
	struct discHdr *header = NULL;
 	char gameName[31]; 
	
	/* No game list */
	if (!self.gameCnt)
		return false;

	/* Selected game */
	header = &self.gameList[self.gameSelected];
	char title[MAX_TITLE_LEN];

	if(self.usingTitlesTxt){
		sprintf(title, "%s", header->title);
		getTitle(titleList, (char*)header->id, title);
	}
	else
		sprintf(title, "%s", (header->title));

	if(strlen(title) < 30) {
		sprintf(gameName, "%s", title);
	}
	else
	{
		strncpy(gameName, title, 27);
		gameName[27] = '\0';
		strncat(gameName, "...", 3);
	}

	//if(WindowPrompt(TX.askDelete, gameName, &yesButton, &noButton))
	if(WindowPromptInstall((char*)header->id, gameName, TX.askDelete, &yesButton, &noButton, 1))
	{
		BUFFER_KillBuffer();
		if(0 > WBFS_RemoveGame(header->id))
		{
			InitializeBuffer(self.gameList,self.gameCnt,BUFFER_WINDOW,COVER_COUNT/2.0 +self.shift,(settings.covers3d+settings.hq));
			BUFFER_InitBuffer();
			WindowPrompt(TX.errorDelete, TX.cantDelete, &okButton, 0);
		}
		else
		{
			GetEntries();
			InitializeBuffer(self.gameList,self.gameCnt,BUFFER_WINDOW,COVER_COUNT/2.0 +self.shift,(settings.covers3d+settings.hq));
			BUFFER_InitBuffer();
			WindowPrompt(TX.successDelete, TX.pressOkContinue, &okButton, 0);
			WBFS_DiskSpace(&self.usedSpace, &self.freeSpace);
			return true;
		}
	}
	
	return false;
}
Example #6
0
void DoRumble(int i)
{
	if(rumbleRequest[i] && rumbleCount[i] < 3)
	{
		WPAD_Rumble(i, 1); // rumble on
		rumbleCount[i]++;
	}
	else if(rumbleRequest[i])
	{
		rumbleCount[i] = 12;
		rumbleRequest[i] = 0;
	}
	else
	{
		if(rumbleCount[i])
			rumbleCount[i]--;
		WPAD_Rumble(i, 0); // rumble off
	}
}
Example #7
0
void ShutoffRumble()
{
#ifdef HW_RVL
	for(int i=0;i<4;i++)
	{
		WPAD_Rumble(i, 0);
		rumbleCount[i] = 0;
	}
#endif
	PAD_ControlMotor(PAD_CHAN0, PAD_MOTOR_STOP);
}
Example #8
0
void ShutoffRumble()
{
	if(CONF_GetPadMotorMode() == 0)
		return;

	for(int i=0;i<4;i++)
	{
		WPAD_Rumble(i, 0);
		rumbleCount[i] = 0;
		rumbleRequest[i] = 0;
	}
}
Example #9
0
void DoRumble(int i)
{
	if(CONF_GetPadMotorMode() == 0 || !GCSettings.Rumble)
		return;

	if(rumbleRequest[i] && rumbleCount[i] < 3)
	{
		WPAD_Rumble(i, 1); // rumble on
		rumbleCount[i]++;
	}
	else if(rumbleRequest[i])
	{
		rumbleCount[i] = 12;
		rumbleRequest[i] = 0;
	}
	else
	{
		if(rumbleCount[i])
			rumbleCount[i]--;
		WPAD_Rumble(i, 0); // rumble off
	}
}
Example #10
0
void RequestRumble(int i)
{
	if(CONF_GetPadMotorMode() == 0 || rumbleDisabled || i < 0) // !WiiSettings.rumble
		return;

	now[i] = gettime();

	if(prev[i] > now[i])
		return;

	if(diff_usec(prev[i], now[i]) > RUMBLE_MAX)
	{
		rumbleOn[i] = 1;
		WPAD_Rumble(i, 1); // rumble on
		prev[i] = now[i];
	}
}
Example #11
0
static void updateRumble()
{
	bool r = false;
	if (ConfigRequested) r = (menuRumbleCount > 0);
	else r = cartridgeRumble || possibleCartridgeRumble || (gameRumbleCount > 0) || (menuRumbleCount > 0);

	if (SilenceNeeded>0) {
		if (r) SilenceNeeded = 5;
		else SilenceNeeded--;
		if (SilenceNeeded>0) r = false;
	}

#ifdef HW_RVL
	// Rumble wii remote 0
	WPAD_Rumble(0, r);
#endif
	PAD_ControlMotor(PAD_CHAN0, r?PAD_MOTOR_RUMBLE:PAD_MOTOR_STOP);
}
Example #12
0
void HCheckForHit(Sprite *Aim){

int startrumble = 0;

if(Aim->CollidesWith(Alley1)){
if(alive[0] == true){
alive[0] = false;
startrumble = 1;
if(Alley1->GetImage() == good1 || Alley1->GetImage() == good2 || Alley1->GetImage() == good3)
Ghealth--;
if(Alley1->GetImage() == bad1 || Alley1->GetImage() == bad2 || Alley1->GetImage() == bad3)
Gscore++;
}
}

if(Aim->CollidesWith(Alley2)){
if(alive[1] == true){
alive[1] = false;
startrumble = 1;
if(Alley2->GetImage() == good1 || Alley2->GetImage() == good2 || Alley2->GetImage() == good3)
Ghealth--;
if(Alley2->GetImage() == bad1 || Alley2->GetImage() == bad2 || Alley2->GetImage() == bad3)
Gscore++;
}
}

if(Aim->CollidesWith(Alley3)){
if(alive[2] == true){
alive[2] = false;
startrumble = 1;
if(Alley3->GetImage() == good1 || Alley3->GetImage() == good2 || Alley3->GetImage() == good3)
Ghealth--;
if(Alley3->GetImage() == bad1 || Alley3->GetImage() == bad2 || Alley3->GetImage() == bad3)
Gscore++;
}
}

if(startrumble == 1 && Grumble == 1){
	WPAD_Rumble(WPAD_CHAN_0, 1);
    hrumblecounter = 1;
	}

}
Example #13
0
 int showDOLWindow(int nr)
 { 
         int ret = 1;
         bool doloop = true; 
         int fade = 5; 
         int y, sp; 
         int i;
		 
		 okButton.x = 353;
		 okButton.y = 335;
  
		 switch(nr)
		 {
			case 1:
				CFG_COUNT = CFG_METROID_COUNT;
				for ( i=0; i<CFG_COUNT; i++)
					strcpy(Episode[i], MPT_DOL[i]);
				break;
			case 2:
				CFG_COUNT = CFG_HOD23_COUNT;
				for ( i=0; i<CFG_COUNT; i++)
					strcpy(Episode[i], HOD23_DOL[i]);
				break;
		 }
  
         do{ 
			y = 115; 
			sp = 0; 

			WPAD_ScanPads(); 
			PAD_ScanPads(); 
			GetWiimoteData(); 

			draw_covers(); 
			GRRLIB_2D_Init(); 
			GRRLIB_FillScreen(0x00000000|fade); 

			GRRLIB_Rectangle(40, 106, 560, 276, 0xffffffdd, true);
			GRRLIB_Rectangle(42, 108, 556, 272, 0x737373FF, true);
			GRRLIB_Rectangle(268, 168, 304, 44, 0xffffffdd, true);
			GRRLIB_Rectangle(270, 170, 300, 40, 0x000000FF, true);

			// Get the title info
			struct discHdr *header = NULL;
			header = &self.gameList[self.gameSelected];
			char gameName[MAX_TITLE_LEN]; 

			if(self.usingTitlesTxt)
			{
				// Load a custom title
				sprintf(gameName, "%s", header->title);
				getTitle(titleList, (char*)header->id, gameName);
			}
			else
				sprintf(gameName, "%s", (header->title));

			// Chomp the title to fit
			if(strlen(gameName) >= 22)
			{
				//strncpy(gameName, header->title, 17);
				gameName[19] = '\0';
				strncat(gameName, "...", 3);
			}

			// Display Title, Last Played, and Size
			char tTemp[50];
			sprintf(tTemp,"%s",gameName);
			CFreeTypeGX_DrawText(ttf20pt, 420, 200, tTemp, (GXColor){0xff, 0xff, 0xff, 0xff}, FTGX_JUSTIFY_CENTER);
			CFreeTypeGX_DrawText(ttf20pt, 268, 149, "Episode to play ?", (GXColor){0xff, 0xff, 0xff, 0xff}, FTGX_JUSTIFY_LEFT);

			CFreeTypeGX_DrawText(ttf16pt, 350, 280, "Episode:", (GXColor){0x00, 0x00, 0x00, 0xff}, FTGX_JUSTIFY_RIGHT);
			CFreeTypeGX_DrawText(ttf16pt, 503, 280,  Episode[ret -1], (GXColor){0xff, 0xff, 0xff, 0xff}, FTGX_JUSTIFY_CENTER);


			// Draw the game cover
			if(self.gameSelected < MAX_BUFFERED_COVERS || self.gameSelected >= 0)
			{
				if(BUFFER_IsCoverReady(self.gameSelected))
				{
					pthread_mutex_lock(&buffer_mutex[self.gameSelected]);
					if(_texture_data[self.gameSelected].data)
					{
						if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
						{
							if(settings.covers3d)
							{
								GRRLIB_DrawFlatCoverImg(60, 131, _texture_data[self.gameSelected], 0, AR_16_9, 1, 0xFFFFFFFF);
							}
							else
							{
								GRRLIB_DrawImg(60, 131, _texture_data[self.gameSelected], 0, AR_16_9, 1, 0xFFFFFFFF);
							}
						}
						else
						{
							if(settings.covers3d)
							{
								GRRLIB_DrawFlatCoverImg(60, 131, _texture_data[self.gameSelected], 0, 1, 1, 0xFFFFFFFF);
							}
							else
							{
								GRRLIB_DrawImg(60, 131, _texture_data[self.gameSelected], 0, 1, 1, 0xFFFFFFFF);
							}
						}
					}
					else
					{
						if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
						{
							if(settings.covers3d)
							{
								GRRLIB_DrawFlatCoverImg(60, 131 , cover_texture_3d, 0, AR_16_9, 1, 0xFFFFFFFF);
							}
							else
							{
								GRRLIB_DrawImg(60, 131, cover_texture, 0, AR_16_9, 1, 0xFFFFFFFF);
							}
						}
						else
						{
							if(settings.covers3d)
							{
								GRRLIB_DrawFlatCoverImg(60, 131, cover_texture_3d, 0, 1, 1, 0xFFFFFFFF);
							}
							else
							{
								GRRLIB_DrawImg(60, 131, cover_texture, 0, 1, 1, 0xFFFFFFFF);
							}
						}
					}
					
					pthread_mutex_unlock(&buffer_mutex[self.gameSelected]);
				}
				else
				{	
				if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
				{
					if(settings.covers3d)
					{
						GRRLIB_DrawFlatCoverImg(60, 131, cover_texture_3d, 0, AR_16_9, 1, 0xFFFFFFFF);
					}
					else
					{
						GRRLIB_DrawImg(60, 131, cover_texture, 0, AR_16_9, 1, 0xFFFFFFFF);
					}
				}
				else
				{
					if(settings.covers3d)
					{
						GRRLIB_DrawFlatCoverImg(60, 131, cover_texture_3d, 0, 1, 1, 0xFFFFFFFF);
					}
					else
					{
						GRRLIB_DrawImg(60, 131, cover_texture, 0, 1, 1, 0xFFFFFFFF);
					}
				}
				}
			}
			else
			{
				if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
				{
					if(settings.covers3d)
					{
						GRRLIB_DrawFlatCoverImg(60, 131, cover_texture_3d, 0, AR_16_9, 1, 0xFFFFFFFF);
					}
					else
					{
						GRRLIB_DrawImg(60, 131, cover_texture, 0, AR_16_9, 1, 0xFFFFFFFF);
					}
				}
				else
				{
					if(settings.covers3d)
					{
						GRRLIB_DrawFlatCoverImg(60, 131, cover_texture_3d, 0, 1, 1, 0xFFFFFFFF);
					}
					else
					{
						GRRLIB_DrawImg(60, 131, cover_texture, 0, 1, 1, 0xFFFFFFFF);
					}
				}
			}


			Button_TTF_Paint(&okButton); 
			Button_Paint(&gDOLdownButton);
			Button_Paint(&gDOLupButton);

			DrawCursor(0, pointer.p_x, pointer.p_y, pointer.p_ang, 1, 1, 0xFFFFFFFF); 

			if ( Button_Hover(&okButton, pointer.p_x, pointer.p_y) ||
				 Button_Hover(&gDOLupButton, pointer.p_x, pointer.p_y) ||
			     Button_Hover(&gDOLdownButton, pointer.p_x, pointer.p_y) ) 
			{ 
				 // Should we be rumbling? 
				 if (--self.rumbleAmt > 0) 
						 WPAD_Rumble(0,1); // Turn on Wiimote rumble 
				 else  
						 WPAD_Rumble(0,0); // Kill the rumble 
			} 
			else 
			{ // If no button is being hovered, kill the rumble 
				 WPAD_Rumble(0,0); 
				 self.rumbleAmt = 5; 
			} 
			
			if((WPAD_ButtonsDown(0) & WPAD_BUTTON_A)||(PAD_ButtonsDown(0) & PAD_BUTTON_A))
			{
				if(Button_Select(&okButton, pointer.p_x, pointer.p_y) && WPAD_ButtonsDown(0) & WPAD_BUTTON_A) 
				{
					doloop = false;
				}
				else if (Button_Select(&gDOLdownButton, pointer.p_x, pointer.p_y))
				{ // Clicked on the episodeDOL buttons
					if (ret > 1)
					{
						ret --;
					}
					else
					{
						ret = (CFG_COUNT);
					}
				}
				else if (Button_Select(&gDOLupButton, pointer.p_x, pointer.p_y))
				{
					if (ret < (CFG_COUNT))
					{
						ret ++;
					}
					else
					{
						ret = 1;
					}
				}
			}
			GRRLIB_Render(); 
                  
         }while(doloop); 
  return ret;

}
Example #14
0
static void rumble(int Control, int rumble){
	WPAD_Rumble(Control, (rumble && rumbleEnabled) ? 1 : 0);
}
Example #15
0
static void pause(int Control){
	WPAD_Rumble(Control, 0);
}
Example #16
0
/**
 * Process controllerinput into a new mapview
 */
void updateworld()
{
	//Zooming
	if(wpaddown & WPAD_BUTTON_PLUS) {
		if(world_zoom_target < MAX_ZOOM)
		{
			stopslide();
			world_zoom_target += 1;
		} else {
			rumble = 1;
		}
	}
	
	if(wpaddown & WPAD_BUTTON_MINUS) {
		if(world_zoom_target > MIN_ZOOM) {
			stopslide();
			world_zoom_target -= 1;
		} else {
			rumble = 1;
		}
	}
	
	if(rumble == 1)
		WPAD_Rumble(WPAD_CHAN_0, 1);

	if(rumble > 2) {
		WPAD_Rumble(WPAD_CHAN_0, 0);
		rumble = 0;
	}
		
	if(rumble >= 1)
		rumble++;		

	
	//Let world_zoom approach world_zoom_target
	world_zoom = world_zoom + ((world_zoom_target - world_zoom) / 10);
	
	world_width = coordinates2pixels(1); //Used within drawtile();
	
	//Dragging
	if(wpaddown & WPAD_BUTTON_B) {
		stopslide();
		struct point cursorworld = screen2world(cursor_x, cursor_y);
		world_grab_x = cursorworld.x;
		world_grab_y = cursorworld.y;
		
		world_grab_x -= floor(world_grab_x);
	}
	
	//Zooming towards a specific spot
	if(wpaddown & WPAD_BUTTON_A) {
		stopslide();
		if(world_zoom_target < MAX_ZOOM)
			world_zoom_target++;
		else
			rumble = 1;
		
		
		struct point cursorworld = screen2world(cursor_x, cursor_y);
		world_zoomto_x = cursorworld.x;
		world_zoomto_y = cursorworld.y;
		world_zoomto_x -= floor(world_zoomto_x);
		if(world_zoomto_y < 0) world_zoomto_y = 0;
		if(world_zoomto_y > 1) world_zoomto_y = 1;
		world_zooming_to = TRUE;
	}
	
	//If the user is holding the world then move the world so that the world_grab_x & y variables
	//are always right under the cursor
	world_grabbed = wpadheld & WPAD_BUTTON_B;
	
	if(world_grabbed)
	{
		float cursor_xcenter_distance = pixels2coordinates(cursor_x - SCREEN_XCENTER);
		float cursor_ycenter_distance = pixels2coordinates(cursor_y - SCREEN_YCENTER);

		float newworld_x = world_grab_x - cursor_xcenter_distance;
		float newworld_y = world_grab_y - cursor_ycenter_distance;
		
		//Keep it between 0 and 1
		newworld_x -= floor(newworld_x);
		
		if(newworld_y > 1) newworld_y = 1;
		if(newworld_y < 0) newworld_y = 0;

		//Store the speed in case the user lets go
		world_speed_x = newworld_x - world_x;
		world_speed_y = newworld_y - world_y;
		
		world_speed_x -= (int)(world_speed_x);		
		
		world_x = newworld_x;
		world_y = newworld_y;
	} else {
		world_speed_x /= world_speed_x < pixels2coordinates(SPEED_CUTOFFPOINT) ? HIGHSPEED_DECAYRATE : LOWSPEED_DECAYRATE;
		world_speed_y /= world_speed_y < pixels2coordinates(SPEED_CUTOFFPOINT) ? HIGHSPEED_DECAYRATE : LOWSPEED_DECAYRATE;
		
		world_x += world_speed_x;
		world_y += world_speed_y;
	}
	
	//D-pad movement
	if(!world_grabbed)
	{
		if(wpadheld & WPAD_BUTTON_UP) {
			stopslide();
			world_y -= pixels2coordinates(DPAD_SPEED);
		}
		
		if(wpadheld & WPAD_BUTTON_DOWN) {
			stopslide();
			world_y += pixels2coordinates(DPAD_SPEED);
		}
		
		if(wpadheld & WPAD_BUTTON_LEFT) {
			stopslide();
			world_x -= pixels2coordinates(DPAD_SPEED);
		}
		
		if(wpadheld & WPAD_BUTTON_RIGHT) {
			stopslide();
			world_x += pixels2coordinates(DPAD_SPEED);
		}
	}
	
	//Move to point
	if(world_zooming_to)
	{
		world_x += (world_zoomto_x - world_x)  / 10;
		world_y += (world_zoomto_y - world_y)  / 10;
	}
	
	//Correct for panning across the earth
	world_x -= floor(world_x);
	if(world_y > 1) world_y = 1;
	if(world_y < 0) world_y = 0;	

	//Update screen variables
	struct point topleft = screen2world(0, 0);
	struct point bottomright = screen2world(SCREEN_WIDTH, SCREEN_HEIGHT);
	screen_left = topleft.x;
	screen_top = topleft.y;
	screen_right = bottomright.x;
	screen_bottom = bottomright.y;
}
Example #17
0
int hogansnewalley(Sprite *Aim, Sprite *Health, Sprite *Background, int rumble, int maxtime, int diff, GameWindow *gwd){
  
  checkbadguys = false;
  
  gametime = 0;
  
  curalleytime = 200;

  Ghealth = 3;
  
  Grumble = rumble;
  
  Gscore = 0;
  
  switch(diff){
  
  case 1:
  resetalleytime = 90;
  grid = false;
  Alley1->SetPosition(70, 190);
  Alley2->SetPosition(260, 190);
  Alley3->SetPosition(450, 190);
  break;
  
  case 2:
  resetalleytime = 90;
  grid = true;
  //Alley1->SetPosition(70, 190);
  //Alley2->SetPosition(260, 190);
  //Alley3->SetPosition(450, 190);
  break;
  
  case 3:
  resetalleytime = 55;
  grid = false;
  Alley1->SetPosition(70, 190);
  Alley2->SetPosition(260, 190);
  Alley3->SetPosition(450, 190);
  break;
  
  case 4:
  resetalleytime = 55;
  grid = true;
  break;
  
  }
  
  alive[0] = false;
  alive[1] = false;
  alive[2] = false;

  good1->LoadImage("/apps/WiiShootingGallery/data/good1.png");
  good2->LoadImage("/apps/WiiShootingGallery/data/good2.png");
  good3->LoadImage("/apps/WiiShootingGallery/data/good3.png");
  bad1->LoadImage("/apps/WiiShootingGallery/data/bad1.png");
  bad2->LoadImage("/apps/WiiShootingGallery/data/bad2.png");
  bad3->LoadImage("/apps/WiiShootingGallery/data/bad3.png");
  
  quitcheck = false;

 while(true){//Game Loop
 
   WPAD_ScanPads();
   if(dontcheck)
   dontcheck = false;
   
   Music();

   if(curalleytime >= resetalleytime)
   resetalley();

   Background->Draw();
   
   if(alive[0] == true)
   Alley1->Draw();
   
   if(alive[1] == true)
   Alley2->Draw();
   
   if(alive[2] == true)
   Alley3->Draw();
   
    // Infrared calculation - The X and Y of the wiimote sprite
    ir_t ir; // The struct for infrared
	WPAD_IR(WPAD_CHAN_0, &ir); // Let's get our infrared data
	// Give our sprite the positions and the angle.
	Aim->SetPosition(ir.sx-WSP_POINTER_CORRECTION_X, ir.sy-WSP_POINTER_CORRECTION_Y); // We use these constants to translate the position correctly to the screen
	Aim->Move(-((f32)Aim->GetWidth()/2), -((f32)Aim->GetHeight()/2)); // And these to make our image appear at the center of this position.
	Aim->SetRotation(ir.angle/2); // Set angle/2 to translate correctly
   
   Aim->Draw();
   
   DrawHealth(Health, Ghealth);
   
   if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_PLUS){
	InMenu(gwd, false, Ghealth, Gscore);
	dontcheck = true;
	if(Ghealth > 3)
	Ghealth = 3;
	}
		
	if(quitcheck == true)
	break;
   
   if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_HOME)
   homemenu(gwd);
   
   if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_B){
   if(!dontcheck)
   HCheckForHit(Aim);
   }
   
   if(hrumblecounter == 7){
   WPAD_Rumble(WPAD_CHAN_0, 0);
   hrumblecounter = 0;
   }

   if(hrumblecounter != 0)
   hrumblecounter++;
   
   if(gametime > maxtime)
   break;
   
   if(maxtime > 0)
   gametime++;
   
   curalleytime++;
   
   if(Ghealth <= 0) 
   break;
   
   if(shutdown == true)
   SYS_ResetSystem(SYS_POWEROFF, 0, 0);
   
   gwd->Flush();



}//End Game Loop

WPAD_Rumble(WPAD_CHAN_0, 0);

return Gscore;

}
Example #18
0
void CMenu::_CheatSettings() {
	s32 padsState;
	WPADData *wd;
	u32 btn;
	WPAD_Rumble(WPAD_CHAN_0, 0);

	// try to load cheat file
	int txtavailable=0;
	m_cheatSettingsPage = 1; // init page
	
	txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str())); 
	
	_showCheatSettings();
	_textCheatSettings();
	
	if (txtavailable)
		m_btnMgr.setText(m_cheatLblTitle,wfmt(L"%s",m_cheatfile.getGameName().c_str()));
	else 
		m_btnMgr.setText(m_cheatLblTitle,L"");
	
	while (true)
	{
		WPAD_ScanPads();
		padsState = WPAD_ButtonsDown(0);
		wd = WPAD_Data(0);
		btn = _btnRepeat(wd->btns_h);
		if ((padsState & (WPAD_BUTTON_HOME | WPAD_BUTTON_B)) != 0)
			break;
		if (wd->ir.valid)
			m_btnMgr.mouse(wd->ir.x - m_cur.width() / 2, wd->ir.y - m_cur.height() / 2);
		else if ((padsState & WPAD_BUTTON_UP) != 0)
			m_btnMgr.up();
		else if ((padsState & WPAD_BUTTON_DOWN) != 0)
			m_btnMgr.down();
		if ((padsState & WPAD_BUTTON_MINUS) != 0)
		{
			if (m_cheatSettingsPage > 1)
				--m_cheatSettingsPage;
			_hideCheatSettings();
			_showCheatSettings();
			m_btnMgr.click(m_cheatBtnPageM);
		}
		else if ((padsState & WPAD_BUTTON_PLUS) != 0)
		{
			_hideCheatSettings();
			if (m_cheatSettingsPage < (m_cheatfile.getCnt()+CHEATSPERPAGE-1)/CHEATSPERPAGE)
				++m_cheatSettingsPage;
			_showCheatSettings();
			m_btnMgr.click(m_cheatBtnPageP);
		}		
		if ((padsState & WPAD_BUTTON_A) != 0)
		{
			m_btnMgr.click();
			if (m_btnMgr.selected() == m_cheatBtnBack)
				break;
			else if (m_btnMgr.selected() == m_cheatBtnPageM)
			{
				_hideCheatSettings();
				if (m_cheatSettingsPage > 1)
					--m_cheatSettingsPage;
				_showCheatSettings();
			}
			else if (m_btnMgr.selected() == m_cheatBtnPageP)
			{
				_hideCheatSettings();
				if (m_cheatSettingsPage < (m_cheatfile.getCnt()+CHEATSPERPAGE-1)/CHEATSPERPAGE)
					++m_cheatSettingsPage;
				_showCheatSettings();
			}
				
			for (int i = 0; i < CHEATSPERPAGE; ++i)
				if (m_btnMgr.selected() == m_cheatBtnItem[i]) {
					// handling code for clicked cheat
					m_cheatfile.sCheatSelected[(m_cheatSettingsPage-1)*CHEATSPERPAGE + i] = !m_cheatfile.sCheatSelected[(m_cheatSettingsPage-1)*CHEATSPERPAGE + i];
					_showCheatSettings();
				}
			
			if (m_btnMgr.selected() == m_cheatBtnApply)
			{
				int operation_ok,check = 0;
				//checks if at least one cheat is selected
				for (unsigned int i=0; i < m_cheatfile.getCnt(); ++i) {
					if (m_cheatfile.sCheatSelected[i] == true) 
						{
						check = 1;
						break;
						}
					
					}
					
				if (check)
				{
					operation_ok = m_cheatfile.createGCT(fmt("%s/%s.gct", m_cheatDir.c_str(), m_cf.getId().c_str())); 
					operation_ok = m_cheatfile.createTXT(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str())); 
					
				}
					
				m_cfg.setOptBool(m_cf.getId(), "cheat",1);
				if (operation_ok)
					break;
			}

			if (m_btnMgr.selected() == m_cheatBtnDownload)
			{
				// Download cheat code
				m_btnMgr.hide(m_cheatLblTitle);
				
				u32 bufferSize = 0x100000;	// Maximum download size 1 MB
				SmartBuf buffer;
				block cheatfile;
				FILE *file;
				char ip[16];
				
				if (!m_networkInit && _initNetwork(ip) < 0) {
					m_btnMgr.hide(m_cheatLblTitle);
					break;
				}
				m_networkInit = true;

				buffer = smartCoverAlloc(bufferSize);
				cheatfile = downloadfile(buffer.get(), bufferSize, sfmt(GECKOURL, m_cf.getId().c_str()).c_str(),CMenu::_downloadProgress, this);

				if (cheatfile.data != NULL && cheatfile.size > 65 && cheatfile.data[0] != '<') {
					// cheat file was downloaded and presumably no 404
					file = fopen(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str()), "wb");
							
					if (file != NULL)
					{
						fwrite(cheatfile.data, 1, cheatfile.size, file);
						fclose(file);
						break;
					}
				}
				else
				{
					// cheat code not found, show result
					m_btnMgr.setText(m_cheatLblItem[0], _t("cheat4", L"Download not found."));
					m_btnMgr.setText(m_cheatLblItem[1], wfmt(L"http://www.geckocodes.org/codes/R/%s.txt",m_cf.getId().c_str()));
					m_btnMgr.show(m_cheatLblItem[1]);
				}
			}
		}
		_mainLoopCommon(wd);
	}
	_hideCheatSettings();
}