Changeset - r6283:91e7bd5c3b9a
[Not reviewed]
master
0 5 0
truelight - 17 years ago 2007-03-10 12:10:00
truelight@openttd.org
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
-Change: store news_display_opt in his own section, so it is no longer stored as uint in openttd.cfg (allows adding news-types easier)
5 files changed with 104 insertions and 31 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1661,25 +1661,25 @@ static void ExtChangeIndustryProduction(
 
					);
 
				}
 
			}
 
			break;
 
	}
 

	
 
	/* If industry will be closed down, show this */
 
	if (closeit) {
 
		i->prod_level = 0;
 
		SetDParam(0, i->index);
 
		AddNewsItem(
 
			indspec->closure_text,
 
			NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_ECONOMY, 0),
 
			NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_OPENCLOSE, 0),
 
			i->xy + TileDiffXY(1, 1), 0
 
		);
 
	}
 
}
 

	
 

	
 
static void UpdateIndustryStatistics(Industry *i)
 
{
 
	byte pct;
 

	
 
	if (i->produced_cargo[0] != CT_INVALID) {
 
		pct = 0;
 
@@ -1740,25 +1740,25 @@ static void MaybeNewIndustry(uint32 r)
 
	if (type == IT_OIL_RIG  && _cur_year < 1960) return;
 

	
 
	j = 2000;
 
	for (;;) {
 
		i = CreateNewIndustry(RandomTile(), type);
 
		if (i != NULL) break;
 
		if (--j == 0) return;
 
	}
 

	
 
	SetDParam(0, ind_spc->name);
 
	SetDParam(1, i->town->index);
 
	AddNewsItem(ind_spc->new_industry_text,
 
		NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_ECONOMY,0), i->xy, 0);
 
		NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_OPENCLOSE, 0), i->xy, 0);
 
}
 

	
 
static void ChangeIndustryProduction(Industry *i)
 
{
 
	bool only_decrease = false;
 
	StringID str = STR_NULL;
 
	int type = i->type;
 
	const IndustrySpec *indspec = GetIndustrySpec(type);
 

	
 
	switch (indspec->life_type) {
 
		case INDUSTRYLIFE_NOT_CLOSABLE:
 
			return;
 
@@ -1807,25 +1807,25 @@ static void ChangeIndustryProduction(Ind
 

	
 
		case INDUSTRYLIFE_CLOSABLE:
 
			/* maybe close */
 
			if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1,2)) {
 
				i->prod_level = 0;
 
				str = indspec->closure_text;
 
			}
 
			break;
 
	}
 

	
 
	if (str != STR_NULL) {
 
		SetDParam(0, i->index);
 
		AddNewsItem(str, NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_ECONOMY, 0), i->xy + TileDiffXY(1, 1), 0);
 
		AddNewsItem(str, NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, str == indspec->closure_text ? NT_OPENCLOSE : NT_ECONOMY, 0), i->xy + TileDiffXY(1, 1), 0);
 
	}
 
}
 

	
 
void IndustryMonthlyLoop()
 
