summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-03-10 12:10:00 +0000
committertruelight <truelight@openttd.org>2007-03-10 12:10:00 +0000
commit146e5e12ecf9c7e9c0b7b768fdb4b153821503d3 (patch)
tree0fec6ef4cf0f5115edac8e54f6eeb6d8aef39cce
parent1461e39bb9f0640758244a4a30e7cc0eaee6db94 (diff)
downloadopenttd-146e5e12ecf9c7e9c0b7b768fdb4b153821503d3.tar.xz
(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)
-rw-r--r--src/industry_cmd.cpp6
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/news.h3
-rw-r--r--src/news_gui.cpp54
-rw-r--r--src/settings.cpp71
5 files changed, 104 insertions, 31 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 5be05d0ea..b7fb11d1d 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1670,7 +1670,7 @@ static void ExtChangeIndustryProduction(Industry *i)
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
);
}
@@ -1749,7 +1749,7 @@ static void MaybeNewIndustry(uint32 r)
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)
@@ -1816,7 +1816,7 @@ static void ChangeIndustryProduction(Industry *i)
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);
}
}
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 1ad03870d..e1e8b9c7b 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -591,6 +591,7 @@ STR_0206_ARRIVAL_OF_FIRST_VEHICLE :{YELLOW}Arrival
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
diff --git a/src/news.h b/src/news.h
index 39cab2a4f..362b34a03 100644
--- a/src/news.h
+++ b/src/news.h
@@ -35,6 +35,7 @@ enum NewsType {
NT_ARRIVAL_OTHER,
NT_ACCIDENT,
NT_COMPANY_INFO,
+ NT_OPENCLOSE,
NT_ECONOMY,
NT_ADVICE,
NT_NEW_VEHICLES,
@@ -44,6 +45,8 @@ enum NewsType {
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)
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 42a7ab14b..420fc9aef 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -355,17 +355,32 @@ static WindowDesc _news_type0_desc = {
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
@@ -761,7 +776,7 @@ static void MessageOptionsWndProc(Window *w, WindowEvent *e)
}
/* 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:
@@ -796,8 +811,8 @@ static void MessageOptionsWndProc(Window *w, WindowEvent *e)
WP(w, def_d).data_1 = e->we.dropdown.index;
for (i = 0; i < NT_END; i++) {
- SetNewsDisplayValue(i, e->we.dropdown.index);
SetMessageButtonStates(w, e->we.dropdown.index, i);
+ SetNewsDisplayValue(i, e->we.dropdown.index);
}
SetWindowDirty(w);
} break;
@@ -807,18 +822,18 @@ static void MessageOptionsWndProc(Window *w, WindowEvent *e)
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},
@@ -844,38 +859,43 @@ static const Widget _message_options_widgets[] = {
{ 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,
diff --git a/src/settings.cpp b/src/settings.cpp
index 3f251551b..613156945 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -41,6 +41,7 @@
#include "date.h"
#include "rail.h"
#include "helpers.hpp"
+#include "news.h"
#ifdef WITH_FREETYPE
#include "gfx.h"
#include "fontcache.h"
@@ -1183,7 +1184,6 @@ static const SettingDescGlobVarList _win32_settings[] = {
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),
@@ -1502,6 +1502,43 @@ static const SettingDesc _currency_settings[] = {
#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)
@@ -1556,6 +1593,26 @@ static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_stati
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)
@@ -1605,6 +1662,7 @@ void LoadFromConfig()
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);
}
@@ -1615,6 +1673,7 @@ void SaveToConfig()
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);
}
@@ -1824,16 +1883,6 @@ static void Save_PATS()
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) {