1
0
Fork 0

Compare commits

...

9 Commits

Author SHA1 Message Date
Joan Josep 6b7537646d
Fix: Allow NewGRF inspection of road tiles. (#11323) 2023-09-20 22:54:34 +01:00
Peter Nelson 122bfa2afd Codechange: Use less locals for station free names bitmask. 2023-09-20 21:57:51 +01:00
Peter Nelson aeaa552385 Codechange: Use std::bitset instead of bool array.
This avoids use of C-style pointers and memset.
2023-09-20 21:57:51 +01:00
Peter Nelson 2eacf36d0a Codechange: List fallback station names by ID instead of magic number.
This improves readability and intention of the station name generator.
2023-09-20 21:57:51 +01:00
frosch f40816503f Codechange: Add enum items for dynmically created setting dropdowns. 2023-09-20 22:35:32 +02:00
frosch 39e67b6f4c Codechange: Use existing widget ids instead of raw numbers. 2023-09-20 22:35:32 +02:00
frosch e0df937247 Fix b5885295: NewGRF preset dropdown was broken. 2023-09-20 22:35:32 +02:00
translators 72323ae9e6 Update: Translations from eints
danish: 20 changes by bscargo
2023-09-20 18:38:51 +00:00
Joan Josep b9a1cb5d7c
Fix: Spelling of NIHAirport. (#11322) 2023-09-20 20:22:37 +02:00
15 changed files with 89 additions and 48 deletions

View File

@ -239,7 +239,7 @@ public:
void DrawWidget(const Rect &r, int widget) const override
{
if (widget != 0) return;
if (widget != WID_BAFD_QUESTION) return;
DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext), STR_MISSING_GRAPHICS_SET_MESSAGE, TC_FROMSTRING, SA_CENTER);
}

View File