{
 
	Industry *i;
 
	PlayerID old_player = _current_player;
 
	_current_player = OWNER_NONE;
 

	
 
	FOR_ALL_INDUSTRIES(i) {
 
		UpdateIndustryStatistics(i);
 
	}
src/lang/english.txt
Show inline comments
 
@@ -582,24 +582,25 @@ STR_01FD_CLICK_ON_SERVICE_TO_CENTER     
 
STR_01FE_DIFFICULTY                                             :{BLACK}Difficulty ({STRING})
 
STR_01FF                                                        :{TINYFONT}{BLACK}{DATE_LONG}
 
STR_0200_LAST_MESSAGE_NEWS_REPORT                               :Last message/news report
 
STR_0201_MESSAGE_SETTINGS                                       :Message settings
 
STR_MESSAGE_HISTORY_MENU                                        :Message History
 
STR_0203_SHOW_LAST_MESSAGE_NEWS                                 :{BLACK}Show last message/news report, show message options
 
STR_0204_MESSAGE_OPTIONS                                        :{WHITE}Message Options
 
STR_0205_MESSAGE_TYPES                                          :{BLACK}Message types:
 
STR_0206_ARRIVAL_OF_FIRST_VEHICLE                               :{YELLOW}Arrival of first vehicle at player's station
 
STR_0207_ARRIVAL_OF_FIRST_VEHICLE                               :{YELLOW}Arrival of first vehicle at competitor's station
 
STR_0208_ACCIDENTS_DISASTERS                                    :{YELLOW}Accidents / disasters
 
STR_0209_COMPANY_INFORMATION                                    :{YELLOW}Company information
 
STR_NEWS_OPEN_CLOSE                                             :{YELLOW}Open / close of industries
 
STR_020A_ECONOMY_CHANGES                                        :{YELLOW}Economy changes
 
STR_020B_ADVICE_INFORMATION_ON_PLAYER                           :{YELLOW}Advice / information on player's vehicles
 
STR_020C_NEW_VEHICLES                                           :{YELLOW}New vehicles
 
STR_020D_CHANGES_OF_CARGO_ACCEPTANCE                            :{YELLOW}Changes to cargo acceptance
 
STR_020E_SUBSIDIES                                              :{YELLOW}Subsidies
 
STR_020F_GENERAL_INFORMATION                                    :{YELLOW}General information
 
STR_MESSAGES_ALL                                                :{YELLOW}Set all message types to: Off / Summary/ Full
 
STR_MESSAGE_SOUND                                               :{YELLOW}Play sound for summarised news messages
 
STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO                       :{WHITE}...too far from previous destination
 
STR_0211_TOP_COMPANIES_WHO_REACHED                              :{BIGFONT}{BLACK}Top companies who reached {NUM}{}({STRING} Level)
 
STR_TOP_COMPANIES_NETWORK_GAME                                  :{BIGFONT}{BLACK}Company League Table in {NUM}
 
STR_0212                                                        :{BIGFONT}{COMMA}.
src/news.h
Show inline comments
 
@@ -26,33 +26,36 @@ typedef StringID GetNewsStringCallbackPr
 
void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b);
 
void NewsLoop();
 
void DrawNewsBorder(const Window *w);
 
void InitNewsItemStructs();
 

	
 
VARDEF NewsItem _statusbar_news_item;
 

	
 
enum NewsType {
 
	NT_ARRIVAL_PLAYER,
 
	NT_ARRIVAL_OTHER,
 
	NT_ACCIDENT,
 
	NT_COMPANY_INFO,
 
	NT_OPENCLOSE,
 
	NT_ECONOMY,
 
	NT_ADVICE,
 
	NT_NEW_VEHICLES,
 
	NT_ACCEPTANCE,
 
	NT_SUBSIDIES,
 
	NT_GENERAL,
 
	NT_END,
 
};
 

	
 
extern const char *_news_display_name[NT_END];
 

	
 
enum NewsMode {
 
	NM_SMALL    = 0, ///< Show only a small popup informing us about vehicle age for example
 
	NM_NORMAL   = 1, ///< Show a simple news message (height 170 pixels)
 
	NM_THIN     = 2, ///< Show a simple news message (height 130 pixels)
 
	NM_CALLBACK = 3, ///< Do some special processing before displaying news message. Which callback to call is in NewsCallback
 
};
 

	
 
enum NewsFlags {
 
	NF_VIEWPORT  = (1 << 1), ///< Does the news message have a viewport? (ingame picture of happening)
 
	NF_TILE      = (1 << 2), ///< When clicked on the news message scroll to a given tile? Tile is in data_a/data_b
 
	NF_VEHICLE   = (1 << 3), ///< When clicked on the message scroll to the vehicle? VehicleID is in data_a
 
