src/subsidy_gui.cpp
author rubidium
Fri, 25 Apr 2008 15:22:32 +0000
changeset 9055 4dc6a0c0ef47
parent 8852 c5e9e67b130a
child 9094 48004fcef409
permissions -rw-r--r--
(svn r12897) -Codechange: some coding style in station_cmd.cpp.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6328
diff changeset
     3
/** @file subsidy_gui.cpp */
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6328
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1093
diff changeset
     6
#include "openttd.h"
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8264
diff changeset
     7
#include "station_base.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
#include "industry.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "town.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    10
#include "economy_func.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 1962
diff changeset
    11
#include "variables.h"
6328
1a886da998fa (svn r9300) -Codechange: Use cargo's town effect property in the subsidy gui
peter1138
parents: 6247
diff changeset
    12
#include "cargotype.h"
8106
e6790dd9e750 (svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium
parents: 7956
diff changeset
    13
#include "window_gui.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8106
diff changeset
    14
#include "strings_func.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8131
diff changeset
    15
#include "date_func.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8140
diff changeset
    16
#include "viewport_func.h"
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8140
diff changeset
    17
#include "gfx_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    19
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    20
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
static void HandleSubsidyClick(int y)
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    22
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2857
diff changeset
    23
	const Subsidy *s;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    24
	uint num;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    25
	int offs;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
	TileIndex xy;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    28
	if (y < 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
	num = 0;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    31
	for (s = _subsidies; s != endof(_subsidies); s++) {
2469
59a0073914d8 (svn r2995) Replace 0xFF/0xFFFF with CT_INVALID/OWNER_SPECTATOR/INVALID_STATION where appropriate
tron
parents: 2186
diff changeset
    32
		if (s->cargo_type != CT_INVALID && s->age < 12) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
			y -= 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
			if (y < 0) goto handle_click;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
			num++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
	if (num == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
		y -= 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
		if (y < 0) return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
	y -= 11;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
	if (y < 0) return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    47
	for (s = _subsidies; s != endof(_subsidies); s++) {
2469
59a0073914d8 (svn r2995) Replace 0xFF/0xFFFF with CT_INVALID/OWNER_SPECTATOR/INVALID_STATION where appropriate
tron
parents: 2186
diff changeset
    48
		if (s->cargo_type != CT_INVALID && s->age >= 12) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
			y -= 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
			if (y < 0) goto handle_click;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
	return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    54
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
handle_click:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
6328
1a886da998fa (svn r9300) -Codechange: Use cargo's town effect property in the subsidy gui
peter1138
parents: 6247
diff changeset
    57
	TownEffect te = GetCargo(s->cargo_type)->town_effect;
1a886da998fa (svn r9300) -Codechange: Use cargo's town effect property in the subsidy gui
peter1138
parents: 6247
diff changeset
    58
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
	/* determine from coordinate for subsidy and try to scroll to it */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
	offs = s->from;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
	if (s->age >= 12) {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 867
diff changeset
    62
		xy = GetStation(offs)->xy;
6328
1a886da998fa (svn r9300) -Codechange: Use cargo's town effect property in the subsidy gui
peter1138
parents: 6247
diff changeset
    63
	} else if (te == TE_PASSENGERS || te == TE_MAIL) {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 867
diff changeset
    64
		xy = GetTown(offs)->xy;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
	} else {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 867
diff changeset
    66
		xy = GetIndustry(offs)->xy;
6328
1a886da998fa (svn r9300) -Codechange: Use cargo's town effect property in the subsidy gui
peter1138
parents: 6247
diff changeset
    67
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    68
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
	if (!ScrollMainWindowToTile(xy)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
		/* otherwise determine to coordinate for subsidy and scroll to it */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
		offs = s->to;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
		if (s->age >= 12) {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 867
diff changeset
    73
			xy = GetStation(offs)->xy;
6328
1a886da998fa (svn r9300) -Codechange: Use cargo's town effect property in the subsidy gui
peter1138
parents: 6247
diff changeset
    74
		} else if (te == TE_PASSENGERS || te == TE_MAIL || te == TE_GOODS || te == TE_FOOD) {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 867
diff changeset
    75
			xy = GetTown(offs)->xy;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
		} else {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 867
diff changeset
    77
			xy = GetIndustry(offs)->xy;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
		ScrollMainWindowToTile(xy);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2857
diff changeset
    83
static void DrawSubsidiesWindow(const Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	YearMonthDay ymd;
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2857
diff changeset
    86
	const Subsidy *s;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    87
	uint num;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    88
	int x;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    89
	int y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
4288
393de75451b1 (svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
rubidium
parents: 4261
diff changeset
    93
	ConvertDateToYMD(_date, &ymd);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
8813
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
    95
	int width = w->width - 13;  // scroll bar = 11 + pixel each side
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	y = 15;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
	x = 1;
8852
c5e9e67b130a (svn r12609) -Codechange: Remove wrong comments and give more comments on the drawing part of subsidies
belugas
parents: 8813
diff changeset
    98
c5e9e67b130a (svn r12609) -Codechange: Remove wrong comments and give more comments on the drawing part of subsidies
belugas
parents: 8813
diff changeset
    99
	/* Section for drawing the offered subisidies */
7956
b6b1b5d53252 (svn r11512) -Change: make the subsidy window able to resize to something smaller than 640x127 (especially the 640 part) when the screen is really too small.
rubidium
parents: 7824
diff changeset
   100
	DrawStringTruncated(x, y, STR_2026_SUBSIDIES_ON_OFFER_FOR, TC_FROMSTRING, width);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
	y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
	num = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   104
	for (s = _subsidies; s != endof(_subsidies); s++) {
2469
59a0073914d8 (svn r2995) Replace 0xFF/0xFFFF with CT_INVALID/OWNER_SPECTATOR/INVALID_STATION where appropriate
tron
parents: 2186
diff changeset
   105
		if (s->cargo_type != CT_INVALID && s->age < 12) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   106
			int x2;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   107
8852
c5e9e67b130a (svn r12609) -Codechange: Remove wrong comments and give more comments on the drawing part of subsidies
belugas
parents: 8813
diff changeset
   108
			/* Displays the two offered towns */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
			SetupSubsidyDecodeParam(s, 1);
7956
b6b1b5d53252 (svn r11512) -Change: make the subsidy window able to resize to something smaller than 640x127 (especially the 640 part) when the screen is really too small.
rubidium
parents: 7824
diff changeset
   110
			x2 = DrawStringTruncated(x + 2, y, STR_2027_FROM_TO, TC_FROMSTRING, width);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   111
8852
c5e9e67b130a (svn r12609) -Codechange: Remove wrong comments and give more comments on the drawing part of subsidies
belugas
parents: 8813
diff changeset
   112
			/* Displays the deadline before voiding the proposal */
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   113
			SetDParam(0, _date - ymd.day + 384 - s->age * 32);
7956
b6b1b5d53252 (svn r11512) -Change: make the subsidy window able to resize to something smaller than 640x127 (especially the 640 part) when the screen is really too small.
rubidium
parents: 7824
diff changeset
   114
			DrawStringTruncated(x2, y, STR_2028_BY, TC_FROMSTRING, width - x2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
			num++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
		}
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
	if (num == 0) {
7956
b6b1b5d53252 (svn r11512) -Change: make the subsidy window able to resize to something smaller than 640x127 (especially the 640 part) when the screen is really too small.
rubidium
parents: 7824
diff changeset
   121
		DrawStringTruncated(x + 2, y, STR_202A_NONE, TC_FROMSTRING, width - 2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
		y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
8852
c5e9e67b130a (svn r12609) -Codechange: Remove wrong comments and give more comments on the drawing part of subsidies
belugas
parents: 8813
diff changeset
   125
	/* Section for drawing the already granted subisidies */
7956
b6b1b5d53252 (svn r11512) -Change: make the subsidy window able to resize to something smaller than 640x127 (especially the 640 part) when the screen is really too small.
rubidium
parents: 7824
diff changeset
   126
	DrawStringTruncated(x, y + 1, STR_202B_SERVICES_ALREADY_SUBSIDISED, TC_FROMSTRING, width);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	num = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   130
	for (s = _subsidies; s != endof(_subsidies); s++) {
2469
59a0073914d8 (svn r2995) Replace 0xFF/0xFFFF with CT_INVALID/OWNER_SPECTATOR/INVALID_STATION where appropriate
tron
parents: 2186
diff changeset
   131
		if (s->cargo_type != CT_INVALID && s->age >= 12) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   132
			int xt;
2630
7206058a7e82 (svn r3172) static, const
tron
parents: 2469
diff changeset
   133
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
			SetupSubsidyDecodeParam(s, 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
7058
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 6420
diff changeset
   136
			PlayerID player = GetStation(s->to)->owner;
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 6420
diff changeset
   137
			SetDParam(3, player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
8852
c5e9e67b130a (svn r12609) -Codechange: Remove wrong comments and give more comments on the drawing part of subsidies
belugas
parents: 8813
diff changeset
   139
			/* Displays the two connected stations */
7956
b6b1b5d53252 (svn r11512) -Change: make the subsidy window able to resize to something smaller than 640x127 (especially the 640 part) when the screen is really too small.
rubidium
parents: 7824
diff changeset
   140
			xt = DrawStringTruncated(x + 2, y, STR_202C_FROM_TO, TC_FROMSTRING, width - 2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
8852
c5e9e67b130a (svn r12609) -Codechange: Remove wrong comments and give more comments on the drawing part of subsidies
belugas
parents: 8813
diff changeset
   142
			/* Displays the date where the granted subsidy will end */
c5e9e67b130a (svn r12609) -Codechange: Remove wrong comments and give more comments on the drawing part of subsidies
belugas
parents: 8813
diff changeset
   143
			if ((xt > 3) && (width - xt) > 9 ) { // do not draw if previous drawing failed or if it will overlap on scrollbar
8813
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
   144
				SetDParam(0, _date - ymd.day + 768 - s->age * 32);
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
   145
				DrawStringTruncated(xt, y, STR_202D_UNTIL, TC_FROMSTRING, width - xt);
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
   146
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
			num++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
7956
b6b1b5d53252 (svn r11512) -Change: make the subsidy window able to resize to something smaller than 640x127 (especially the 640 part) when the screen is really too small.
rubidium
parents: 7824
diff changeset
   152
	if (num == 0) DrawStringTruncated(x + 2, y, STR_202A_NONE, TC_FROMSTRING, width - 2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
static void SubsidiesListWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   157
	switch (e->event) {
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   158
		case WE_PAINT: DrawSubsidiesWindow(w); break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   159
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   160
		case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4288
diff changeset
   161
			switch (e->we.click.widget) {
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4288
diff changeset
   162
				case 3:
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4288
diff changeset
   163
					HandleSubsidyClick(e->we.click.pt.y - 25);
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4288
diff changeset
   164
					break;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   165
			}
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   166
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
static const Widget _subsidies_list_widgets[] = {
8813
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
   171
{   WWT_CLOSEBOX, RESIZE_NONE,   13,   0,  10,   0,  13, STR_00C5,           STR_018B_CLOSE_WINDOW},
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
   172
{    WWT_CAPTION, RESIZE_RIGHT,  13,  11, 307,   0,  13, STR_2025_SUBSIDIES, STR_018C_WINDOW_TITLE_DRAG_THIS},
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
   173
{  WWT_STICKYBOX, RESIZE_LR,     13, 308, 319,   0,  13, STR_NULL,           STR_STICKY_BUTTON},
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
   174
{      WWT_PANEL, RESIZE_RB,     13,   0, 307,  14, 126, 0x0,                STR_01FD_CLICK_ON_SERVICE_TO_CENTER},
8852
c5e9e67b130a (svn r12609) -Codechange: Remove wrong comments and give more comments on the drawing part of subsidies
belugas
parents: 8813
diff changeset
   175
{  WWT_SCROLLBAR, RESIZE_LRB,    13, 308, 319,  14, 114, 0x0,                STR_0190_SCROLL_BAR_SCROLLS_LIST},
c5e9e67b130a (svn r12609) -Codechange: Remove wrong comments and give more comments on the drawing part of subsidies
belugas
parents: 8813
diff changeset
   176
{  WWT_RESIZEBOX, RESIZE_LRTB,   13, 308, 319, 115, 126, 0x0,                STR_RESIZE_BUTTON},
8813
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
   177
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 0
diff changeset
   178
{   WIDGETS_END},
0
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
static const WindowDesc _subsidies_list_desc = {
8813
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
   182
	WDP_AUTO, WDP_AUTO, 320, 127, 320, 127,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5584
diff changeset
   183
	WC_SUBSIDIES_LIST, WC_NONE,
8813
80db9335a3f2 (svn r12558) -Feature: subsidy window can now be resized.
belugas
parents: 8785
diff changeset
   184
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
	_subsidies_list_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
	SubsidiesListWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
};
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
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5893
diff changeset
   190
void ShowSubsidiesList()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
	AllocateWindowDescFront(&_subsidies_list_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
}