249 |
249 |
250 switch (e->event) { |
250 switch (e->event) { |
251 case WE_CREATE: { |
251 case WE_CREATE: { |
252 uint i; |
252 uint i; |
253 for (i = 3; i < w->widget_count; i++) { |
253 for (i = 3; i < w->widget_count; i++) { |
254 if (!HASBIT(_legend_excluded_players, i - 3)) LowerWindowWidget(w, i); |
254 if (!HASBIT(_legend_excluded_players, i - 3)) w->LowerWidget(i); |
255 } |
255 } |
256 break; |
256 break; |
257 } |
257 } |
258 |
258 |
259 case WE_PAINT: |
259 case WE_PAINT: |
260 FOR_ALL_PLAYERS(p) { |
260 FOR_ALL_PLAYERS(p) { |
261 if (!p->is_active) { |
261 if (!p->is_active) { |
262 SETBIT(_legend_excluded_players, p->index); |
262 SETBIT(_legend_excluded_players, p->index); |
263 RaiseWindowWidget(w, p->index + 3); |
263 w->RaiseWidget(p->index + 3); |
264 } |
264 } |
265 } |
265 } |
266 w->DrawWidgets(); |
266 w->DrawWidgets(); |
267 |
267 |
268 FOR_ALL_PLAYERS(p) { |
268 FOR_ALL_PLAYERS(p) { |
278 break; |
278 break; |
279 |
279 |
280 case WE_CLICK: |
280 case WE_CLICK: |
281 if (IS_INT_INSIDE(e->we.click.widget, 3, 11)) { |
281 if (IS_INT_INSIDE(e->we.click.widget, 3, 11)) { |
282 TOGGLEBIT(_legend_excluded_players, e->we.click.widget - 3); |
282 TOGGLEBIT(_legend_excluded_players, e->we.click.widget - 3); |
283 ToggleWidgetLoweredState(w, e->we.click.widget); |
283 w->ToggleWidgetLoweredState(e->we.click.widget); |
284 w->SetDirty(); |
284 w->SetDirty(); |
285 InvalidateWindow(WC_INCOME_GRAPH, 0); |
285 InvalidateWindow(WC_INCOME_GRAPH, 0); |
286 InvalidateWindow(WC_OPERATING_PROFIT, 0); |
286 InvalidateWindow(WC_OPERATING_PROFIT, 0); |
287 InvalidateWindow(WC_DELIVERED_CARGO, 0); |
287 InvalidateWindow(WC_DELIVERED_CARGO, 0); |
288 InvalidateWindow(WC_PERFORMANCE_HISTORY, 0); |
288 InvalidateWindow(WC_PERFORMANCE_HISTORY, 0); |
746 for (i = 0; i != NUM_CARGO; i++) { |
746 for (i = 0; i != NUM_CARGO; i++) { |
747 /* Since the buttons have no text, no images, |
747 /* Since the buttons have no text, no images, |
748 * both the text and the colored box have to be manually painted. |
748 * both the text and the colored box have to be manually painted. |
749 * clk_dif will move one pixel down and one pixel to the right |
749 * clk_dif will move one pixel down and one pixel to the right |
750 * when the button is clicked */ |
750 * when the button is clicked */ |
751 byte clk_dif = IsWindowWidgetLowered(w, i + 3) ? 1 : 0; |
751 byte clk_dif = w->IsWidgetLowered(i + 3) ? 1 : 0; |
752 |
752 |
753 GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0); |
753 GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0); |
754 GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, _cargo_colours[i]); |
754 GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, _cargo_colours[i]); |
755 SetDParam(0, _cargoc.names_s[i]); |
755 SetDParam(0, _cargoc.names_s[i]); |
756 DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, 0); |
756 DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, 0); |
771 switch (e->we.click.widget) { |
771 switch (e->we.click.widget) { |
772 case 3: case 4: case 5: case 6: |
772 case 3: case 4: case 5: case 6: |
773 case 7: case 8: case 9: case 10: |
773 case 7: case 8: case 9: case 10: |
774 case 11: case 12: case 13: case 14: |
774 case 11: case 12: case 13: case 14: |
775 TOGGLEBIT(_legend_excluded_cargo, e->we.click.widget - 3); |
775 TOGGLEBIT(_legend_excluded_cargo, e->we.click.widget - 3); |
776 ToggleWidgetLoweredState(w, e->we.click.widget); |
776 w->ToggleWidgetLoweredState(e->we.click.widget); |
777 w->SetDirty(); |
777 w->SetDirty(); |
778 break; |
778 break; |
779 } |
779 } |
780 } break; |
780 } break; |
781 } |
781 } |
925 |
925 |
926 /* Check if the currently selected player is still active. */ |
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) { |
927 if (_performance_rating_detail_player == INVALID_PLAYER || !GetPlayer(_performance_rating_detail_player)->is_active) { |
928 if (_performance_rating_detail_player != INVALID_PLAYER) { |
928 if (_performance_rating_detail_player != INVALID_PLAYER) { |
929 /* Raise and disable the widget for the previous selection. */ |
929 /* Raise and disable the widget for the previous selection. */ |
930 RaiseWindowWidget(w, _performance_rating_detail_player + 13); |
930 w->RaiseWidget(_performance_rating_detail_player + 13); |
931 w->DisableWidget(_performance_rating_detail_player + 13); |
931 w->DisableWidget(_performance_rating_detail_player + 13); |
932 w->SetDirty(); |
932 w->SetDirty(); |
933 |
933 |
934 _performance_rating_detail_player = INVALID_PLAYER; |
934 _performance_rating_detail_player = INVALID_PLAYER; |
935 } |
935 } |
936 |
936 |
937 for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
937 for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
938 if (GetPlayer(i)->is_active) { |
938 if (GetPlayer(i)->is_active) { |
939 /* Lower the widget corresponding to this player. */ |
939 /* Lower the widget corresponding to this player. */ |
940 LowerWindowWidget(w, i + 13); |
940 w->LowerWidget(i + 13); |
941 w->SetDirty(); |
941 w->SetDirty(); |
942 |
942 |
943 _performance_rating_detail_player = i; |
943 _performance_rating_detail_player = i; |
944 break; |
944 break; |
945 } |
945 } |
1052 case WE_CLICK: |
1052 case WE_CLICK: |
1053 // Check which button is clicked |
1053 // Check which button is clicked |
1054 if (IS_INT_INSIDE(e->we.click.widget, 13, 21)) { |
1054 if (IS_INT_INSIDE(e->we.click.widget, 13, 21)) { |
1055 // Is it no on disable? |
1055 // Is it no on disable? |
1056 if (!w->IsWidgetDisabled(e->we.click.widget)) { |
1056 if (!w->IsWidgetDisabled(e->we.click.widget)) { |
1057 RaiseWindowWidget(w, _performance_rating_detail_player + 13); |
1057 w->RaiseWidget(_performance_rating_detail_player + 13); |
1058 _performance_rating_detail_player = (PlayerID)(e->we.click.widget - 13); |
1058 _performance_rating_detail_player = (PlayerID)(e->we.click.widget - 13); |
1059 LowerWindowWidget(w, _performance_rating_detail_player + 13); |
1059 w->LowerWidget(_performance_rating_detail_player + 13); |
1060 w->SetDirty(); |
1060 w->SetDirty(); |
1061 } |
1061 } |
1062 } |
1062 } |
1063 break; |
1063 break; |
1064 |
1064 |