@ -314,7 +314,7 @@ struct GSConfigWindow : public Window {
list.emplace_back(new DropDownListStringItem(config_item.labels.find(i)->second, i, false));
}
ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE);
ShowDropDownListAt(this, std::move(list), old_val, WID_GSC_SETTING_DROPDOWN, wi_rect, COLOUR_ORANGE);
}
}
} else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
@ -367,14 +367,14 @@ struct GSConfigWindow : public Window {
void OnDropdownSelect(int widget, int index) override
{
if (widget >= 0) return;
if (widget != WID_GSC_SETTING_DROPDOWN) return;
assert(this->clicked_dropdown);
SetValue(index);
}
void OnDropdownClose(Point, int widget, int, bool) override
{
if (widget >= 0) return;
if (widget != WID_GSC_SETTING_DROPDOWN) return;
/* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
* the same dropdown button was clicked again, and then not open the dropdown again.
* So, we only remember that it was closed, and process it on the next OnPaint, which is

View File

@ -523,6 +523,7 @@ STR_NEWS_MENU_DELETE_ALL_MESSAGES :Slet alle beske
# About menu
###length 11
STR_ABOUT_MENU_LAND_BLOCK_INFO :Landområde information
STR_ABOUT_MENU_HELP :Hjælp & manualer
STR_ABOUT_MENU_SEPARATOR :
STR_ABOUT_MENU_TOGGLE_CONSOLE :Tænd/Sluk konsol
STR_ABOUT_MENU_AI_DEBUG :Computerspiller/spilscript debug
@ -2124,6 +2125,7 @@ STR_INTRO_MULTIPLAYER :{BLACK}Netværk
STR_INTRO_GAME_OPTIONS :{BLACK}Opsætning
STR_INTRO_HIGHSCORE :{BLACK} Topresultater
STR_INTRO_HELP :{BLACK}Hjælp og manualer
STR_INTRO_CONFIG_SETTINGS_TREE :{BLACK}Indstillinger
STR_INTRO_NEWGRF_SETTINGS :{BLACK}NewGRF indstillinger
STR_INTRO_ONLINE_CONTENT :{BLACK}Tjek Online Indhold
@ -2145,6 +2147,7 @@ STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE :{BLACK}Vælg 'l
STR_INTRO_TOOLTIP_GAME_OPTIONS :{BLACK}Sæt spillet op
STR_INTRO_TOOLTIP_HIGHSCORE :{BLACK}Hvis topscoreliste
STR_INTRO_TOOLTIP_HELP :{BLACK}Få adgang til dokumentation og online ressourcer
STR_INTRO_TOOLTIP_CONFIG_SETTINGS_TREE :{BLACK}Skærm indstillinger
STR_INTRO_TOOLTIP_NEWGRF_SETTINGS :{BLACK}Vis NewGRF-indstillinger
STR_INTRO_TOOLTIP_ONLINE_CONTENT :{BLACK}Tjek for nyt og opdateret indhold til download
@ -2167,6 +2170,17 @@ STR_ABANDON_GAME_QUERY :{YELLOW}Er du s
STR_ABANDON_SCENARIO_QUERY :{YELLOW}Er du sikker på, at du vil afslutte dette scenarie ?
# Help window
STR_HELP_WINDOW_CAPTION :{WHITE}Hjælp og manualer
STR_HELP_WINDOW_WEBSITES :{BLACK}Hjemmesider
STR_HELP_WINDOW_DOCUMENTS :{BLACK}Dokumenter
STR_HELP_WINDOW_README :{BLACK}Læs mig
STR_HELP_WINDOW_CHANGELOG :{BLACK}Ændringslog
STR_HELP_WINDOW_KNOWN_BUGS :{BLACK}Kendte Bugs
STR_HELP_WINDOW_LICENSE :{BLACK}Licens
STR_HELP_WINDOW_MAIN_WEBSITE :{BLACK}OpenTTD
STR_HELP_WINDOW_MANUAL_WIKI :{BLACK}Manual / Wiki
STR_HELP_WINDOW_BUGTRACKER :{BLACK}Anmeld en fejl
STR_HELP_WINDOW_COMMUNITY :{BLACK}Fællesskab
# Cheat window
STR_CHEATS :{WHITE}Snydefunktioner
@ -4701,6 +4715,11 @@ STR_AI_SETTINGS_SETTING :{STRING}: {ORAN
# Textfile window
STR_TEXTFILE_JUMPLIST :{WHITE}Indholdsfortegnelse
STR_TEXTFILE_JUMPLIST_TOOLTIP :{BLACK}Spring hurtigt til en sektion i den viste fil via denne liste
STR_TEXTFILE_JUMPLIST_ITEM :{WHITE}{STRING}
STR_TEXTFILE_NAVBACK_TOOLTIP :{BLACK}Gå tilbage i navigationshistorikken
STR_TEXTFILE_NAVFORWARD_TOOLTIP :{BLACK}Vend tilbage i navigationshistorikken
STR_TEXTFILE_WRAP_TEXT :{WHITE}Ombryd tekst
STR_TEXTFILE_WRAP_TEXT_TOOLTIP :{BLACK}Ombryd teksten i vinduet, så det hele passer uden at skulle rulle
STR_TEXTFILE_VIEW_README :{BLACK}Se readme
@ -4711,6 +4730,7 @@ STR_TEXTFILE_README_CAPTION :{WHITE}{STRING}
STR_TEXTFILE_CHANGELOG_CAPTION :{WHITE}{STRING} ændringslog for {STRING}
STR_TEXTFILE_LICENCE_CAPTION :{WHITE}{STRING} licens for {STRING}
STR_TEXTFILE_SURVEY_RESULT_CAPTION :Forhåndsvisning af undersøgelsesresultat
STR_TEXTFILE_GAME_MANUAL_CAPTION :{WHITE}OpenTTD dokument '{STRING}'
# Vehicle loading indicators

View File

@ -3400,6 +3400,7 @@ STR_NEWGRF_INSPECT_PARENT_TOOLTIP :{BLACK}Inspect
STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT :{STRING1} at {HEX}
STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT :Object
STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE :Rail type
STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_ROAD_TYPE :Road type
STR_NEWGRF_INSPECT_QUERY_CAPTION :{WHITE}NewGRF variable 60+x parameter (hexadecimal)

View File

@ -775,7 +775,7 @@ GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
switch (GetTileType(tile)) {
default: return GSF_INVALID;
case MP_RAILWAY: return GSF_RAILTYPES;
case MP_ROAD: return IsLevelCrossing(tile) ? GSF_RAILTYPES : GSF_INVALID;
case MP_ROAD: return IsLevelCrossing(tile) ? GSF_RAILTYPES : GSF_ROADTYPES;
case MP_HOUSE: return GSF_HOUSES;
case MP_INDUSTRY: return GSF_INDUSTRYTILES;
case MP_OBJECT: return GSF_OBJECTS;

View File

@ -395,7 +395,7 @@ struct NewGRFParametersWindow : public Window {
list.emplace_back(new DropDownListStringItem(GetGRFStringFromGRFText(par_info.value_names.find(i)->second), i, false));
}
ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE);
ShowDropDownListAt(this, std::move(list), old_val, WID_NP_SETTING_DROPDOWN, wi_rect, COLOUR_ORANGE);
}
}
} else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
@ -453,7 +453,7 @@ struct NewGRFParametersWindow : public Window {
void OnDropdownSelect(int widget, int index) override
{
if (widget >= 0) return;
if (widget != WID_NP_SETTING_DROPDOWN) return;
assert(this->clicked_dropdown);
GRFParameterInfo &par_info = this->GetParameterInfo(this->clicked_row);
par_info.SetValue(this->grf_config, index);
@ -462,7 +462,7 @@ struct NewGRFParametersWindow : public Window {
void OnDropdownClose(Point, int widget, int, bool) override
{
if (widget >= 0) return;
if (widget != WID_NP_SETTING_DROPDOWN) return;
/* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
* the same dropdown button was clicked again, and then not open the dropdown again.
* So, we only remember that it was closed, and process it on the next OnPaint, which is
@ -1171,7 +1171,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
void OnDropdownSelect(int widget, int index) override
{
if (widget >= 0) return;
if (widget != WID_NS_PRESET_LIST) return;
if (!this->editable) return;
ClearGRFConfigList(&this->actives);

View File

@ -29,10 +29,9 @@ struct ScreenshotWindow : Window {
void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
{
if (widget < 0) return;
ScreenshotType st;
switch (widget) {
default:
default: return;
case WID_SC_TAKE: st = SC_VIEWPORT; break;
case WID_SC_TAKE_ZOOMIN: st = SC_ZOOMEDIN; break;
case WID_SC_TAKE_DEFAULTZOOM: st = SC_DEFAULTZOOM; break;

View File

@ -472,7 +472,7 @@ struct ScriptSettingsWindow : public Window {
list.emplace_back(new DropDownListStringItem(config_item.labels.find(i)->second, i, false));
}
ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE);
ShowDropDownListAt(this, std::move(list), old_val, WID_SCRS_SETTING_DROPDOWN, wi_rect, COLOUR_ORANGE);
}
}
} else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
@ -526,14 +526,14 @@ struct ScriptSettingsWindow : public Window {
void OnDropdownSelect(int widget, int index) override
{
if (widget >= 0) return;
if (widget != WID_SCRS_SETTING_DROPDOWN) return;
assert(this->clicked_dropdown);
SetValue(index);
}
void OnDropdownClose(Point, int widget, int, bool) override
{
if (widget >= 0) return;
if (widget != WID_SCRS_SETTING_DROPDOWN) return;
/* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
* the same dropdown button was clicked again, and then not open the dropdown again.
* So, we only remember that it was closed, and process it on the next OnPaint, which is

View File

@ -2394,7 +2394,7 @@ struct GameSettingsWindow : Window {
list.emplace_back(new DropDownListStringItem(sd->str_val + i - sd->min, i, false));
}
ShowDropDownListAt(this, std::move(list), value, -1, wi_rect, COLOUR_ORANGE);
ShowDropDownListAt(this, std::move(list), value, WID_GS_SETTING_DROPDOWN, wi_rect, COLOUR_ORANGE);
}
}
this->SetDirty();
@ -2526,23 +2526,21 @@ struct GameSettingsWindow : Window {
this->InvalidateData();
break;
default:
if (widget < 0) {
/* Deal with drop down boxes on the panel. */
assert(this->valuedropdown_entry != nullptr);
const IntSettingDesc *sd = this->valuedropdown_entry->setting;
assert(sd->flags & SF_GUI_DROPDOWN);
case WID_GS_SETTING_DROPDOWN:
/* Deal with drop down boxes on the panel. */
assert(this->valuedropdown_entry != nullptr);
const IntSettingDesc *sd = this->valuedropdown_entry->setting;
assert(sd->flags & SF_GUI_DROPDOWN);
SetSettingValue(sd, index);
this->SetDirty();
}
SetSettingValue(sd, index);
this->SetDirty();
break;
}
}
void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
{
if (widget >= 0) {
if (widget != WID_GS_SETTING_DROPDOWN) {
/* Normally the default implementation of OnDropdownClose() takes care of
* a few things. We want that behaviour here too, but only for
* "normal" dropdown boxes. The special dropdown boxes added for every

View File

@ -67,6 +67,8 @@
#include "table/strings.h"
#include <bitset>
#include "safeguards.h"
/**
@ -216,7 +218,7 @@ enum StationNaming {
/** Information to handle station action 0 property 24 correctly */
struct StationNameInformation {
uint32_t free_names; ///< Current bitset of free names (we can remove names).
bool *indtypes; ///< Array of bools telling whether an industry type has been found.
std::bitset<NUM_INDUSTRYTYPES> indtypes; ///< Bit set indicating when an industry type has been found.
};
/**
@ -255,21 +257,20 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
};
const Town *t = st->town;
uint32_t free_names = UINT32_MAX;
bool indtypes[NUM_INDUSTRYTYPES];
memset(indtypes, 0, sizeof(indtypes));
StationNameInformation sni{};
sni.free_names = UINT32_MAX;
for (const Station *s : Station::Iterate()) {
if (s != st && s->town == t) {
if (s->indtype != IT_INVALID) {
indtypes[s->indtype] = true;
sni.indtypes[s->indtype] = true;
StringID name = GetIndustrySpec(s->indtype)->station_name;
if (name != STR_UNDEFINED) {
/* Filter for other industrytypes with the same name */
for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
const IndustrySpec *indsp = GetIndustrySpec(it);
if (indsp->enabled && indsp->station_name == name) indtypes[it] = true;
if (indsp->enabled && indsp->station_name == name) sni.indtypes[it] = true;
}
}
continue;
@ -279,13 +280,12 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
if (str == M(STR_SV_STNAME_FOREST)) {
str = M(STR_SV_STNAME_WOODS);
}
ClrBit(free_names, str);
ClrBit(sni.free_names, str);
}
}
}
TileIndex indtile = tile;
StationNameInformation sni = { free_names, indtypes };
if (CircularTileSearch(&indtile, 7, FindNearIndustryName, &sni)) {
/* An industry has been found nearby */
IndustryType indtype = GetIndustryType(indtile);
@ -298,14 +298,13 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
}
/* Oil rigs/mines name could be marked not free by looking for a near by industry. */
free_names = sni.free_names;
/* check default names */
uint32_t tmp = free_names & _gen_station_name_bits[name_class];
uint32_t tmp = sni.free_names & _gen_station_name_bits[name_class];
if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp);
/* check mine? */
if (HasBit(free_names, M(STR_SV_STNAME_MINES))) {
if (HasBit(sni.free_names, M(STR_SV_STNAME_MINES))) {
if (CountMapSquareAround(tile, CMSAMine) >= 2) {
return STR_SV_STNAME_MINES;
}
@ -313,20 +312,20 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
/* check close enough to town to get central as name? */
if (DistanceMax(tile, t->xy) < 8) {
if (HasBit(free_names, M(STR_SV_STNAME))) return STR_SV_STNAME;
if (HasBit(sni.free_names, M(STR_SV_STNAME))) return STR_SV_STNAME;
if (HasBit(free_names, M(STR_SV_STNAME_CENTRAL))) return STR_SV_STNAME_CENTRAL;
if (HasBit(sni.free_names, M(STR_SV_STNAME_CENTRAL))) return STR_SV_STNAME_CENTRAL;
}
/* Check lakeside */
if (HasBit(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
if (HasBit(sni.free_names, M(STR_SV_STNAME_LAKESIDE)) &&
DistanceFromEdge(tile) < 20 &&
CountMapSquareAround(tile, CMSAWater) >= 5) {
return STR_SV_STNAME_LAKESIDE;
}
/* Check woods */
if (HasBit(free_names, M(STR_SV_STNAME_WOODS)) && (
if (HasBit(sni.free_names, M(STR_SV_STNAME_WOODS)) && (
CountMapSquareAround(tile, CMSATree) >= 8 ||
CountMapSquareAround(tile, IsTileForestIndustry) >= 2)
) {
@ -337,9 +336,9 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
int z = GetTileZ(tile);
int z2 = GetTileZ(t->xy);
if (z < z2) {
if (HasBit(free_names, M(STR_SV_STNAME_VALLEY))) return STR_SV_STNAME_VALLEY;
if (HasBit(sni.free_names, M(STR_SV_STNAME_VALLEY))) return STR_SV_STNAME_VALLEY;
} else if (z > z2) {
if (HasBit(free_names, M(STR_SV_STNAME_HEIGHTS))) return STR_SV_STNAME_HEIGHTS;
if (HasBit(sni.free_names, M(STR_SV_STNAME_HEIGHTS))) return STR_SV_STNAME_HEIGHTS;
}
/* check direction compared to town */
@ -350,12 +349,28 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ),
};
free_names &= _direction_and_table[
sni.free_names &= _direction_and_table[
(TileX(tile) < TileX(t->xy)) +
(TileY(tile) < TileY(t->xy)) * 2];
tmp = free_names & ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 26) | (1 << 27) | (1 << 28) | (1 << 29) | (1 << 30));
return (tmp == 0) ? STR_SV_STNAME_FALLBACK : (STR_SV_STNAME + FindFirstBit(tmp));
/** Bitmask of remaining station names that can be used when a more specific name has not been used. */
static const uint32_t fallback_names = (
(1U << M(STR_SV_STNAME_NORTH)) |
(1U << M(STR_SV_STNAME_SOUTH)) |
(1U << M(STR_SV_STNAME_EAST)) |
(1U << M(STR_SV_STNAME_WEST)) |
(1U << M(STR_SV_STNAME_TRANSFER)) |
(1U << M(STR_SV_STNAME_HALT)) |
(1U << M(STR_SV_STNAME_EXCHANGE)) |
(1U << M(STR_SV_STNAME_ANNEXE)) |
(1U << M(STR_SV_STNAME_SIDINGS)) |
(1U << M(STR_SV_STNAME_BRANCH)) |
(1U << M(STR_SV_STNAME_UPPER)) |
(1U << M(STR_SV_STNAME_LOWER))
);
sni.free_names &= fallback_names;
return (sni.free_names == 0) ? STR_SV_STNAME_FALLBACK : (STR_SV_STNAME + FindFirstBit(sni.free_names));
}
#undef M

View File

@ -533,7 +533,7 @@ static const NIVariable _niv_airports[] = {
NIV_END()
};
class NIHAiport : public NIHelper {
class NIHAirport : public NIHelper {
bool IsInspectable(uint index) const override { return AirportSpec::Get(Station::Get(index)->airport.type)->grf_prop.grffile != nullptr; }
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::Get(index)->town->index); }
const void *GetInstance(uint index)const override { return Station::Get(index); }
@ -562,7 +562,7 @@ static const NIFeature _nif_airport = {
nullptr,
nullptr,
_niv_airports,
new NIHAiport(),
new NIHAirport(),
};
@ -632,7 +632,7 @@ class NIHRoadType : public NIHelper {
uint GetParent(uint) const override { return UINT32_MAX; }
const void *GetInstance(uint) const override { return nullptr; }
const void *GetSpec(uint) const override { return nullptr; }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_ROAD_TYPE, INVALID_STRING_ID, index); }
uint32_t GetGRFID(uint) const override { return 0; }
uint Resolve(uint index, uint var, uint param, bool *avail) const override

View File

@ -23,6 +23,8 @@ enum GSConfigWidgets {
WID_GSC_CONTENT_DOWNLOAD = WID_GSC_TEXTFILE + TFT_CONTENT_END, ///< Download content button.
WID_GSC_ACCEPT, ///< Accept ("Close") button
WID_GSC_RESET, ///< Reset button.
WID_GSC_SETTING_DROPDOWN = -1, ///< Dynamically created dropdown for changing setting value.
};
#endif /* WIDGETS_GS_WIDGET_H */

View File

@ -26,6 +26,8 @@ enum NewGRFParametersWidgets {
WID_NP_RESET, ///< Reset button.
WID_NP_SHOW_DESCRIPTION, ///< #NWID_SELECTION to optionally display parameter descriptions.
WID_NP_DESCRIPTION, ///< Multi-line description of a parameter.
WID_NP_SETTING_DROPDOWN = -1, ///< Dynamically created dropdown for changing setting value.
};
/** Widgets of the #NewGRFWindow class. */

View File

@ -29,6 +29,8 @@ enum ScriptSettingsWidgets {
WID_SCRS_SCROLLBAR, ///< Scrollbar to scroll through all settings.
WID_SCRS_ACCEPT, ///< Accept button.
WID_SCRS_RESET, ///< Reset button.
WID_SCRS_SETTING_DROPDOWN = -1, ///< Dynamically created dropdown for changing setting value.
};
/** Widgets of the #ScriptDebugWindow class. */

View File

@ -64,6 +64,8 @@ enum GameSettingsWidgets {
WID_GS_RESTRICT_TYPE, ///< Label upfront to the type drop-down box to restrict the list of settings to show
WID_GS_RESTRICT_DROPDOWN, ///< The drop down box to restrict the list of settings
WID_GS_TYPE_DROPDOWN, ///< The drop down box to choose client/game/company/all settings
WID_GS_SETTING_DROPDOWN = -1, ///< Dynamically created dropdown for changing setting value.
};
/** Widgets of the #CustomCurrencyWindow class. */