	NF_FORCE_BIG = (1 << 4), ///< Force the appearance of a news message if it has already been shown (internal)
src/news_gui.cpp
Show inline comments
 
@@ -346,35 +346,50 @@ static const Widget _news_type0_widgets[
 
{      WWT_INSET,   RESIZE_NONE,     5,     2,   277,    16,    64, 0x0,              STR_NULL},
 
{   WIDGETS_END},
 
};
 

	
 
static WindowDesc _news_type0_desc = {
 
	WDP_CENTER, 476, 280, 87,
 
	WC_NEWS_WINDOW, WC_NONE,
 
	WDF_DEF_WIDGET,
 
	_news_type0_widgets,
 
	NewsWindowProc
 
};
 

	
 
static const SoundFx _news_sounds[] = {
 
static const SoundFx _news_sounds[NT_END] = {
 
	SND_1D_APPLAUSE,
 
	SND_1D_APPLAUSE,
 
	SND_BEGIN,
 
	SND_BEGIN,
 
	SND_BEGIN,
 
	SND_BEGIN,
 
	SND_BEGIN,
 
	SND_1E_OOOOH,
 
	SND_BEGIN,
 
	SND_BEGIN,
 
	SND_BEGIN
 
	SND_BEGIN,
 
};
 

	
 
const char *_news_display_name[NT_END] = {
 
	"arrival_player",
 
	"arrival_other",
 
	"accident",
 
	"company_info",
 
	"openclose",
 
	"economy",
 
	"advice",
 
	"new_vehicles",
 
	"acceptance",
 
	"subsidies",
 
	"general",
 
};
 

	
 
/** Get the value of an item of the news-display settings. This is
 
 * a little tricky since on/off/summary must use 2 bits to store the value
 
 * @param item the item whose value is requested
 
 * @return return the found value which is between 0-2
 
 */
 
static inline byte GetNewsDisplayValue(byte item)
 
{
 
	assert(item < NT_END && GB(_news_display_opt, item * 2, 2) <= 2);
 
	return GB(_news_display_opt, item * 2, 2);
 
}
 
@@ -752,25 +767,25 @@ static void MessageOptionsWndProc(Window
 

	
 
			if (_news_ticker_sound) LowerWindowWidget(w, WIDGET_NEWSOPT_SOUNDTICKER);
 
			DrawWindowWidgets(w);
 

	
 
			/* Draw the string of each setting on each button. */
 
			for (i = 0, y = 26; i < NT_END; i++, y += 12, val >>= 2) {
 
				/* 51 comes from 13 + 89 (left and right of the button)+1, shiefted by one as to get division,
 
				 * which will give centered position */
 
				DrawStringCentered(51, y + 1, message_opt[val & 0x3], 0x10);
 
			}
 

	
 
			/* Draw the general bottom button string as well */
 
			DrawString(8, y + 10, message_opt[WP(w, def_d).data_1], 0x10);
 
			DrawStringCentered(51, y + 10, message_opt[WP(w, def_d).data_1], 0x10);
 
		} break;
 

	
 
		case WE_CLICK:
 
			switch (e->we.click.widget) {
 
				case WIDGET_NEWSOPT_BTN_SUMMARY:
 
				case WIDGET_NEWSOPT_DROP_SUMMARY: // Dropdown menu for all settings
 
					ShowDropDownMenu(w, message_opt, WP(w, def_d).data_1, WIDGET_NEWSOPT_DROP_SUMMARY, 0, 0);
 
					break;
 

	
 
				case WIDGET_NEWSOPT_SOUNDTICKER: // Change ticker sound on/off
 
					_news_ticker_sound ^= 1;
 
					ToggleWidgetLoweredState(w, e->we.click.widget);
 
@@ -787,47 +802,47 @@ static void MessageOptionsWndProc(Window
 
						SetNewsDisplayValue(element, val);
 
						SetWindowDirty(w);
 
					}
 
				} break;
 
			} break;
 

	
 
		case WE_DROPDOWN_SELECT: { // Select all settings for newsmessages
 
			int i;
 

	
 
			WP(w, def_d).data_1 = e->we.dropdown.index;
 

	
 
			for (i = 0; i < NT_END; i++) {
 
				SetMessageButtonStates(w, e->we.dropdown.index, i);
 
				SetNewsDisplayValue(i, e->we.dropdown.index);
 
				SetMessageButtonStates(w, e->we.dropdown.index, i);
 
			}
 
			SetWindowDirty(w);
 
		} break;
 
	}
 
}
 

	
 
static const Widget _message_options_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,   10,     0,    13, STR_00C5,                              STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,    13,    11,  409,     0,    13, STR_0204_MESSAGE_OPTIONS,              STR_018C_WINDOW_TITLE_DRAG_THIS},
 
{      WWT_PANEL,   RESIZE_NONE,    13,     0,  409,    14,   184, 0x0,                                   STR_NULL},
 
{      WWT_PANEL,   RESIZE_NONE,    13,     0,  409,    14,   196, 0x0,                                   STR_NULL},
 

	
 
