Exemple #1
0
void RacingKeys (unsigned int key, bool special, bool release, int x, int y) {
	switch (key) {
		// steering flipflops
		case 273: key_paddling = !release; break;	
		case 274: key_braking = !release; break;	
		case 276: left_turn = !release; break;	
		case 275: right_turn = !release; break;	
		case 32:  key_charging = !release; break;
		case SDLK_t: trick_modifier = !release; break;		

		// mode changing and other actions
		case 27:  if (!release) { 
			g_game.raceaborted = true;
			g_game.race_result = -1;
			Winsys.SetMode (GAME_OVER);
		} break;	
		case SDLK_p: if (!release) Winsys.SetMode (PAUSED); break;			
		case SDLK_r: if (!release) Winsys.SetMode (RESET); break;				
		case SDLK_s: if (!release) ScreenshotN (); break;

		// view changing
		case SDLK_1: if (!release) {
			set_view_mode (Players.GetCtrl (g_game.player_id), ABOVE);
			param.view_mode = ABOVE;
		} break;	
		case SDLK_2: if (!release) {
			set_view_mode (Players.GetCtrl (g_game.player_id), FOLLOW);
			param.view_mode = FOLLOW;
		} break;	
		case SDLK_3: if (!release) {
			set_view_mode (Players.GetCtrl (g_game.player_id), BEHIND);
			param.view_mode = BEHIND;
		} break;	
		
		// toggle
		case SDLK_h:  if (!release) param.show_hud = !param.show_hud; break;
		case SDLK_f:  if (!release) param.display_fps = !param.display_fps; break;
		case SDLK_F5: if (!release) sky = !sky; break;
		case SDLK_F6: if (!release) fog = !fog; break;
		case SDLK_F7: if (!release) terr = !terr; break;
		case SDLK_F8: if (!release) trees = !trees; break;
	}
}
void CRacing::Keyb (unsigned int key, bool special, bool release, int x, int y) {
	switch (key) {
		// steering flipflops
		case SDLK_UP: key_paddling = !release; break;
		case SDLK_DOWN: key_braking = !release; break;
		case SDLK_LEFT: left_turn = !release; break;
		case SDLK_RIGHT: right_turn = !release; break;
		case SDLK_SPACE: key_charging = !release; break;
		case SDLK_t: trick_modifier = !release; break;
		// mode changing and other actions
		case SDLK_ESCAPE: if (!release) {
			g_game.raceaborted = true;
			g_game.race_result = -1;
			State::manager.RequestEnterState (GameOver);
		} break;
		case SDLK_p: if (!release) State::manager.RequestEnterState (Paused); break;
		case SDLK_r: if (!release) State::manager.RequestEnterState (Reset); break;
		case SDLK_s: if (!release) ScreenshotN (); break;

		// view changing
		case SDLK_1: if (!release) {
			set_view_mode (Players.GetCtrl (g_game.player_id), ABOVE);
			param.view_mode = ABOVE;
		} break;
		case SDLK_2: if (!release) {
			set_view_mode (Players.GetCtrl (g_game.player_id), FOLLOW);
			param.view_mode = FOLLOW;
		} break;
		case SDLK_3: if (!release) {
			set_view_mode (Players.GetCtrl (g_game.player_id), BEHIND);
			param.view_mode = BEHIND;
		} break;

		// toggle
		case SDLK_h:  if (!release) param.show_hud = !param.show_hud; break;
		case SDLK_f:  if (!release) param.display_fps = !param.display_fps; break;
		case SDLK_F5: if (!release) sky = !sky; break;
		case SDLK_F6: if (!release) fog = !fog; break;
		case SDLK_F7: if (!release) terr = !terr; break;
		case SDLK_F8: if (!release) trees = !trees; break;
	}
}
void CharKeys (unsigned int key, bool special, bool release, int x, int y) {
	int keyfact;
	must_render = true;

	if (ToolsFinalStage ()) {
		if (key == SDLK_y || key == SDLK_j) {
			SaveToolCharacter ();
			SaveToolFrame ();
			Winsys.Quit();
		} else if (key == SDLK_n) Winsys.Quit ();
		return;
	}

	if (key == 304) shift = !release;
	if (key == 306) control = !release;
	if (key == 308) alt = !release;
	if (shift) keyfact = -1; else keyfact = 1;

	if (release) return;

	int type = action->type[curr_act];	
	switch (key) {
		case SDLK_TAB: SetToolMode (1); break;
		case SDLK_ESCAPE: case SDLK_q: QuitTool (); break;
		case SDLK_F10: ScreenshotN (); break;
		case SDLK_s: SaveToolCharacter ();  break;
		case SDLK_c: ScreenshotN (); break;
		case SDLK_m: TestChar.useMaterials = !TestChar.useMaterials; break;
		case SDLK_h: TestChar.useHighlighting = !TestChar.useHighlighting; break;
		case SDLK_r: 
			TestChar.Reset (); 
			ReloadToolCharacter ();
			ToolsInit ();
			break;
		case SDLK_u: if (action != NULL) {
				RecallAction (action);
				TestChar.RefreshNode (curr_node);
			} break;
		case SDLK_PLUS: case SDLK_EQUALS: // zoom in
			zposition += 0.1;
			xposition -= 0.03;
			break;
		case SDLK_MINUS: // zoom out
			zposition -= 0.1;
			xposition += 0.03;
			break;

		// set rotations for view
		case SDLK_1: SetRotation (0, 0, 0); break;
		case SDLK_2: SetRotation (-50, 180, 15); break;
		case SDLK_3: SetRotation (0, 180, 0); break;
		case SDLK_4: SetRotation (0, -80, 0); break;

		// select node
		case SDLK_PAGEUP: ChangeNode (-1); break;
		case SDLK_PAGEDOWN: ChangeNode (1); break;
		case SDLK_END: ChangeNode (charbase); break;
		case SDLK_HOME: ChangeNode (-charbase); break;

		// select action
		case SDLK_DOWN: 
			if (curr_act < lastact) curr_act++; 
			if (action->type[curr_act] == 4) comp = 0; else comp = 1;
			break; 
		case SDLK_UP: 
			if (curr_act > 0) curr_act--; 
			if (action->type[curr_act] == 4) comp = 0; else comp = 1;
			break; 
		case SDLK_LEFT: ChangeValue (type, -1); break;
		case SDLK_RIGHT: ChangeValue (type, 1); break;

		// select value
		case SDLK_SPACE: 
			if (type == 0 || type == 4) {
				comp++;
				if (comp > 3) comp = 0;
				if (type == 0 && comp == 0) comp = 1;
			} break;
		default: break;
	}
}
void SingleFrameKeys (unsigned int key, bool special, bool release, int x, int y) {
//PrintInt (key);
	must_render = true;
	int keyfact;
	TKeyframe2 *frame = TestFrame.GetFrame (curr_frame);

	// setting the camera change state
	if (key == SDLK_F1) {GluCamera.turnright = !release; return;}
	else if (key == SDLK_F2) {GluCamera.turnleft = !release; return;}
	else if (key == SDLK_F3) {GluCamera.nearer = !release; return;}
	else if (key == SDLK_F4) {GluCamera.farther = !release; return;}

	// additional keys if needed
	switch (key)
	{
	case SDLK_LSHIFT:
	case SDLK_RSHIFT:
		shift = !release; break;
	case SDLK_LCTRL:
	case SDLK_RCTRL:
		control = !release; break;
	case SDLK_LALT:
	case SDLK_RALT:
		alt = !release; break;
	}

	if (shift) keyfact = -1; else keyfact = 1;

	if (release) return;

	switch (key) {
		case SDLK_y: case SDLK_j:
			if (ToolsFinalStage ()) {
				SaveToolCharacter ();
				SaveToolFrame ();
				Winsys.Quit();
			} break;
		case SDLK_n: if (ToolsFinalStage ()) Winsys.Quit (); break;

		case SDLK_ESCAPE: case SDLK_q: QuitTool (); break;
		case SDLK_s: SaveToolFrame (); break;
		case SDLK_TAB: SetToolMode (0); break;

		case SDLK_a:
			TestFrame.AddFrame (); 
			SetFrameChanged (true);
			break;
		case SDLK_INSERT:
			TestFrame.InsertFrame (curr_frame); 
			SetFrameChanged (true);
			break;
		case SDLK_DELETE:
			curr_frame = TestFrame.DeleteFrame (curr_frame); 
			SetFrameChanged (true);
			break;
		case SDLK_PAGEDOWN: if (curr_frame < TestFrame.numFrames-1) curr_frame++; break;
		case SDLK_PAGEUP: if (curr_frame > 0) curr_frame--; break;
		case SDLK_UP: if (curr_joint > 0) curr_joint--; break;
		case SDLK_DOWN: if (curr_joint < last_joint) curr_joint++; break;
		case SDLK_RIGHT:
				if (curr_joint < 4) frame->val[curr_joint] += 0.05;
				else frame->val[curr_joint] += 1;
				SetFrameChanged (true);
				break;
		case SDLK_LEFT: 
				if (curr_joint < 4) frame->val[curr_joint] -= 0.05;
				else frame->val[curr_joint] -= 1;
				SetFrameChanged (true);
				break;
		case SDLK_0: 
			frame->val[curr_joint] = 0.0;
			SetFrameChanged (true);
			break;
		case SDLK_SPACE:
			if (curr_joint < 4) frame->val[curr_joint] += 0.05 * keyfact;
			else frame->val[curr_joint] += 1 * keyfact;
			SetFrameChanged (true);
			break;

		case SDLK_RETURN:
			TestFrame.InitTest (ref_position, &TestChar); 
			SetToolMode (2);
			must_render = true;
			break;

		case SDLK_m: TestChar.useMaterials = !TestChar.useMaterials; break;
		case SDLK_h: TestChar.useHighlighting = !TestChar.useHighlighting; break;
		case SDLK_c: 
			if (control) TestFrame.CopyToClipboard (curr_frame); 
			else TestFrame.ClearFrame (curr_frame);
			SetFrameChanged (true);
			break;
		case SDLK_v: 
			if (control) TestFrame.PasteFromClipboard (curr_frame); 
			SetFrameChanged (true);
			break;
		case SDLK_p: if (curr_frame>0) 
			TestFrame.CopyFrame (curr_frame-1, curr_frame); break;
		case SDLK_F10: ScreenshotN (); break;

		case SDLK_1: GluCamera.angle = 0; break;
		case SDLK_2: GluCamera.angle = 45; break;
		case SDLK_3: GluCamera.angle = 90; break;
		case SDLK_4: GluCamera.angle = 135; break;
		case SDLK_5: GluCamera.angle = 180; break;
		case SDLK_6: GluCamera.angle = 225; break;
		case SDLK_7: GluCamera.angle = 270; break;
		case SDLK_8: GluCamera.angle = 315; break;
	}
}