13 #include "signs.h" |
13 #include "signs.h" |
14 #include "strings.h" |
14 #include "strings.h" |
15 #include "debug.h" |
15 #include "debug.h" |
16 #include "variables.h" |
16 #include "variables.h" |
17 #include "date.h" |
17 #include "date.h" |
|
18 #include "helpers.hpp" |
18 |
19 |
19 const byte _cargo_colours[NUM_CARGO] = {152, 32, 15, 174, 208, 194, 191, 84, 184, 10, 202, 48}; |
20 const byte _cargo_colours[NUM_CARGO] = {152, 32, 15, 174, 208, 194, 191, 84, 184, 10, 202, 48}; |
20 |
21 |
21 static uint _legend_excludebits; |
22 static uint _legend_excludebits; |
22 static uint _legend_cargobits; |
23 static uint _legend_cargobits; |
63 int64 cur_val; |
64 int64 cur_val; |
64 uint sel; |
65 uint sel; |
65 |
66 |
66 /* the colors and cost array of GraphDrawer must accomodate |
67 /* the colors and cost array of GraphDrawer must accomodate |
67 * both values for cargo and players. So if any are higher, quit */ |
68 * both values for cargo and players. So if any are higher, quit */ |
68 assert(GRAPH_NUM >= NUM_CARGO && GRAPH_NUM >= MAX_PLAYERS); |
69 assert(GRAPH_NUM >= (int)NUM_CARGO && GRAPH_NUM >= (int)MAX_PLAYERS); |
69 |
70 |
70 color = _colour_gradient[gw->bg_line_color][4]; |
71 color = _colour_gradient[gw->bg_line_color][4]; |
71 |
72 |
72 /* draw the vertical lines */ |
73 /* draw the vertical lines */ |
73 i = gw->num_vert_lines; assert(i > 0); |
74 i = gw->num_vert_lines; assert(i > 0); |
116 num_x = gw->num_on_x_axis; |
117 num_x = gw->num_on_x_axis; |
117 assert(num_x > 0); |
118 assert(num_x > 0); |
118 col_ptr = row_ptr; |
119 col_ptr = row_ptr; |
119 do { |
120 do { |
120 if (*col_ptr != INVALID_VALUE) { |
121 if (*col_ptr != INVALID_VALUE) { |
121 mx = max64(mx, myabs64(*col_ptr)); |
122 mx = max64(mx, *col_ptr); |
122 } |
123 } |
123 } while (col_ptr++, --num_x); |
124 } while (col_ptr++, --num_x); |
124 } |
125 } |
125 } while (sel>>=1, row_ptr+=24, --num_dataset); |
126 } while (sel>>=1, row_ptr+=24, --num_dataset); |
126 |
127 |
904 /* PERFORMANCE RATING DETAIL */ |
905 /* PERFORMANCE RATING DETAIL */ |
905 /*****************************/ |
906 /*****************************/ |
906 |
907 |
907 static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e) |
908 static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e) |
908 { |
909 { |
909 static PlayerID _performance_rating_detail_player = 0; |
910 static PlayerID _performance_rating_detail_player = PLAYER_FIRST; |
910 |
911 |
911 switch (e->event) { |
912 switch (e->event) { |
912 case WE_PAINT: { |
913 case WE_PAINT: { |
913 int i; |
|
914 byte x; |
914 byte x; |
915 uint16 y = 14; |
915 uint16 y = 14; |
916 int total_score = 0; |
916 int total_score = 0; |
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 // Paint the player icons |
922 // Paint the player icons |
923 for (i = 0; i < MAX_PLAYERS; i++) { |
923 for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
924 if (!GetPlayer(i)->is_active) { |
924 if (!GetPlayer(i)->is_active) { |
925 // Check if we have the player as an active player |
925 // Check if we have the player as an active player |
926 if (!IsWindowWidgetDisabled(w, i + 13)) { |
926 if (!IsWindowWidgetDisabled(w, i + 13)) { |
927 // Bah, player gone :( |
927 // Bah, player gone :( |
928 DisableWindowWidget(w, i + 13); |
928 DisableWindowWidget(w, i + 13); |
929 // Is this player selected? If so, select first player (always save? :s) |
929 // Is this player selected? If so, select first player (always save? :s) |
930 if (IsWindowWidgetLowered(w, i + 13)) { |
930 if (IsWindowWidgetLowered(w, i + 13)) { |
931 RaiseWindowWidget(w, i + 13); |
931 RaiseWindowWidget(w, i + 13); |
932 LowerWindowWidget(w, 13); |
932 LowerWindowWidget(w, 13); |
933 _performance_rating_detail_player = 0; |
933 _performance_rating_detail_player = PLAYER_FIRST; |
934 } |
934 } |
935 // We need a repaint |
935 // We need a repaint |
936 SetWindowDirty(w); |
936 SetWindowDirty(w); |
937 } |
937 } |
938 continue; |
938 continue; |
953 // The colors used to show how the progress is going |
953 // The colors used to show how the progress is going |
954 color_done = _colour_gradient[COLOUR_GREEN][4]; |
954 color_done = _colour_gradient[COLOUR_GREEN][4]; |
955 color_notdone = _colour_gradient[COLOUR_RED][4]; |
955 color_notdone = _colour_gradient[COLOUR_RED][4]; |
956 |
956 |
957 // Draw all the score parts |
957 // Draw all the score parts |
958 for (i = 0; i < NUM_SCORE; i++) { |
958 for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) { |
959 int val = _score_part[_performance_rating_detail_player][i]; |
959 int val = _score_part[_performance_rating_detail_player][i]; |
960 int needed = _score_info[i].needed; |
960 int needed = _score_info[i].needed; |
961 int score = _score_info[i].score; |
961 int score = _score_info[i].score; |
962 |
962 |
963 y += 20; |
963 y += 20; |
1028 // Check which button is clicked |
1028 // Check which button is clicked |
1029 if (IS_INT_INSIDE(e->we.click.widget, 13, 21)) { |
1029 if (IS_INT_INSIDE(e->we.click.widget, 13, 21)) { |
1030 // Is it no on disable? |
1030 // Is it no on disable? |
1031 if (!IsWindowWidgetDisabled(w, e->we.click.widget)) { |
1031 if (!IsWindowWidgetDisabled(w, e->we.click.widget)) { |
1032 RaiseWindowWidget(w, _performance_rating_detail_player + 13); |
1032 RaiseWindowWidget(w, _performance_rating_detail_player + 13); |
1033 _performance_rating_detail_player = e->we.click.widget - 13; |
1033 _performance_rating_detail_player = (PlayerID)(e->we.click.widget - 13); |
1034 LowerWindowWidget(w, _performance_rating_detail_player + 13); |
1034 LowerWindowWidget(w, _performance_rating_detail_player + 13); |
1035 SetWindowDirty(w); |
1035 SetWindowDirty(w); |
1036 } |
1036 } |
1037 } |
1037 } |
1038 break; |
1038 break; |
1039 |
1039 |
1040 case WE_CREATE: { |
1040 case WE_CREATE: { |
1041 int i; |
1041 PlayerID i; |
1042 Player *p2; |
1042 Player *p2; |
1043 |
1043 |
1044 /* Disable the players who are not active */ |
1044 /* Disable the players who are not active */ |
1045 for (i = 0; i < MAX_PLAYERS; i++) { |
1045 for (i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
1046 SetWindowWidgetDisabledState(w, i + 13, !GetPlayer(i)->is_active); |
1046 SetWindowWidgetDisabledState(w, i + 13, !GetPlayer(i)->is_active); |
1047 } |
1047 } |
1048 /* Update all player stats with the current data |
1048 /* Update all player stats with the current data |
1049 * (this is because _score_info is not saved to a savegame) */ |
1049 * (this is because _score_info is not saved to a savegame) */ |
1050 FOR_ALL_PLAYERS(p2) { |
1050 FOR_ALL_PLAYERS(p2) { |