/* Text at the top of the main panel, in black */
 
{      WWT_LABEL,   RESIZE_NONE,    13,     0,  409,    13,    26, STR_0205_MESSAGE_TYPES,                STR_NULL},
 

	
 
/* General drop down and sound button */
 
{      WWT_PANEL,   RESIZE_NONE,     3,     4,   86,   154,   165, 0x0,                                   STR_NULL},
 
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    87,   98,   154,   165, STR_0225,                              STR_NULL},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   155,   167, STR_MESSAGES_ALL,                      STR_NULL},
 
{      WWT_PANEL,   RESIZE_NONE,     3,     4,   86,   166,   177, 0x0,                                   STR_NULL},
 
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    87,   98,   166,   177, STR_0225,                              STR_NULL},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   167,   179, STR_MESSAGES_ALL,                      STR_NULL},
 

	
 
{  WWT_TEXTBTN_2,   RESIZE_NONE,     3,     4,   98,   166,   177, STR_02DB_OFF,                          STR_NULL},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   167,   179, STR_MESSAGE_SOUND,                     STR_NULL},
 
{  WWT_TEXTBTN_2,   RESIZE_NONE,     3,     4,   98,   178,   189, STR_02DB_OFF,                          STR_NULL},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   179,   191, STR_MESSAGE_SOUND,                     STR_NULL},
 

	
 
/* Each four group is composed of the buttons [<] [..] [>] and the descriptor of the setting */
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,     4,   12,    26,    37, SPR_ARROW_LEFT,                        STR_HSCROLL_BAR_SCROLLS_LIST},
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,    26,    37, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,    26,    37, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,    27,    39, STR_0206_ARRIVAL_OF_FIRST_VEHICLE,     STR_NULL},
 

	
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,     4,   12,    38,    49, SPR_ARROW_LEFT,                        STR_HSCROLL_BAR_SCROLLS_LIST},
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,    38,    49, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,    38,    49, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,    39,    51, STR_0207_ARRIVAL_OF_FIRST_VEHICLE,     STR_NULL},
 

	
 
@@ -835,56 +850,61 @@ static const Widget _message_options_wid
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,    50,    61, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,    50,    61, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,    51,    63, STR_0208_ACCIDENTS_DISASTERS,          STR_NULL},
 

	
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,     4,   12,    62,    73, SPR_ARROW_LEFT,                        STR_HSCROLL_BAR_SCROLLS_LIST},
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,    62,    73, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,    62,    73, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,    63,    75, STR_0209_COMPANY_INFORMATION,          STR_NULL},
 

	
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,     4,   12,    74,    85, SPR_ARROW_LEFT,                        STR_HSCROLL_BAR_SCROLLS_LIST},
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,    74,    85, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,    74,    85, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,    75,    87, STR_020A_ECONOMY_CHANGES,              STR_NULL},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,    75,    87, STR_NEWS_OPEN_CLOSE,                   STR_NULL},
 

	
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,     4,   12,    86,    97, SPR_ARROW_LEFT,                        STR_HSCROLL_BAR_SCROLLS_LIST},
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,    86,    97, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,    86,    97, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,    87,    99, STR_020B_ADVICE_INFORMATION_ON_PLAYER, STR_NULL},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,    87,    99, STR_020A_ECONOMY_CHANGES,              STR_NULL},
 

	
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,     4,   12,    98,   109, SPR_ARROW_LEFT,                        STR_HSCROLL_BAR_SCROLLS_LIST},
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,    98,   109, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,    98,   109, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,    99,   111, STR_020C_NEW_VEHICLES,                 STR_NULL},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,    99,   111, STR_020B_ADVICE_INFORMATION_ON_PLAYER, STR_NULL},
 

	
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,     4,   12,   110,   121, SPR_ARROW_LEFT,                        STR_HSCROLL_BAR_SCROLLS_LIST},
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,   110,   121, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,   110,   121, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   111,   123, STR_020D_CHANGES_OF_CARGO_ACCEPTANCE,  STR_NULL},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   111,   123, STR_020C_NEW_VEHICLES,                 STR_NULL},
 

	
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,     4,   12,   122,   133, SPR_ARROW_LEFT,                        STR_HSCROLL_BAR_SCROLLS_LIST},
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,   122,   133, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,   122,   133, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   123,   135, STR_020E_SUBSIDIES,                    STR_NULL},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   123,   135, STR_020D_CHANGES_OF_CARGO_ACCEPTANCE,  STR_NULL},
 

	
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,     4,   12,   134,   145, SPR_ARROW_LEFT,                        STR_HSCROLL_BAR_SCROLLS_LIST},
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,   134,   145, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,   134,   145, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   135,   147, STR_020F_GENERAL_INFORMATION,          STR_NULL},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   135,   147, STR_020E_SUBSIDIES,                    STR_NULL},
 

	
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,     4,   12,   146,   157, SPR_ARROW_LEFT,                        STR_HSCROLL_BAR_SCROLLS_LIST},
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    13,   89,   146,   157, STR_EMPTY,                             STR_NULL},
 
