mirror of https://github.com/OpenTTD/OpenTTD
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
parent
9a87e1e0ea
commit
c7d3d996bf
1
Makefile
1
Makefile
|
@ -735,6 +735,7 @@ SRCS += newgrf.c
|
||||||
SRCS += newgrf_cargo.c
|
SRCS += newgrf_cargo.c
|
||||||
SRCS += newgrf_config.c
|
SRCS += newgrf_config.c
|
||||||
SRCS += newgrf_engine.c
|
SRCS += newgrf_engine.c
|
||||||
|
SRCS += newgrf_gui.c
|
||||||
SRCS += newgrf_sound.c
|
SRCS += newgrf_sound.c
|
||||||
SRCS += newgrf_spritegroup.c
|
SRCS += newgrf_spritegroup.c
|
||||||
SRCS += newgrf_station.c
|
SRCS += newgrf_station.c
|
||||||
|
|
1
gui.h
1
gui.h
|
@ -17,7 +17,6 @@ void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||||
void ShowGameOptions(void);
|
void ShowGameOptions(void);
|
||||||
void ShowGameDifficulty(void);
|
void ShowGameDifficulty(void);
|
||||||
void ShowPatchesSelection(void);
|
void ShowPatchesSelection(void);
|
||||||
void ShowNewgrf(void);
|
|
||||||
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right);
|
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right);
|
||||||
|
|
||||||
/* graph_gui.c */
|
/* graph_gui.c */
|
||||||
|
|
12
intro_gui.c
12
intro_gui.c
|
@ -15,10 +15,11 @@
|
||||||
#include "heightmap.h"
|
#include "heightmap.h"
|
||||||
#include "genworld.h"
|
#include "genworld.h"
|
||||||
#include "network_gui.h"
|
#include "network_gui.h"
|
||||||
|
#include "newgrf.h"
|
||||||
|
|
||||||
static const Widget _select_game_widgets[] = {
|
static const Widget _select_game_widgets[] = {
|
||||||
{ WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL},
|
{ WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL},
|
||||||
{ WWT_PANEL, RESIZE_NONE, 13, 0, 335, 14, 176, 0x0, STR_NULL},
|
{ WWT_PANEL, RESIZE_NONE, 13, 0, 335, 14, 194, 0x0, STR_NULL},
|
||||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME},
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME},
|
||||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 22, 33, STR_0141_LOAD_GAME, STR_02FC_LOAD_A_SAVED_GAME},
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 22, 33, STR_0141_LOAD_GAME, STR_02FC_LOAD_A_SAVED_GAME},
|
||||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 40, 51, STR_029A_PLAY_SCENARIO, STR_0303_START_A_NEW_GAME_USING},
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 40, 51, STR_029A_PLAY_SCENARIO, STR_0303_START_A_NEW_GAME_USING},
|
||||||
|
@ -34,7 +35,9 @@ static const Widget _select_game_widgets[] = {
|
||||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 139, 150, STR_0148_GAME_OPTIONS, STR_0301_DISPLAY_GAME_OPTIONS},
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 139, 150, STR_0148_GAME_OPTIONS, STR_0301_DISPLAY_GAME_OPTIONS},
|
||||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 139, 150, STR_01FE_DIFFICULTY, STR_0302_DISPLAY_DIFFICULTY_OPTIONS},
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 139, 150, STR_01FE_DIFFICULTY, STR_0302_DISPLAY_DIFFICULTY_OPTIONS},
|
||||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 157, 168, STR_CONFIG_PATCHES, STR_CONFIG_PATCHES_TIP},
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 157, 168, STR_CONFIG_PATCHES, STR_CONFIG_PATCHES_TIP},
|
||||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 157, 168, STR_0304_QUIT, STR_0305_QUIT_OPENTTD},
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 157, 168, STR_NEWGRF_SETTINGS_BUTTON, STR_NULL},
|
||||||
|
|
||||||
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 175, 186, STR_0304_QUIT, STR_0305_QUIT_OPENTTD},
|
||||||
{ WIDGETS_END},
|
{ WIDGETS_END},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,7 +84,8 @@ static void SelectGameWndProc(Window *w, WindowEvent *e)
|
||||||
case 12: ShowGameOptions(); break;
|
case 12: ShowGameOptions(); break;
|
||||||
case 13: ShowGameDifficulty(); break;
|
case 13: ShowGameDifficulty(); break;
|
||||||
case 14: ShowPatchesSelection(); break;
|
case 14: ShowPatchesSelection(); break;
|
||||||
case 15: HandleExitGameRequest(); break;
|
case 15: ShowNewGRFSettings(true, true, &_grfconfig_newgame); break;
|
||||||
|
case 16: HandleExitGameRequest(); break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -90,7 +94,7 @@ static void SelectGameWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const WindowDesc _select_game_desc = {
|
static const WindowDesc _select_game_desc = {
|
||||||
WDP_CENTER, WDP_CENTER, 336, 177,
|
WDP_CENTER, WDP_CENTER, 336, 195,
|
||||||
WC_SELECT_GAME,0,
|
WC_SELECT_GAME,0,
|
||||||
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
||||||
_select_game_widgets,
|
_select_game_widgets,
|
||||||
|
|
|
@ -760,7 +760,7 @@ STR_CHECKMARK :{CHECKMARK}
|
||||||
STR_02C3_GAME_OPTIONS :Game options
|
STR_02C3_GAME_OPTIONS :Game options
|
||||||
STR_02C5_DIFFICULTY_SETTINGS :Difficulty settings
|
STR_02C5_DIFFICULTY_SETTINGS :Difficulty settings
|
||||||
STR_02C7_CONFIG_PATCHES :Configure patches
|
STR_02C7_CONFIG_PATCHES :Configure patches
|
||||||
STR_NEWGRF_SETTINGS :Newgrf settings
|
STR_NEWGRF_SETTINGS :NewGRF settings
|
||||||
STR_GAMEOPTMENU_0A :
|
STR_GAMEOPTMENU_0A :
|
||||||
STR_02CA_TOWN_NAMES_DISPLAYED :{SETX 12}Town names displayed
|
STR_02CA_TOWN_NAMES_DISPLAYED :{SETX 12}Town names displayed
|
||||||
STR_02CC_STATION_NAMES_DISPLAYED :{SETX 12}Station names displayed
|
STR_02CC_STATION_NAMES_DISPLAYED :{SETX 12}Station names displayed
|
||||||
|
@ -2870,13 +2870,37 @@ STR_PERFORMANCE_DETAIL_MONEY_TIP :{BLACK}Amount o
|
||||||
STR_PERFORMANCE_DETAIL_LOAN_TIP :{BLACK}The amount of money this company has taken on loan
|
STR_PERFORMANCE_DETAIL_LOAN_TIP :{BLACK}The amount of money this company has taken on loan
|
||||||
STR_PERFORMANCE_DETAIL_TOTAL_TIP :{BLACK}Total points out of possible points
|
STR_PERFORMANCE_DETAIL_TOTAL_TIP :{BLACK}Total points out of possible points
|
||||||
|
|
||||||
STR_NEWGRF_SETTINGS_CAPTION :{WHITE}Newgrf settings
|
STR_NEWGRF_SETTINGS_BUTTON :{BLACK}NewGRF Settings
|
||||||
|
STR_NEWGRF_SETTINGS_CAPTION :{WHITE}NewGRF settings
|
||||||
STR_NEWGRF_APPLY_CHANGES :{BLACK}Apply changes
|
STR_NEWGRF_APPLY_CHANGES :{BLACK}Apply changes
|
||||||
STR_NEWGRF_SET_PARAMETERS :{BLACK}Set parameters
|
STR_NEWGRF_SET_PARAMETERS :{BLACK}Set parameters
|
||||||
STR_NEWGRF_TIP :{BLACK}A list of all the Newgrf sets that you have installed. Click a set to change the settings
|
STR_NEWGRF_TIP :{BLACK}A list of all the Newgrf sets that you have installed. Click a set to change the settings
|
||||||
STR_NEWGRF_NO_FILES_INSTALLED :{BLACK}There are currently no newgrf files installed! Please refer to the manual for instructions on installing new graphics
|
STR_NEWGRF_NO_FILES_INSTALLED :{BLACK}There are currently no newgrf files installed! Please refer to the manual for instructions on installing new graphics
|
||||||
STR_NEWGRF_FILENAME :{BLACK}Filename:
|
STR_NEWGRF_FILENAME :{BLACK}Filename: {SILVER}{STRING}
|
||||||
STR_NEWGRF_GRF_ID :{BLACK}GRF ID:
|
STR_NEWGRF_GRF_ID :{BLACK}GRF ID: {SILVER}{STRING}
|
||||||
|
STR_NEWGRF_MD5SUM :{BLACK}MD5sum: {SILVER}{STRING}
|
||||||
|
|
||||||
|
STR_NEWGRF_ADD :{BLACK}Add
|
||||||
|
STR_NEWGRF_ADD_TIP :{BLACK}Add a NewGRF file to the list
|
||||||
|
STR_NEWGRF_REMOVE :{BLACK}Remove
|
||||||
|
STR_NEWGRF_REMOVE_TIP :{BLACK}Remove the selected NewGRF file from the list
|
||||||
|
STR_NEWGRF_MOVEUP :{BLACK}Move Up
|
||||||
|
STR_NEWGRF_MOVEUP_TIP :{BLACK}Move the selected NewGRF file up the list
|
||||||
|
STR_NEWGRF_MOVEDOWN :{BLACK}Move Down
|
||||||
|
STR_NEWGRF_MOVEDOWN_TIP :{BLACK}Move the selected NewGRF file down the list
|
||||||
|
STR_NEWGRF_FILE_TIP :{BLACK}A list of the NewGRF files that are installed. Click a file to change its parameters
|
||||||
|
STR_NEWGRF_PARAMETER :{BLACK}Parameters: {SILVER}{STRING}
|
||||||
|
STR_NEWGRF_PARAMETER_QUERY :{BLACK}Enter NewGRF parameters
|
||||||
|
STR_NEWGRF_NO_INFO :{BLACK}No information available
|
||||||
|
|
||||||
|
STR_NEWGRF_ADD_CAPTION :{WHITE}Available NewGRF files
|
||||||
|
STR_NEWGRF_ADD_FILE :{BLACK}Add to selection
|
||||||
|
STR_NEWGRF_ADD_FILE_TIP :{BLACK}Add the selected NewGRF file to your configuration
|
||||||
|
STR_NEWGRF_RESCAN_FILES :{BLACK}Rescan files
|
||||||
|
STR_NEWGRF_RESCAN_FILES_TIP :{BLACK}Update the list of available NewGRF files
|
||||||
|
|
||||||
|
STR_NEWGRF_NOT_FOUND :{RED}Matching file not found
|
||||||
|
STR_NEWGRF_DISABLED :{RED}Disabled
|
||||||
|
|
||||||
STR_CURRENCY_WINDOW :{WHITE}Custom currency
|
STR_CURRENCY_WINDOW :{WHITE}Custom currency
|
||||||
STR_CURRENCY_EXCHANGE_RATE :{LTBLUE}Exchange rate: {ORANGE}{CURRENCY} = £ {COMMA}
|
STR_CURRENCY_EXCHANGE_RATE :{LTBLUE}Exchange rate: {ORANGE}{CURRENCY} = £ {COMMA}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
#include "vehicle_gui.h"
|
#include "vehicle_gui.h"
|
||||||
|
#include "newgrf_config.h"
|
||||||
|
|
||||||
#include "network_data.h"
|
#include "network_data.h"
|
||||||
#include "network_client.h"
|
#include "network_client.h"
|
||||||
|
@ -152,7 +153,7 @@ static void MenuClickSettings(int index)
|
||||||
case 0: ShowGameOptions(); return;
|
case 0: ShowGameOptions(); return;
|
||||||
case 1: ShowGameDifficulty(); return;
|
case 1: ShowGameDifficulty(); return;
|
||||||
case 2: ShowPatchesSelection(); return;
|
case 2: ShowPatchesSelection(); return;
|
||||||
case 3: ShowNewgrf(); return;
|
case 3: ShowNewGRFSettings(false, true, &_grfconfig); return;
|
||||||
|
|
||||||
case 5: _display_opt ^= DO_SHOW_TOWN_NAMES; break;
|
case 5: _display_opt ^= DO_SHOW_TOWN_NAMES; break;
|
||||||
case 6: _display_opt ^= DO_SHOW_STATION_NAMES; break;
|
case 6: _display_opt ^= DO_SHOW_STATION_NAMES; break;
|
||||||
|
@ -2450,3 +2451,4 @@ void InitializeMainGui(void)
|
||||||
_last_built_railtype = 0;
|
_last_built_railtype = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,4 +41,7 @@ void ResetGRFConfig(bool defaults);
|
||||||
bool IsGoodGRFConfigList(void);
|
bool IsGoodGRFConfigList(void);
|
||||||
bool FillGRFDetails(GRFConfig *config);
|
bool FillGRFDetails(GRFConfig *config);
|
||||||
|
|
||||||
|
/* In newgrf_gui.c */
|
||||||
|
void ShowNewGRFSettings(bool editable, bool show_params, GRFConfig **config);
|
||||||
|
|
||||||
#endif /* NEWGRF_CONFIG_H */
|
#endif /* NEWGRF_CONFIG_H */
|
||||||
|
|
|
@ -0,0 +1,459 @@
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "openttd.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "variables.h"
|
||||||
|
#include "gfx.h"
|
||||||
|
#include "gui.h"
|
||||||
|
#include "window.h"
|
||||||
|
#include "strings.h"
|
||||||
|
#include "table/strings.h"
|
||||||
|
#include "table/sprites.h"
|
||||||
|
#include "newgrf_config.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Build a space separated list of parameters, and terminate */
|
||||||
|
static char *BuildParamList(char *dst, const GRFConfig *c, const char *last)
|
||||||
|
{
|
||||||
|
uint i;
|
||||||
|
|
||||||
|
/* Return an empty string if there are no parameters */
|
||||||
|
if (c->num_params == 0) return strecpy(dst, "", last);
|
||||||
|
|
||||||
|
for (i = 0; i < c->num_params; i++) {
|
||||||
|
if (i > 0) dst = strecpy(dst, " ", last);
|
||||||
|
dst += snprintf(dst, last - dst, "%d", c->param[i]);
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Parse an integerlist string and set each found value
|
||||||
|
* @param p the string to be parsed. Each element in the list is seperated by a
|
||||||
|
* comma or a space character
|
||||||
|
* @param items pointer to the integerlist-array that will be filled with values
|
||||||
|
* @param maxitems the maximum number of elements the integerlist-array has
|
||||||
|
* @return returns the number of items found, or -1 on an error */
|
||||||
|
static int parse_intlist(const char *p, int *items, int maxitems)
|
||||||
|
{
|
||||||
|
int n = 0, v;
|
||||||
|
char *end;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
v = strtol(p, &end, 0);
|
||||||
|
if (p == end || n == maxitems) return -1;
|
||||||
|
p = end;
|
||||||
|
items[n++] = v;
|
||||||
|
if (*p == '\0') break;
|
||||||
|
if (*p != ',' && *p != ' ') return -1;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, bool show_params)
|
||||||
|
{
|
||||||
|
char buff[512];
|
||||||
|
char *s;
|
||||||
|
uint i;
|
||||||
|
|
||||||
|
/* Draw filename */
|
||||||
|
SetDParamStr(0, c->filename);
|
||||||
|
y += DrawStringMultiLine(x, y, STR_NEWGRF_FILENAME, w);
|
||||||
|
|
||||||
|
/* Prepare and draw GRF ID */
|
||||||
|
snprintf(buff, lengthof(buff), "%08X", (uint32)BSWAP32(c->grfid));
|
||||||
|
SetDParamStr(0, buff);
|
||||||
|
y += DrawStringMultiLine(x, y, STR_NEWGRF_GRF_ID, w);
|
||||||
|
|
||||||
|
/* Prepare and draw MD5 sum */
|
||||||
|
s = buff;
|
||||||
|
for (i = 0; i < lengthof(c->md5sum); i++) {
|
||||||
|
s += snprintf(s, lastof(buff) - s, "%02X", c->md5sum[i]);
|
||||||
|
}
|
||||||
|
SetDParamStr(0, buff);
|
||||||
|
y += DrawStringMultiLine(x, y, STR_NEWGRF_MD5SUM, w);
|
||||||
|
|
||||||
|
/* Show GRF parameter list */
|
||||||
|
if (show_params) {
|
||||||
|
if (c->num_params > 0) {
|
||||||
|
BuildParamList(buff, c, lastof(buff));
|
||||||
|
SetDParamStr(0, buff);
|
||||||
|
} else {
|
||||||
|
SetDParam(0, STR_01A9_NONE);
|
||||||
|
}
|
||||||
|
y += DrawStringMultiLine(x, y, STR_NEWGRF_PARAMETER, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show flags */
|
||||||
|
if (HASBIT(c->flags, GCF_NOT_FOUND)) y += DrawStringMultiLine(x, y, STR_NEWGRF_NOT_FOUND, w);
|
||||||
|
if (HASBIT(c->flags, GCF_DISABLED)) y += DrawStringMultiLine(x, y, STR_NEWGRF_DISABLED, w);
|
||||||
|
|
||||||
|
/* Draw GRF info if it exists */
|
||||||
|
if (c->info != NULL && strlen(c->info) != 0) {
|
||||||
|
SetDParamStr(0, c->info);
|
||||||
|
y += DrawStringMultiLine(x, y, STR_02BD, w);
|
||||||
|
} else {
|
||||||
|
y += DrawStringMultiLine(x, y, STR_NEWGRF_NO_INFO, w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Dialogue for adding NewGRF files to the selection */
|
||||||
|
typedef struct newgrf_add_d {
|
||||||
|
GRFConfig **list;
|
||||||
|
const GRFConfig *sel;
|
||||||
|
} newgrf_add_d;
|
||||||
|
|
||||||
|
|
||||||
|
static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
|
||||||
|
{
|
||||||
|
switch (e->event) {
|
||||||
|
case WE_PAINT: {
|
||||||
|
const GRFConfig *c;
|
||||||
|
int y;
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
/* Count the number of GRFs */
|
||||||
|
for (c = _all_grfs; c != NULL; c = c->next) n++;
|
||||||
|
|
||||||
|
w->vscroll.cap = (w->widget[3].bottom - w->widget[3].top) / 10;
|
||||||
|
SetVScrollCount(w, n);
|
||||||
|
|
||||||
|
SetWindowWidgetDisabledState(w, 6, WP(w, newgrf_add_d).sel == NULL);
|
||||||
|
DrawWindowWidgets(w);
|
||||||
|
|
||||||
|
GfxFillRect(w->widget[3].left + 1, w->widget[3].top + 1, w->widget[3].right, w->widget[3].bottom, 0xD7);
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
y = w->widget[3].top + 1;
|
||||||
|
|
||||||
|
for (c = _all_grfs; c != NULL; c = c->next) {
|
||||||
|
if (n >= w->vscroll.pos && n < w->vscroll.pos + w->vscroll.cap) {
|
||||||
|
bool h = c == WP(w, newgrf_add_d).sel;
|
||||||
|
const char *text = (c->name != NULL && strlen(c->name) != 0) ? c->name : c->filename;
|
||||||
|
|
||||||
|
/* Draw selection background */
|
||||||
|
if (h) GfxFillRect(3, y, w->width - 15, y + 9, 156);
|
||||||
|
DoDrawStringTruncated(text, 4, y, h ? 0xC : 0x6, w->width - 18);
|
||||||
|
y += 10;
|
||||||
|
}
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WP(w, newgrf_add_d).sel != NULL) {
|
||||||
|
const Widget *wi = &w->widget[5];
|
||||||
|
ShowNewGRFInfo(WP(w, newgrf_add_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WE_CLICK:
|
||||||
|
switch (e->we.click.widget) {
|
||||||
|
case 3: {
|
||||||
|
// Get row...
|
||||||
|
const GRFConfig *c;
|
||||||
|
uint i = (e->we.click.pt.y - w->widget[3].top) / 10 + w->vscroll.pos;
|
||||||
|
|
||||||
|
for (c = _all_grfs; c != NULL && i > 0; c = c->next, i--);
|
||||||
|
WP(w, newgrf_add_d).sel = c;
|
||||||
|
SetWindowDirty(w);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 6: /* Add selection to list */
|
||||||
|
if (WP(w, newgrf_add_d).sel != NULL) {
|
||||||
|
const GRFConfig *src = WP(w, newgrf_add_d).sel;
|
||||||
|
GRFConfig *c = calloc(1, sizeof(*c));
|
||||||
|
*c = *src;
|
||||||
|
c->filename = strdup(src->filename);
|
||||||
|
if (src->name != NULL) c->name = strdup(src->name);
|
||||||
|
if (src->info != NULL) c->info = strdup(src->info);
|
||||||
|
c->next = NULL;
|
||||||
|
*WP(w, newgrf_add_d).list = c;
|
||||||
|
|
||||||
|
DeleteWindowByClass(WC_SAVELOAD);
|
||||||
|
InvalidateWindowData(WC_GAME_OPTIONS, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 7: /* Rescan list */
|
||||||
|
WP(w, newgrf_add_d).sel = NULL;
|
||||||
|
ScanNewGRFFiles();
|
||||||
|
SetWindowDirty(w);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const Widget _newgrf_add_dlg_widgets[] = {
|
||||||
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
|
||||||
|
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 306, 0, 13, STR_NEWGRF_ADD_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS },
|
||||||
|
|
||||||
|
/* List of files */
|
||||||
|
{ WWT_PANEL, RESIZE_RB, 14, 0, 294, 14, 221, 0x0, STR_NULL },
|
||||||
|
{ WWT_INSET, RESIZE_RB, 14, 2, 292, 16, 219, 0x0, STR_NULL },
|
||||||
|
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 295, 306, 14, 221, 0x0, STR_NULL },
|
||||||
|
|
||||||
|
/* NewGRF file info */
|
||||||
|
{ WWT_PANEL, RESIZE_RTB, 14, 0, 306, 222, 311, 0x0, STR_NULL },
|
||||||
|
|
||||||
|
{ WWT_PUSHTXTBTN, RESIZE_RTB, 14, 0, 146, 312, 323, STR_NEWGRF_ADD_FILE, STR_NEWGRF_ADD_FILE_TIP },
|
||||||
|
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 147, 294, 312, 323, STR_NEWGRF_RESCAN_FILES, STR_NEWGRF_RESCAN_FILES_TIP },
|
||||||
|
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 295, 306, 312, 323, 0x0, STR_RESIZE_BUTTON },
|
||||||
|
{ WIDGETS_END },
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const WindowDesc _newgrf_add_dlg_desc = {
|
||||||
|
WDP_CENTER, WDP_CENTER, 307, 324,
|
||||||
|
WC_SAVELOAD, 0,
|
||||||
|
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
|
||||||
|
_newgrf_add_dlg_widgets,
|
||||||
|
NewGRFAddDlgWndProc,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* 'NewGRF Settings' dialogue */
|
||||||
|
typedef struct newgrf_d {
|
||||||
|
GRFConfig **list;
|
||||||
|
GRFConfig *sel;
|
||||||
|
bool editable;
|
||||||
|
bool show_params;
|
||||||
|
} newgrf_d;
|
||||||
|
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(newgrf_d));
|
||||||
|
|
||||||
|
|
||||||
|
static void SetupNewGRFState(Window *w)
|
||||||
|
{
|
||||||
|
bool disable_all = WP(w, newgrf_d).sel == NULL || !WP(w, newgrf_d).editable;
|
||||||
|
|
||||||
|
SetWindowWidgetDisabledState(w, 3, !WP(w, newgrf_d).editable);
|
||||||
|
SetWindowWidgetsDisabledState(w, disable_all, 4, 5, 6, WIDGET_LIST_END);
|
||||||
|
SetWindowWidgetDisabledState(w, 10, !WP(w, newgrf_d).show_params || disable_all);
|
||||||
|
|
||||||
|
if (!disable_all) {
|
||||||
|
/* All widgets are now enabled, so disable widgets we can't use */
|
||||||
|
if (WP(w, newgrf_d).sel == *WP(w, newgrf_d).list) DisableWindowWidget(w, 5);
|
||||||
|
if (WP(w, newgrf_d).sel->next == NULL) DisableWindowWidget(w, 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void SetupNewGRFWindow(Window *w)
|
||||||
|
{
|
||||||
|
GRFConfig *c;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (c = *WP(w, newgrf_d).list, i = 0; c != NULL; c = c->next, i++);
|
||||||
|
|
||||||
|
w->vscroll.cap = (w->widget[7].bottom - w->widget[7].top) / 14 + 1;
|
||||||
|
SetVScrollCount(w, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void NewGRFWndProc(Window *w, WindowEvent *e)
|
||||||
|
{
|
||||||
|
switch (e->event) {
|
||||||
|
case WE_PAINT: {
|
||||||
|
GRFConfig *c;
|
||||||
|
int i, y;
|
||||||
|
|
||||||
|
SetupNewGRFState(w);
|
||||||
|
|
||||||
|
DrawWindowWidgets(w);
|
||||||
|
|
||||||
|
/* Draw NewGRF list */
|
||||||
|
y = w->widget[7].top;
|
||||||
|
for (c = *WP(w, newgrf_d).list, i = 0; c != NULL; c = c->next, i++) {
|
||||||
|
if (i >= w->vscroll.pos && i < w->vscroll.pos + w->vscroll.cap) {
|
||||||
|
const char *text = (c->name != NULL && strlen(c->name) != 0) ? c->name : c->filename;
|
||||||
|
PalSpriteID pal;
|
||||||
|
|
||||||
|
/* Pick a colour */
|
||||||
|
if (HASBIT(c->flags, GCF_NOT_FOUND) || HASBIT(c->flags, GCF_DISABLED)) {
|
||||||
|
pal = PALETTE_TO_RED;
|
||||||
|
} else if (HASBIT(c->flags, GCF_ACTIVATED)) {
|
||||||
|
pal = PALETTE_TO_GREEN;
|
||||||
|
} else {
|
||||||
|
pal = PALETTE_TO_BLUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawSprite(SPRITE_PALETTE(SPR_SQUARE | pal), 5, y + 2);
|
||||||
|
DoDrawString(text, 25, y + 3, WP(w, newgrf_d).sel == c ? 0xC : 0x10);
|
||||||
|
y += 14;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WP(w, newgrf_d).sel != NULL) {
|
||||||
|
/* Draw NewGRF file info */
|
||||||
|
const Widget *wi = &w->widget[9];
|
||||||
|
ShowNewGRFInfo(WP(w, newgrf_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, WP(w, newgrf_d).show_params);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WE_CLICK:
|
||||||
|
switch (e->we.click.widget) {
|
||||||
|
case 3: { /* Add GRF */
|
||||||
|
GRFConfig **list = WP(w, newgrf_d).list;
|
||||||
|
Window *w;
|
||||||
|
|
||||||
|
DeleteWindowByClass(WC_SAVELOAD);
|
||||||
|
w = AllocateWindowDesc(&_newgrf_add_dlg_desc);
|
||||||
|
w->resize.step_height = 10;
|
||||||
|
|
||||||
|
/* Find the last entry in the list */
|
||||||
|
for (; *list != NULL; list = &(*list)->next);
|
||||||
|
WP(w, newgrf_add_d).list = list;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 4: { /* Remove GRF */
|
||||||
|
GRFConfig **pc, *c;
|
||||||
|
for (pc = WP(w, newgrf_d).list; (c = *pc) != NULL; pc = &c->next) {
|
||||||
|
if (c == WP(w, newgrf_d).sel) {
|
||||||
|
*pc = c->next;
|
||||||
|
free(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WP(w, newgrf_d).sel = NULL;
|
||||||
|
SetupNewGRFWindow(w);
|
||||||
|
SetWindowDirty(w);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 5: { /* Move GRF up */
|
||||||
|
GRFConfig **pc, *c;
|
||||||
|
if (WP(w, newgrf_d).sel == NULL) break;
|
||||||
|
|
||||||
|
for (pc = WP(w, newgrf_d).list; (c = *pc) != NULL; pc = &c->next) {
|
||||||
|
if (c->next == WP(w, newgrf_d).sel) {
|
||||||
|
c->next = WP(w, newgrf_d).sel->next;
|
||||||
|
WP(w, newgrf_d).sel->next = c;
|
||||||
|
*pc = WP(w, newgrf_d).sel;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetWindowDirty(w);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 6: { /* Move GRF down */
|
||||||
|
GRFConfig **pc, *c;
|
||||||
|
if (WP(w, newgrf_d).sel == NULL) break;
|
||||||
|
|
||||||
|
for (pc = WP(w, newgrf_d).list; (c = *pc) != NULL; pc = &c->next) {
|
||||||
|
if (c == WP(w, newgrf_d).sel) {
|
||||||
|
*pc = c->next;
|
||||||
|
c->next = c->next->next;
|
||||||
|
(*pc)->next = c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetWindowDirty(w);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 7: { /* Select a GRF */
|
||||||
|
GRFConfig *c;
|
||||||
|
uint i = (e->we.click.pt.y - w->widget[7].top) / 14 + w->vscroll.pos;
|
||||||
|
|
||||||
|
for (c = *WP(w, newgrf_d).list; c != NULL && i > 0; c = c->next, i--);
|
||||||
|
WP(w, newgrf_d).sel = c;
|
||||||
|
|
||||||
|
SetWindowDirty(w);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 10: { /* Edit parameters */
|
||||||
|
char buff[512];
|
||||||
|
if (WP(w, newgrf_d).sel == NULL) break;
|
||||||
|
|
||||||
|
BuildParamList(buff, WP(w, newgrf_d).sel, lastof(buff));
|
||||||
|
ShowQueryString(BindCString(buff), STR_NEWGRF_PARAMETER_QUERY, 63, 250, w->window_class, w->window_number, CS_ALPHANUMERAL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WE_ON_EDIT_TEXT:
|
||||||
|
if (e->we.edittext.str != NULL) {
|
||||||
|
/* Parse our new "int list" */
|
||||||
|
GRFConfig *c = WP(w, newgrf_d).sel;
|
||||||
|
c->num_params = parse_intlist(e->we.edittext.str, (int*)c->param, lengthof(c->param));
|
||||||
|
|
||||||
|
/* parse_intlist returns -1 on error */
|
||||||
|
if (c->num_params == (byte)-1) c->num_params = 0;
|
||||||
|
}
|
||||||
|
SetWindowDirty(w);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WE_RESIZE:
|
||||||
|
w->vscroll.cap += e->we.sizing.diff.y / 14;
|
||||||
|
w->widget[7].data = (w->vscroll.cap << 8) + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const Widget _newgrf_widgets[] = {
|
||||||
|
{ WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
|
||||||
|
{ WWT_CAPTION, RESIZE_RIGHT, 10, 11, 299, 0, 13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS },
|
||||||
|
|
||||||
|
/* NewGRF file Add, Remove, Move up, Move down */
|
||||||
|
{ WWT_PANEL, RESIZE_RIGHT, 10, 0, 299, 14, 29, STR_NULL, STR_NULL },
|
||||||
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 10, 79, 16, 27, STR_NEWGRF_ADD, STR_NEWGRF_ADD_TIP },
|
||||||
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 80, 149, 16, 27, STR_NEWGRF_REMOVE, STR_NEWGRF_REMOVE_TIP },
|
||||||
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 150, 219, 16, 27, STR_NEWGRF_MOVEUP, STR_NEWGRF_MOVEUP_TIP },
|
||||||
|
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 220, 289, 16, 27, STR_NEWGRF_MOVEDOWN, STR_NEWGRF_MOVEDOWN_TIP },
|
||||||
|
|
||||||
|
/* NewGRF file list */
|
||||||
|
{ WWT_MATRIX, RESIZE_RB, 10, 0, 287, 30, 99, 0x501, STR_NEWGRF_FILE_TIP },
|
||||||
|
{ WWT_SCROLLBAR, RESIZE_LRB, 10, 288, 299, 30, 99, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST },
|
||||||
|
|
||||||
|
/* NewGRF file info */
|
||||||
|
{ WWT_PANEL, RESIZE_RTB, 10, 0, 299, 100, 199, STR_NULL, STR_NULL },
|
||||||
|
|
||||||
|
/* Edit parameter button... */
|
||||||
|
{ WWT_PUSHTXTBTN, RESIZE_RTB, 10, 0, 287, 200, 211, STR_NEWGRF_SET_PARAMETERS, STR_NULL },
|
||||||
|
{ WWT_RESIZEBOX, RESIZE_LRTB, 10, 288, 299, 200, 211, 0x0, STR_RESIZE_BUTTON },
|
||||||
|
|
||||||
|
{ WIDGETS_END },
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const WindowDesc _newgrf_desc = {
|
||||||
|
WDP_CENTER, WDP_CENTER, 300, 212,
|
||||||
|
WC_GAME_OPTIONS, 0,
|
||||||
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
|
||||||
|
_newgrf_widgets,
|
||||||
|
NewGRFWndProc,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void ShowNewGRFSettings(bool editable, bool show_params, GRFConfig **config)
|
||||||
|
{
|
||||||
|
Window *w;
|
||||||
|
|
||||||
|
DeleteWindowByClass(WC_GAME_OPTIONS);
|
||||||
|
w = AllocateWindowDesc(&_newgrf_desc);
|
||||||
|
if (w == NULL) return;
|
||||||
|
|
||||||
|
w->resize.step_height = 14;
|
||||||
|
|
||||||
|
/* Clear selections */
|
||||||
|
WP(w, newgrf_d).sel = NULL;
|
||||||
|
WP(w, newgrf_d).list = config;
|
||||||
|
WP(w, newgrf_d).editable = editable;
|
||||||
|
WP(w, newgrf_d).show_params = show_params;
|
||||||
|
|
||||||
|
SetupNewGRFWindow(w);
|
||||||
|
}
|
140
settings_gui.c
140
settings_gui.c
|
@ -916,146 +916,6 @@ void ShowPatchesSelection(void)
|
||||||
AllocateWindowDesc(&_patches_selection_desc);
|
AllocateWindowDesc(&_patches_selection_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
|
||||||
NEWGRF_WND_PROC_OFFSET_TOP_WIDGET = 14,
|
|
||||||
NEWGRF_WND_PROC_ROWSIZE = 14
|
|
||||||
};
|
|
||||||
|
|
||||||
static void NewgrfWndProc(Window *w, WindowEvent *e)
|
|
||||||
{
|
|
||||||
static GRFFile *_sel_grffile;
|
|
||||||
switch (e->event) {
|
|
||||||
case WE_PAINT: {
|
|
||||||
int x, y = NEWGRF_WND_PROC_OFFSET_TOP_WIDGET;
|
|
||||||
uint16 i = 0;
|
|
||||||
GRFFile *c = _first_grffile;
|
|
||||||
|
|
||||||
DrawWindowWidgets(w);
|
|
||||||
|
|
||||||
if (_first_grffile == NULL) { // no grf sets installed
|
|
||||||
DrawStringMultiCenter(140, 210, STR_NEWGRF_NO_FILES_INSTALLED, 250);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw list of all grf files
|
|
||||||
while (c != NULL) {
|
|
||||||
if (i >= w->vscroll.pos) { // draw files according to scrollbar position
|
|
||||||
bool h = (_sel_grffile == c);
|
|
||||||
// show highlighted item with a different background and highlighted text
|
|
||||||
if (h) GfxFillRect(1, y + 1, 267, y + 12, 156);
|
|
||||||
// XXX - will be grf name later
|
|
||||||
DoDrawString(c->filename, 25, y + 2, h ? 0xC : 0x10);
|
|
||||||
DrawSprite(SPRITE_PALETTE(SPR_SQUARE | PALETTE_TO_RED), 5, y + 2);
|
|
||||||
y += NEWGRF_WND_PROC_ROWSIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
c = c->next;
|
|
||||||
if (++i == w->vscroll.cap + w->vscroll.pos) break; // stop after displaying 12 items
|
|
||||||
}
|
|
||||||
|
|
||||||
// DoDrawString(_sel_grffile->setname, 120, 200, 0x01); // draw grf name
|
|
||||||
|
|
||||||
if (_sel_grffile == NULL) { // no grf file selected yet
|
|
||||||
DrawStringMultiCenter(140, 210, STR_NEWGRF_TIP, 250);
|
|
||||||
} else {
|
|
||||||
// draw filename
|
|
||||||
x = DrawString(5, 199, STR_NEWGRF_FILENAME, 0);
|
|
||||||
DoDrawString(_sel_grffile->filename, x + 2, 199, 0x01);
|
|
||||||
|
|
||||||
// draw grf id
|
|
||||||
x = DrawString(5, 209, STR_NEWGRF_GRF_ID, 0);
|
|
||||||
snprintf(_userstring, lengthof(_userstring), "%08X", (uint32)BSWAP32(_sel_grffile->grfid));
|
|
||||||
DrawString(x + 2, 209, STR_SPEC_USERSTRING, 0x01);
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case WE_CLICK:
|
|
||||||
switch (e->we.click.widget) {
|
|
||||||
case 3: { // select a grf file
|
|
||||||
int y = (e->we.click.pt.y - NEWGRF_WND_PROC_OFFSET_TOP_WIDGET) / NEWGRF_WND_PROC_ROWSIZE;
|
|
||||||
|
|
||||||
if (y >= w->vscroll.cap) return; // click out of bounds
|
|
||||||
|
|
||||||
y += w->vscroll.pos;
|
|
||||||
|
|
||||||
if (y >= w->vscroll.count) return;
|
|
||||||
|
|
||||||
_sel_grffile = _first_grffile;
|
|
||||||
// get selected grf-file
|
|
||||||
while (y-- != 0) _sel_grffile = _sel_grffile->next;
|
|
||||||
|
|
||||||
SetWindowDirty(w);
|
|
||||||
} break;
|
|
||||||
case 9: /* Cancel button */
|
|
||||||
DeleteWindowById(WC_GAME_OPTIONS, 0);
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
|
|
||||||
#if 0 /* Parameter edit box not used yet */
|
|
||||||
case WE_TIMEOUT:
|
|
||||||
WP(w,def_d).data_2 = 0;
|
|
||||||
SetWindowDirty(w);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WE_ON_EDIT_TEXT: {
|
|
||||||
if (*e->edittext.str) {
|
|
||||||
SetWindowDirty(w);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case WE_DESTROY:
|
|
||||||
_sel_grffile = NULL;
|
|
||||||
DeleteWindowById(WC_QUERY_STRING, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const Widget _newgrf_widgets[] = {
|
|
||||||
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
||||||
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 279, 0, 13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
||||||
{ WWT_PANEL, RESIZE_NONE, 14, 0, 279, 183, 276, 0x0, STR_NULL},
|
|
||||||
|
|
||||||
{ WWT_MATRIX, RESIZE_NONE, 14, 0, 267, 14, 182, 0xC01, /*small rows*/ STR_NEWGRF_TIP},
|
|
||||||
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 268, 279, 14, 182, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
||||||
|
|
||||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 147, 158, 244, 255, STR_0188, STR_NULL},
|
|
||||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 159, 170, 244, 255, STR_0189, STR_NULL},
|
|
||||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 175, 274, 244, 255, STR_NEWGRF_SET_PARAMETERS, STR_NULL},
|
|
||||||
|
|
||||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 5, 138, 261, 272, STR_NEWGRF_APPLY_CHANGES, STR_NULL},
|
|
||||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 142, 274, 261, 272, STR_012E_CANCEL, STR_NULL},
|
|
||||||
{ WIDGETS_END},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const WindowDesc _newgrf_desc = {
|
|
||||||
WDP_CENTER, WDP_CENTER, 280, 277,
|
|
||||||
WC_GAME_OPTIONS,0,
|
|
||||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
||||||
_newgrf_widgets,
|
|
||||||
NewgrfWndProc,
|
|
||||||
};
|
|
||||||
|
|
||||||
void ShowNewgrf(void)
|
|
||||||
{
|
|
||||||
const GRFFile* c;
|
|
||||||
Window *w;
|
|
||||||
uint count;
|
|
||||||
|
|
||||||
DeleteWindowById(WC_GAME_OPTIONS, 0);
|
|
||||||
w = AllocateWindowDesc(&_newgrf_desc);
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
for (c = _first_grffile; c != NULL; c = c->next) count++;
|
|
||||||
|
|
||||||
w->vscroll.cap = 12;
|
|
||||||
w->vscroll.count = count;
|
|
||||||
w->vscroll.pos = 0;
|
|
||||||
DisableWindowWidget(w, 5); // Small up arrow
|
|
||||||
DisableWindowWidget(w, 6); // Small sown arrow
|
|
||||||
DisableWindowWidget(w, 7); // Set parameter button
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw [<][>] boxes.
|
* Draw [<][>] boxes.
|
||||||
|
|
Loading…
Reference in New Issue