1181 }; |
1182 }; |
1182 #endif /* WIN32 */ |
1183 #endif /* WIN32 */ |
1183 |
1184 |
1184 static const SettingDescGlobVarList _misc_settings[] = { |
1185 static const SettingDescGlobVarList _misc_settings[] = { |
1185 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), |
1186 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), |
1186 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 |
|
1187 SDTG_BOOL("news_ticker_sound", S, 0, _news_ticker_sound, true, STR_NULL, NULL), |
1187 SDTG_BOOL("news_ticker_sound", S, 0, _news_ticker_sound, true, STR_NULL, NULL), |
1188 SDTG_BOOL("fullscreen", S, 0, _fullscreen, false, STR_NULL, NULL), |
1188 SDTG_BOOL("fullscreen", S, 0, _fullscreen, false, STR_NULL, NULL), |
1189 SDTG_STR("videodriver", SLE_STRB,C|S,0, _ini_videodriver, NULL, STR_NULL, NULL), |
1189 SDTG_STR("videodriver", SLE_STRB,C|S,0, _ini_videodriver, NULL, STR_NULL, NULL), |
1190 SDTG_STR("musicdriver", SLE_STRB,C|S,0, _ini_musicdriver, NULL, STR_NULL, NULL), |
1190 SDTG_STR("musicdriver", SLE_STRB,C|S,0, _ini_musicdriver, NULL, STR_NULL, NULL), |
1191 SDTG_STR("sounddriver", SLE_STRB,C|S,0, _ini_sounddriver, NULL, STR_NULL, NULL), |
1191 SDTG_STR("sounddriver", SLE_STRB,C|S,0, _ini_sounddriver, NULL, STR_NULL, NULL), |
1500 #undef NC |
1500 #undef NC |
1501 #undef MS |
1501 #undef MS |
1502 #undef NO |
1502 #undef NO |
1503 #undef CR |
1503 #undef CR |
1504 |
1504 |
|
1505 static uint NewsDisplayLoadConfig(IniFile *ini, const char *grpname) |
|
1506 { |
|
1507 IniGroup *group = ini_getgroup(ini, grpname, -1); |
|
1508 IniItem *item; |
|
1509 /* By default, set everything to full (0xAAAAAAAA = 1010101010101010) */ |
|
1510 uint res = 0xAAAAAAAA; |
|
1511 |
|
1512 /* If no group exists, return everything full */ |
|
1513 if (group == NULL) return res; |
|
1514 |
|
1515 for (item = group->item; item != NULL; item = item->next) { |
|
1516 int news_item = -1; |
|
1517 for (int i = 0; i < NT_END; i++) { |
|
1518 if (strcasecmp(item->name, _news_display_name[i]) == 0) { |
|
1519 news_item = i; |
|
1520 break; |
|
1521 } |
|
1522 } |
|
1523 if (news_item == -1) { |
|
1524 DEBUG(misc, 0, "Invalid display option: %s", item->name); |
|
1525 continue; |
|
1526 } |
|
1527 |
|
1528 if (strcasecmp(item->value, "full") == 0) { |
|
1529 SB(res, news_item * 2, 2, 2); |
|
1530 } else if (strcasecmp(item->value, "off") == 0) { |
|
1531 SB(res, news_item * 2, 2, 0); |
|
1532 } else if (strcasecmp(item->value, "summarized") == 0) { |
|
1533 SB(res, news_item * 2, 2, 1); |
|
1534 } else { |
|
1535 DEBUG(misc, 0, "Invalid display value: %s", item->value); |
|
1536 continue; |
|
1537 } |
|
1538 } |
|
1539 |
|
1540 return res; |
|
1541 } |
1505 |
1542 |
1506 /* Load a GRF configuration from the given group name */ |
1543 /* Load a GRF configuration from the given group name */ |
1507 static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_static) |
1544 static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_static) |
1508 { |
1545 { |
1509 IniGroup *group = ini_getgroup(ini, grpname, -1); |
1546 IniGroup *group = ini_getgroup(ini, grpname, -1); |
1554 } |
1591 } |
1555 |
1592 |
1556 return first; |
1593 return first; |
1557 } |
1594 } |
1558 |
1595 |
|
1596 static void NewsDisplaySaveConfig(IniFile *ini, const char *grpname, uint news_display) |
|
1597 { |
|
1598 IniGroup *group = ini_getgroup(ini, grpname, -1); |
|
1599 IniItem **item; |
|
1600 |
|
1601 if (group == NULL) return; |
|
1602 group->item = NULL; |
|
1603 item = &group->item; |
|
1604 |
|
1605 for (int i = 0; i < NT_END; i++) { |
|
1606 const char *value; |
|
1607 int v = GB(news_display, i * 2, 2); |
|
1608 |
|
1609 value = (v == 0 ? "off" : (v == 1 ? "summarized" : "full")); |
|
1610 |
|
1611 *item = ini_item_alloc(group, _news_display_name[i], strlen(_news_display_name[i])); |
|
1612 (*item)->value = (char*)pool_strdup(&ini->pool, value, strlen(value)); |
|
1613 item = &(*item)->next; |
|
1614 } |
|
1615 } |
1559 |
1616 |
1560 /* Save a GRF configuration to the given group name */ |
1617 /* Save a GRF configuration to the given group name */ |
1561 static void GRFSaveConfig(IniFile *ini, const char *grpname, const GRFConfig *list) |
1618 static void GRFSaveConfig(IniFile *ini, const char *grpname, const GRFConfig *list) |
1562 { |
1619 { |
1563 IniGroup *group = ini_getgroup(ini, grpname, -1); |
1620 IniGroup *group = ini_getgroup(ini, grpname, -1); |
1603 { |
1660 { |
1604 IniFile *ini = ini_load(_config_file); |
1661 IniFile *ini = ini_load(_config_file); |
1605 HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list); |
1662 HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list); |
1606 _grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false); |
1663 _grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false); |
1607 _grfconfig_static = GRFLoadConfig(ini, "newgrf-static", true); |
1664 _grfconfig_static = GRFLoadConfig(ini, "newgrf-static", true); |
|
1665 _news_display_opt = NewsDisplayLoadConfig(ini, "news_display"); |
1608 ini_free(ini); |
1666 ini_free(ini); |
1609 } |
1667 } |
1610 |
1668 |
1611 /** Save the values to the configuration file */ |
1669 /** Save the values to the configuration file */ |
1612 void SaveToConfig() |
1670 void SaveToConfig() |
1613 { |
1671 { |
1614 IniFile *ini = ini_load(_config_file); |
1672 IniFile *ini = ini_load(_config_file); |
1615 HandleSettingDescs(ini, ini_save_settings, ini_save_setting_list); |
1673 HandleSettingDescs(ini, ini_save_settings, ini_save_setting_list); |
1616 GRFSaveConfig(ini, "newgrf", _grfconfig_newgame); |
1674 GRFSaveConfig(ini, "newgrf", _grfconfig_newgame); |
1617 GRFSaveConfig(ini, "newgrf-static", _grfconfig_static); |
1675 GRFSaveConfig(ini, "newgrf-static", _grfconfig_static); |
|
1676 NewsDisplaySaveConfig(ini, "news_display", _news_display_opt); |
1618 ini_save(_config_file, ini); |
1677 ini_save(_config_file, ini); |
1619 ini_free(ini); |
1678 ini_free(ini); |
1620 } |
1679 } |
1621 |
1680 |
1622 static const SettingDesc *GetSettingDescription(uint index) |
1681 static const SettingDesc *GetSettingDescription(uint index) |
1822 SaveSettings(_patch_settings, &_patches); |
1881 SaveSettings(_patch_settings, &_patches); |
1823 } |
1882 } |
1824 |
1883 |
1825 void CheckConfig() |
1884 void CheckConfig() |
1826 { |
1885 { |
1827 // fix up news_display_opt from old to new |
|
1828 int i; |
|
1829 uint32 tmp; |
|
1830 for (i = 0, tmp = _news_display_opt; i != 10; i++, tmp >>= 2) { |
|
1831 if ((tmp & 0x3) == 0x3) { // old settings |
|
1832 _news_display_opt = 0xAAAAAAAA; // set all news-messages to full 1010101010... |
|
1833 break; |
|
1834 } |
|
1835 } |
|
1836 |
|
1837 // Increase old default values for pf_maxdepth and pf_maxlength |
1886 // Increase old default values for pf_maxdepth and pf_maxlength |
1838 // to support big networks. |
1887 // to support big networks. |
1839 if (_patches_newgame.pf_maxdepth == 16 && _patches_newgame.pf_maxlength == 512) { |
1888 if (_patches_newgame.pf_maxdepth == 16 && _patches_newgame.pf_maxlength == 512) { |
1840 _patches_newgame.pf_maxdepth = 48; |
1889 _patches_newgame.pf_maxdepth = 48; |
1841 _patches_newgame.pf_maxlength = 4096; |
1890 _patches_newgame.pf_maxlength = 4096; |