equal
deleted
inserted
replaced
1 /* $Id$ */ |
1 /* $Id$ */ |
|
2 |
|
3 /** @file player_gui.cpp */ |
2 |
4 |
3 #include "stdafx.h" |
5 #include "stdafx.h" |
4 #include "openttd.h" |
6 #include "openttd.h" |
5 #include "table/sprites.h" |
7 #include "table/sprites.h" |
6 #include "table/strings.h" |
8 #include "table/strings.h" |
74 tbl--; |
76 tbl--; |
75 } while (--j != 0); |
77 } while (--j != 0); |
76 |
78 |
77 y = 171; |
79 y = 171; |
78 |
80 |
79 // draw max loan aligned to loan below (y += 10) |
81 /* draw max loan aligned to loan below (y += 10) */ |
80 SetDParam64(0, (uint64)_economy.max_loan); |
82 SetDParam64(0, (uint64)_economy.max_loan); |
81 DrawString(202, y+10, STR_MAX_LOAN, 0); |
83 DrawString(202, y+10, STR_MAX_LOAN, 0); |
82 } else { |
84 } else { |
83 y = 15; |
85 y = 15; |
84 } |
86 } |
402 MarkWholeScreenDirty(); |
404 MarkWholeScreenDirty(); |
403 break; |
405 break; |
404 } |
406 } |
405 |
407 |
406 case 9: |
408 case 9: |
407 case 10: // First colour dropdown |
409 case 10: /* First colour dropdown */ |
408 ShowColourDropDownMenu(w, 10); |
410 ShowColourDropDownMenu(w, 10); |
409 break; |
411 break; |
410 |
412 |
411 case 11: |
413 case 11: |
412 case 12: // Second colour dropdown |
414 case 12: /* Second colour dropdown */ |
413 ShowColourDropDownMenu(w, 12); |
415 ShowColourDropDownMenu(w, 12); |
414 break; |
416 break; |
415 |
417 |
416 case 13: { |
418 case 13: { |
417 LiveryScheme scheme; |
419 LiveryScheme scheme; |
759 DrawString(110, 25, STR_7038_INAUGURATED, 0); |
761 DrawString(110, 25, STR_7038_INAUGURATED, 0); |
760 |
762 |
761 DrawPlayerVehiclesAmount((PlayerID)w->window_number); |
763 DrawPlayerVehiclesAmount((PlayerID)w->window_number); |
762 |
764 |
763 DrawString(110,48, STR_7006_COLOR_SCHEME, 0); |
765 DrawString(110,48, STR_7006_COLOR_SCHEME, 0); |
764 // Draw company-colour bus |
766 /* Draw company-colour bus */ |
765 DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 49); |
767 DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 49); |
766 |
768 |
767 DrawPlayerFace(p->face, p->player_color, 2, 16); |
769 DrawPlayerFace(p->face, p->player_color, 2, 16); |
768 |
770 |
769 SetDParam(0, p->president_name_1); |
771 SetDParam(0, p->president_name_1); |
880 break; |
882 break; |
881 |
883 |
882 case WE_ON_EDIT_TEXT: { |
884 case WE_ON_EDIT_TEXT: { |
883 char *b = e->we.edittext.str; |
885 char *b = e->we.edittext.str; |
884 |
886 |
885 // empty string is allowed for password |
887 /* empty string is allowed for password */ |
886 if (*b == '\0' && WP(w,def_d).byte_1 != 2) return; |
888 if (*b == '\0' && WP(w,def_d).byte_1 != 2) return; |
887 |
889 |
888 _cmd_text = b; |
890 _cmd_text = b; |
889 switch (WP(w,def_d).byte_1) { |
891 switch (WP(w,def_d).byte_1) { |
890 case 0: /* Change president name */ |
892 case 0: /* Change president name */ |
985 |
987 |
986 /* Always draw a maximized window and within there the centered background */ |
988 /* Always draw a maximized window and within there the centered background */ |
987 static void SetupHighScoreEndWindow(Window *w, uint *x, uint *y) |
989 static void SetupHighScoreEndWindow(Window *w, uint *x, uint *y) |
988 { |
990 { |
989 uint i; |
991 uint i; |
990 // resize window to "full-screen" |
992 /* resize window to "full-screen" */ |
991 w->width = _screen.width; |
993 w->width = _screen.width; |
992 w->height = _screen.height; |
994 w->height = _screen.height; |
993 w->widget[0].right = w->width - 1; |
995 w->widget[0].right = w->width - 1; |
994 w->widget[0].bottom = w->height - 1; |
996 w->widget[0].bottom = w->height - 1; |
995 |
997 |
1002 DrawSprite(WP(w, highscore_d).background_img + i, PAL_NONE, *x, *y + (i * 50)); |
1004 DrawSprite(WP(w, highscore_d).background_img + i, PAL_NONE, *x, *y + (i * 50)); |
1003 } |
1005 } |
1004 |
1006 |
1005 extern StringID EndGameGetPerformanceTitleFromValue(uint value); |
1007 extern StringID EndGameGetPerformanceTitleFromValue(uint value); |
1006 |
1008 |
1007 /* End game window shown at the end of the game */ |
1009 /** End game window shown at the end of the game */ |
1008 static void EndGameWndProc(Window *w, WindowEvent *e) |
1010 static void EndGameWndProc(Window *w, WindowEvent *e) |
1009 { |
1011 { |
1010 switch (e->event) { |
1012 switch (e->event) { |
1011 case WE_PAINT: { |
1013 case WE_PAINT: { |
1012 const Player *p; |
1014 const Player *p; |
1104 0, |
1106 0, |
1105 _highscore_widgets, |
1107 _highscore_widgets, |
1106 EndGameWndProc |
1108 EndGameWndProc |
1107 }; |
1109 }; |
1108 |
1110 |
1109 /* Show the highscore table for a given difficulty. When called from |
1111 /** Show the highscore table for a given difficulty. When called from |
1110 * endgame ranking is set to the top5 element that was newly added |
1112 * endgame ranking is set to the top5 element that was newly added |
1111 * and is thus highlighted */ |
1113 * and is thus highlighted */ |
1112 void ShowHighscoreTable(int difficulty, int8 ranking) |
1114 void ShowHighscoreTable(int difficulty, int8 ranking) |
1113 { |
1115 { |
1114 Window *w; |
1116 Window *w; |
1115 |
1117 |
1116 // pause game to show the chart |
1118 /* pause game to show the chart */ |
1117 if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
1119 if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
1118 |
1120 |
1119 /* Close all always on-top windows to get a clean screen */ |
1121 /* Close all always on-top windows to get a clean screen */ |
1120 if (_game_mode != GM_MENU) HideVitalWindows(); |
1122 if (_game_mode != GM_MENU) HideVitalWindows(); |
1121 |
1123 |
1128 WP(w, highscore_d).background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show |
1130 WP(w, highscore_d).background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show |
1129 WP(w, highscore_d).rank = ranking; |
1131 WP(w, highscore_d).rank = ranking; |
1130 } |
1132 } |
1131 } |
1133 } |
1132 |
1134 |
1133 /* Show the endgame victory screen in 2050. Update the new highscore |
1135 /** Show the endgame victory screen in 2050. Update the new highscore |
1134 * if it was high enough */ |
1136 * if it was high enough */ |
1135 void ShowEndGameChart() |
1137 void ShowEndGameChart() |
1136 { |
1138 { |
1137 Window *w; |
1139 Window *w; |
1138 |
1140 |
1160 * as well as generate a TOP5 of that game, and not an all-time top5. */ |
1162 * as well as generate a TOP5 of that game, and not an all-time top5. */ |
1161 if (_networking) { |
1163 if (_networking) { |
1162 w->window_number = lengthof(_highscore_table) - 1; |
1164 w->window_number = lengthof(_highscore_table) - 1; |
1163 WP(w, highscore_d).rank = SaveHighScoreValueNetwork(); |
1165 WP(w, highscore_d).rank = SaveHighScoreValueNetwork(); |
1164 } else { |
1166 } else { |
1165 // in single player _local player is always valid |
1167 /* in single player _local player is always valid */ |
1166 const Player *p = GetPlayer(_local_player); |
1168 const Player *p = GetPlayer(_local_player); |
1167 w->window_number = _opt.diff_level; |
1169 w->window_number = _opt.diff_level; |
1168 WP(w, highscore_d).rank = SaveHighScoreValue(p); |
1170 WP(w, highscore_d).rank = SaveHighScoreValue(p); |
1169 } |
1171 } |
1170 } |
1172 } |