{ WWT_PUSHIMGBTN,   RESIZE_NONE,     3,    90,   98,   146,   157, SPR_ARROW_RIGHT,                       STR_HSCROLL_BAR_SCROLLS_LIST},
 
{       WWT_TEXT,   RESIZE_NONE,     3,    103, 409,   147,   159, STR_020F_GENERAL_INFORMATION,          STR_NULL},
 

	
 
{   WIDGETS_END},
 
};
 

	
 
static const WindowDesc _message_options_desc = {
 
	270, 22, 410, 185,
 
	270, 22, 410, 197,
 
	WC_GAME_OPTIONS, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
 
	_message_options_widgets,
 
	MessageOptionsWndProc
 
};
 

	
 
void ShowMessageOptions()
 
{
 
	DeleteWindowById(WC_GAME_OPTIONS, 0);
 
	AllocateWindowDesc(&_message_options_desc);
 
}
 

	
src/settings.cpp
Show inline comments
 
@@ -32,24 +32,25 @@
 
#include "settings.h"
 
#include "command.h"
 
#include "console.h"
 
#include "saveload.h"
 
#include "npf.h"
 
#include "yapf/yapf.h"
 
#include "newgrf.h"
 
#include "newgrf_config.h"
 
#include "genworld.h"
 
#include "date.h"
 
#include "rail.h"
 
#include "helpers.hpp"
 
#include "news.h"
 
#ifdef WITH_FREETYPE
 
#include "gfx.h"
 
#include "fontcache.h"
 
#endif
 

	
 
/** The patch values that are used for new games and/or modified in config file */
 
Patches _patches_newgame;
 

	
 
struct IniFile;
 
struct IniItem;
 
struct IniGroup;
 
struct SettingsMemoryPool;
 
@@ -1174,25 +1175,24 @@ extern uint _display_hz, _fullscreen_bpp
 
static const SettingDescGlobVarList _win32_settings[] = {
 
	 SDTG_VAR("display_hz",     SLE_UINT, S, 0, _display_hz,       0, 0, 120, 0, STR_NULL, NULL),
 
	SDTG_BOOL("force_full_redraw",        S, 0, _force_full_redraw,false,        STR_NULL, NULL),
 
	 SDTG_VAR("fullscreen_bpp", SLE_UINT, S, 0, _fullscreen_bpp,   8, 8,  32, 0, STR_NULL, NULL),
 
	SDTG_BOOL("double_size",              S, 0, _double_size,      false,        STR_NULL, NULL),
 
	SDTG_BOOL("window_maximize",          S, 0, _window_maximize,  false,        STR_NULL, NULL),
 
	 SDTG_END()
 
};
 
#endif /* WIN32 */
 

	
 
