player_gui.c
author Darkvater
Mon, 02 May 2005 15:52:19 +0000
changeset 1739 4f3082735fbc
parent 1363 01d3de5d8039
child 1767 394867897b0a
permissions -rw-r--r--
(svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
- Some variables are really special and cannot be assigned normally, use their callback procedure for assignment/querying. This commit also obsoletes "[1172804] Console set command cleanup"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     1
#include "stdafx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     2
#include "ttd.h"
1363
01d3de5d8039 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1323
diff changeset
     3
#include "table/sprites.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 200
diff changeset
     4
#include "table/strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "player.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "vehicle.h"
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    12
#include "economy.h"
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
    13
#include "network.h"
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
    14
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
    15
#ifdef ENABLE_NETWORK
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
    16
#include "network_data.h"
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
    17
#include "network_client.h"
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
    18
#endif
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
    20
static void DoShowPlayerFinances(int player, bool show_small, bool show_stickied);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
static void DrawPlayerEconomyStats(Player *p, byte mode)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
	int x,y,i,j,year;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
	int64 (*tbl)[13], sum,cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
	StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    29
	if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
		/* draw categories */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
		DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
		for(i=0; i!=13; i++)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
			DrawString(2, 27 + i*10, STR_7011_CONSTRUCTION + i, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
		DrawStringRightAligned(111, 27 + 10*13 + 2, STR_7020_TOTAL, 0);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    35
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
		/* draw the price columns */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
		year = _cur_year - 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
		j = 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
		x = 215;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
		tbl = p->yearly_expenses + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
			if (year >= p->inaugurated_year) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    43
				SetDParam(0, year + 1920);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
				DrawStringCenterUnderline(x-17, 15, STR_7010, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
				sum = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
				for(i=0; i!=13; i++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
					/* draw one row in the price column */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
					cost = (*tbl)[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
					if (cost != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
						sum += cost;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    51
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
						str = STR_701E;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
						if (cost < 0) { cost = -cost; str++; }
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    54
						SetDParam64(0, cost);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
						DrawStringRightAligned(x, 27+i*10, str, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
				str = STR_701E;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
				if (sum < 0) { sum = -sum; str++; }
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    61
				SetDParam64(0, sum);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
				DrawStringRightAligned(x, 27 + 13*10 + 2, str, 0);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
    63
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
				GfxFillRect(x - 75, 27 + 10*13, x, 27 + 10*13, 215);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
				x += 95;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
			year++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
			tbl--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
		} while (--j != 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
		y = 171;
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    72
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    73
		// draw max loan aligned to loan below (y += 10)
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    74
		SetDParam64(0, (uint64)_economy.max_loan);
186
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    75
		DrawString(202, y+10, STR_MAX_LOAN, 0);
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    76
d6fde0ea62f0 (svn r187) -Feature: [1024044] Show max loan in finances window. (ledow)
darkvater
parents: 176
diff changeset
    77
	} else
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
		y = 15;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	DrawString(2, y, STR_7026_BANK_BALANCE, 0);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    81
	SetDParam64(0, p->money64);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
	DrawStringRightAligned(182, y, STR_7028, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
	y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	DrawString(2, y, STR_7027_LOAN, 0);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    87
	SetDParam64(0, p->current_loan);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	DrawStringRightAligned(182, y, STR_7028, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	y += 12;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	GfxFillRect(182 - 75, y-2, 182, y-2, 215);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    94
	SetDParam64(0, p->money64 - p->current_loan);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	DrawStringRightAligned(182, y, STR_7028, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
static const Widget _player_finances_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
    99
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,					STR_018B_CLOSE_WINDOW},
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   100
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   379,     0,    13, STR_700E_FINANCES,	STR_018C_WINDOW_TITLE_DRAG_THIS},
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   101
{     WWT_IMGBTN,   RESIZE_NONE,    14,   380,   394,     0,    13, 0x2AA,							STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   102
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   395,   406,     0,    13, 0x0,								STR_STICKY_BUTTON},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   103
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   406,    14,   169, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   104
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   406,   170,   203, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   105
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   202,   204,   215, STR_7029_BORROW,		STR_7035_INCREASE_SIZE_OF_LOAN},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   106
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   203,   406,   204,   215, STR_702A_REPAY,		STR_7036_REPAY_PART_OF_LOAN},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   107
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
static const Widget _other_player_finances_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   111
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,					STR_018B_CLOSE_WINDOW},
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   112
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   379,     0,    13, STR_700E_FINANCES,	STR_018C_WINDOW_TITLE_DRAG_THIS},
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   113
{     WWT_IMGBTN,   RESIZE_NONE,    14,   380,   394,     0,    13, 0x2AA,							STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   114
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   395,   406,     0,    13, 0x0,								STR_STICKY_BUTTON},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   115
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   406,    14,   169, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   116
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   406,   170,   203, 0x0,								STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   117
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
static const Widget _other_player_finances_small_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   121
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,					STR_018B_CLOSE_WINDOW},
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   122
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   253,     0,    13, STR_700E_FINANCES,	STR_018C_WINDOW_TITLE_DRAG_THIS},
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   123
{     WWT_IMGBTN,   RESIZE_NONE,    14,   254,   267,     0,    13, 0x2AA,							STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   124
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   268,   279,     0,    13, 0x0,								STR_STICKY_BUTTON},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   125
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   126
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   279,    14,    47, 0x0,								STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   127
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
static const Widget _player_finances_small_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   131
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,					STR_018B_CLOSE_WINDOW},
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   132
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   253,     0,    13, STR_700E_FINANCES,	STR_018C_WINDOW_TITLE_DRAG_THIS},
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   133
{     WWT_IMGBTN,   RESIZE_NONE,    14,   254,   267,     0,    13, 0x2AA,							STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   134
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   268,   279,     0,    13, 0x0,								STR_STICKY_BUTTON},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   135
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   136
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   279,    14,    47, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   137
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   139,    48,    59, STR_7029_BORROW,		STR_7035_INCREASE_SIZE_OF_LOAN},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   138
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   140,   279,    48,    59, STR_702A_REPAY,		STR_7036_REPAY_PART_OF_LOAN},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   139
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
		Player *p = DEREF_PLAYER(w->window_number);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   148
