909 /* PERFORMANCE RATING DETAIL */ |
909 /* PERFORMANCE RATING DETAIL */ |
910 /*****************************/ |
910 /*****************************/ |
911 |
911 |
912 static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e) |
912 static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e) |
913 { |
913 { |
914 static PlayerID _performance_rating_detail_player = PLAYER_FIRST; |
914 static PlayerID _performance_rating_detail_player = INVALID_PLAYER; |
915 |
915 |
916 switch (e->event) { |
916 switch (e->event) { |
917 case WE_PAINT: { |
917 case WE_PAINT: { |
918 byte x; |
918 byte x; |
919 uint16 y = 14; |
919 uint16 y = 14; |
920 int total_score = 0; |
920 int total_score = 0; |
921 int color_done, color_notdone; |
921 int color_done, color_notdone; |
922 |
922 |
923 // Draw standard stuff |
923 // Draw standard stuff |
924 DrawWindowWidgets(w); |
924 DrawWindowWidgets(w); |
|
925 |
|
926 /* Check if the currently selected player is still active. */ |
|
927 if (_performance_rating_detail_player == INVALID_PLAYER || !GetPlayer(_performance_rating_detail_player)->is_active) { |
|
928 if (_performance_rating_detail_player != INVALID_PLAYER) { |
|
929 /* Raise and disable the widget for the previous selection. */ |
|
930 RaiseWindowWidget(w, _performance_rating_detail_player + 13); |
|
931 DisableWindowWidget(w, _performance_rating_detail_player + 13); |
|
932 SetWindowDirty(w); |
|
933 |
|
934 _performance_rating_detail_player = INVALID_PLAYER; |
|
935 } |
|
936 |
|
937 for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
|
938 if (GetPlayer(i)->is_active) { |
|
939 /* Lower the widget corresponding to this player. */ |
|
940 LowerWindowWidget(w, i + 13); |
|
941 SetWindowDirty(w); |
|
942 |
|
943 _performance_rating_detail_player = i; |
|
944 break; |
|
945 } |
|
946 } |
|
947 } |
|
948 |
|
949 /* If there are no active players, don't display anything else. */ |
|
950 if (_performance_rating_detail_player == INVALID_PLAYER) break; |
925 |
951 |
926 // Paint the player icons |
952 // Paint the player icons |
927 for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
953 for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
928 if (!GetPlayer(i)->is_active) { |
954 if (!GetPlayer(i)->is_active) { |
929 // Check if we have the player as an active player |
955 // Check if we have the player as an active player |
930 if (!IsWindowWidgetDisabled(w, i + 13)) { |
956 if (!IsWindowWidgetDisabled(w, i + 13)) { |
931 // Bah, player gone :( |
957 // Bah, player gone :( |
932 DisableWindowWidget(w, i + 13); |
958 DisableWindowWidget(w, i + 13); |
933 // Is this player selected? If so, select first player (always save? :s) |
959 |
934 if (IsWindowWidgetLowered(w, i + 13)) { |
|
935 RaiseWindowWidget(w, i + 13); |
|
936 LowerWindowWidget(w, 13); |
|
937 _performance_rating_detail_player = PLAYER_FIRST; |
|
938 } |
|
939 // We need a repaint |
960 // We need a repaint |
940 SetWindowDirty(w); |
961 SetWindowDirty(w); |
941 } |
962 } |
942 continue; |
963 continue; |
943 } |
964 } |
944 |
965 |
945 // Check if we have the player marked as inactive |
966 // Check if we have the player marked as inactive |
946 if (IsWindowWidgetDisabled(w, i + 13)) { |
967 if (IsWindowWidgetDisabled(w, i + 13)) { |
947 // New player! Yippie :p |
968 // New player! Yippie :p |