Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Allow manually placing town buildings in scenario editor. #12661

Merged
merged 5 commits into from
May 14, 2024

Conversation

PeterN
Copy link
Member

@PeterN PeterN commented May 11, 2024

Motivation / Problem

Very little manual control over where houses are placed in towns. This is mostly to be expected as the game is meant to manage towns itself, however some manual control in the Scenario Editor (and perhaps a Sandbox mode) might be useful.

Description

  • Add a network command to manually place houses. (Not strictly necessary for Scenario Editor but very useful for a sandbox mode.)
  • Allow Houses to be resolved without a Town and Tile.
  • Add a Town House builder to the Scenario Editor. This is accessed from the Landscaping toolbar as there is no town toolbar.

Once placed these houses behave like any other and can be removed by players and towns.

Uses the unified picker system, so also supports used/saved favourites. As town building don't have class labels, town zones are use to imitate them.

Houses sometimes have up to 4 variations, selected psuedo randomly based on tile. The House Selection window does not provide a way to choose between these, as there is no manual control, so in order to represent them in the UI it will cycle through each variation every 2.5 seconds.

"Some highly advanced town planning"
image

More of the same, with NewGRFs...
image

Limitations

This is limited to Scenario Editor only. No sandbox mode as been implemented as the Sandbox Settings window is still using the old cheats system.

Once that is changed to use normal settings, not much effort is required to enable this.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

src/town_gui.cpp Fixed Show fixed Hide fixed
src/town_gui.cpp Fixed Show fixed Hide fixed
@2TallTyler 2TallTyler added the preview This PR is receiving preview builds label May 11, 2024
Copy link
Member

@2TallTyler 2TallTyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great feature. A few thoughts:

  • Adding this to Scenario Editor first and then adding it to normal gameplay as a later PR makes sense.
  • Adding the button to the object toolbar works, but another option (which might make more sense) is adding it to the Town button dropdown. In SE there is no dropdown since there's only one option, but in-game you long-click the Town button to open a dropdown containing Town directory and Found town. This is where I would expect to find Build houses.

src/town_cmd.cpp Show resolved Hide resolved
src/town_cmd.cpp Show resolved Hide resolved
src/newgrf_house.cpp Outdated Show resolved Hide resolved
src/terraform_gui.cpp Outdated Show resolved Hide resolved
src/town_cmd.cpp Outdated Show resolved Hide resolved
src/town_cmd.cpp Outdated Show resolved Hide resolved
src/terraform_gui.cpp Outdated Show resolved Hide resolved
Copy link
Member

@2TallTyler 2TallTyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still prefer to see this accessed from a dropdown in the town button of the main toolbar, but if you feel strongly otherwise I'm open to having my mind changed. 😄

src/town_cmd.cpp Outdated

TileIndex origin_tile = tile;
if (hs->building_flags & TILE_SIZE_2x2) {
if (!CheckTownBuild2x2House(&tile, t, maxz, noslope)) return_cmd_error(STR_ERROR_CAN_T_CLEAR_THIS_AREA);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this (and the others nearby) return the error string STR_ERROR_CAN_T_BUILD_HOUSE instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's a sub-error, although actually it was an incorrect string for a sub-error.

So I've changed this instead to actually call CMD_CLEAR for each tile to get a decent error message.

src/town_gui.cpp Show resolved Hide resolved
@PeterN
Copy link
Member Author

PeterN commented May 14, 2024

I'd still prefer to see this accessed from a dropdown in the town button of the main toolbar, but if you feel strongly otherwise I'm open to having my mind changed. 😄

I've moved it to a toolbar menu now so you can try it. Although after doing so I noticed that JGRPP has a house picker in the same spot as it was, heh...

src/town_cmd.cpp Outdated Show resolved Hide resolved
src/town_gui.cpp Show resolved Hide resolved
@2TallTyler
Copy link
Member

Oh yes, I like the toolbar placement much better than in the landscaping toolbar. 😃

This could previous be done but only with a town and tile in mind, but for drawing in the UI, neither of those exist yet.
House picker is accessed from the Landscaping toolbar as there is no town toolbar.

Once placed these houses behave like any other and can be removed by players and towns.

Uses the unified picker system, so also supports used/saved favourites. As town building don't have class labels, town zones are use to imitate them.
@PeterN PeterN merged commit ed67aed into OpenTTD:master May 14, 2024
15 checks passed
@PeterN PeterN deleted the house-placer branch May 14, 2024 20:11
@LC-Zorg
Copy link

LC-Zorg commented May 15, 2024

Nice feature. I admit that I missed it. :) This won't solve the problem of not being able to build cities on your own street grid, because, well, building many cities this way would be way too time-consuming, but in many cases it will be very helpful. :)
However, I would like to make a few comments, I know it's a bit late, but I hope it will still be useful.

