src/network/newgrf_download.cpp
author Tero Marttila <terom@fixme.fi>
Fri, 18 Jul 2008 21:59:53 +0300
changeset 11176 874f8008e6e5
parent 11175 020c61e39c94
child 11177 6d9a43c48924
permissions -rw-r--r--
have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
/* $Id$ */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
/** @file newgrf_download.cpp GUI to download NewGRFs. */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
#include "../stdafx.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
#include "../openttd.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
#include "../strings_func.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
#include "../date_func.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
#include "../gui.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
#include "../window_gui.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
#include "../textbuf_gui.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
#include "../variables.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
#include "../newgrf.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
#include "newgrf_download.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
#include "../functions.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
#include "../window_func.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
#include "../core/alloc_func.hpp"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
#include "../string_func.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
#include "../gfx_func.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
#include "../querystring_gui.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
#include "../sortlist_type.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
#include "table/strings.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
#include "../table/sprites.h"
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
// XXX: copy-pasted from newgrf_gui.cpp
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
static void ShowDownloadNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, uint bottom, bool show_params)
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
{
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
	char buff[256];
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
	if (c->error != NULL) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
		char message[512];
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
		if (c->error->custom_message == NULL) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
			SetDParamStr(0, c->filename);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
			SetDParamStr(1, c->error->data);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
			for (uint i = 0; i < c->error->num_params; i++) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
				uint32 param = 0;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
				byte param_number = c->error->param_number[i];
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
				if (param_number < c->num_params) param = c->param[param_number];
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
				SetDParam(2 + i, param);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
			}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
			GetString(message, c->error->message, lastof(message));
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    45
		} else {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    46
			SetDParamStr(0, c->error->custom_message);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
			GetString(message, STR_JUST_RAW_STRING, lastof(message));
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
		}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    49
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    50
		SetDParamStr(0, message);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    51
		y += DrawStringMultiLine(x, y, c->error->severity, w, bottom - y);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    52
	}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    53
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    54
	/* Draw filename or not if it is not known (GRF sent over internet) */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    55
	if (c->filename != NULL) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    56
		SetDParamStr(0, c->filename);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    57
		y += DrawStringMultiLine(x, y, STR_NEWGRF_FILENAME, w, bottom - y);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    58
	}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    59
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    60
	/* Prepare and draw GRF ID */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    61
	snprintf(buff, lengthof(buff), "%08X", BSWAP32(c->grfid));
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    62
	SetDParamStr(0, buff);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    63
	y += DrawStringMultiLine(x, y, STR_NEWGRF_GRF_ID, w, bottom - y);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    64
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    65
	/* Prepare and draw MD5 sum */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    66
	md5sumToString(buff, lastof(buff), c->md5sum);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    67
	SetDParamStr(0, buff);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    68
	y += DrawStringMultiLine(x, y, STR_NEWGRF_MD5SUM, w, bottom - y);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    69
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    70
	/* Show GRF parameter list */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    71
	if (show_params) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    72
		if (c->num_params > 0) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    73
			GRFBuildParamList(buff, c, lastof(buff));
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    74
			SetDParam(0, STR_JUST_RAW_STRING);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    75
			SetDParamStr(1, buff);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    76
		} else {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    77
			SetDParam(0, STR_01A9_NONE);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    78
		}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    79
		y += DrawStringMultiLine(x, y, STR_NEWGRF_PARAMETER, w, bottom - y);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    80
	}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    81
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    82
	/* Show flags */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    83
	if (c->status == GCS_NOT_FOUND)        y += DrawStringMultiLine(x, y, STR_NEWGRF_NOT_FOUND, w, bottom - y);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    84
	if (c->status == GCS_DISABLED)         y += DrawStringMultiLine(x, y, STR_NEWGRF_DISABLED, w, bottom - y);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    85
	if (HasBit(c->flags, GCF_COMPATIBLE)) y += DrawStringMultiLine(x, y, STR_NEWGRF_COMPATIBLE_LOADED, w, bottom - y);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    86
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    87
	/* Draw GRF info if it exists */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    88
	if (c->info != NULL && !StrEmpty(c->info)) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    89
		SetDParam(0, STR_JUST_RAW_STRING);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    90
		SetDParamStr(1, c->info);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    91
		y += DrawStringMultiLine(x, y, STR_02BD, w, bottom - y);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    92
	} else {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    93
		y += DrawStringMultiLine(x, y, STR_NEWGRF_NO_INFO, w, bottom - y);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    94
	}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    95
}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    96
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    97
/**
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    98
 * Window for downloading NewGRF files
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    99
 */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   100
