graph_gui.c
branch0.5
changeset 5431 bad513e2c7d8
parent 5291 5e4d9ab3cc0f
child 5541 08e4afe5e927
equal deleted inserted replaced
5430:526e40487347 5431:bad513e2c7d8
   904 /* PERFORMANCE RATING DETAIL */
   904 /* PERFORMANCE RATING DETAIL */
   905 /*****************************/
   905 /*****************************/
   906 
   906 
   907 static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
   907 static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
   908 {
   908 {
   909 	static PlayerID _performance_rating_detail_player = 0;
   909 	static PlayerID _performance_rating_detail_player = INVALID_PLAYER;
   910 
   910 
   911 	switch (e->event) {
   911 	switch (e->event) {
   912 		case WE_PAINT: {
   912 		case WE_PAINT: {
   913 			int i;
   913 			int i;
   914 			byte x;
   914 			byte x;
   917 			int color_done, color_notdone;
   917 			int color_done, color_notdone;
   918 
   918 
   919 			// Draw standard stuff
   919 			// Draw standard stuff
   920 			DrawWindowWidgets(w);
   920 			DrawWindowWidgets(w);
   921 
   921 
       
   922 			/* Check if the currently selected player is still active. */
       
   923 			if (_performance_rating_detail_player == INVALID_PLAYER || !GetPlayer(_performance_rating_detail_player)->is_active) {
       
   924 				if (_performance_rating_detail_player != INVALID_PLAYER) {
       
   925 					/* Raise and disable the widget for the previous selection. */
       
   926 					RaiseWindowWidget(w, _performance_rating_detail_player + 13);
       
   927 					DisableWindowWidget(w, _performance_rating_detail_player + 13);
       
   928 					SetWindowDirty(w);
       
   929 
       
   930 					_performance_rating_detail_player = INVALID_PLAYER;
       
   931 				}
       
   932 
       
   933 				for (i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
       
   934 					if (GetPlayer(i)->is_active) {
       
   935 						/* Lower the widget corresponding to this player. */
       
   936 						LowerWindowWidget(w, i + 13);
       
   937 						SetWindowDirty(w);
       
   938 
       
   939 						_performance_rating_detail_player = i;
       
   940 						break;
       
   941 					}
       
   942 				}
       
   943 			}
       
   944 
       
   945 			/* If there are no active players, don't display anything else. */
       
   946 			if (_performance_rating_detail_player == INVALID_PLAYER) break;
       
   947 
   922 			// Paint the player icons
   948 			// Paint the player icons
   923 			for (i = 0; i < MAX_PLAYERS; i++) {
   949 			for (i = 0; i < MAX_PLAYERS; i++) {
   924 				if (!GetPlayer(i)->is_active) {
   950 				if (!GetPlayer(i)->is_active) {
   925 					// Check if we have the player as an active player
   951 					// Check if we have the player as an active player
   926 					if (!IsWindowWidgetDisabled(w, i + 13)) {
   952 					if (!IsWindowWidgetDisabled(w, i + 13)) {
   927 						// Bah, player gone :(
   953 						// Bah, player gone :(
   928 						DisableWindowWidget(w, i + 13);
   954 						DisableWindowWidget(w, i + 13);
   929 						// Is this player selected? If so, select first player (always save? :s)
   955 
   930 						if (IsWindowWidgetLowered(w, i + 13)) {
       
   931 							RaiseWindowWidget(w, i + 13);
       
   932 							LowerWindowWidget(w, 13);
       
   933 							_performance_rating_detail_player = 0;
       
   934 						}
       
   935 						// We need a repaint
   956 						// We need a repaint
   936 						SetWindowDirty(w);
   957 						SetWindowDirty(w);
   937 					}
   958 					}
   938 				continue;
   959 					continue;
   939 				}
   960 				}
   940 
   961 
   941 				// Check if we have the player marked as inactive
   962 				// Check if we have the player marked as inactive
   942 				if (IsWindowWidgetDisabled(w, i + 13)) {
   963 				if (IsWindowWidgetDisabled(w, i + 13)) {
   943 					// New player! Yippie :p
   964 					// New player! Yippie :p
  1052 			}
  1073 			}
  1053 
  1074 
  1054 			w->custom[0] = DAY_TICKS;
  1075 			w->custom[0] = DAY_TICKS;
  1055 			w->custom[1] = 5;
  1076 			w->custom[1] = 5;
  1056 
  1077 
  1057 			_performance_rating_detail_player = 0;
  1078 			if (_performance_rating_detail_player != INVALID_PLAYER) LowerWindowWidget(w, _performance_rating_detail_player + 13);
  1058 			LowerWindowWidget(w, _performance_rating_detail_player + 13);
       
  1059 			SetWindowDirty(w);
  1079 			SetWindowDirty(w);
  1060 
  1080 
  1061 			break;
  1081 			break;
  1062 		}
  1082 		}
  1063 
  1083