Grouping of buildings
Well, I would definitely prefer a division into addons (e.g. Default / Swedish Houses / Japan... / European...). I think it would be easier to find specific buildings then. This would be especially useful if you wanted to build a part or an entire city in a specific style. Probably few players are aware of the division into zones and it is a hidden feature during the game, so each building will have to be searched for separately in the editor. However, if for some reason this really isn't possible, then I think such a division is better than none at all. Any way I would like to comment on the order of zones, which seems to be reversed. If I wanted to build a city, I would definitely prefer to start from its center, not from the outskirts and usually more important things are at the top of lists, not at the bottom.

Unnecessary search bar
In the case of division by zones, it is completely unnecessary and looks realy pointless. Why search for anything when everything is visible on the surface? Even if it were possible to divide them by addons, it still doesn't make sense due to the number of possible lines.

Too long a list
If it's only going to be 5 items, why extend it to the full height? I think this space could contain something more useful.

No preview or information about the building
This is something that the JGR version has that is not here. Meanwhile, this is not only interesting, but can be also very useful information. Especially those about accepting cargoes can be useful. Information about the population may also be helpful if someone cares about a specific number of inhabitants.

Ignoring zones during construction
I just wanted to write that it was a very good decision. :) My first experience with this feature in the JGR version was quite irritating due to the restrictions imposed by the zones. What's even more irritating is that when building subsequent buildings, the zone boundaries kept changing. Changing an available setting was like turning on a light in a dark room. No more constantly banging your shins against invisible furniture. Here the light will always be on. :)

It is not possible to place buildings that are too old or too new
This, however, is not good. :( When you build cities in a scenario, it is very likely that you will also want to place historical buildings in them. Currently, to be able to do this, the player will have to constantly change the current date in the game depending on what building he wants to build at that moment. Of course, these restrictions may make sense in the game, where placing buildings that are too modern may look bad. Even here, in the case of old buildings, it could be an unnecessary restriction - recreating old buildings or building in an old style is not something unheard of and unnatural.

Lack possibility to choose variant of buildings
I like the preview of available variants that changes every 2.5 seconds. At first I thought it would be too fast, but it's ok. :) The problem is that the player has no influence on which variant will be built. To build one, the player will often have to construct and demolish a building multiple times. I don't know the difficulty level, but I think that if a preview of the building was available, an option to choose a variant could also be added.
House Selection - preview and information

Location of functions in the interface

I've moved it to a toolbar menu now so you can try it

I also think it's a good change.

The cost of placing a building
In the scenario editor it doesn't matter, but in game it definitely would. Funding for free might make sense for eyecandy players, but for others it would be pointless. Currently, funding new buildings costs at least £155,273 on a low cost setting. This option means that at most a few additional buildings will be built within 3 months. Meanwhile, possibility to placing a single building will ensure that these buildings will be built immediately and in the place the player expects. To balance these two forms, I believe that placing buildings should be appropriately expensive. In the case of the largest buildings, I think it could be 80-100% of the cost of funding new buildings. The population of the building could be the basis for determining this costs.

Unintuitive filtering logic
I have to come back to this because it keeps bugging me. I know you gave the right explanation, but it doesn't change the problem of unintuitive behavior. The player shouldn't be forced to read explanations for every step he takes. The logic is that you select a group on the left and an element of this group on the right. Above on both sides you have a search option for these specific parts. On the right side you have additional buttons that should refer to what is on the right side, but this is not the case and in fact they refer to the left side. "All" allows you to show the contents of all groups. The same goes for "Used" and "Saved", which also show elements from all groups first. In my opinion, if these buttons were to remain in this place, then after turning them on, all groups from which the visible elements come should be selected on the left side.
An example of what it could look like
House Selection - marking all classes with content

I suppose that the division by add-ons is not very realistic, but if it were otherwise, I would think about such an arrangement. ;)
House Selection - division by addons and zones

@PeterN
Copy link
Member Author

PeterN commented May 15, 2024

Grouping of buildings

Grouping by NewGRF is something that could equally be applied to all the build pickers, in which case it would be an additional filter.

I'm not sure how that will fit in the UI yet, but that's why I didn't make the class-list behave as a NewGRF filter here.

Unnecessary search bar

It's just part of the standard picker interface.

Too long a list

Because currently if it's not expandable then the window can't be made taller. When we add an extra information panel below it then that can change.

No preview or information about the building

Correct, this is a bare-minimum of an interface. There is a preview -- it's in the main list, just like when picking Waypoints.

It is not possible to place buildings that are too old or too new

Good point, this can probably go. I probably got carried away that it was easy to implement...

Lack possiblity to choose variant of builds

The variant is completely impossible to choose*, as it's based on the tile position on the map. Deleting and replacing a building will not change the variant on that tile. Not all house types have variant either.

*I guess the 2 random bits derived from tile posiition could instead be stored on the map instead, but we know people hate random data being stored...

The cost of placing a building

I don't intend to enable placing houses in normal gameplay mode. I do intend for it to be available as a sandbox setting for those players who enjoy this.

Gameplay-wise, being able to manually place buildings would conflict with existing town and local authority behaviour, and I don't think it makes sense to try to shoe-horn this in. After all, this is OpenTTD, not SimCity.

@PeterN PeterN removed the preview This PR is receiving preview builds label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants