예제 #1
0
void ScenePatch(){
	bool quit = false;
	SDL_Event event;

	Sprite *bgi = new Sprite("resource\\bgi_patcher.jpg",1,1);
	Sprite *title = new Sprite("resource\\title.png",1,1);

	FONT gulim;

	float progress_total = 50;
	float progress_current = 30;

	gulim.InitFont("c:\\windows\\fonts\\gulim.ttc",12);
	gulim.SetColor(255,255,255);
	gulim.SetStyle(TTF_STYLE_BOLD);

	while(!quit){
		while(SDL_PollEvent(&event)){
			switch(event.type){
			case SDL_QUIT:
				break;
			}
		}
		{
			SDL_RenderClear(renderer);

			bgi->Draw(0,0,480,272);
			title->Draw(20,20,440,170);


			SDL_Rect rtProgressTotalFrame = {20,200,440,25};
			SDL_Rect rtProgressCurrentFrame = {20,235,440,25};
			SDL_Rect rtProgressTotal = {25,205,progress_total * 4.4,15};
			SDL_Rect rtProgressCurrent = {25,240,progress_current * 4.4,15};

			SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_NONE);
			SDL_SetRenderDrawColor(renderer,64,64,64,255);
			SDL_RenderFillRect(renderer,&rtProgressTotalFrame);
			SDL_RenderFillRect(renderer,&rtProgressCurrentFrame);

			SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_BLEND);
			SDL_SetRenderDrawColor(renderer,64,255,64,196);
			SDL_RenderFillRect(renderer,&rtProgressTotal);
			SDL_RenderFillRect(renderer,&rtProgressCurrent);

			gulim.Draw(renderer,"전체 진행률",25,190);
			gulim.Draw(renderer,"현재 진행률",25,225);

			gulim.Draw(renderer,"Tank Online Patcher",343,258);

			SDL_RenderPresent(renderer);
		}

		SDL_Delay(1);
	}

	delete bgi;
}
예제 #2
0
void SceneLogin(){
	SDL_Event event;
		
	Sprite *bgi = new Sprite("resource\\bgi_login.jpg",1,1);
	Sprite *profile = NULL;

	FONT gulim;
	
	Timer t_login;
	Timer t_result;
	Timer t_cursor;

	int login_animation = 0;
	int result_animation = 0;

	char id[32] = "\0";
	char pw[32] = "\0";
	char *input;
	int id_cur = 0,pw_cur = 0;
	int cursor = 0;
	int cursor_animation = 0;

	int logined = 0;

	int nextScene = 0;

	gulim.InitFont("c:\\windows\\fonts\\gulim.ttc",20);
	gulim.SetColor(0,0,0);
	
	t_login.SetInterval(30);
	t_login.start();
	t_cursor.SetInterval(30);
	t_result.SetInterval(30);

	input = id;

	quit = false;
	while(!quit){
		while(SDL_PollEvent(&event)){
			switch(event.type){
			case SDL_QUIT:
				quit = true;
				break;
	
			case SDL_MOUSEBUTTONDOWN:
				{
					SceneLogin_Signup();
				}
				break;
			// 입력 처리
			case SDL_KEYDOWN:
				if(cursor < 2){
					if(event.key.keysym.sym == SDLK_RETURN){
						cursor ++;
						input = pw;
					}
					else if(event.key.keysym.sym == SDLK_BACKSPACE
							&&
							strlen(input) > 0){
						int len = strlen(input);
						input[len-1] = '\0';
					}
					else{
						if((event.key.keysym.sym >= 'a' && event.key.keysym.sym <= 'z')
							||
							(event.key.keysym.sym >= 'A' && event.key.keysym.sym <= 'Z')
							||
							(event.key.keysym.sym >= '0' && event.key.keysym.sym <= '9')){
							int len = strlen(input);
							input[len] = event.key.keysym.sym;
							input[len+1] = '\0';
						}
					}
				}
				else{
					if(event.key.keysym.sym == SDLK_SPACE){
						quit = true;
						nextScene = 1;
					}
				}
				break;

			case EVENT_LOGIN_OK:
				{
					printf("login ok\n");

					t_result.start();

					// 프로필 이미지 수신이 완료될때까지 대기
					printf("1fileRecv %d\n", fileReceived);
					while(fileReceived == false);
					printf("2fileRecv %d\n", fileReceived);
					fileReceived = false;
					// 로그인 상태를 변경 -> 성공
					logined = 1;

					// 프로필 이미지를 로드
					char path[256];
					sprintf(path,fileName);
					profile = new Sprite(path,1,1,1,1,1);

					sprintf(player.id,id);
					sprintf(player.nick,(char*)event.user.data1);

					printf("%s\n", event.user.data1);

					break;
				}
			case EVENT_LOGIN_DENY:
				printf("login denied\n");
				t_result.start();
				logined = -1;
				break;
			case EVENT_LOGIN_SESSION_EXIST:
				printf("already logged in\n");
				t_result.start();
				logined = -2;
				break;
			case EVENT_LOGOUT_OK:
				printf("logout ok\n");
				break;
			case EVENT_LOGOUT_ERR:
				printf("logout err\n");
				break;
			case EVENT_SIGNUP_OK:
				printf("signup ok\n");
				break;
			case EVENT_SIGNUP_ERR_ID:
				printf("signup err\n");
				break;
			case EVENT_SIGNUP_ERR_UNKNOWN:
				printf("signup err\n");
				break;
			}
		}
		if(t_login.done()){
			if(cursor < 2){
				if(login_animation <= 70)
					login_animation += 2;
			}
			else{
				if(login_animation != 0)
					login_animation -= 2;
				else{
					SceneLogin_DoLogin(id,pw);
					t_login.stop();
				}
			}
			gulim.SetColor(
					255-login_animation*3 - 40,
					255-login_animation*3 - 40,
					255-login_animation*3 - 40);


		}
		if(t_result.done()){
			if(result_animation != 200)
				result_animation += 5;
		}
		if(t_cursor.done()){

		}
		{
			bgi->Draw(0,0,480,272);

			if(logined == 0){
				SDL_Rect rt = {250,170,200,login_animation};
				SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_BLEND);
				SDL_SetRenderDrawColor(renderer,32,64,255,128);
				SDL_RenderFillRect(renderer,&rt);

				SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_NONE);

				gulim.SetStyle(TTF_STYLE_BOLD);
				gulim.Draw(renderer,"ID : ",260,180);
				gulim.Draw(renderer,"PW: ",260,210);

				gulim.SetStyle(TTF_STYLE_NORMAL);
				gulim.Draw(renderer,id,310,180);
				for(int i=0;i<strlen(pw);i++){
					gulim.Draw(renderer,"*",310 + i*10,210);
				}
			}
			else{
				SDL_Rect rt = {150,30,200,result_animation};
				SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_BLEND);
				SDL_SetRenderDrawColor(renderer,32,64,255,128);
				SDL_RenderFillRect(renderer,&rt);

				SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_NONE);

				if(profile != NULL)
					profile->Draw(185,50,130,100);

				gulim.SetStyle(TTF_STYLE_BOLD);
				if(logined == 1){
					gulim.Draw(renderer,player.nick,235,150);
					gulim.Draw(renderer,"입장",230,200);
				}
				else if(logined == -1){
					gulim.Draw(renderer,"로그인실패",195,130);
					gulim.Draw(renderer,"확인",230,200);
				}
				else {
					gulim.Draw(renderer,"이미 접속중",195,130);
					gulim.Draw(renderer,"확인",230,200);
				}
				
			}

			SDL_RenderPresent(renderer);
		}
		

		SDL_Delay(1);
	}
	
	delete bgi;
	if(profile != NULL)
		delete profile;

	if(nextScene == 1)
		SceneGame();
}