706 "vehicle.plane_speed", |
706 "vehicle.plane_speed", |
707 "order.timetabling", |
707 "order.timetabling", |
708 "vehicle.dynamic_engines", |
708 "vehicle.dynamic_engines", |
709 }; |
709 }; |
710 |
710 |
|
711 /** Data structure describing a single patch in a tab */ |
711 struct PatchEntry { |
712 struct PatchEntry { |
712 const SettingDesc *setting; |
713 const SettingDesc *setting; ///< Setting description of the patch |
713 uint index; |
714 uint index; ///< Index of the setting in the settings table |
714 }; |
715 }; |
715 |
716 |
|
717 /** |
|
718 * Data structure describing one page of patches in the patch settings window. |
|
719 * |
|
720 * The names of the patches to display are statically defined, and from this |
|
721 * information, a dynamic array (with length \a num) of PatchEntry entries is |
|
722 * constructed. |
|
723 */ |
716 struct PatchPage { |
724 struct PatchPage { |
717 const char **names; |
725 const char **names; ///< Static list of strings with patch names that are settable from the tab |
718 PatchEntry *entries; |
726 PatchEntry *entries; ///< Array of patch entries of the page. Initially \c NULL, filled in at run time |
719 byte num; |
727 byte num; ///< Number of entries on the page (statically filled). |
720 }; |
728 }; |
721 |
729 |
722 /* PatchPage holds the categories, the number of elements in each category |
730 /** Array of pages (tabs), where each page holds a number of advanced settings. */ |
723 * and (in NULL) a dynamic array of settings based on the string-representations |
|
724 * of the settings. This way there is no worry about indeces, and such */ |
|
725 static PatchPage _patches_page[] = { |
731 static PatchPage _patches_page[] = { |
726 {_patches_ui, NULL, lengthof(_patches_ui)}, |
732 {_patches_ui, NULL, lengthof(_patches_ui)}, |
727 {_patches_construction, NULL, lengthof(_patches_construction)}, |
733 {_patches_construction, NULL, lengthof(_patches_construction)}, |
728 {_patches_vehicles, NULL, lengthof(_patches_vehicles)}, |
734 {_patches_vehicles, NULL, lengthof(_patches_vehicles)}, |
729 {_patches_stations, NULL, lengthof(_patches_stations)}, |
735 {_patches_stations, NULL, lengthof(_patches_stations)}, |
730 {_patches_economy, NULL, lengthof(_patches_economy)}, |
736 {_patches_economy, NULL, lengthof(_patches_economy)}, |
731 {_patches_ai, NULL, lengthof(_patches_ai)}, |
737 {_patches_ai, NULL, lengthof(_patches_ai)}, |
732 }; |
738 }; |
733 |
739 |
|
740 /** Widget numbers of config patches window */ |
734 enum PatchesSelectionWidgets { |
741 enum PatchesSelectionWidgets { |
735 PATCHSEL_OPTIONSPANEL = 3, |
742 PATCHSEL_OPTIONSPANEL = 3, ///< Panel widget containing the option lists |
736 PATCHSEL_INTERFACE, |
743 PATCHSEL_INTERFACE, ///< Button 'Interface' |
737 PATCHSEL_CONSTRUCTION, |
744 PATCHSEL_CONSTRUCTION, ///< Button 'Construction' |
738 PATCHSEL_VEHICLES, |
745 PATCHSEL_VEHICLES, ///< Button 'Vehicles' |
739 PATCHSEL_STATIONS, |
746 PATCHSEL_STATIONS, ///< Button 'Stations' |
740 PATCHSEL_ECONOMY, |
747 PATCHSEL_ECONOMY, ///< Button 'Economy' |
741 PATCHSEL_COMPETITORS |
748 PATCHSEL_COMPETITORS ///< Button 'Competitors' |
742 }; |
749 }; |
743 |
750 |
744 struct PatchesSelectionWindow : Window { |
751 struct PatchesSelectionWindow : Window { |
745 static GameSettings *patches_ptr; |
752 static GameSettings *patches_ptr; |
746 static int patches_max; |
753 static int patches_max; ///< Maximal number of patches on a single page |
747 |
754 |
748 int page; |
755 int page; |
749 int entry; |
756 int entry; |
750 int click; |
757 int click; |
751 |
758 |
853 void *var; |
860 void *var; |
854 int32 value; |
861 int32 value; |
855 int x, y; |
862 int x, y; |
856 byte btn; |
863 byte btn; |
857 |
864 |
858 y = pt.y - 46 - 1; |
865 y = pt.y - 46 - 1; // Shift y coordinate |
859 if (y < 0) return; |
866 if (y < 0) return; // Clicked above first entry |
860 |
867 |
861 x = pt.x - 5; |
868 x = pt.x - 5; // Shift x coordinate |
862 if (x < 0) return; |
869 if (x < 0) return; // Clicked left of the entry |
863 |
870 |
864 btn = y / 11; |
871 btn = y / 11; // Compute which setting is selected |
865 if (y % 11 > 9) return; |
872 if (y % 11 > 9) return; // Clicked too low at the setting |
866 if (btn >= page->num) return; |
873 if (btn >= page->num) return; // Clicked below the last setting of the page |
867 |
874 |
868 sd = page->entries[btn].setting; |
875 sd = page->entries[btn].setting; |
869 |
876 |
870 /* return if action is only active in network, or only settable by server */ |
877 /* return if action is only active in network, or only settable by server */ |
871 if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return; |
878 if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return; |