1
0
Fork 0

Compare commits

...

5 Commits

Author SHA1 Message Date
Tyler Trahan 0316dfc34e
Merge 1e1b2c8037 into 13759e9f23 2025-07-25 07:43:58 +00:00
Peter Nelson 13759e9f23
Fix: Display GRFID in correct hex format. (#14478) 2025-07-25 08:41:48 +01:00
translators 3e06c69e26 Update: Translations from eints
portuguese: 1 change by jcteotonio
polish: 6 changes by pAter-exe
2025-07-25 04:47:26 +00:00
Tyler Trahan 1e1b2c8037 Change: Convert house placer protection buttons to a single toggle 2025-07-21 14:18:29 -04:00
Tyler Trahan 632029e277 Feature: House placer mode to overbuild existing houses 2025-07-21 14:18:29 -04:00
8 changed files with 64 additions and 49 deletions

View File

@ -2859,10 +2859,11 @@ STR_HOUSE_PICKER_CLASS_ZONE3 :Outer Suburbs
STR_HOUSE_PICKER_CLASS_ZONE4 :Inner Suburbs
STR_HOUSE_PICKER_CLASS_ZONE5 :Town centre
STR_HOUSE_PICKER_PROTECT_TITLE :Prevent upgrades
STR_HOUSE_PICKER_PROTECT :Prevent upgrades
STR_HOUSE_PICKER_PROTECT_TOOLTIP :Choose whether this house will be protected from replacement as the town grows
STR_HOUSE_PICKER_PROTECT_OFF :Off
STR_HOUSE_PICKER_PROTECT_ON :On
STR_HOUSE_PICKER_OVERBUILD :Overbuild existing
STR_HOUSE_PICKER_OVERBUILD_TOOLTIP :Choose whether to automatically remove an existing house on the tile where this house is placed
STR_STATION_CLASS_DFLT :Default
STR_STATION_CLASS_DFLT_STATION :Default station

View File

@ -1010,11 +1010,14 @@ STR_GRAPH_CARGO_ENABLE_ALL :{TINY_FONT}{BLA
STR_GRAPH_CARGO_DISABLE_ALL :{TINY_FONT}{BLACK}Żaden
STR_GRAPH_CARGO_TOOLTIP_ENABLE_ALL :{BLACK}Wyświetl wszystkie ładunki na wykresie stawek za ładunek
STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL :{BLACK}Ukryj wszystkie ładunki na wykresie stawek za ładunek
STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO :{BLACK}Przełącz ukrywanie/wyświetlanie wykresu danego typu ładunku
STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO :{BLACK}Przełącz ukrywanie/wyświetlanie wykresu ładunku danego typu
STR_GRAPH_CARGO_PAYMENT_CARGO :{TINY_FONT}{BLACK}{STRING}
STR_GRAPH_INDUSTRY_CAPTION :{WHITE}{INDUSTRY} - Historia Ładunków
STR_GRAPH_INDUSTRY_RANGE_PRODUCED :Wyprodukowano
STR_GRAPH_INDUSTRY_RANGE_TRANSPORTED :Przetransportowano
STR_GRAPH_INDUSTRY_RANGE_DELIVERED :Dostarczono
STR_GRAPH_INDUSTRY_RANGE_WAITING :Oczekujący
STR_GRAPH_PERFORMANCE_DETAIL_TOOLTIP :{BLACK}Pokaż szczegóły oceny wydajności
@ -4403,6 +4406,8 @@ STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE :{BLACK}Wyproduk
STR_INDUSTRY_VIEW_PRODUCTION_LAST_MINUTE_TITLE :{BLACK}Wyprodukowano w poprzedniej minucie:
STR_INDUSTRY_VIEW_TRANSPORTED :{YELLOW}{CARGO_LONG}{STRING}{BLACK} ({COMMA}% przetransportowano)
STR_INDUSTRY_VIEW_LOCATION_TOOLTIP :{BLACK}Wyśrodkuj widok główny na lokalizacji przedsiębiorstwa. Użyj Ctrl, aby otworzyć nowy podgląd na jego lokalizację
STR_INDUSTRY_VIEW_CARGO_GRAPH :{BLACK}Wykres Produkcji
STR_INDUSTRY_VIEW_CARGO_GRAPH_TOOLTIP :{BLACK}Wyświetl na wykresie historię stanu ładunków w tym przedsiębiorstwie
STR_INDUSTRY_VIEW_PRODUCTION_LEVEL :{BLACK}Poziom produkcji: {YELLOW}{COMMA}%
STR_INDUSTRY_VIEW_INDUSTRY_ANNOUNCED_CLOSURE :{YELLOW}Przedsiębiorstwo ogłosiło likwidację!

View File

@ -20,7 +20,7 @@
##id 0x0000
STR_NULL :
STR_EMPTY :
STR_UNDEFINED :(frase indefinida)
STR_UNDEFINED :(cadeia de caracteres indefinida)
STR_JUST_NOTHING :Nada
# Cargo related strings

View File

@ -59,7 +59,7 @@ static ChangeInfoResult LoadTranslationTable(uint first, uint last, ByteReader &
GRFFile *grf_override = GetCurrentGRFOverride();
if (grf_override != nullptr) {
/* GRF override is present, copy the translation table to the overridden GRF as well. */
GrfMsg(1, "LoadTranslationTable: Copying {} translation table to override GRFID '{}'", name, std::byteswap(grf_override->grfid));
GrfMsg(1, "LoadTranslationTable: Copying {} translation table to override GRFID {:08X}", name, std::byteswap(grf_override->grfid));
std::vector<T> &override_table = gettable(*grf_override);
override_table = translation_table;
}

View File

@ -2894,9 +2894,10 @@ static bool TryBuildTownHouse(Town *t, TileIndex tile, TownExpandModes modes)
* @param tile Tile on which to place the house.
* @param HouseID The HouseID of the house spec.
* @param is_protected Whether the house is protected from the town upgrading it.
* @param overbuild Whether to automatically demolish an existing house on this tile, if present.
* @return Empty cost or an error.
*/
CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, bool is_protected)
CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, bool is_protected, bool overbuild)
{
if (_game_mode != GM_EDITOR && _settings_game.economy.place_houses == PH_FORBIDDEN) return CMD_ERROR;
@ -2906,39 +2907,45 @@ CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, b
const HouseSpec *hs = HouseSpec::Get(house);
if (!hs->enabled) return CMD_ERROR;
Town *t = ClosestTownFromTile(tile, UINT_MAX);
/* cannot build on these slopes... */
Slope slope = GetTileSlope(tile);
if (IsSteepSlope(slope)) return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
/* building under a bridge? */
if (IsBridgeAbove(tile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
/* can we clear the land? */
CommandCost cost = Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile);
if (!cost.Succeeded()) return cost;
int maxz = GetTileMaxZ(tile);
/* Make sure there is no slope? */
bool noslope = hs->building_flags.Test(BuildingFlag::NotSloped);
if (noslope && slope != SLOPE_FLAT) return CommandCost(STR_ERROR_FLAT_LAND_REQUIRED);
TileArea ta = tile;
/* Check each tile of a multi-tile house. */
TileArea ta(tile, 1, 1);
if (hs->building_flags.Test(BuildingFlag::Size2x2)) ta.Add(TileAddXY(tile, 1, 1));
if (hs->building_flags.Test(BuildingFlag::Size2x1)) ta.Add(TileAddByDiagDir(tile, DIAGDIR_SW));
if (hs->building_flags.Test(BuildingFlag::Size1x2)) ta.Add(TileAddByDiagDir(tile, DIAGDIR_SE));
/* Check additional tiles covered by this house. */
for (const TileIndex &subtile : ta) {
cost = Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, subtile);
if (!cost.Succeeded()) return cost;
for (const TileIndex subtile : ta) {
/* Houses cannot be built on steep slopes. */
Slope slope = GetTileSlope(subtile);
if (IsSteepSlope(slope)) return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
if (!CheckBuildHouseSameZ(subtile, maxz, noslope)) return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
/* Houses cannot be built under bridges. */
if (IsBridgeAbove(subtile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
/* Make sure there is no slope? */
bool noslope = hs->building_flags.Test(BuildingFlag::NotSloped);
if (noslope && slope != SLOPE_FLAT) return CommandCost(STR_ERROR_FLAT_LAND_REQUIRED);
/* All tiles of a multi-tile house must have the same z-level. */
if (GetTileMaxZ(subtile) != maxz) return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
/* We might be overbuilding an existing house, otherwise check if we can clear land. */
if (!(overbuild && GetTileType(subtile) == MP_HOUSE)) {
CommandCost cost = Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, subtile);
if (!cost.Succeeded()) return cost;
}
}
if (flags.Test(DoCommandFlag::Execute)) {
/* If overbuilding, clear any existing houses first. */
if (overbuild) {
for (const TileIndex &subtile : ta) {
if (GetTileType(subtile) == MP_HOUSE) ClearTownHouse(Town::GetByTile(subtile), subtile);
}
}
Town *t = ClosestTownFromTile(tile, UINT_MAX);
bool house_completed = _settings_game.economy.place_houses == PH_ALLOWED_CONSTRUCTED;
BuildTownHouse(t, tile, hs, house, Random(), house_completed, is_protected);
}

View File

@ -27,7 +27,7 @@ CommandCost CmdTownCargoGoal(DoCommandFlags flags, TownID town_id, TownAcceptanc
CommandCost CmdTownSetText(DoCommandFlags flags, TownID town_id, const EncodedString &text);
CommandCost CmdExpandTown(DoCommandFlags flags, TownID town_id, uint32_t grow_amount, TownExpandModes modes);
CommandCost CmdDeleteTown(DoCommandFlags flags, TownID town_id);
CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, bool house_protected);
CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, bool house_protected, bool overbuild);
DEF_CMD_TRAIT(CMD_FOUND_TOWN, CmdFoundTown, CommandFlags({CommandFlag::Deity, CommandFlag::NoTest}), CMDT_LANDSCAPE_CONSTRUCTION) // founding random town can fail only in exec run
DEF_CMD_TRAIT(CMD_RENAME_TOWN, CmdRenameTown, CommandFlags({CommandFlag::Deity, CommandFlag::Server}), CMDT_OTHER_MANAGEMENT)

View File

@ -1629,6 +1629,7 @@ static CargoTypes GetProducedCargoOfHouse(const HouseSpec *hs)
struct BuildHouseWindow : public PickerWindow {
std::string house_info{};
static inline bool house_protected;
static inline bool overbuild;
BuildHouseWindow(WindowDesc &desc, Window *parent) : PickerWindow(desc, parent, 0, HousePickerCallbacks::instance)
{
@ -1733,11 +1734,17 @@ struct BuildHouseWindow : public PickerWindow {
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
{
switch (widget) {
case WID_BH_PROTECT_OFF:
case WID_BH_PROTECT_ON:
BuildHouseWindow::house_protected = (widget == WID_BH_PROTECT_ON);
this->SetWidgetLoweredState(WID_BH_PROTECT_OFF, !BuildHouseWindow::house_protected);
this->SetWidgetLoweredState(WID_BH_PROTECT_ON, BuildHouseWindow::house_protected);
case WID_BH_PROTECT_TOGGLE:
BuildHouseWindow::house_protected = !BuildHouseWindow::house_protected;
this->SetWidgetLoweredState(WID_BH_PROTECT_TOGGLE, BuildHouseWindow::house_protected);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->SetDirty();
break;
case WID_BH_OVERBUILD_TOGGLE:
BuildHouseWindow::overbuild = !BuildHouseWindow::overbuild;
this->SetWidgetLoweredState(WID_BH_OVERBUILD_TOGGLE, BuildHouseWindow::overbuild);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->SetDirty();
@ -1766,17 +1773,16 @@ struct BuildHouseWindow : public PickerWindow {
bool hasflag = spec->extra_flags.Test(HouseExtraFlag::BuildingIsProtected);
if (hasflag) BuildHouseWindow::house_protected = true;
this->SetWidgetLoweredState(WID_BH_PROTECT_OFF, !BuildHouseWindow::house_protected);
this->SetWidgetLoweredState(WID_BH_PROTECT_ON, BuildHouseWindow::house_protected);
this->SetWidgetLoweredState(WID_BH_PROTECT_TOGGLE, BuildHouseWindow::house_protected);
this->SetWidgetLoweredState(WID_BH_OVERBUILD_TOGGLE, BuildHouseWindow::overbuild);
this->SetWidgetDisabledState(WID_BH_PROTECT_OFF, hasflag);
this->SetWidgetDisabledState(WID_BH_PROTECT_ON, hasflag);
this->SetWidgetDisabledState(WID_BH_PROTECT_TOGGLE, hasflag);
}
void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
{
const HouseSpec *spec = HouseSpec::Get(HousePickerCallbacks::sel_type);
Command<CMD_PLACE_HOUSE>::Post(STR_ERROR_CAN_T_BUILD_HOUSE, CcPlaySound_CONSTRUCTION_OTHER, tile, spec->Index(), BuildHouseWindow::house_protected);
Command<CMD_PLACE_HOUSE>::Post(STR_ERROR_CAN_T_BUILD_HOUSE, CcPlaySound_CONSTRUCTION_OTHER, tile, spec->Index(), BuildHouseWindow::house_protected, BuildHouseWindow::overbuild);
}
const IntervalTimer<TimerWindow> view_refresh_interval = {std::chrono::milliseconds(2500), [this](auto) {
@ -1806,14 +1812,10 @@ static constexpr NWidgetPart _nested_build_house_widgets[] = {
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0), SetPadding(WidgetDimensions::unscaled.picker),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BH_INFO), SetFill(1, 1), SetMinimalTextLines(10, 0),
NWidget(WWT_LABEL, INVALID_COLOUR), SetStringTip(STR_HOUSE_PICKER_PROTECT_TITLE, STR_NULL), SetFill(1, 0),
NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BH_PROTECT_OFF), SetMinimalSize(60, 12), SetStringTip(STR_HOUSE_PICKER_PROTECT_OFF, STR_HOUSE_PICKER_PROTECT_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BH_PROTECT_ON), SetMinimalSize(60, 12), SetStringTip(STR_HOUSE_PICKER_PROTECT_ON, STR_HOUSE_PICKER_PROTECT_TOOLTIP),
EndContainer(),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BH_PROTECT_TOGGLE), SetMinimalSize(60, 12), SetStringTip(STR_HOUSE_PICKER_PROTECT, STR_HOUSE_PICKER_PROTECT_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BH_OVERBUILD_TOGGLE), SetMinimalSize(60, 12), SetStringTip(STR_HOUSE_PICKER_OVERBUILD, STR_HOUSE_PICKER_OVERBUILD_TOOLTIP),
EndContainer(),
EndContainer(),
EndContainer(),
NWidgetFunction(MakePickerTypeWidgets),
EndContainer(),

View File

@ -77,8 +77,8 @@ enum TownFoundingWidgets : WidgetID {
/** Widgets of the #BuildHouseWindow class. */
enum BuildHouseWidgets : WidgetID {
WID_BH_INFO, ///< Information panel of selected house.
WID_BH_PROTECT_OFF, ///< Button to protect the next house built.
WID_BH_PROTECT_ON, ///< Button to not protect the next house built.
WID_BH_PROTECT_TOGGLE, ///< Button to toggle protecting the next house built.
WID_BH_OVERBUILD_TOGGLE, ///< Button to toggle overbuilding existing houses.
};
#endif /* WIDGETS_TOWN_WIDGET_H */