static const SettingDescGlobVarList _misc_settings[] = {
 
	SDTG_MMANY("display_opt",     SLE_UINT8, S, 0, _display_opt,       (DO_SHOW_TOWN_NAMES|DO_SHOW_STATION_NAMES|DO_SHOW_SIGNS|DO_FULL_ANIMATION|DO_FULL_DETAIL|DO_TRANS_BUILDINGS|DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION|TRANS_BUILDINGS|FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
 
	  SDTG_VAR("news_display_opt", SLE_UINT, S, 0, _news_display_opt,0xAAAAAAAA,0,0xAAAAAAAA,0,STR_NULL, NULL), // default to all full messages: 10101010101010101010 = 0xAAAAAAAA
 
	 SDTG_BOOL("news_ticker_sound",          S, 0, _news_ticker_sound,     true,    STR_NULL, NULL),
 
	 SDTG_BOOL("fullscreen",                 S, 0, _fullscreen,           false,    STR_NULL, NULL),
 
	  SDTG_STR("videodriver",      SLE_STRB,C|S,0, _ini_videodriver,       NULL,    STR_NULL, NULL),
 
	  SDTG_STR("musicdriver",      SLE_STRB,C|S,0, _ini_musicdriver,       NULL,    STR_NULL, NULL),
 
	  SDTG_STR("sounddriver",      SLE_STRB,C|S,0, _ini_sounddriver,       NULL,    STR_NULL, NULL),
 
	  SDTG_STR("language",         SLE_STRB, S, 0, _dynlang.curr_file,     NULL,    STR_NULL, NULL),
 
	 SDTG_LIST("resolution",     SLE_UINT16, S, 0, _cur_resolution,   "640,480",    STR_NULL, NULL),
 
	  SDTG_STR("screenshot_format",SLE_STRB, S, 0, _screenshot_format_name,NULL,    STR_NULL, NULL),
 
	  SDTG_STR("savegame_format",  SLE_STRB, S, 0, _savegame_format,       NULL,    STR_NULL, NULL),
 
	 SDTG_BOOL("rightclick_emulate",         S, 0, _rightclick_emulate,   false,    STR_NULL, NULL),
 
#ifdef WITH_FREETYPE
 
	  SDTG_STR("small_font",       SLE_STRB, S, 0, _freetype.small_font,   NULL,    STR_NULL, NULL),
 
@@ -1493,24 +1493,61 @@ static const SettingDesc _currency_setti
 

	
 
/* Undefine for the shortcut macros above */
 
#undef S
 
#undef C
 
#undef N
 

	
 
#undef D0
 
#undef NC
 
#undef MS
 
#undef NO
 
#undef CR
 

	
 
static uint NewsDisplayLoadConfig(IniFile *ini, const char *grpname)
 
{
 
	IniGroup *group = ini_getgroup(ini, grpname, -1);
 
	IniItem *item;
 
	/* By default, set everything to full (0xAAAAAAAA = 1010101010101010) */
 
	uint res = 0xAAAAAAAA;
 

	
 
	/* If no group exists, return everything full */
 
	if (group == NULL) return res;
 

	
 
	for (item = group->item; item != NULL; item = item->next) {
 
		int news_item = -1;
 
		for (int i = 0; i < NT_END; i++) {
 
			if (strcasecmp(item->name, _news_display_name[i]) == 0) {
 
				news_item = i;
 
				break;
 
			}
 
		}
 
		if (news_item == -1) {
 
			DEBUG(misc, 0, "Invalid display option: %s", item->name);
 
			continue;
 
		}
 

	
 
		if (strcasecmp(item->value, "full") == 0) {
 
			SB(res, news_item * 2, 2, 2);
 
		} else if (strcasecmp(item->value, "off") == 0) {
 
			SB(res, news_item * 2, 2, 0);
 
		} else if (strcasecmp(item->value, "summarized") == 0) {
 
			SB(res, news_item * 2, 2, 1);
 
		} else {
 
			DEBUG(misc, 0, "Invalid display value: %s", item->value);
 
			continue;
 
		}
 
	}
 

	
 
	return res;
 
}
 

	
 
/* Load a GRF configuration from the given group name */
 
static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_static)
 
{
 
	IniGroup *group = ini_getgroup(ini, grpname, -1);
 
	IniItem *item;
 
	GRFConfig *first = NULL;
 
	GRFConfig **curr = &first;
 

	
 
	if (group == NULL) return NULL;
 

	
 
	for (item = group->item; item != NULL; item = item->next) {
 
@@ -1547,24 +1584,44 @@ static GRFConfig *GRFLoadConfig(IniFile 
 

	
 
		/* Mark file as static to avoid saving in savegame. */
 
		if (is_static) SETBIT(c->flags, GCF_STATIC);
 

	
 
		/* Add item to list */
 
		*curr = c;
 
		curr = &c->next;
 
	}
 

	
 
	return first;
 
}
 

	
 
static void NewsDisplaySaveConfig(IniFile *ini, const char *grpname, uint news_display)
 
{
 
	IniGroup *group = ini_getgroup(ini, grpname, -1);
 
	IniItem **item;
 

	
 
	if (group == NULL) return;
 
	group->item = NULL;
 
	item = &group->item;
 

	
 
	for (int i = 0; i < NT_END; i++) {
 
		const char *value;
 
		int v = GB(news_display, i * 2, 2);
 

	
 
		value = (v == 0 ? "off" : (v == 1 ? "summarized" : "full"));
 

	
 
		*item = ini_item_alloc(group, _news_display_name[i], strlen(_news_display_name[i]));
 
		(*item)->value = (char*)pool_strdup(&ini->pool, value, strlen(value));
 
		item = &(*item)->next;
 
	}
 
}
 

	
 
/* Save a GRF configuration to the given group name */
 
static void GRFSaveConfig(IniFile *ini, const char *grpname, const GRFConfig *list)
 
{
 
	IniGroup *group = ini_getgroup(ini, grpname, -1);
 
	IniItem **item;
 
	const GRFConfig *c;
 

	
 
	if (group == NULL) return;
 
	group->item = NULL;
 
	item = &group->item;
 

	
 
@@ -1596,34 +1653,36 @@ static void HandleSettingDescs(IniFile *
 
	proc_list(ini, "servers", _network_host_list, lengthof(_network_host_list), NULL);
 
	proc_list(ini, "bans",    _network_ban_list,  lengthof(_network_ban_list), NULL);
 
#endif /* ENABLE_NETWORK */
 
}
 

	
 
/** Load the values from the configuration files */
 
void LoadFromConfig()
 
{
 
	IniFile *ini = ini_load(_config_file);
 
	HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list);
 
	_grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false);
 
	_grfconfig_static  = GRFLoadConfig(ini, "newgrf-static", true);
 
	_news_display_opt  = NewsDisplayLoadConfig(ini, "news_display");
 
	ini_free(ini);
 
}
 

	
 
/** Save the values to the configuration file */
 
void SaveToConfig()
 
{
 
	IniFile *ini = ini_load(_config_file);
 
	HandleSettingDescs(ini, ini_save_settings, ini_save_setting_list);
 
	GRFSaveConfig(ini, "newgrf", _grfconfig_newgame);
 
	GRFSaveConfig(ini, "newgrf-static", _grfconfig_static);
 
	NewsDisplaySaveConfig(ini, "news_display", _news_display_opt);
 
	ini_save(_config_file, ini);
 
	ini_free(ini);
 
}
 

	
 
static const SettingDesc *GetSettingDescription(uint index)
 
{
 
	if (index >= lengthof(_patch_settings)) return NULL;
 
	return &_patch_settings[index];
 
}
 

	
 
/** Network-safe changing of patch-settings (server-only).
 
 * @param p1 the index of the patch in the SettingDesc array which identifies it
 
@@ -1815,34 +1874,24 @@ static void Load_PATS()
 
	 * signal_side stays when joining a network-server */
 
	_patches = _patches_newgame;
 
	LoadSettings(_patch_settings, &_patches);
 
}
 

	
 
static void Save_PATS()
 
{
 
	SaveSettings(_patch_settings, &_patches);
 
}
 

	
 
void CheckConfig()
 
{
 
	// fix up news_display_opt from old to new
 
	int i;
 
	uint32 tmp;
 
	for (i = 0, tmp = _news_display_opt; i != 10; i++, tmp >>= 2) {
 
		if ((tmp & 0x3) == 0x3) { // old settings
 
			_news_display_opt = 0xAAAAAAAA; // set all news-messages to full 1010101010...
 
			break;
 
		}
 
	}
 

	
 
	// Increase old default values for pf_maxdepth and pf_maxlength
 
	// to support big networks.
 
	if (_patches_newgame.pf_maxdepth == 16 && _patches_newgame.pf_maxlength == 512) {
 
		_patches_newgame.pf_maxdepth = 48;
 
		_patches_newgame.pf_maxlength = 4096;
 
	}
 
}
 

	
 
void UpdatePatches()
 
{
 
	/* Since old(er) savegames don't have any patches saved, we initialise
 
	 * them with the default values just as it was in the old days.
0 comments (0 inline, 0 general)