pduthie_au wrote:How do you switch the text on a single button ? I'm leaning towards the single button option, but I need to switch the text on them.
Code: Select all
w->widget[widget number].data = STR_BUTTON;
w->widget[DEPOT_WIDGET_BUILD].tooltips = STR_BUTTON_TOOLTIP;
Depending on how you create the click event for the button, you can also (in WE_PAINT) type
Code: Select all
if (closed) {
HideWindowWidget(w, button_a);
ShowWindowWidget(w, button_b);
} else {
HideWindowWidget(w, button_b);
ShowWindowWidget(w, button_a);
}
Then you can create two buttons in the widget array at the same location and it will only show one of them at a time. The benefit from this would be that they don't have the same widget number and click actions can be based on the widget number in WE_CLICK.
You can try to look in depot_gui.c to see how to modify a window to make it show stuff, that's not in the widget array, but some of it is likely too complex for what you are doing (resizing widgets, moving widgets and so on), so it's ok if you don't get everything in that file. One adwiseable thing is to make an enum with widget names as this would make the code more readable and make it easier to add widgets without messing with code that's hardcoded to the current order of the widgets. Later additions will just have to deal with the enum and the rest of the code will be ok.
Also it's ok not to get all of the GUI stuff overnight, so nobody will kill you for asking for more help if you fail to figure out something.
pduthie_au wrote:Eventually, this could become a multiple option to close the station for other vehicle types, but at the moment it's just for aircraft.
Then make this a byte right away so we only have to modify savegames once and solve the issue where we need to figure out how to load a bool and put it in a byte (it should be possible, but it's easier not to create that problem in the first place), then make it a bitmask. I would say it would be best to give bit 0 to trains, 1 to road vehicles, 2 to ships and 3 to aircrafts because then we can check if the bit is set for a particular type by
The types are actually numbered 16 to 19, but with the VEH_Train offset, we can call them 0 to 3, which will then do as the bit numbers in the byte.
pduthie_au wrote:I will post some code, but at the moment I'm working on a really old version of the code, and it has some other mods in it as well (such as bulldozing an airport leaves the ground underneath owned by the player) I'll download the latest source (would people prefer this in the MiniIN or in a format for the main trunk ?) and put it into this.
When writing anything, always work from an svn checkout of the trunk. This will make it way easier to apply the code to the trunk as stuff have changed since 0.4.8 (like we got a new widget system).
Also about owning the land of the bulldozed airport. There is another option. Automatic removal of the airport when building another one (like with train stations).
pduthie_au wrote:Could a mod also prune out some of the replies that where originally for the string comparison stuff. I'll fix up the first post with some more detail shortly.
I could, but it's against the forum policy
pduthie_au wrote:How do I save the stations with the open/closed variable ? If i load a game that doesn't have the variable in station struct, what will happen then ? Can I set it to default to false in this situation ?
First you increase the savegame version by one in the top of saveload.c, then you edit _station_desc[] in station_cmd.c to save/load this bool if the savegame version if the new version or newer.
Setting the variable in savegames, that are too old to have this bool is done in AfterLoadGame() in openttd.c. I presume you need to loop all stations and set this bool to false.
Have you considered what to do if the airport is closed? If we got X planes flying between two airports and we close one of them, then we block the other one with X planes. In that case it would be best to head for the hangar in the airport previous to the closed one and stay in there until the next airport is reopened.