893
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
   149
		w->disabled_state = p->current_loan != 0 ? 0 : (1 << 7);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   151
		SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   152
		SetDParam(1, p->name_2);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   153
		SetDParam(2, GetPlayerNameString((byte)w->window_number, 3));
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   154
		SetDParam(4, 10000);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
		DrawPlayerEconomyStats(p, (byte)WP(w,def_d).data_1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
		switch(e->click.widget) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
		case 2: {/* toggle size */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
			byte mode = (byte)WP(w,def_d).data_1;
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   164
			bool stickied = !!(w->flags4 & WF_STICKY);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
			int player = w->window_number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
			DeleteWindow(w);
1003
5ce43e332bab (svn r1502) -Fix: [1101889] Crash under windows... stupid typo in player_gui.c ^ should've been &
darkvater
parents: 998
diff changeset
   167
			DoShowPlayerFinances(player, !HASBIT(mode, 0), stickied);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   170
		case 6: /* increase loan */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
			DoCommandP(0, w->window_number, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   174
		case 7: /* repay loan */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
			DoCommandP(0, w->window_number, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
static const WindowDesc _player_finances_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	-1,-1, 407, 216,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	WC_FINANCES,0,
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   185
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESTORE_DPARAM | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
	_player_finances_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
	PlayerFinancesWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
static const WindowDesc _player_finances_small_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
	-1,-1, 280, 60,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
	WC_FINANCES,0,
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   193
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESTORE_DPARAM | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
	_player_finances_small_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
	PlayerFinancesWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
static const WindowDesc _other_player_finances_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
	-1,-1, 407, 204,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
	WC_FINANCES,0,
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   201
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESTORE_DPARAM | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
	_other_player_finances_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
	PlayerFinancesWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
static const WindowDesc _other_player_finances_small_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
	-1,-1, 280, 48,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
	WC_FINANCES,0,
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   209
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESTORE_DPARAM | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
	_other_player_finances_small_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
	PlayerFinancesWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
static const WindowDesc * const desc_table[2*2] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
	&_player_finances_desc,&_player_finances_small_desc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
	&_other_player_finances_desc,&_other_player_finances_small_desc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   219
static void DoShowPlayerFinances(int player, bool show_small, bool show_stickied)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
	int mode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
790
e19caa5f0ddf (svn r1260) -Fix: [1090357] Patch for braindead MinGW compiler (luzi82)
darkvater
parents: 773
diff changeset
   224
	mode = ((byte)player != _local_player)*2 + show_small;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
	w = AllocateWindowDescFront( desc_table[mode], player);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
	if (w) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
		w->caption_color = w->window_number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
		WP(w,def_d).data_1 = mode;
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   229
		if (show_stickied) {
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   230
			w->flags4 |= WF_STICKY;
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   231
			w->click_state ^= (1 << 3);
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   232
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
void ShowPlayerFinances(int player)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
{
888
127b65c07558 (svn r1374) -Feature: Add sticky item to finances window; sticky remains when requesting big/small window
darkvater
parents: 867
diff changeset
   238
	DoShowPlayerFinances(player, false, false);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
static void SelectPlayerColorWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
		Player *p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
		uint used_colors = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
		int num_free = 16;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
		int x,y,pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
		int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
		FOR_ALL_PLAYERS(p) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
			if (p->is_active) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
				SETBIT(used_colors, p->player_color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
				num_free--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
		WP(w,def_d).data_1 = used_colors;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
		SetVScrollCount(w, num_free);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
		DrawWindowWidgets(w);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   260
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
		x = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
		y = 17;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
		pos = w->vscroll.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
		for(i=0; i!=16; i++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
			if (!(used_colors & 1) && --pos < 0 && pos >= -8) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
				DrawString(x + 30, y, STR_00D1_DARK_BLUE + i, 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
				DrawSprite((i << 16) + 0x3078C1A, x + 14, y + 4);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
				y += 14;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
			used_colors >>= 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
	} break;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   274
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
		if (e->click.widget == 2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
			int item = (e->click.pt.y - 13) / 14;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
			uint used_colors;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
			int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
			if ((uint)item >= 8)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
			item += w->vscroll.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
			used_colors = WP(w,def_d).data_1;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   285
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
			for(i=0; i!=16; i++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
				if (!(used_colors & 1) && --item < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
					DoCommandP(0, w->window_number, i, NULL, CMD_SET_PLAYER_COLOR);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
					DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
					break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
				used_colors >>= 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
static const Widget _select_player_color_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   300
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   301
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   149,     0,    13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS},
893
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
   302
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   137,    14,   127, 0x0, STR_7034_CLICK_ON_SELECTED_NEW_COLOR},
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
   303
{  WWT_SCROLLBAR,   RESIZE_NONE,    14,   138,   149,    14,   127, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   304
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
static const WindowDesc _select_player_color_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
	-1,-1, 150, 128,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
	WC_PLAYER_COLOR,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
	_select_player_color_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
	SelectPlayerColorWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
		Player *p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
		w->click_state = (w->click_state & ~(1<<5|1<<6)) | ((1<<5) << WP(w,facesel_d).gender);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
		p = DEREF_PLAYER(w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
		DrawPlayerFace(WP(w,facesel_d).face, p->player_color, 2, 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
		switch(e->click.widget) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
		case 3: DeleteWindow(w); break;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   329
		case 4: /* ok click */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
			DoCommandP(0, w->window_number, WP(w,facesel_d).face, NULL, CMD_SET_PLAYER_FACE);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
		case 5: /* male click */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
		case 6: /* female click */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
			WP(w,facesel_d).gender = e->click.widget - 5;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
		case 7:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
			WP(w,facesel_d).face = (InteractiveRandom() & 0x7FFFFFFF) + (WP(w,facesel_d).gender << 31);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
static const Widget _select_player_face_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   348
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,								STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   349
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   189,     0,    13, STR_7043_FACE_SELECTION,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   350
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   189,    14,   136, 0x0,											STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   351
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    94,   137,   148, STR_012E_CANCEL,					STR_7047_CANCEL_NEW_FACE_SELECTION},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   352
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   189,   137,   148, STR_012F_OK,							STR_7048_ACCEPT_NEW_FACE_SELECTION},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   353
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    95,   187,    25,    36, STR_7044_MALE,						STR_7049_SELECT_MALE_FACES},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   354
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    95,   187,    37,    48, STR_7045_FEMALE,					STR_704A_SELECT_FEMALE_FACES},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   355
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    95,   187,    79,    90, STR_7046_NEW_FACE,				STR_704B_GENERATE_RANDOM_NEW_FACE},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   356
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
static const WindowDesc _select_player_face_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
	-1,-1, 190, 149,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
	WC_PLAYER_FACE,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
	_select_player_face_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
	SelectPlayerFaceWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
static const Widget _my_player_company_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   368
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   369
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   359,     0,    13, STR_7001,                STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   370
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   359,    14,   157, 0x0,                     STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   371
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    89,   158,   169, STR_7004_NEW_FACE,       STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   372
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    90,   179,   158,   169, STR_7005_COLOR_SCHEME,   STR_7031_CHANGE_THE_COMPANY_VEHICLE},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   373
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   180,   269,   158,   169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   374
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   270,   359,   158,   169, STR_7008_COMPANY_NAME,   STR_7033_CHANGE_THE_COMPANY_NAME},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   375
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   266,   355,    18,    29, STR_706F_BUILD_HQ,       STR_7070_BUILD_COMPANY_HEADQUARTERS},
917
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   376
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   355,    32,    43, 0x0,                     STR_NULL},
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   377
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   355,    32,    43, 0x0,                     STR_NULL},
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   378
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   355,    32,    43, 0x0,                     STR_NULL},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   379
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   266,   355,   138,   149, STR_COMPANY_PASSWORD,    STR_COMPANY_PASSWORD_TOOLTIP},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   380
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
static const Widget _other_player_company_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   384
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,					STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   385
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   359,     0,    13, STR_7001,					STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   386
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   359,    14,   157, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   387
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   388
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   389
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   390
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   391
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   266,   355,    18,    29, STR_7072_VIEW_HQ,	STR_7070_BUILD_COMPANY_HEADQUARTERS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   392
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   393
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   179,   158,   169, STR_7077_BUY_25_SHARE_IN_COMPANY,	STR_7079_BUY_25_SHARE_IN_THIS_COMPANY},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   394
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   180,   359,   158,   169, STR_7078_SELL_25_SHARE_IN_COMPANY,	STR_707A_SELL_25_SHARE_IN_THIS_COMPANY},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   395
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
static const Widget _my_player_company_bh_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   399
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   400
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   359,     0,    13, STR_7001,                STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   401
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   359,    14,   157, 0x0,                     STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   402
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    89,   158,   169, STR_7004_NEW_FACE,       STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   403
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    90,   179,   158,   169, STR_7005_COLOR_SCHEME,   STR_7031_CHANGE_THE_COMPANY_VEHICLE},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   404
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   180,   269,   158,   169, STR_7009_PRESIDENT_NAME, STR_7032_CHANGE_THE_PRESIDENT_S},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   405
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   270,   359,   158,   169, STR_7008_COMPANY_NAME,   STR_7033_CHANGE_THE_COMPANY_NAME},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   406
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   266,   355,    18,    29, STR_7072_VIEW_HQ,        STR_7070_BUILD_COMPANY_HEADQUARTERS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   407
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   266,   355,    32,    43, STR_RELOCATE_HQ,         STR_RELOCATE_COMPANY_HEADQUARTERS},
917
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   408
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   355,    32,    43, 0x0,                     STR_NULL},
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   409
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   355,    32,    43, 0x0,                     STR_NULL},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   410
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   266,   355,   138,   149, STR_COMPANY_PASSWORD,    STR_COMPANY_PASSWORD_TOOLTIP},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   411
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
static void DrawPlayerVehiclesAmount(int player)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
	const int x = 110;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
	int y = 72;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
	Vehicle *v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
	uint train,road,air,ship;
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   420
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
	DrawString(x, y, STR_7039_VEHICLES, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
	train = road = air = ship = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
	FOR_ALL_VEHICLES(v) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
		if (v->owner == player) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
			if (v->type == VEH_Train) {
1067
a083a6dd1419 (svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents: 1019
diff changeset
   428
				if (v->subtype == TS_Front_Engine)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
					train++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
			} else if (v->type == VEH_Road) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
				road++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
			} else if (v->type == VEH_Aircraft) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
				if (v->subtype <= 2)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
					air++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   435
			} else if (v->type == VEH_Ship) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
				ship++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
	if (train+road+air+ship == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
		DrawString(x+70, y, STR_7042_NONE, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
		if (train != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   445
			SetDParam(0, train);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
			DrawString(x + 70, y, train==1 ? STR_703A_TRAIN : STR_703B_TRAINS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
		if (road != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   451
			SetDParam(0, road);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
			DrawString(x + 70, y, road==1 ? STR_703C_ROAD_VEHICLE : STR_703D_ROAD_VEHICLES, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
		if (air != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   457
			SetDParam(0, air);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
			DrawString(x + 70, y, air==1 ? STR_703E_AIRCRAFT : STR_703F_AIRCRAFT, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
		if (ship != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   463
			SetDParam(0, ship);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
			DrawString(x + 70, y, ship==1 ? STR_7040_SHIP : STR_7041_SHIPS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
599
80e49e323483 (svn r1023) -Fix: [Network] [ 1083692 ] You can no longer buy out a company in MP
truelight
parents: 543
diff changeset
   469
int GetAmountOwnedBy(Player *p, byte owner)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
{
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   471
	return (p->share_owners[0] == owner) +
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   472
				 (p->share_owners[1] == owner) +
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   473
				 (p->share_owners[2] == owner) +
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
				 (p->share_owners[3] == owner);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
static void DrawCompanyOwnerText(Player *p)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
	int num = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
	Player *p2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
	int amt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
	FOR_ALL_PLAYERS(p2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
		if ((amt=GetAmountOwnedBy(p, p2->index)) != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
			num++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   487
			SetDParam(num*3+0, amt*25);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   488
			SetDParam(num*3+1, p2->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   489
			SetDParam(num*3+2, p2->name_2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
			if (num != 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   492
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
	if (num >= 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
		DrawString(120, 124, STR_707D_OWNED_BY+num, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
		Player *p = DEREF_PLAYER(w->window_number);
914
c3ad2a35b937 (svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents: 893
diff changeset
   505
		uint32 dis = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   507
		if (!IsWindowOfPrototype(w, _other_player_company_widgets)) {
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   508
			AssignWidgetToWindow(w, (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets);
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   509
930
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   510
			if (!_networking) SETBIT(w->hidden_state, 11); // hide company-password widget
914
c3ad2a35b937 (svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents: 893
diff changeset
   511
		} else {
930
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   512
			if (_patches.allow_shares) { /* shares are allowed */
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   513
				if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) SETBIT(dis, 9);
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   514
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   515
				/* We cannot buy out real players in a network game */
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   516
				if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) SETBIT(dis, 9);
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   517
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   518
				if (GetAmountOwnedBy(p, _local_player) == 0) SETBIT(dis, 10);
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   519
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   520
				if (_local_player == OWNER_SPECTATOR) dis |= (1 << 9) | (1 << 10);
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   521
			} else /* shares are not allowed, disable buy/sell buttons */
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 917
diff changeset
   522
				dis |= (1 << 9) | (1 << 10);
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   523
		}
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   524
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   525
		SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   526
		SetDParam(1, p->name_2);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   527
		SetDParam(2, GetPlayerNameString((byte)w->window_number, 3));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
		w->disabled_state = dis;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   532
		SetDParam(0, p->inaugurated_year + 1920);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
		DrawString(110, 25, STR_7038_INAUGURATED, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
		DrawPlayerVehiclesAmount(w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   537
		DrawString(110,48, STR_7006_COLOR_SCHEME, 0);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   538
		// Draw company-colour bus (0xC19)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   539
		DrawSprite(PLAYER_SPRITE_COLOR(p->index) + 0x8C19, 215, 49);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
		DrawPlayerFace(p->face, p->player_color, 2, 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   543
		SetDParam(0, p->president_name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   544
		SetDParam(1, p->president_name_2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
		DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   547
		SetDParam64(0, CalculateCompanyValue(p));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
		DrawString(110, 114, STR_7076_COMPANY_VALUE, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
		DrawCompanyOwnerText(p);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
		switch(e->click.widget) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
		case 3: { /* select face */
1007
65b0cbc302cc (svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents: 1003
diff changeset
   556
			Window *wf = AllocateWindowDescFront(&_select_player_face_desc, w->window_number);
65b0cbc302cc (svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents: 1003
diff changeset
   557
			if (wf) {
65b0cbc302cc (svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents: 1003
diff changeset
   558
				wf->caption_color = w->window_number;
65b0cbc302cc (svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents: 1003
diff changeset
   559
				WP(wf,facesel_d).face = DEREF_PLAYER(wf->window_number)->face;
65b0cbc302cc (svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents: 1003
diff changeset
   560
				WP(wf,facesel_d).gender = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
		case 4: {/* change color */
1007
65b0cbc302cc (svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents: 1003
diff changeset
   565
			Window *wf = AllocateWindowDescFront(&_select_player_color_desc,w->window_number);
65b0cbc302cc (svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents: 1003
diff changeset
   566
			if (wf) {
65b0cbc302cc (svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents: 1003
diff changeset
   567
				wf->caption_color = wf->window_number;
65b0cbc302cc (svn r1506) Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
dominik
parents: 1003
diff changeset
   568
				wf->vscroll.cap = 8;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
		case 5: {/* change president name */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
			Player *p = DEREF_PLAYER(w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
			WP(w,def_d).byte_1 = 0;
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   575
			SetDParam(0, p->president_name_2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
			ShowQueryString(p->president_name_1, STR_700B_PRESIDENT_S_NAME, 31, 94, w->window_class, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
		case 6: {/* change company name */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
			Player *p = DEREF_PLAYER(w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
			WP(w,def_d).byte_1 = 1;
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   582
			SetDParam(0, p->name_2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
			ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w->window_class, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
		case 7: {/* build hq */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
			TileIndex tile = DEREF_PLAYER(w->window_number)->location_of_house;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
			if (tile == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   589
				if ((byte)w->window_number != _local_player)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
					return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
				SetObjectToPlaceWnd(0x2D0, 1, w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
				SetTileSelectSize(2, 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
			} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
				ScrollMainWindowToTile(tile);
200
03b8104d1479 (svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents: 186
diff changeset
   595
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
147
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   598
		case 8: /* relocate HQ */
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   599
			SetObjectToPlaceWnd(0x2D0, 1, w);
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   600
			SetTileSelectSize(2, 2);
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   601
			break;
917
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   602
		case 9: /* buy 25% */
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   603
			DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS));
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   604
			break;
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   605
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   606
		case 10: /* sell 25% */
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   607
			DoCommandP(0, w->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   608
			break;
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   609
		case 11: { /* Password protect company */
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   610
			#ifdef ENABLE_NETWORK
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   611
			if (!IsWindowOfPrototype(w, _other_player_company_widgets)) {
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   612
				StringID str;
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   613
				WP(w,def_d).byte_1 = 2;
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   614
				str = AllocateName(_network_player_info[_local_player].password, 0);
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   615
				ShowQueryString(str, STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w->window_class, w->window_number);
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   616
				DeleteName(str);
917
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   617
			}
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   618
			#endif
917
f5779d4b6c3a (svn r1404) -Fix: Company password no longer shares a widget with buying shares
darkvater
parents: 914
diff changeset
   619
		}	break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   622
	case WE_MOUSELOOP:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   623
		/* redraw the window every now and then */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
		if ((++w->vscroll.pos & 0x1F) == 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
147
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   628
	case WE_PLACE_OBJ: {
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   629
		// you cannot destroy a HQ, only relocate it. So build_HQ is called, just with different flags
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   630
		TileIndex tile = DEREF_PLAYER(w->window_number)->location_of_house;
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   631
		if (DoCommandP(e->place.tile, (tile == 0) ? 0 : (1 << 16) | w->window_number, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
			ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
		break;
147
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   634
	}
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 16
diff changeset
   635
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   637
	case WE_DESTROY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
		DeleteWindowById(WC_PLAYER_COLOR, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
		DeleteWindowById(WC_PLAYER_FACE, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
	case WE_ON_EDIT_TEXT: {
1323
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1109
diff changeset
   643
		char *b = e->edittext.str;
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   644
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   645
		if (*b == 0 && WP(w,def_d).byte_1 != 2) // empty string is allowed for password
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   646
			return;
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   647
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
		memcpy(_decode_parameters, b, 32);
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   649
		switch (WP(w,def_d).byte_1) {
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   650
		case 0: /* Change president name */
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   651
			DoCommandP(0, w->window_number, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   652
			break;
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   653
		case 1: /* Change company name */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   654
			DoCommandP(0, w->window_number, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME));
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   655
			break;
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   656
		#ifdef ENABLE_NETWORK
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   657
		case 2: /* Change company password */
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   658
			if (*b == 0) *b = '*'; // empty password is a '*' because of console argument
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1363
diff changeset
   659
			NetworkChangeCompanyPassword(1, &b);
773
0c5d7a4bac3d (svn r1239) -Feature: Added gui option of setting company password. It can be found in the 'company information' window
darkvater
parents: 669
diff changeset
   660
		#endif
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   662
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   663
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   664
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   667
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
static const WindowDesc _my_player_company_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
	-1,-1, 360, 170,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
	WC_COMPANY,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   671
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
	_my_player_company_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
	PlayerCompanyWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   674
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
static const WindowDesc _other_player_company_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
	-1,-1, 360, 170,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
	WC_COMPANY,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   680
	_other_player_company_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   681
	PlayerCompanyWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   683
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   684
void ShowPlayerCompany(int player)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   685
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   687
	w = AllocateWindowDescFront((byte)player == _local_player ? &_my_player_company_desc : &_other_player_company_desc,  player);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
	if (w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   689
		w->caption_color = w->window_number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   690
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   692
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   693
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   694
static void BuyCompanyWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   695
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   696
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   697
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
		Player *p = DEREF_PLAYER(w->window_number);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   699
		SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   700
		SetDParam(1, p->name_2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   703
		DrawPlayerFace(p->face, p->player_color, 2, 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   704
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   705
		SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   706
		SetDParam(1, p->name_2);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   707
		SetDParam(2, p->bankrupt_value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   708
		DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   709
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   710
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   711
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
		switch(e->click.widget) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   714
		case 3:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   715
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   716
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   717
		case 4: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   718
			DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   719
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   720
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   721
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   722
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   723
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   724
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   726
static const Widget _buy_company_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   727
{    WWT_TEXTBTN,   RESIZE_NONE,     5,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   728
{    WWT_CAPTION,   RESIZE_NONE,     5,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   729
{     WWT_IMGBTN,   RESIZE_NONE,     5,     0,   333,    14,   136, 0x0,										STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   730
{    WWT_TEXTBTN,   RESIZE_NONE,     5,   148,   207,   117,   128, STR_00C9_NO,						STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 790
diff changeset
   731
{    WWT_TEXTBTN,   RESIZE_NONE,     5,   218,   277,   117,   128, STR_00C8_YES,					STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 150
diff changeset
   732
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   733
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   734
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   735
static const WindowDesc _buy_company_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
	153,171, 334, 137,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
	WC_BUY_COMPANY,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   738
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
	_buy_company_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   740
	BuyCompanyWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   741
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   742
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   743
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   744
void ShowBuyCompanyDialog(uint player)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   745
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   746
	AllocateWindowDescFront(&_buy_company_desc, player);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   747
}
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   748
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   749
/********** HIGHSCORE and ENDGAME windows */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   750
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   751
/* Always draw a maximized window and within there the centered background */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   752
static void SetupHighScoreEndWindow(Window *w, uint *x, uint *y)
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   753
{
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   754
	uint i;
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   755
	// resize window to "full-screen"
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   756
	w->width = _screen.width;
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   757
	w->height = _screen.height;
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   758
	w->widget[0].right = w->width - 1;
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   759
	w->widget[0].bottom = w->height - 1;
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   760
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   761
	DrawWindowWidgets(w);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   762
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   763
	/* Center Highscore/Endscreen background */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   764
	*x = max(0, (_screen.width  / 2) - (640 / 2));
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   765
	*y = max(0, (_screen.height / 2) - (480 / 2));
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   766
	for (i = 0; i < 10; i++) // the image is split into 10 50px high parts
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   767
		DrawSprite(WP(w, highscore_d).background_img + i, *x, *y + (i * 50));
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   768
}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   769
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   770
extern StringID EndGameGetPerformanceTitleFromValue(uint value);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   771
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   772
/* End game window shown at the end of the game */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   773
static void EndGameWndProc(Window *w, WindowEvent *e)
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   774
{
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   775
	switch (e->event) {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   776
	case WE_PAINT: {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   777
		const Player *p = DEREF_PLAYER(_local_player);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   778
		uint x, y;
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   779
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   780
		SetupHighScoreEndWindow(w, &x, &y);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   781
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   782
		/* We need to get performance from last year because the image is shown
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   783
		 * at the start of the new year when these things have already been copied */
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   784
		if (WP(w, highscore_d).background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   785
			SetDParam(0, p->president_name_1);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   786
			SetDParam(1, p->president_name_2);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   787
			SetDParam(2, p->name_1);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   788
			SetDParam(3, p->name_2);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   789
			SetDParam(4, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   790
			DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   791
		} else {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   792
			SetDParam(0, p->name_1);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   793
			SetDParam(1, p->name_2);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   794
			SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   795
			DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   796
		}
1017
608592d4d7a6 (svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents: 1016
diff changeset
   797
	} break;
608592d4d7a6 (svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents: 1016
diff changeset
   798
	case WE_CLICK: { /* OnClick show the highscore chart */
608592d4d7a6 (svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents: 1016
diff changeset
   799
		int diff = w->window_number; // save values because deletewindow is called
608592d4d7a6 (svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents: 1016
diff changeset
   800
		int8 rank = WP(w, highscore_d).rank;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   801
		DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
1016
026b2de61647 (svn r1516) -Cheating players do not get their names added to the highscore table/file
darkvater
parents: 1007
diff changeset
   802
		DeleteWindow(w);
1017
608592d4d7a6 (svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents: 1016
diff changeset
   803
608592d4d7a6 (svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents: 1016
diff changeset
   804
		ShowHighscoreTable(diff, rank);
608592d4d7a6 (svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents: 1016
diff changeset
   805
	} break;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   806
	}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   807
}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   808
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   809
static void HighScoreWndProc(Window *w, WindowEvent *e)
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   810
{
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   811
	switch (e->event) {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   812
	case WE_PAINT: {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   813
		const HighScore *hs = _highscore_table[w->window_number];
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   814
		uint x, y;
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   815
		uint8 i;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   816
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   817
		SetupHighScoreEndWindow(w, &x, &y);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   818
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   819
		SetDParam(0, _patches.ending_date);
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   820
		SetDParam(1, w->window_number + STR_6801_EASY);
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   821
		DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500);
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   822
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   823
		/* Draw Highscore peepz */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   824
		for (i = 0; i < lengthof(_highscore_table[0]); i++) {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   825
			SetDParam(0, i + 1);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   826
			DrawString(x + 40, y + 140 + (i * 55), STR_0212, 0x10);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   827
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   828
			if (hs[i].company[0] != '\0') {
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   829
				uint16 colour = (WP(w, highscore_d).rank == (int8)i) ? 0x3 : 0x10; // draw new highscore in red
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   830
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   831
				DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   832
				SetDParam(0, hs[i].title);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   833
				SetDParam(1, hs[i].score);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   834
				DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   835
			}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   836
		}
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1017
diff changeset
   837
	} break;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   838
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   839
	case WE_CLICK: /* Onclick get back all hidden windows */
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1017
diff changeset
   840
		if (_game_mode != GM_MENU && !_networking)
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   841
			ShowVitalWindows();
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   842
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   843
		DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   844
		DeleteWindow(w);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   845
		break;
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   846
	}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   847
}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   848
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   849
static const Widget _highscore_widgets[] = {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   850
{      WWT_PANEL, RESIZE_NONE, 16, 0, 640, 0, 480, 0x0, STR_NULL},
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   851
{   WIDGETS_END},
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   852
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   853
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   854
static const WindowDesc _highscore_desc = {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   855
	0, 0, 641, 481,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   856
	WC_HIGHSCORE_ENDSCREEN,0,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   857
	0,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   858
	_highscore_widgets,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   859
	HighScoreWndProc
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   860
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   861
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   862
static const WindowDesc _endgame_desc = {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   863
	0, 0, 641, 481,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   864
	WC_HIGHSCORE_ENDSCREEN,0,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   865
	0,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   866
	_highscore_widgets,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   867
	EndGameWndProc
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   868
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   869
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   870
/* Show the highscore table for a given difficulty. When called from
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   871
 * endgame ranking is set to the top5 element that was newly added
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   872
 * and is thus highlighted */
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   873
void ShowHighscoreTable(int difficulty, int8 ranking)
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   874
{
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   875
	Window *w;
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   876
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   877
	if (!_networking) { // pause game to show chart
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   878
		DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   879
		/* Close all always on-top windows to get a clean screen */
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   880
		if (_game_mode != GM_MENU)
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   881
			HideVitalWindows();
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   882
	}
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   883
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   884
	DeleteWindowById(WC_HIGHSCORE_ENDSCREEN, 0);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   885
	w = AllocateWindowDesc(&_highscore_desc);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   886
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   887
	if (w != NULL) {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   888
		MarkWholeScreenDirty();
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   889
		w->window_number = difficulty; // show highscore chart for difficulty...
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   890
		WP(w, highscore_d).background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   891
		WP(w, highscore_d).rank = ranking;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   892
	}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   893
}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   894
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   895
/* Show the endgame victory screen in 2050. Update the new highscore
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   896
 * if it was high enough */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   897
void ShowEndGameChart(void)
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   898
{
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   899
	Window *w;
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   900
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   901
	if (!_networking) { // pause the game and hide all windows to show end-chart
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   902
		DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   903
		HideVitalWindows();
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   904
	}
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   905
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   906
	DeleteWindowById(WC_HIGHSCORE_ENDSCREEN, 0);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   907
	w = AllocateWindowDesc(&_endgame_desc);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   908
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   909
	if (w != NULL) {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   910
		MarkWholeScreenDirty();
1077
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   911
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   912
		WP(w, highscore_d).background_img = SPR_TYCOON_IMG1_BEGIN;
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   913
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   914
		if (_local_player != OWNER_SPECTATOR) {
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   915
			const Player *p = DEREF_PLAYER(_local_player);
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   916
			if (p->old_economy[0].performance_history == SCORE_MAX)
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   917
				WP(w, highscore_d).background_img = SPR_TYCOON_IMG2_BEGIN;
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   918
		}
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   919
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   920
		/* In a network game show the endscores of the custom difficulty 'network' which is the last one
1077
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   921
		 * as well as generate a TOP5 of that game, and not an all-time top5. */
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   922
		if (_networking) {
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   923
			w->window_number = lengthof(_highscore_table) - 1;
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   924
			WP(w, highscore_d).rank = SaveHighScoreValueNetwork();
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   925
		} else {
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   926
			// in single player _local player is always valid
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   927
			const Player *p = DEREF_PLAYER(_local_player);
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   928
			w->window_number = _opt.diff_level;
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   929
			WP(w, highscore_d).rank = SaveHighScoreValue(p);
3a38f07dddcc (svn r1578) -Fix: [1102454] dedicated server crashes after some hours (highscore problems for dedicated...should be really solved now)
darkvater
parents: 1067
diff changeset
   930
		}
1109
1bab892228cd (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1077
diff changeset
   931
	}
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 930
diff changeset
   932
}