summaryrefslogtreecommitdiffstats
path: root/src/game/pause.c
blob: 6aae8dc7aed451e9d911b881799ae0868b9a86a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "game/gltron.h"

/* very brief - just the pause mode */

void idlePause(void) {
  Sound_idle();
  game2->time.dt = 0;
  doCameraMovement();
	
  scripting_RunGC();
  SystemPostRedisplay();
}

void displayPause(void) {
  drawGame();
  drawPause(gScreen);

  SystemSwapBuffers();
}

void keyboardPause(int state, int key, int x, int y) {
	if(state == SYSTEM_KEYSTATE_UP)
		return;

  switch(key) {
  case 27:
		SystemExitLoop(RETURN_PAUSE_ESCAPE);
    break;
  case SYSTEM_KEY_F1: changeDisplay(0); break;
  case SYSTEM_KEY_F2: changeDisplay(1); break;
  case SYSTEM_KEY_F3: changeDisplay(2); break;
  case SYSTEM_KEY_F4: changeDisplay(3); break;

  case SYSTEM_KEY_F5: saveSettings(); break;

  case SYSTEM_KEY_F10: nextCameraType(); break;

  case SYSTEM_KEY_F11: doBmpScreenShot(gScreen); break;
  case SYSTEM_KEY_F12: doPngScreenShot(gScreen); break;
    
  case SYSTEM_KEY_UP: consoleScrollBackward(1); break;
  case SYSTEM_KEY_DOWN: consoleScrollForward(1); break;

  case SYSTEM_KEY_TAB: 
	// SystemExitLoop(RETURN_MENU_PROMPT);
		break;

	default:
    if(game->pauseflag == PAUSE_GAME_FINISHED)
      initData();
    /* lasttime = SystemGetElapsedTime(); */
    SystemExitLoop(RETURN_GAME_UNPAUSE);
    break;
  }
}

void initPause(void) {
  SystemHidePointer();
  SystemWarpPointer(MOUSE_ORIG_X, MOUSE_ORIG_Y);

  /* disable game sound effects */
  Audio_DisableEngine();

  /* 
   * TODO: Provide an option to disable game music here. 
   * Game should be totally silent in pause mode. (Nice when 
   * the boss is walking by, phone call, etc...)
   */

  /* set pause flag to suspended */
  if (game->pauseflag != PAUSE_GAME_FINISHED) {
    game->pauseflag = PAUSE_GAME_SUSPENDED;
  }
  
  updateSettingsCache();
}

void exitPause(void) {
/* sound effects are re-enabled in enterGame() */
// Audio_EnableEngine(); 
}

void initPauseGL(void) {
  initGLGame();
}

Callbacks pauseCallbacks = {
  displayPause, idlePause, keyboardPause,
  initPause, exitPause, initPauseGL, gameMouse, gameMouseMotion, "pause"
};

void keyboardPrompt(int state, int key, int x, int y) {
	if(state == SYSTEM_KEYSTATE_UP)
		return;

  switch(key) {
  case 27:
  case SYSTEM_KEY_TAB:
		SystemExitLoop(RETURN_PAUSE_ESCAPE);
    break;
  case SYSTEM_KEY_RETURN:
    /* promptEvaluate(); */
    break;
  }
}

void initPrompt(void) { }
void exitPrompt(void) { }

Callbacks promptCallbacks = {
  displayPause, idlePause, keyboardPrompt,
  initPrompt, exitPrompt, NULL, NULL, NULL, "prompt"
};