struct NewGRFDownloadWindow : public Window {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   101
	/* Names of the add a newgrf window widgets */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   102
	enum DownloadNewGRFWindowWidgets {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   103
        DNGRFS_CLOSEBOX = 0,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   104
		DNGRFS_CAPTION,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   105
		DNGRFS_BACKGROUND,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   106
		DNGRFS_FILE_LIST,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   107
		DNGRFS_SCROLLBAR,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   108
		DNGRFS_NEWGRF_INFO,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   109
		DNGRFS_CHECK_AVAILABLE,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   110
		DNGRFS_DOWNLOAD_AVAILABLE,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   111
		DNGRFS_RESIZE,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   112
	};
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   113
    
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   114
    // XXX: do we need a temp. copy? I think not
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   115
	GRFConfig *list;       ///< temporary grf list to which changes are made
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   116
	const GRFConfig *sel;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   117
11176
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   118
	NewGRFDownloadWindow(const WindowDesc *desc, GRFConfig *list) : Window(desc, 0)
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   119
	{
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   120
        // resize magic
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   121
		this->resize.step_height = 14;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   122
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   123
        // the list of GRFs
11176
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   124
        this->list = list;
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   125
        
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   126
        // display window?
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   127
		this->FindWindowPlacementAndResize(desc);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   128
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   129
        // set up our own state
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   130
		this->SetupDownloadNewGRFWindow();
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   131
	}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   132
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   133
	~NewGRFDownloadWindow()
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   134
	{
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   135
		/* Remove the temporary copy of grf-list used in window */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   136
		ClearGRFConfigList(&this->list);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   137
    }
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   138
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   139
    void SetupDownloadNewGRFWindow()
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   140
	{
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   141
		const GRFConfig *c;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   142
		int i;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   143
        
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   144
        // count how many NewGRFs in our list
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   145
		for (c = this->list, i = 0; c != NULL; c = c->next, i++) {}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   146
        
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   147
        // something to do with vertical scrolling...
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   148
		this->vscroll.cap = (this->widget[DNGRFS_FILE_LIST].bottom - this->widget[DNGRFS_FILE_LIST].top) / 14 + 1;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   149
		SetVScrollCount(this, i);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   150
        
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   151
        // disable the "Check Available" button if there are no incompatible NewGRFs
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   152
		this->SetWidgetDisabledState(DNGRFS_CHECK_AVAILABLE, (i == 0));
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   153
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   154
        // disable the "Download Available" button until we've checked for available NewGRFs
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   155
		this->SetWidgetDisabledState(DNGRFS_DOWNLOAD_AVAILABLE, 1);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   156
	}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   157
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   158
    virtual void OnPaint()
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   159
	{
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   160
        // superclass widget-drawing
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   161
		this->DrawWidgets();
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   162
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   163
		/* Draw the NewGRF file list */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   164
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   165
		int y = this->widget[DNGRFS_FILE_LIST].top;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   166
		int i = 0;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   167
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   168
        // for each GRF...
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   169
		for (const GRFConfig *c = this->list; c != NULL; c = c->next, i++) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   170
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   171
            // is scrolled into view
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   172
			if (i >= this->vscroll.pos && i < this->vscroll.pos + this->vscroll.cap) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   173
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   174
				SpriteID pal;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   175
				byte txtoffset;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   176
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   177
                // the NewGRF name
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   178
				const char *text = (c->name != NULL && !StrEmpty(c->name)) ? c->name : c->filename;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   179
11175
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   180
				/* 
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   181
                 * Pick a colour 
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   182
                 *
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   183
                 *  orange  - server has it, we don't, haven't checked availablity yet
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   184
                 *  red     - not available
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   185
                 *  green   - available
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   186
                 *  blue    - downloaded
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   187
                 */
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   188
				switch (c->status) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   189
					case GCS_NOT_FOUND:
11175
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   190
                        pal = PALETTE_TO_ORANGE;
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   191
                        break;
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   192
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   193
					case GCS_DISABLED:
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   194
						pal = PALETTE_TO_RED;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   195
						break;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   196
11175
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   197
					case GCS_AVAILABLE:
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   198
						pal = PALETTE_TO_GREEN;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   199
						break;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   200
11175
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   201
					default:    // GCS_INITIALIZED or GCS_ACTIVATED
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   202
						pal = PALETTE_TO_BLUE;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   203
						break;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   204
				}
11175
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   205
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   206
            /*
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   207
                 XXX: flags?
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   208
				if (pal != PALETTE_TO_RED) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   209
					if (HasBit(c->flags, GCF_STATIC)) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   210
						pal = PALETTE_TO_GREY;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   211
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   212
					} else if (HasBit(c->flags, GCF_COMPATIBLE)) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   213
						pal = PALETTE_TO_ORANGE;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   214
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   215
					}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   216
				}
11175
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   217
            */
020c61e39c94 added a GCS_AVAILABLE status, and changed the colours used in the download GUI
Tero Marttila <terom@fixme.fi>
parents: 11174
diff changeset
   218
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   219
                // draw the square in the chosen colour
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   220
				DrawSprite(SPR_SQUARE, pal, 5, y + 2);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   221
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   222
                // XXX: hmm... use for download errors?
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   223
				if (c->error != NULL) DrawSprite(SPR_WARNING_SIGN, 0, 20, y + 2);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   224
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   225
                // where to draw the text
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   226
				txtoffset = c->error != NULL ? 35 : 25;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   227
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   228
                // draw the chosen text (GRF name/filename)
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   229
				DoDrawStringTruncated(text, txtoffset, y + 3, this->sel == c ? TC_WHITE : TC_BLACK, this->width - txtoffset - 10);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   230
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   231
                // advance on to the next row
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   232
				y += 14;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   233
			}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   234
		}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   235
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   236
		if (this->sel != NULL) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   237
			/* Draw NewGRF file info */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   238
			const Widget *wi = &this->widget[DNGRFS_NEWGRF_INFO];
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   239
    
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   240
			ShowDownloadNewGRFInfo(this->sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, wi->bottom, false);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   241
		}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   242
	}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   243
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   244
	virtual void OnClick(Point pt, int widget)
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   245
	{
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   246
		switch (widget) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   247
            case DNGRFS_CHECK_AVAILABLE:
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   248
                // XXX: implement
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   249
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   250
                break;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   251
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   252
            case DNGRFS_DOWNLOAD_AVAILABLE:
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   253
                // XXX: implement
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   254
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   255
                break;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   256
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   257
			case DNGRFS_FILE_LIST: { // Select a GRF
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   258
				GRFConfig *c;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   259
				uint i = (pt.y - this->widget[DNGRFS_FILE_LIST].top) / 14 + this->vscroll.pos;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   260
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   261
				for (c = this->list; c != NULL && i > 0; c = c->next, i--) {}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   262
				this->sel = c;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   263
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   264
				this->SetDirty();
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   265
				break;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   266
			}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   267
		}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   268
	}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   269
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   270
    virtual void OnResize(Point new_size, Point delta)
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   271
	{
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   272
		if (delta.x != 0) {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   273
			ResizeButtons(this, DNGRFS_CHECK_AVAILABLE, DNGRFS_DOWNLOAD_AVAILABLE);
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   274
		}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   275
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   276
		this->vscroll.cap += delta.y / 14;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   277
		this->widget[DNGRFS_FILE_LIST].data = (this->vscroll.cap << 8) + 1;
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   278
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   279
		this->SetupDownloadNewGRFWindow();
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   280
	}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   281
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   282
	virtual void OnInvalidateData(int data = 0)
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   283
	{
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   284
		this->SetupDownloadNewGRFWindow();
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   285
	}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   286
};
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   287
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   288
/* Widget definition of the download newgrfs window */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   289
static const Widget _newgrf_download_widgets[] = {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   290
{   WWT_CLOSEBOX,  RESIZE_NONE, 10,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW },            // DNGRFS_CLOSEBOX
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   291
{    WWT_CAPTION, RESIZE_RIGHT, 10,  11, 299,   0,  13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS },  // DNGRFS_CAPTION
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   292
{      WWT_PANEL, RESIZE_RIGHT, 10,   0, 299,  14,  29, STR_NULL,                    STR_NULL },                         // DNGRFS_BACKGROUND
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   293
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   294
    /*
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   295
{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  10,  79,  16,  27, STR_NEWGRF_ADD,              STR_NEWGRF_ADD_TIP },               // SNGRFS_ADD
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   296
{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  80, 149,  16,  27, STR_NEWGRF_REMOVE,           STR_NEWGRF_REMOVE_TIP },            // SNGRFS_REMOVE
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   297
{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3, 150, 219,  16,  27, STR_NEWGRF_MOVEUP,           STR_NEWGRF_MOVEUP_TIP },            // SNGRFS_MOVE_UP
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   298
{ WWT_PUSHTXTBTN, RESIZE_RIGHT,  3, 220, 289,  16,  27, STR_NEWGRF_MOVEDOWN,         STR_NEWGRF_MOVEDOWN_TIP },          // SNGRFS_MOVE_DOWN
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   299
    */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   300
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   301
{     WWT_MATRIX,    RESIZE_RB, 10,   0, 287,  30,  99, 0x501,                       STR_NEWGRF_DOWNLOAD_LIST_TIP },     // DNGRFS_FILE_LIST
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   302
{  WWT_SCROLLBAR,   RESIZE_LRB, 10, 288, 299,  30,  99, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST }, // DNGRFS_SCROLLBAR
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   303
{      WWT_PANEL,   RESIZE_RTB, 10,   0, 299, 100, 212, STR_NULL,                    STR_NULL },                         // DNGRFS_NEWGRF_INFO
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   304
{ WWT_PUSHTXTBTN,    RESIZE_TB, 10,   0, 143, 213, 224, STR_NEWGRF_CHECK_AVAILABLE,  STR_NULL },                         // DNGRFS_CHECK_AVILABLE
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   305
{ WWT_PUSHTXTBTN,   RESIZE_RTB, 10, 144, 287, 213, 224, STR_NEWGRF_DOWNLOAD_AVAILABLE,  STR_NULL },                      // DNGRFS_DOWNLOAD_AVAILABLE
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   306
{  WWT_RESIZEBOX,  RESIZE_LRTB, 10, 288, 299, 213, 224, 0x0,                         STR_RESIZE_BUTTON },                // DNGRFS_RESIZE
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   307
{ WIDGETS_END },
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   308
};
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   309
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   310
/* Window definition of the manage newgrfs window */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   311
static const WindowDesc _newgrf_download_desc = {
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   312
	WDP_CENTER, WDP_CENTER, 300, 225, 300, 225,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   313
	WC_GAME_OPTIONS, WC_NONE,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   314
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   315
	_newgrf_download_widgets,
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   316
};
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   317
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   318
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   319
/** Setup the NewGRF download gui
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   320
 * @param config pointer to a linked-list of grfconfig's needed */
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   321
void ShowNewGRFDownload(GRFConfig **config)
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   322
{
11176
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   323
    // filter out those that we don't need to download
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   324
    GRFConfig *head = NULL, **item = &head;
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   325
    const GRFConfig *src;
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   326
    
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   327
    for (src = *config; src != NULL; src = src->next) {
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   328
        if (src->status == GCS_NOT_FOUND || HasBit(src->flags, GCF_COMPATIBLE)) {
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   329
            // copy-past from newgrf_config.cpp CopyGRFConfigList
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   330
            GRFConfig *c = CallocT<GRFConfig>(1);
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   331
            *c = *src;
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   332
            if (src->filename  != NULL) c->filename  = strdup(src->filename);
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   333
            if (src->name      != NULL) c->name      = strdup(src->name);
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   334
            if (src->info      != NULL) c->info      = strdup(src->info);
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   335
            if (src->error     != NULL) {
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   336
                c->error = CallocT<GRFError>(1);
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   337
                memcpy(c->error, src->error, sizeof(GRFError));
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   338
                if (src->error->data != NULL) c->error->data = strdup(src->error->data);
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   339
                if (src->error->custom_message != NULL) c->error->custom_message = strdup(src->error->custom_message);
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   340
            }
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   341
            
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   342
            *item = c;
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   343
            item = &c->next;
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   344
        }
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   345
    }
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   346
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   347
	DeleteWindowByClass(WC_GAME_OPTIONS);
11176
874f8008e6e5 have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
Tero Marttila <terom@fixme.fi>
parents: 11175
diff changeset
   348
	new NewGRFDownloadWindow(&_newgrf_download_desc, head);
11174
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   349
}
b29402c54ffe create the newgrf download GUI (mostly by copy-pasting from newgrf_gui.cpp) - compiles, needs testing
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   350