コード例 #1
0
ファイル: StateScore.cpp プロジェクト: foxblock/Project4
StateScore::StateScore( StateLevel *level ) :
	StateBase(),
	file( FOLDER_DATA "/" FILE_HIGHSCORE_NORMAL )
{
	SDL_Surface *temp = spCreateSurface( APP_SCREEN_WIDTH, APP_SCREEN_HEIGHT );
	killFrame = spCreateSurface( APP_SCREEN_WIDTH, APP_SCREEN_HEIGHT );
	spSelectRenderTarget( temp );
	level->render( temp );
	spUnlockRenderTarget();
	SDL_SetAlpha( temp, SDL_SRCALPHA, 128 );
	SDL_BlitSurface( temp, NULL, killFrame, NULL );
	spLockRenderTarget();
	spSelectRenderTarget( spGetWindowSurface() );
	spDeleteSurface( temp );
	if ( level->player->toBeRemoved )
		playerDead = true;
	else
		playerDead = false;

	score = level->scoreKeeper->getScore();
	scoreText = spFontLoad( FONT_GENERAL, SCORE_FONT_SIZE );
	if ( scoreText )
	{
		spFontAdd( scoreText, SP_FONT_GROUP_ALPHABET SP_FONT_GROUP_GERMAN ".:!\"_", -1 );
		spFontAdd( scoreText, SP_FONT_GROUP_NUMBERS, spGetRGB( 255, 128, 0 ) );
	}

	nameBkup[0] = 0;
	if ( level->run->playing )
	{
		state = 1;
		caret = false;
		strcpy( nameBkup, name );
		strcpy( name, level->run->info.name.c_str() );
		run = level->run;
		level->run = NULL;
	}
	else
	{
		caret = true;
		state = 0;
		spPollKeyboardInput( name, SCORE_MAX_NAME_LENGTH, NULL );
		run = level->run;
		level->run = NULL;
	}

	caretTimer.start( SCORE_CARET_BLINK_TIME );
	timers.push_back( &caretTimer );

	type = stScore;
}
コード例 #2
0
ファイル: account.c プロジェクト: theZiz/Sparrow-C4A-Manager
void start_account()
{
	spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK);
	mode = 0;
	line = 0;
	profile = spNetC4AGetProfile();
	if (profile)
	{
		memcpy(longName,profile->longname,256);
		memcpy(shortName,profile->shortname,4);
		memcpy(password,profile->password,256);
		memcpy(mail,profile->email,256);
		mode = 1;
	}	
}
コード例 #3
0
ファイル: account.c プロジェクト: theZiz/Sparrow-C4A-Manager
int calc_account(Uint32 steps)
{
	blink+=steps;
	if (spNetC4AGetStatus() > 0)
	{
		right_after_status = 1;
		return 0;
	}
	if (right_after_status)
	{
		if (spNetC4AGetTaskResult() == 0)
		{
			mode = nextMode;
			askMode = last_task+7;
		}
		else
		{
			askMode = 6;
			spStopKeyboardInput();
		}
			
	}
	right_after_status = 0;
	if (askMode)
	{
		switch ( askMode )
		{
			case 1:
				if ( spGetInput()->button[SP_BUTTON_START_NOWASD] )
				{
					spGetInput()->button[SP_BUTTON_START_NOWASD] = 0;
					if (spNetC4ADeleteAccount(&profile,1,TIME_OUT) == 0)
					{
						right_after_status = 1;
						last_task = 2;
					}
					nextMode = 0;
					sprintf(longName,"");
					sprintf(shortName,"");
					sprintf(password,"");
					sprintf(mail,"");
					askMode = 0;
					switch (line)
					{
						case 0: spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK); break;
						case 1: spPollKeyboardInput(longName,256,SP_PRACTICE_OK_NOWASD_MASK); break;
						case 2: spPollKeyboardInput(password,256,SP_PRACTICE_OK_NOWASD_MASK); break;
						case 3: spPollKeyboardInput(mail,256,SP_PRACTICE_OK_NOWASD_MASK); break;
					}
				}
				if ( spGetInput()->button[SP_PRACTICE_CANCEL_NOWASD] )
				{
					spGetInput()->button[SP_PRACTICE_CANCEL_NOWASD] = 0;
					askMode = 0;
					switch (line)
					{
						case 0: spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK); break;
						case 1: spPollKeyboardInput(longName,256,SP_PRACTICE_OK_NOWASD_MASK); break;
						case 2: spPollKeyboardInput(password,256,SP_PRACTICE_OK_NOWASD_MASK); break;
						case 3: spPollKeyboardInput(mail,256,SP_PRACTICE_OK_NOWASD_MASK); break;
					}
				}
				break;
			default:
				if ( spGetInput()->button[SP_PRACTICE_OK_NOWASD] )
				{
					spGetInput()->button[SP_PRACTICE_OK_NOWASD] = 0;
					askMode = 0;
					switch (line)
					{
						case 0: spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK); break;
						case 1: spPollKeyboardInput(longName,256,SP_PRACTICE_OK_NOWASD_MASK); break;
						case 2: spPollKeyboardInput(password,256,SP_PRACTICE_OK_NOWASD_MASK); break;
						case 3: spPollKeyboardInput(mail,256,SP_PRACTICE_OK_NOWASD_MASK); break;
					}
				}
		}
		return 0;
	}
	if ( spGetInput()->button[SP_PRACTICE_CANCEL_NOWASD] )
	{
		spGetInput()->button[SP_PRACTICE_CANCEL_NOWASD] = 0;
		spStopKeyboardInput();
		return 1;
	}
	
	int i;
	for (i = 0; shortName[i] != 0; i++)
	{
		if ('a' <= shortName[i] && shortName[i] <= 'z')
			shortName[i] += 'A'-'a';
	}
		
	if ((spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS && spGetInput()->button[SP_BUTTON_R_NOWASD]) ||
	    (spGetVirtualKeyboardState() != SP_VIRTUAL_KEYBOARD_ALWAYS && spGetInput()->axis[1] > 0))
	{
		line = (line + 1) % 4;
		spGetInput()->button[SP_BUTTON_R_NOWASD] = 0;
		if (spGetVirtualKeyboardState() != SP_VIRTUAL_KEYBOARD_ALWAYS)
			spGetInput()->axis[1] = 0;
		blink = 0;
		switch (line)
		{
			case 0: spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK); break;
			case 1: spPollKeyboardInput(longName,256,SP_PRACTICE_OK_NOWASD_MASK); break;
			case 2: spPollKeyboardInput(password,256,SP_PRACTICE_OK_NOWASD_MASK); break;
			case 3: spPollKeyboardInput(mail,256,SP_PRACTICE_OK_NOWASD_MASK); break;
		}
	}
	if ((spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS && spGetInput()->button[SP_BUTTON_L_NOWASD]) ||
	    (spGetVirtualKeyboardState() != SP_VIRTUAL_KEYBOARD_ALWAYS && spGetInput()->axis[1] < 0))
	{
		line = (line + 3) % 4;
		spGetInput()->button[SP_BUTTON_L_NOWASD] = 0;
		if (spGetVirtualKeyboardState() != SP_VIRTUAL_KEYBOARD_ALWAYS)
			spGetInput()->axis[1] = 0;
		blink = 0;
		switch (line)
		{
			case 0: spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK); break;
			case 1: spPollKeyboardInput(longName,256,SP_PRACTICE_OK_NOWASD_MASK); break;
			case 2: spPollKeyboardInput(password,256,SP_PRACTICE_OK_NOWASD_MASK); break;
			case 3: spPollKeyboardInput(mail,256,SP_PRACTICE_OK_NOWASD_MASK); break;
		}
	}
	if ( spGetInput()->button[SP_BUTTON_START_NOWASD] )
	{
		spGetInput()->button[SP_BUTTON_START_NOWASD] = 0;
		if (check_shortname())
		{
			askMode = 2;
			spStopKeyboardInput();
		}
		else
		if (check_longname())
		{
			askMode = 3;
			spStopKeyboardInput();
		}
		else
		if (check_password())
		{
			askMode = 4;
			spStopKeyboardInput();
		}
		else
		if (check_mail())
		{
			askMode = 5;
			spStopKeyboardInput();
		}
		else
		{
			if (mode == 0)
			{
				if (spNetC4ACreateProfile(&profile,longName,shortName,password,mail,TIME_OUT) == 0)
				{
					right_after_status = 1;
					last_task = 0;
				}
				nextMode = 1;
			}
			else
			{
				if (spNetC4AEditProfile(&profile,longName,shortName,password,mail,TIME_OUT) == 0)
				{
					right_after_status = 1;
					last_task = 1;
				}
				nextMode = 1;
			}
		}
	}
	if ( mode == 1 && spGetInput()->button[SP_BUTTON_SELECT_NOWASD] )
	{
		 spGetInput()->button[SP_BUTTON_SELECT_NOWASD] = 0;
		 askMode = 1;
		 spStopKeyboardInput();
	}
	return 0;
}