diff --git a/.github/windowdesc-ini-key.py b/.github/windowdesc-ini-key.py deleted file mode 100644 index 36b20f9948..0000000000 --- a/.github/windowdesc-ini-key.py +++ /dev/null @@ -1,50 +0,0 @@ -""" -Script to scan the OpenTTD source-tree for ini_key issues in WindowDesc entries. -""" - -import glob -import os -import re -import sys - - -def scan_source_files(path, ini_keys=None): - if ini_keys is None: - ini_keys = set() - - errors = [] - - for new_path in glob.glob(f"{path}/*.cpp"): - if os.path.isdir(new_path): - errors.append(scan_source_files(new_path, ini_keys)) - continue - - with open(new_path) as fp: - output = fp.read() - - for (name, ini_key, widgets) in re.findall(r"^static WindowDesc ([a-zA-Z0-9_]*).*?, (?:\"(.*?)\")?.*?,(?:\s+.*?,){6}\s+[^\s]+\((.*?)\)", output, re.S|re.M): - if ini_key: - if ini_key in ini_keys: - errors.append(f"{new_path}: {name} ini_key is a duplicate") - ini_keys.add(ini_key) - widget = re.findall("static const (?:struct )?NWidgetPart " + widgets + ".*?(?:WWT_(DEFSIZE|STICKY)BOX.*?)?;", output, re.S)[0] - if widget and not ini_key: - errors.append(f"{new_path}: {name} has WWT_DEFSIZEBOX/WWT_STICKYBOX without ini_key") - if ini_key and not widget: - errors.append(f"{new_path}: {name} has ini_key without WWT_DEFSIZEBOX/WWT_STICKYBOX") - - return errors - - -def main(): - errors = scan_source_files("src") - - if errors: - print("\n".join(errors)) - sys.exit(1) - - print("OK") - - -if __name__ == "__main__": - main() diff --git a/.github/workflows/windowdesc-ini-key.yml b/.github/workflows/windowdesc-ini-key.yml deleted file mode 100644 index b69172d5af..0000000000 --- a/.github/workflows/windowdesc-ini-key.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: WindowDesc ini_key - -on: - pull_request: - branches: - - master - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} - -jobs: - windowdesc-ini-key: - name: WindowDesc ini_key issues - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Check for ini_key issues in WindowDesc entries - shell: bash - run: | - python3 .github/windowdesc-ini-key.py diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index ce6f7a21c9..86db840449 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -72,8 +72,8 @@ static const NWidgetPart _nested_ai_config_widgets[] = { }; /** Window definition for the configure AI window. */ -static WindowDesc _ai_config_desc( - WDP_CENTER, "settings_script_config", 0, 0, +static WindowDesc _ai_config_desc(__FILE__, __LINE__, + WDP_CENTER, nullptr, 0, 0, WC_GAME_OPTIONS, WC_NONE, 0, std::begin(_nested_ai_config_widgets), std::end(_nested_ai_config_widgets) diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 08066b3c1f..9bb3e341c4 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -199,7 +199,7 @@ static const NWidgetPart _nested_air_toolbar_widgets[] = { EndContainer(), }; -static WindowDesc _air_toolbar_desc( +static WindowDesc _air_toolbar_desc(__FILE__, __LINE__, WDP_ALIGN_TOOLBAR, "toolbar_air", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -606,7 +606,7 @@ static const NWidgetPart _nested_build_airport_widgets[] = { EndContainer(), }; -static WindowDesc _build_airport_desc( +static WindowDesc _build_airport_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp index d0db9205c3..00aa611dc0 100644 --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -318,19 +318,6 @@ CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial return union_mask; } -/** - * Ands the refit_masks of all articulated parts. - * @param engine the first part - * @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask - * @return bit mask of CargoIDs which are a refit option for every articulated part (with default capacity > 0) - */ -CargoTypes GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type) -{ - CargoTypes union_mask, intersection_mask; - GetArticulatedRefitMasks(engine, include_initial_cargo_type, &union_mask, &intersection_mask); - return intersection_mask; -} - /** * Get cargo mask of all cargoes carried by an articulated vehicle. * Note: Vehicles not carrying anything are ignored diff --git a/src/articulated_vehicles.h b/src/articulated_vehicles.h index 5741b15565..547abb8ca9 100644 --- a/src/articulated_vehicles.h +++ b/src/articulated_vehicles.h @@ -22,7 +22,6 @@ void AddArticulatedParts(Vehicle *first); void GetArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type, CargoTypes *union_mask, CargoTypes *intersection_mask); std::vector GetArticulatedRefitMaskVector(EngineID engine, bool include_initial_cargo_type); CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type); -CargoTypes GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type); CargoTypes GetCargoTypesOfArticulatedVehicle(const Vehicle *v, CargoID *cargo_type); CargoID GetOverallCargoOfArticulatedVehicle(const Vehicle *v); bool IsArticulatedVehicleRefittable(EngineID engine); diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 63230436dc..35e798cd77 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -810,7 +810,7 @@ static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = { EndContainer(), }; -static WindowDesc _replace_rail_vehicle_desc( +static WindowDesc _replace_rail_vehicle_desc(__FILE__, __LINE__, WDP_AUTO, "replace_vehicle_train", 500, 140, WC_REPLACE_VEHICLE, WC_NONE, WDF_CONSTRUCTION, @@ -868,7 +868,7 @@ static const NWidgetPart _nested_replace_road_vehicle_widgets[] = { EndContainer(), }; -static WindowDesc _replace_road_vehicle_desc( +static WindowDesc _replace_road_vehicle_desc(__FILE__, __LINE__, WDP_AUTO, "replace_vehicle_road", 500, 140, WC_REPLACE_VEHICLE, WC_NONE, WDF_CONSTRUCTION, @@ -922,7 +922,7 @@ static const NWidgetPart _nested_replace_vehicle_widgets[] = { EndContainer(), }; -static WindowDesc _replace_vehicle_desc( +static WindowDesc _replace_vehicle_desc(__FILE__, __LINE__, WDP_AUTO, "replace_vehicle", 456, 118, WC_REPLACE_VEHICLE, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/base_media_base.h b/src/base_media_base.h index 272aec82ea..5ee0ca2f31 100644 --- a/src/base_media_base.h +++ b/src/base_media_base.h @@ -96,6 +96,7 @@ struct BaseSet { } bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename, bool allow_empty_filename = true); + void CopyCompatibleConfig([[maybe_unused]] const T &src) {} /** * Get the description for the given ISO code. @@ -170,9 +171,6 @@ protected: */ static const char *GetExtension(); public: - /** The set as saved in the config file. */ - static std::string ini_set; - /** * Determine the graphics pack that has to be used. * The one with the most correct files wins. @@ -191,7 +189,9 @@ public: static Tbase_set *GetAvailableSets(); - static bool SetSet(const std::string &name); + static bool SetSet(const Tbase_set *set); + static bool SetSetByName(const std::string &name); + static bool SetSetByShortname(uint32_t shortname); static char *GetSetsList(char *p, const char *last); static int GetNumSets(); static int GetIndexOfUsedSet(); @@ -207,7 +207,6 @@ public: static bool HasSet(const ContentInfo *ci, bool md5sum); }; -template /* static */ std::string BaseMedia::ini_set; template /* static */ const Tbase_set *BaseMedia::used_set; template /* static */ Tbase_set *BaseMedia::available_sets; template /* static */ Tbase_set *BaseMedia::duplicate_sets; @@ -239,12 +238,24 @@ enum BlitterType { BLT_32BPP, ///< Base set has both 8 bpp and 32 bpp sprites. }; +struct GRFConfig; + /** All data of a graphics set. */ struct GraphicsSet : BaseSet { +private: + mutable std::unique_ptr extra_cfg; ///< Parameters for extra GRF +public: PaletteType palette; ///< Palette of this graphics set BlitterType blitter; ///< Blitter of this graphics set + GraphicsSet(); + ~GraphicsSet(); + bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename); + GRFConfig *GetExtraConfig() const { return this->extra_cfg.get(); } + GRFConfig &GetOrCreateExtraConfig() const; + bool IsConfigurable() const; + void CopyCompatibleConfig(const GraphicsSet &src); static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir); }; @@ -252,6 +263,15 @@ struct GraphicsSet : BaseSet { /** All data/functions related with replacing the base graphics. */ class BaseGraphics : public BaseMedia { public: + /** Values loaded from config file. */ + struct Ini { + std::string name; + uint32_t shortname; ///< unique key for base set + uint32_t extra_version; ///< version of the extra GRF + std::vector extra_params; ///< parameters for the extra GRF + }; + static inline Ini ini_data; + }; /** All data of a sounds set. */ @@ -261,6 +281,9 @@ struct SoundsSet : BaseSet { /** All data/functions related with replacing the base sounds */ class BaseSounds : public BaseMedia { public: + /** The set as saved in the config file. */ + static inline std::string ini_set; + }; /** Maximum number of songs in the 'class' playlists. */ @@ -307,6 +330,9 @@ struct MusicSet : BaseSet { /** All data/functions related with replacing the base music */ class BaseMusic : public BaseMedia { public: + /** The set as saved in the config file. */ + static inline std::string ini_set; + }; #endif /* BASE_MEDIA_BASE_H */ diff --git a/src/base_media_func.h b/src/base_media_func.h index 9586f0f9ac..816a881689 100644 --- a/src/base_media_func.h +++ b/src/base_media_func.h @@ -197,6 +197,9 @@ bool BaseMedia::AddFile(const std::string &filename, size_t basepath_ *prev = set; set->next = duplicate->next; + /* Keep baseset configuration, if compatible */ + set->CopyCompatibleConfig(*duplicate); + /* If the duplicate set is currently used (due to rescanning this can happen) * update the currently used set to the new one. This will 'lie' about the * version number until a new game is started which isn't a big problem */ @@ -225,25 +228,58 @@ bool BaseMedia::AddFile(const std::string &filename, size_t basepath_ return ret; } +/** + * Set the set to be used. + * @param set the set to use + * @return true if it could be loaded + */ +template +/* static */ bool BaseMedia::SetSet(const Tbase_set *set) +{ + if (set == nullptr) { + if (!BaseMedia::DetermineBestSet()) return false; + } else { + BaseMedia::used_set = set; + } + CheckExternalFiles(); + return true; +} + /** * Set the set to be used. * @param name of the set to use * @return true if it could be loaded */ template -/* static */ bool BaseMedia::SetSet(const std::string &name) +/* static */ bool BaseMedia::SetSetByName(const std::string &name) { if (name.empty()) { - if (!BaseMedia::DetermineBestSet()) return false; - CheckExternalFiles(); - return true; + return SetSet(nullptr); } for (const Tbase_set *s = BaseMedia::available_sets; s != nullptr; s = s->next) { if (name == s->name) { - BaseMedia::used_set = s; - CheckExternalFiles(); - return true; + return SetSet(s); + } + } + return false; +} + +/** + * Set the set to be used. + * @param shortname of the set to use + * @return true if it could be loaded + */ +template +/* static */ bool BaseMedia::SetSetByShortname(uint32_t shortname) +{ + if (shortname == 0) { + return SetSet(nullptr); + } + + for (const Tbase_set *s = BaseMedia::available_sets; s != nullptr; s = s->next) { + if (shortname == s->shortname) { + return SetSet(s); } } return false; @@ -376,11 +412,12 @@ template * @param set_type the type of the BaseSet to instantiate */ #define INSTANTIATE_BASE_MEDIA_METHODS(repl_type, set_type) \ - template std::string repl_type::ini_set; \ template const char *repl_type::GetExtension(); \ template bool repl_type::AddFile(const std::string &filename, size_t pathlength, const std::string &tar_filename); \ template bool repl_type::HasSet(const struct ContentInfo *ci, bool md5sum); \ - template bool repl_type::SetSet(const std::string &name); \ + template bool repl_type::SetSet(const set_type *set); \ + template bool repl_type::SetSetByName(const std::string &name); \ + template bool repl_type::SetSetByShortname(uint32_t shortname); \ template char *repl_type::GetSetsList(char *p, const char *last); \ template int repl_type::GetNumSets(); \ template int repl_type::GetIndexOfUsedSet(); \ diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp index 5367b940d2..5a64de2afc 100644 --- a/src/blitter/32bpp_anim.hpp +++ b/src/blitter/32bpp_anim.hpp @@ -52,7 +52,6 @@ public: Blitter::PaletteAnimation UsePaletteAnimation() override; const char *GetName() override { return "32bpp-anim"; } - int GetBytesPerPixel() override { return 6; } void PostResize() override; /** diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp index 2855579fed..0f774f4c5e 100644 --- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -38,7 +38,6 @@ public: size_t BufferSize(uint width, uint height) override; void PaletteAnimate(const Palette &palette) override; Blitter::PaletteAnimation UsePaletteAnimation() override; - int GetBytesPerPixel() override { return 4; } /** * Look up the colour in the current palette. diff --git a/src/blitter/40bpp_anim.hpp b/src/blitter/40bpp_anim.hpp index 861f7dd43a..c77c67f610 100644 --- a/src/blitter/40bpp_anim.hpp +++ b/src/blitter/40bpp_anim.hpp @@ -37,7 +37,6 @@ public: bool NeedsAnimationBuffer() override; const char *GetName() override { return "40bpp-anim"; } - int GetBytesPerPixel() override { return 5; } template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); diff --git a/src/blitter/8bpp_base.hpp b/src/blitter/8bpp_base.hpp index e4ac4e1524..1ac30a15e6 100644 --- a/src/blitter/8bpp_base.hpp +++ b/src/blitter/8bpp_base.hpp @@ -35,7 +35,6 @@ public: size_t BufferSize(uint width, uint height) override; void PaletteAnimate(const Palette &palette) override; Blitter::PaletteAnimation UsePaletteAnimation() override; - int GetBytesPerPixel() override { return 1; } }; #endif /* BLITTER_8BPP_BASE_HPP */ diff --git a/src/blitter/base.hpp b/src/blitter/base.hpp index c3df549219..1717b18475 100644 --- a/src/blitter/base.hpp +++ b/src/blitter/base.hpp @@ -270,11 +270,6 @@ public: */ virtual const char *GetName() = 0; - /** - * Get how many bytes are needed to store a pixel. - */ - virtual int GetBytesPerPixel() = 0; - /** * Post resize event */ diff --git a/src/blitter/null.hpp b/src/blitter/null.hpp index d29bbc14ca..deb2b1d2cb 100644 --- a/src/blitter/null.hpp +++ b/src/blitter/null.hpp @@ -41,7 +41,6 @@ public: Blitter::PaletteAnimation UsePaletteAnimation() override { return Blitter::PALETTE_ANIMATION_NONE; }; const char *GetName() override { return "null"; } - int GetBytesPerPixel() override { return 0; } }; /** Factory for the blitter that does nothing. */ diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index 2d3247a4e0..4aa3f74156 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -39,7 +39,7 @@ static const struct NWidgetPart _background_widgets[] = { /** * Window description for the background window to prevent smearing. */ -static WindowDesc _background_desc( +static WindowDesc _background_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_BOOTSTRAP, WC_NONE, WDF_NO_CLOSE, @@ -75,7 +75,7 @@ static const NWidgetPart _nested_bootstrap_errmsg_widgets[] = { }; /** Window description for the error window. */ -static WindowDesc _bootstrap_errmsg_desc( +static WindowDesc _bootstrap_errmsg_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_BOOTSTRAP, WC_NONE, WDF_MODAL | WDF_NO_CLOSE, @@ -132,7 +132,7 @@ static const NWidgetPart _nested_bootstrap_download_status_window_widgets[] = { }; /** Window description for the download window */ -static WindowDesc _bootstrap_download_status_window_desc( +static WindowDesc _bootstrap_download_status_window_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL | WDF_NO_CLOSE, @@ -184,7 +184,7 @@ static const NWidgetPart _bootstrap_query_widgets[] = { }; /** The window description for the query. */ -static WindowDesc _bootstrap_query_desc( +static WindowDesc _bootstrap_query_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_CONFIRM_POPUP_QUERY, WC_NONE, WDF_NO_CLOSE, diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 020f3cacb1..cae293e44b 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -356,7 +356,7 @@ static const NWidgetPart _nested_build_bridge_widgets[] = { }; /** Window definition for the rail bridge selection window. */ -static WindowDesc _build_bridge_desc( +static WindowDesc _build_bridge_desc(__FILE__, __LINE__, WDP_AUTO, "build_bridge", 200, 114, WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 661fb4fbff..4ea952d590 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -3263,7 +3263,7 @@ void CcMoveNewVirtualEngine(const CommandCost &result, TileIndex tile, uint32 p1 InvalidateWindowClassesData(WC_CREATE_TEMPLATE); } -static WindowDesc _build_vehicle_desc( +static WindowDesc _build_vehicle_desc(__FILE__, __LINE__, WDP_AUTO, "build_vehicle", 240, 268, WC_BUILD_VEHICLE, WC_NONE, WDF_CONSTRUCTION, @@ -3271,7 +3271,7 @@ static WindowDesc _build_vehicle_desc( &BuildVehicleWindow::hotkeys ); -static WindowDesc _build_template_vehicle_desc( +static WindowDesc _build_template_vehicle_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 240, 268, WC_BUILD_VIRTUAL_TRAIN, WC_CREATE_TEMPLATE, WDF_CONSTRUCTION, @@ -3279,7 +3279,7 @@ static WindowDesc _build_template_vehicle_desc( &BuildVehicleWindow::hotkeys, &_build_vehicle_desc ); -static WindowDesc _build_vehicle_desc_train_advanced( +static WindowDesc _build_vehicle_desc_train_advanced(__FILE__, __LINE__, WDP_AUTO, "build_vehicle_dual", 480, 268, WC_BUILD_VEHICLE, WC_NONE, WDF_CONSTRUCTION, @@ -3287,7 +3287,7 @@ static WindowDesc _build_vehicle_desc_train_advanced( &BuildVehicleWindow::hotkeys ); -static WindowDesc _build_template_vehicle_desc_advanced( +static WindowDesc _build_template_vehicle_desc_advanced(__FILE__, __LINE__, WDP_AUTO, nullptr, 480, 268, WC_BUILD_VIRTUAL_TRAIN, WC_CREATE_TEMPLATE, WDF_CONSTRUCTION, diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 349ddc39b5..87f48700e4 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -520,7 +520,7 @@ struct CheatWindow : Window { }; /** Window description of the cheats GUI. */ -static WindowDesc _cheats_desc( +static WindowDesc _cheats_desc(__FILE__, __LINE__, WDP_AUTO, "cheats", 0, 0, WC_CHEATS, WC_NONE, 0, diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 973a83b00d..dd720c03ea 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -52,7 +52,7 @@ static void DoSelectCompanyManagerFace(Window *parent); static void ShowCompanyInfrastructure(CompanyID company); /** List of revenues. */ -static ExpensesType _expenses_list_revenue[] = { +static const std::initializer_list _expenses_list_revenue = { EXPENSES_TRAIN_REVENUE, EXPENSES_ROADVEH_REVENUE, EXPENSES_AIRCRAFT_REVENUE, @@ -61,7 +61,7 @@ static ExpensesType _expenses_list_revenue[] = { }; /** List of operating expenses. */ -static ExpensesType _expenses_list_operating_costs[] = { +static const std::initializer_list _expenses_list_operating_costs = { EXPENSES_TRAIN_RUN, EXPENSES_ROADVEH_RUN, EXPENSES_AIRCRAFT_RUN, @@ -72,7 +72,7 @@ static ExpensesType _expenses_list_operating_costs[] = { }; /** List of capital expenses. */ -static ExpensesType _expenses_list_capital_costs[] = { +static const std::initializer_list _expenses_list_capital_costs = { EXPENSES_CONSTRUCTION, EXPENSES_NEW_VEHICLES, EXPENSES_OTHER, @@ -80,25 +80,24 @@ static ExpensesType _expenses_list_capital_costs[] = { /** Expense list container. */ struct ExpensesList { - const ExpensesType *et; ///< Expenses items. - const uint length; ///< Number of items in list. + const StringID title; ///< StringID of list title. + const std::initializer_list &items; ///< List of expenses types. - ExpensesList(ExpensesType *et, int length) : et(et), length(length) + ExpensesList(StringID title, const std::initializer_list &list) : title(title), items(list) { } uint GetHeight() const { /* Add up the height of all the lines. */ - return this->length * FONT_HEIGHT_NORMAL; + return static_cast(this->items.size()) * FONT_HEIGHT_NORMAL; } /** Compute width of the expenses categories in pixels. */ uint GetListWidth() const { uint width = 0; - for (uint i = 0; i < this->length; i++) { - ExpensesType et = this->et[i]; + for (const ExpensesType &et : this->items) { width = std::max(width, GetStringBoundingBox(STR_FINANCES_SECTION_CONSTRUCTION + et).width); } return width; @@ -106,10 +105,10 @@ struct ExpensesList { }; /** Types of expense lists */ -static const ExpensesList _expenses_list_types[] = { - ExpensesList(_expenses_list_revenue, lengthof(_expenses_list_revenue)), - ExpensesList(_expenses_list_operating_costs, lengthof(_expenses_list_operating_costs)), - ExpensesList(_expenses_list_capital_costs, lengthof(_expenses_list_capital_costs)), +static const std::initializer_list _expenses_list_types = { + { STR_FINANCES_REVENUE_TITLE, _expenses_list_revenue }, + { STR_FINANCES_OPERATING_EXPENSES_TITLE, _expenses_list_operating_costs }, + { STR_FINANCES_CAPITAL_EXPENSES_TITLE, _expenses_list_capital_costs }, }; /** @@ -121,9 +120,9 @@ static uint GetTotalCategoriesHeight() /* There's an empty line and blockspace on the year row */ uint total_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; - for (uint i = 0; i < lengthof(_expenses_list_types); i++) { + for (const ExpensesList &list : _expenses_list_types) { /* Title + expense list + total line + total + blockspace after category */ - total_height += FONT_HEIGHT_NORMAL + _expenses_list_types[i].GetHeight() + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; + total_height += FONT_HEIGHT_NORMAL + list.GetHeight() + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; } /* Total income */ @@ -141,11 +140,11 @@ static uint GetMaxCategoriesWidth() uint max_width = 0; /* Loop through categories to check max widths. */ - for (uint i = 0; i < lengthof(_expenses_list_types); i++) { + for (const ExpensesList &list : _expenses_list_types) { /* Title of category */ - max_width = std::max(max_width, GetStringBoundingBox(STR_FINANCES_REVENUE_TITLE + i).width); + max_width = std::max(max_width, GetStringBoundingBox(list.title).width); /* Entries in category */ - max_width = std::max(max_width, _expenses_list_types[i].GetListWidth() + WidgetDimensions::scaled.hsep_indent); + max_width = std::max(max_width, list.GetListWidth() + WidgetDimensions::scaled.hsep_indent); } return max_width; @@ -154,15 +153,13 @@ static uint GetMaxCategoriesWidth() /** * Draw a category of expenses (revenue, operating expenses, capital expenses). */ -static void DrawCategory(const Rect &r, int start_y, ExpensesList list) +static void DrawCategory(const Rect &r, int start_y, const ExpensesList &list) { Rect tr = r.Indent(WidgetDimensions::scaled.hsep_indent, _current_text_dir == TD_RTL); tr.top = start_y; - ExpensesType et; - for (uint i = 0; i < list.length; i++) { - et = list.et[i]; + for (const ExpensesType &et : list.items) { DrawString(tr, STR_FINANCES_SECTION_CONSTRUCTION + et); tr.top += FONT_HEIGHT_NORMAL; } @@ -178,14 +175,14 @@ static void DrawCategories(const Rect &r) /* Start with an empty space in the year row, plus the blockspace under the year. */ int y = r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; - for (uint i = 0; i < lengthof(_expenses_list_types); i++) { + for (const ExpensesList &list : _expenses_list_types) { /* Draw category title and advance y */ - DrawString(r.left, r.right, y, (STR_FINANCES_REVENUE_TITLE + i), TC_FROMSTRING, SA_LEFT); + DrawString(r.left, r.right, y, list.title, TC_FROMSTRING, SA_LEFT); y += FONT_HEIGHT_NORMAL; /* Draw category items and advance y */ - DrawCategory(r, y, _expenses_list_types[i]); - y += _expenses_list_types[i].GetHeight(); + DrawCategory(r, y, list); + y += list.GetHeight(); /* Advance y by the height of the horizontal line between amounts and subtotal */ y += WidgetDimensions::scaled.vsep_normal; @@ -228,14 +225,12 @@ static void DrawPrice(Money amount, int left, int right, int top, TextColour col * Draw a category of expenses/revenues in the year column. * @return The income sum of the category. */ -static Money DrawYearCategory(const Rect &r, int start_y, ExpensesList list, const Expenses &tbl) +static Money DrawYearCategory(const Rect &r, int start_y, const ExpensesList &list, const Expenses &tbl) { int y = start_y; - ExpensesType et; Money sum = 0; - for (uint i = 0; i < list.length; i++) { - et = list.et[i]; + for (const ExpensesType &et : list.items) { Money cost = tbl[et]; sum += cost; if (cost != 0) DrawPrice(cost, r.left, r.right, y, TC_BLACK); @@ -270,11 +265,11 @@ static void DrawYearColumn(const Rect &r, int year, const Expenses &tbl) y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; /* Categories */ - for (uint i = 0; i < lengthof(_expenses_list_types); i++) { + for (const ExpensesList &list : _expenses_list_types) { y += FONT_HEIGHT_NORMAL; - sum += DrawYearCategory(r, y, _expenses_list_types[i], tbl); + sum += DrawYearCategory(r, y, list, tbl); /* Expense list + expense category title + expense category total + blockspace after category */ - y += _expenses_list_types[i].GetHeight() + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; + y += list.GetHeight() + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide; } /* Total income. */ @@ -584,7 +579,7 @@ struct CompanyFinancesWindow : Window { } }; -static WindowDesc _company_finances_desc( +static WindowDesc _company_finances_desc(__FILE__, __LINE__, WDP_AUTO, "company_finances", 0, 0, WC_FINANCES, WC_NONE, 0, @@ -1180,7 +1175,7 @@ static const NWidgetPart _nested_select_company_livery_widgets [] = { EndContainer(), }; -static WindowDesc _select_company_livery_desc( +static WindowDesc _select_company_livery_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_COMPANY_COLOUR, WC_NONE, 0, @@ -1797,7 +1792,7 @@ public: }; /** Company manager face selection window description */ -static WindowDesc _select_company_manager_face_desc( +static WindowDesc _select_company_manager_face_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_COMPANY_MANAGER_FACE, WC_NONE, WDF_CONSTRUCTION, @@ -2201,7 +2196,7 @@ struct CompanyInfrastructureWindow : Window } }; -static WindowDesc _company_infrastructure_desc( +static WindowDesc _company_infrastructure_desc(__FILE__, __LINE__, WDP_AUTO, "company_infrastructure", 0, 0, WC_COMPANY_INFRASTRUCTURE, WC_NONE, 0, @@ -2849,7 +2844,7 @@ struct CompanyWindow : Window } }; -static WindowDesc _company_desc( +static WindowDesc _company_desc(__FILE__, __LINE__, WDP_AUTO, "company", 0, 0, WC_COMPANY, WC_NONE, 0, @@ -3002,7 +2997,7 @@ static const NWidgetPart _nested_buy_company_widgets[] = { EndContainer(), }; -static WindowDesc _buy_company_desc( +static WindowDesc _buy_company_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_BUY_COMPANY, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 95c48c1abf..d048621d66 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -104,7 +104,7 @@ static const struct NWidgetPart _nested_console_window_widgets[] = { NWidget(WWT_EMPTY, INVALID_COLOUR, WID_C_BACKGROUND), SetResize(1, 1), }; -static WindowDesc _console_window_desc( +static WindowDesc _console_window_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_CONSOLE, WC_NONE, 0, @@ -540,7 +540,7 @@ void IConsoleGUIPrint(TextColour colour_code, char *str) * all lines in the buffer are aged by one. When a line exceeds both the maximum position * and also the maximum age, it gets removed. * @return true if any lines were removed -*/ + */ static bool TruncateBuffer() { bool need_truncation = false; diff --git a/src/core/bitmath_func.hpp b/src/core/bitmath_func.hpp index ab0d642bbc..817d22dbf4 100644 --- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -427,7 +427,7 @@ static inline T ROR(const T x, const uint8 n) * Iterable ensemble of each set bit in a value. * @tparam Tbitpos Type of the position variable. * @tparam Tbitset Type of the bitset value. -*/ + */ template struct SetBitIterator { struct Iterator { diff --git a/src/core/kdtree.hpp b/src/core/kdtree.hpp index 36dee3be8f..06f5f55c4f 100644 --- a/src/core/kdtree.hpp +++ b/src/core/kdtree.hpp @@ -449,14 +449,14 @@ public: } /** - * Find all items contained within the given rectangle. - * @note Start coordinates are inclusive, end coordinates are exclusive. x1 void FindContained(CoordT x1, CoordT y1, CoordT x2, CoordT y2, const Outputter &outputter) const { diff --git a/src/date_gui.cpp b/src/date_gui.cpp index b84fc02996..307a9d3917 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -339,14 +339,14 @@ static const NWidgetPart _nested_set_minutes_widgets[] = { }; /** Description of the date setting window. */ -static WindowDesc _set_date_desc( +static WindowDesc _set_date_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_SET_DATE, WC_NONE, 0, std::begin(_nested_set_date_widgets), std::end(_nested_set_date_widgets) ); -static WindowDesc _set_minutes_desc( +static WindowDesc _set_minutes_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_SET_DATE, WC_NONE, 0, diff --git a/src/date_type.h b/src/date_type.h index 2eb7b2dde9..387a8aacb4 100644 --- a/src/date_type.h +++ b/src/date_type.h @@ -85,6 +85,8 @@ static const Year ORIGINAL_MAX_YEAR = 2090; */ #define DAYS_TILL_ORIGINAL_BASE_YEAR DAYS_TILL(ORIGINAL_BASE_YEAR) +static const Date MIN_DATE = 0; + /** The absolute minimum & maximum years in OTTD */ static const Year MIN_YEAR = 0; diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 0f2e90c7c9..d3c1391e34 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -66,7 +66,7 @@ static const NWidgetPart _nested_departures_list[] = { EndContainer(), }; -static WindowDesc _departures_desc( +static WindowDesc _departures_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 260, 246, WC_DEPARTURES_BOARD, WC_NONE, 0, diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 00621c4b4f..bccde9c097 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -84,28 +84,28 @@ static const NWidgetPart _nested_train_depot_widgets[] = { EndContainer(), }; -static WindowDesc _train_depot_desc( +static WindowDesc _train_depot_desc(__FILE__, __LINE__, WDP_AUTO, "depot_train", 362, 123, WC_VEHICLE_DEPOT, WC_NONE, 0, std::begin(_nested_train_depot_widgets), std::end(_nested_train_depot_widgets) ); -static WindowDesc _road_depot_desc( +static WindowDesc _road_depot_desc(__FILE__, __LINE__, WDP_AUTO, "depot_roadveh", 316, 97, WC_VEHICLE_DEPOT, WC_NONE, 0, std::begin(_nested_train_depot_widgets), std::end(_nested_train_depot_widgets) ); -static WindowDesc _ship_depot_desc( +static WindowDesc _ship_depot_desc(__FILE__, __LINE__, WDP_AUTO, "depot_ship", 306, 99, WC_VEHICLE_DEPOT, WC_NONE, 0, std::begin(_nested_train_depot_widgets), std::end(_nested_train_depot_widgets) ); -static WindowDesc _aircraft_depot_desc( +static WindowDesc _aircraft_depot_desc(__FILE__, __LINE__, WDP_AUTO, "depot_aircraft", 332, 99, WC_VEHICLE_DEPOT, WC_NONE, 0, diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 8caa10eb13..05d02808f6 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -347,7 +347,7 @@ static const NWidgetPart _nested_build_docks_toolbar_widgets[] = { EndContainer(), }; -static WindowDesc _build_docks_toolbar_desc( +static WindowDesc _build_docks_toolbar_desc(__FILE__, __LINE__, WDP_ALIGN_TOOLBAR, "toolbar_water", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -391,7 +391,7 @@ static const NWidgetPart _nested_build_docks_scen_toolbar_widgets[] = { }; /** Window definition for the build docks in scenario editor window. */ -static WindowDesc _build_docks_scen_toolbar_desc( +static WindowDesc _build_docks_scen_toolbar_desc(__FILE__, __LINE__, WDP_AUTO, "toolbar_water_scen", 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -494,7 +494,7 @@ static const NWidgetPart _nested_build_dock_station_widgets[] = { EndContainer(), }; -static WindowDesc _build_dock_station_desc( +static WindowDesc _build_dock_station_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -581,21 +581,15 @@ static const NWidgetPart _nested_build_docks_depot_widgets[] = { NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_DEPOT_BUILD_SHIP_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), EndContainer(), NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BDD_BACKGROUND), - NWidget(NWID_SPACER), SetMinimalSize(0, 3), - NWidget(NWID_HORIZONTAL_LTR), - NWidget(NWID_SPACER), SetMinimalSize(3, 0), - NWidget(WWT_PANEL, COLOUR_GREY, WID_BDD_X), SetMinimalSize(98, 66), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP), - EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(2, 0), - NWidget(WWT_PANEL, COLOUR_GREY, WID_BDD_Y), SetMinimalSize(98, 66), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP), - EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(3, 0), + NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1), SetPadding(WidgetDimensions::unscaled.picker), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDD_X), SetMinimalSize(98, 66), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDD_Y), SetMinimalSize(98, 66), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP), EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(0, 3), EndContainer(), }; -static WindowDesc _build_docks_depot_desc( +static WindowDesc _build_docks_depot_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index b8041b39a3..5c470ef2fe 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -143,7 +143,7 @@ struct EnginePreviewWindow : Window { } }; -static WindowDesc _engine_preview_desc( +static WindowDesc _engine_preview_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_ENGINE_PREVIEW, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 8566a3193d..cffb84db24 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -41,7 +41,7 @@ static const NWidgetPart _nested_errmsg_widgets[] = { EndContainer(), }; -static WindowDesc _errmsg_desc( +static WindowDesc _errmsg_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_ERRMSG, WC_NONE, 0, @@ -61,7 +61,7 @@ static const NWidgetPart _nested_errmsg_face_widgets[] = { EndContainer(), }; -static WindowDesc _errmsg_face_desc( +static WindowDesc _errmsg_face_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_ERRMSG, WC_NONE, 0, diff --git a/src/fios.cpp b/src/fios.cpp index a59d694b7f..194b67fd7e 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -739,7 +739,7 @@ void ScanScenarios() /** * Constructs FiosNumberedSaveName. Initial number is the most recent save, or -1 if not found. * @param prefix The prefix to use to generate a filename. -*/ + */ FiosNumberedSaveName::FiosNumberedSaveName(const std::string &prefix) : prefix(prefix), number(-1) { static std::optional _autosave_path; @@ -776,7 +776,7 @@ FiosNumberedSaveName::FiosNumberedSaveName(const std::string &prefix) : prefix(p /** * Generate a savegame name and number according to _settings_client.gui.max_num_autosaves. * @return A filename in format ".sav". -*/ + */ std::string FiosNumberedSaveName::Filename() { return this->FilenameUsingMaxSaves(_settings_client.gui.max_num_autosaves); @@ -800,7 +800,7 @@ std::string FiosNumberedSaveName::FilenameUsingNumber(int num, const char *suffi /** * Generate an extension for a savegame name. * @return An extension in format "-.sav". -*/ + */ std::string FiosNumberedSaveName::Extension() { return stdstr_fmt("-%s.sav", this->prefix.c_str()); diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index b8e05c9eca..e079d8f29d 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -930,7 +930,7 @@ public: }; /** Load game/scenario */ -static WindowDesc _load_dialog_desc( +static WindowDesc _load_dialog_desc(__FILE__, __LINE__, WDP_CENTER, "load_game", 500, 294, WC_SAVELOAD, WC_NONE, 0, @@ -938,7 +938,7 @@ static WindowDesc _load_dialog_desc( ); /** Load heightmap */ -static WindowDesc _load_heightmap_dialog_desc( +static WindowDesc _load_heightmap_dialog_desc(__FILE__, __LINE__, WDP_CENTER, "load_heightmap", 257, 320, WC_SAVELOAD, WC_NONE, 0, @@ -946,7 +946,7 @@ static WindowDesc _load_heightmap_dialog_desc( ); /** Save game/scenario */ -static WindowDesc _save_dialog_desc( +static WindowDesc _save_dialog_desc(__FILE__, __LINE__, WDP_CENTER, "save_game", 500, 294, WC_SAVELOAD, WC_NONE, 0, diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index c4997c0d0f..482e420079 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -1,9 +1,9 @@ /* -* This file is part of OpenTTD. -* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. -* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . -*/ + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ /** @file framerate_gui.cpp GUI for displaying framerate/game speed information. */ @@ -724,7 +724,7 @@ struct FramerateWindow : Window { } }; -static WindowDesc _framerate_display_desc( +static WindowDesc _framerate_display_desc(__FILE__, __LINE__, WDP_AUTO, "framerate_display", 0, 0, WC_FRAMERATE_DISPLAY, WC_NONE, 0, @@ -801,7 +801,7 @@ struct FrametimeGraphWindow : Window { void SelectHorizontalScale(TimingMeasurement range) { /* Determine horizontal scale based on period covered by 60 points - * (slightly less than 2 seconds at full game speed) */ + * (slightly less than 2 seconds at full game speed) */ struct ScaleDef { TimingMeasurement range; int scale; }; static const ScaleDef hscales[] = { { 120, 60 }, @@ -1010,7 +1010,7 @@ struct FrametimeGraphWindow : Window { } }; -static WindowDesc _frametime_graph_window_desc( +static WindowDesc _frametime_graph_window_desc(__FILE__, __LINE__, WDP_AUTO, "frametime_graph", 140, 90, WC_FRAMETIME_GRAPH, WC_NONE, 0, diff --git a/src/framerate_type.h b/src/framerate_type.h index f0116d8182..3ca0a7abd0 100644 --- a/src/framerate_type.h +++ b/src/framerate_type.h @@ -1,9 +1,9 @@ /* -* This file is part of OpenTTD. -* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. -* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . -*/ + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ /** @file framerate_type.h * Types for recording game performance data. diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index 6aa5514089..c886ca91ea 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -67,7 +67,7 @@ static const NWidgetPart _nested_gs_config_widgets[] = { }; /** Window definition for the configure GS window. */ -static WindowDesc _gs_config_desc( +static WindowDesc _gs_config_desc(__FILE__, __LINE__, WDP_CENTER, "settings_gs_config", 500, 350, WC_GAME_OPTIONS, WC_NONE, 0, diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index cbd68e0fe0..8d7b8a984b 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -1150,14 +1150,14 @@ struct GenerateLandscapeWindow : public Window { } }; -static WindowDesc _generate_landscape_desc( +static WindowDesc _generate_landscape_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_GENERATE_LANDSCAPE, WC_NONE, 0, std::begin(_nested_generate_landscape_widgets), std::end(_nested_generate_landscape_widgets) ); -static WindowDesc _heightmap_load_desc( +static WindowDesc _heightmap_load_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_GENERATE_LANDSCAPE, WC_NONE, 0, @@ -1460,7 +1460,7 @@ static const NWidgetPart _nested_create_scenario_widgets[] = { EndContainer(), }; -static WindowDesc _create_scenario_desc( +static WindowDesc _create_scenario_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_GENERATE_LANDSCAPE, WC_NONE, 0, @@ -1486,7 +1486,7 @@ static const NWidgetPart _nested_generate_progress_widgets[] = { }; -static WindowDesc _generate_progress_desc( +static WindowDesc _generate_progress_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_MODAL_PROGRESS, WC_NONE, 0, diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 4c2aa531f1..a08d4fa610 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -260,18 +260,8 @@ static void LoadSpriteTables() ClrBit(master->flags, GCF_INIT_ONLY); /* Baseset extra graphics */ - GRFConfig *extra = new GRFConfig(used_set->files[GFT_EXTRA].filename.c_str()); - - /* We know the palette of the base set, so if the base NewGRF is not - * setting one, use the palette of the base set and not the global - * one which might be the wrong palette for this base NewGRF. - * The value set here might be overridden via action14 later. */ - switch (used_set->palette) { - case PAL_DOS: extra->palette |= GRFP_GRF_DOS; break; - case PAL_WINDOWS: extra->palette |= GRFP_GRF_WINDOWS; break; - default: break; - } - FillGRFDetails(extra, false, BASESET_DIR); + GRFConfig *extra = new GRFConfig(used_set->GetOrCreateExtraConfig()); + if (extra->num_params == 0) extra->SetParameterDefaults(); ClrBit(extra->flags, GCF_INIT_ONLY); extra->next = top; @@ -546,6 +536,17 @@ void GfxLoadSprites() DEBUG(sprite, 2, "Completed loading sprite set %d", _settings_game.game_creation.landscape); } +GraphicsSet::GraphicsSet() + : BaseSet{}, palette{}, blitter{} +{ + // instantiate here, because unique_ptr needs a complete type +} + +GraphicsSet::~GraphicsSet() +{ + // instantiate here, because unique_ptr needs a complete type +} + bool GraphicsSet::FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename) { bool ret = this->BaseSet::FillSetDetails(ini, path, full_filename, false); @@ -564,6 +565,46 @@ bool GraphicsSet::FillSetDetails(const IniFile &ini, const std::string &path, co return ret; } +/** + * Return configuration for the extra GRF, or lazily create it. + * @return NewGRF configuration + */ +GRFConfig &GraphicsSet::GetOrCreateExtraConfig() const +{ + if (!this->extra_cfg) { + this->extra_cfg.reset(new GRFConfig(this->files[GFT_EXTRA].filename)); + + /* We know the palette of the base set, so if the base NewGRF is not + * setting one, use the palette of the base set and not the global + * one which might be the wrong palette for this base NewGRF. + * The value set here might be overridden via action14 later. */ + switch (this->palette) { + case PAL_DOS: this->extra_cfg->palette |= GRFP_GRF_DOS; break; + case PAL_WINDOWS: this->extra_cfg->palette |= GRFP_GRF_WINDOWS; break; + default: break; + } + FillGRFDetails(this->extra_cfg.get(), false, BASESET_DIR); + } + return *this->extra_cfg; +} + +bool GraphicsSet::IsConfigurable() const +{ + const GRFConfig &cfg = this->GetOrCreateExtraConfig(); + /* This check is more strict than the one for NewGRF Settings. + * There are no legacy basesets with parameters, but without Action14 */ + return !cfg.param_info.empty(); +} + +void GraphicsSet::CopyCompatibleConfig(const GraphicsSet &src) +{ + const GRFConfig *src_cfg = src.GetExtraConfig(); + if (src_cfg == nullptr || src_cfg->num_params == 0) return; + GRFConfig &dest_cfg = this->GetOrCreateExtraConfig(); + if (dest_cfg.IsCompatible(src_cfg->version)) return; + dest_cfg.CopyParams(*src_cfg); +} + /** * Calculate and check the MD5 hash of the supplied GRF. * @param file The file get the hash of. diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index 2e266e1bc7..2c5a550c02 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -302,7 +302,7 @@ static const NWidgetPart _nested_goals_list_widgets[] = { EndContainer(), }; -static WindowDesc _goals_list_desc( +static WindowDesc _goals_list_desc(__FILE__, __LINE__, WDP_AUTO, "list_goals", 500, 127, WC_GOALS_LIST, WC_NONE, 0, @@ -512,24 +512,28 @@ static const NWidgetPart _nested_goal_question_widgets_error[] = { static WindowDesc _goal_question_list_desc[] = { { + __FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_GOAL_QUESTION, WC_NONE, WDF_CONSTRUCTION, std::begin(_nested_goal_question_widgets_question), std::end(_nested_goal_question_widgets_question), }, { + __FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_GOAL_QUESTION, WC_NONE, WDF_CONSTRUCTION, std::begin(_nested_goal_question_widgets_info), std::end(_nested_goal_question_widgets_info), }, { + __FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_GOAL_QUESTION, WC_NONE, WDF_CONSTRUCTION, std::begin(_nested_goal_question_widgets_warning), std::end(_nested_goal_question_widgets_warning), }, { + __FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_GOAL_QUESTION, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 3661cd9c0e..ba7bd10e0d 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -144,7 +144,7 @@ static const NWidgetPart _nested_graph_legend_widgets[] = { EndContainer(), }; -static WindowDesc _graph_legend_desc( +static WindowDesc _graph_legend_desc(__FILE__, __LINE__, WDP_AUTO, "graph_legend", 0, 0, WC_GRAPH_LEGEND, WC_NONE, 0, @@ -674,7 +674,7 @@ static const NWidgetPart _nested_operating_profit_widgets[] = { EndContainer(), }; -static WindowDesc _operating_profit_desc( +static WindowDesc _operating_profit_desc(__FILE__, __LINE__, WDP_AUTO, "graph_operating_profit", 0, 0, WC_OPERATING_PROFIT, WC_NONE, 0, @@ -725,7 +725,7 @@ static const NWidgetPart _nested_income_graph_widgets[] = { EndContainer(), }; -static WindowDesc _income_graph_desc( +static WindowDesc _income_graph_desc(__FILE__, __LINE__, WDP_AUTO, "graph_income", 0, 0, WC_INCOME_GRAPH, WC_NONE, 0, @@ -1032,7 +1032,7 @@ static const NWidgetPart _nested_delivered_cargo_graph_widgets[] = { EndContainer(), }; -static WindowDesc _delivered_cargo_graph_desc( +static WindowDesc _delivered_cargo_graph_desc(__FILE__, __LINE__, WDP_AUTO, "graph_delivered_cargo", 0, 0, WC_DELIVERED_CARGO, WC_NONE, 0, @@ -1088,7 +1088,7 @@ static const NWidgetPart _nested_performance_history_widgets[] = { EndContainer(), }; -static WindowDesc _performance_history_desc( +static WindowDesc _performance_history_desc(__FILE__, __LINE__, WDP_AUTO, "graph_performance", 0, 0, WC_PERFORMANCE_HISTORY, WC_NONE, 0, @@ -1137,7 +1137,7 @@ static const NWidgetPart _nested_company_value_graph_widgets[] = { EndContainer(), }; -static WindowDesc _company_value_graph_desc( +static WindowDesc _company_value_graph_desc(__FILE__, __LINE__, WDP_AUTO, "graph_company_value", 0, 0, WC_COMPANY_VALUE, WC_NONE, 0, @@ -1485,7 +1485,7 @@ static const NWidgetPart _nested_cargo_payment_rates_widgets[] = { EndContainer(), }; -static WindowDesc _cargo_payment_rates_desc( +static WindowDesc _cargo_payment_rates_desc(__FILE__, __LINE__, WDP_AUTO, "graph_cargo_payment_rates", 0, 0, WC_PAYMENT_RATES, WC_NONE, 0, @@ -1781,7 +1781,7 @@ static const NWidgetPart _nested_performance_rating_detail_widgets[] = { NWidgetFunction(MakePerformanceDetailPanels), }; -static WindowDesc _performance_rating_detail_desc( +static WindowDesc _performance_rating_detail_desc(__FILE__, __LINE__, WDP_AUTO, "league_details", 0, 0, WC_PERFORMANCE_DETAIL, WC_NONE, 0, @@ -2055,7 +2055,7 @@ static const NWidgetPart _nested_station_cargo_widgets[] = { EndContainer(), }; -static WindowDesc _station_cargo_desc( +static WindowDesc _station_cargo_desc(__FILE__, __LINE__, WDP_AUTO, "graph_station_cargo", 0, 0, WC_STATION_CARGO, WC_NONE, 0, diff --git a/src/group.h b/src/group.h index 3c0a7fbb0a..be019c6daf 100644 --- a/src/group.h +++ b/src/group.h @@ -115,7 +115,6 @@ Money GetGroupProfitLastYearMinAge(CompanyID company, GroupID id_g, VehicleType void SetTrainGroupID(Train *v, GroupID grp); void UpdateTrainGroupID(Train *v); -void RemoveVehicleFromGroup(const Vehicle *v); void RemoveAllGroupsForCompany(const CompanyID company); bool GroupIsInGroup(GroupID search, GroupID group); diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 7ae227c358..5359f03fb7 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -912,19 +912,6 @@ CommandCost CmdSetGroupFlag(TileIndex tile, DoCommandFlag flags, uint32 p1, uint return CommandCost(); } -/** - * Decrease the num_vehicle variable before delete an front engine from a group - * @note Called in CmdSellRailWagon and DeleteLasWagon, - * @param v FrontEngine of the train we want to remove. - */ -void RemoveVehicleFromGroup(const Vehicle *v) -{ - if (!v->IsPrimaryVehicle()) return; - - if (!IsDefaultGroupID(v->group_id)) GroupStatistics::CountVehicle(v, -1); -} - - /** * Affect the groupID of a train to new_g. * @note called in CmdAddVehicleGroup and CmdMoveRailVehicle diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 0935bf60e9..7c1d84550d 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -1245,14 +1245,14 @@ public: }; -static WindowDesc _other_group_desc( +static WindowDesc _other_group_desc(__FILE__, __LINE__, WDP_AUTO, "list_groups", 460, 246, WC_INVALID, WC_NONE, 0, std::begin(_nested_group_widgets), std::end(_nested_group_widgets) ); -static WindowDesc _train_group_desc( +static WindowDesc _train_group_desc(__FILE__, __LINE__, WDP_AUTO, "list_groups_train", 525, 246, WC_TRAINS_LIST, WC_NONE, 0, diff --git a/src/help_gui.cpp b/src/help_gui.cpp index 5c052af917..be28a24de7 100644 --- a/src/help_gui.cpp +++ b/src/help_gui.cpp @@ -205,7 +205,7 @@ static const NWidgetPart _nested_helpwin_widgets[] = { EndContainer(), }; -static WindowDesc _helpwin_desc( +static WindowDesc _helpwin_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_HELPWIN, WC_NONE, 0, diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index cafecf0dcc..a6a50960af 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -211,14 +211,14 @@ static const NWidgetPart _nested_highscore_widgets[] = { NWidget(WWT_PANEL, COLOUR_BROWN, WID_H_BACKGROUND), SetResize(1, 1), EndContainer(), }; -static WindowDesc _highscore_desc( +static WindowDesc _highscore_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_HIGHSCORE, WC_NONE, 0, std::begin(_nested_highscore_widgets), std::end(_nested_highscore_widgets) ); -static WindowDesc _endgame_desc( +static WindowDesc _endgame_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_ENDSCREEN, WC_NONE, 0, diff --git a/src/industry.h b/src/industry.h index ea3ca4c310..a8d85a2178 100644 --- a/src/industry.h +++ b/src/industry.h @@ -132,23 +132,27 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { return pos - this->accepts_cargo; } - /** Test if this industry accepts any cargo. + /** + * Test if this industry accepts any cargo. * @return true iff the industry accepts any cargo. */ bool IsCargoAccepted() const { return std::any_of(std::begin(this->accepts_cargo), std::end(this->accepts_cargo), [](const auto &cargo) { return IsValidCargoID(cargo); }); } - /** Test if this industry produces any cargo. + /** + * Test if this industry produces any cargo. * @return true iff the industry produces any cargo. */ bool IsCargoProduced() const { return std::any_of(std::begin(this->produced_cargo), std::end(this->produced_cargo), [](const auto &cargo) { return IsValidCargoID(cargo); }); } - /** Test if this industry accepts a specific cargo. + /** + * Test if this industry accepts a specific cargo. * @param cargo Cargo type to test. * @return true iff the industry accepts the given cargo type. */ bool IsCargoAccepted(CargoID cargo) const { return std::any_of(std::begin(this->accepts_cargo), std::end(this->accepts_cargo), [&cargo](const auto &cid) { return cid == cargo; }); } - /** Test if this industry produces a specific cargo. + /** + * Test if this industry produces a specific cargo. * @param cargo Cargo type to test. * @return true iff the industry produces the given cargo types. */ diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index a6f02cf0e7..46cdd32172 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -293,7 +293,7 @@ static const NWidgetPart _nested_build_industry_widgets[] = { }; /** Window definition of the dynamic place industries gui */ -static WindowDesc _build_industry_desc( +static WindowDesc _build_industry_desc(__FILE__, __LINE__, WDP_AUTO, "build_industry", 170, 212, WC_BUILD_INDUSTRY, WC_NONE, WDF_CONSTRUCTION, @@ -1205,7 +1205,7 @@ static const NWidgetPart _nested_industry_view_widgets[] = { }; /** Window definition of the view industry gui */ -static WindowDesc _industry_view_desc( +static WindowDesc _industry_view_desc(__FILE__, __LINE__, WDP_AUTO, "view_industry", 260, 120, WC_INDUSTRY_VIEW, WC_NONE, 0, @@ -1228,24 +1228,24 @@ static const NWidgetPart _nested_industry_directory_widgets[] = { EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(NWID_VERTICAL), - NWidget(NWID_VERTICAL), - NWidget(NWID_HORIZONTAL), - NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_ID_DROPDOWN_ORDER), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), - NWidget(WWT_DROPDOWN, COLOUR_BROWN, WID_ID_DROPDOWN_CRITERIA), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA), - NWidget(WWT_EDITBOX, COLOUR_BROWN, WID_ID_FILTER), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), - EndContainer(), - NWidget(NWID_HORIZONTAL), - NWidget(WWT_DROPDOWN, COLOUR_BROWN, WID_ID_FILTER_BY_ACC_CARGO), SetMinimalSize(225, 12), SetFill(0, 1), SetDataTip(STR_INDUSTRY_DIRECTORY_ACCEPTED_CARGO_FILTER, STR_TOOLTIP_FILTER_CRITERIA), - NWidget(WWT_DROPDOWN, COLOUR_BROWN, WID_ID_FILTER_BY_PROD_CARGO), SetMinimalSize(225, 12), SetFill(0, 1), SetDataTip(STR_INDUSTRY_DIRECTORY_PRODUCED_CARGO_FILTER, STR_TOOLTIP_FILTER_CRITERIA), - NWidget(WWT_PANEL, COLOUR_BROWN), SetResize(1, 0), EndContainer(), - EndContainer(), + NWidget(NWID_HORIZONTAL), + NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_ID_DROPDOWN_ORDER), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), + NWidget(WWT_DROPDOWN, COLOUR_BROWN, WID_ID_DROPDOWN_CRITERIA), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA), + NWidget(WWT_EDITBOX, COLOUR_BROWN, WID_ID_FILTER), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), + EndContainer(), + NWidget(NWID_HORIZONTAL), + NWidget(WWT_DROPDOWN, COLOUR_BROWN, WID_ID_FILTER_BY_ACC_CARGO), SetMinimalSize(225, 12), SetFill(0, 1), SetDataTip(STR_INDUSTRY_DIRECTORY_ACCEPTED_CARGO_FILTER, STR_TOOLTIP_FILTER_CRITERIA), + NWidget(WWT_DROPDOWN, COLOUR_BROWN, WID_ID_FILTER_BY_PROD_CARGO), SetMinimalSize(225, 12), SetFill(0, 1), SetDataTip(STR_INDUSTRY_DIRECTORY_PRODUCED_CARGO_FILTER, STR_TOOLTIP_FILTER_CRITERIA), + NWidget(WWT_PANEL, COLOUR_BROWN), SetResize(1, 0), EndContainer(), + EndContainer(), + NWidget(WWT_PANEL, COLOUR_BROWN, WID_ID_INDUSTRY_LIST), SetDataTip(0x0, STR_INDUSTRY_DIRECTORY_LIST_CAPTION), SetResize(1, 1), SetScrollbar(WID_ID_VSCROLLBAR), EndContainer(), - NWidget(WWT_PANEL, COLOUR_BROWN, WID_ID_INDUSTRY_LIST), SetDataTip(0x0, STR_INDUSTRY_DIRECTORY_LIST_CAPTION), SetResize(1, 1), SetScrollbar(WID_ID_SCROLLBAR), EndContainer(), - EndContainer(), - NWidget(NWID_VERTICAL), - NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_ID_SCROLLBAR), - NWidget(WWT_RESIZEBOX, COLOUR_BROWN), EndContainer(), + NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_ID_VSCROLLBAR), + EndContainer(), + NWidget(NWID_HORIZONTAL), + NWidget(NWID_HSCROLLBAR, COLOUR_BROWN, WID_ID_HSCROLLBAR), + NWidget(WWT_RESIZEBOX, COLOUR_BROWN), EndContainer(), }; @@ -1321,6 +1321,7 @@ protected: GUIIndustryList industries; Scrollbar *vscroll; + Scrollbar *hscroll; CargoID cargo_filter[NUM_CARGO + 2]; ///< Available cargo filters; CargoID or CF_ANY or CF_NONE StringID cargo_filter_texts[NUM_CARGO + 3]; ///< Texts for filter_cargo, terminated by INVALID_STRING_ID @@ -1409,6 +1410,19 @@ protected: this->industries.SetFilterState(is_filtering_necessary); } + /** + * Get the width needed to draw the longest industry line. + * @return Returns width of the longest industry line, including padding. + */ + uint GetIndustryListWidth() const + { + uint width = 0; + for (const Industry *i : this->industries) { + width = std::max(width, GetStringBoundingBox(this->GetIndustryString(i)).width); + } + return width + WidgetDimensions::scaled.framerect.Horizontal(); + } + /** (Re)Build industries list */ void BuildSortIndustriesList() { @@ -1427,18 +1441,19 @@ protected: this->industries.shrink_to_fit(); this->industries.RebuildDone(); - } - auto filter = std::make_pair(this->cargo_filter[this->accepted_cargo_filter_criteria], - this->cargo_filter[this->produced_cargo_filter_criteria]); + auto filter = std::make_pair(this->cargo_filter[this->accepted_cargo_filter_criteria], + this->cargo_filter[this->produced_cargo_filter_criteria]); - this->industries.Filter(filter); + this->industries.Filter(filter); + + this->hscroll->SetCount(this->GetIndustryListWidth()); + this->vscroll->SetCount(this->industries.size()); // Update scrollbar as well. + } IndustryDirectoryWindow::produced_cargo_filter = this->cargo_filter[this->produced_cargo_filter_criteria]; this->industries.Sort(); - this->vscroll->SetCount(this->industries.size()); // Update scrollbar as well. - this->SetDirty(); } @@ -1625,7 +1640,8 @@ public: IndustryDirectoryWindow(WindowDesc *desc, WindowNumber) : Window(desc), industry_editbox(MAX_FILTER_LENGTH * MAX_CHAR_LENGTH, MAX_FILTER_LENGTH) { this->CreateNestedTree(); - this->vscroll = this->GetScrollbar(WID_ID_SCROLLBAR); + this->vscroll = this->GetScrollbar(WID_ID_VSCROLLBAR); + this->hscroll = this->GetScrollbar(WID_ID_HSCROLLBAR); this->industries.SetListing(this->last_sorting); this->industries.SetSortFuncs(IndustryDirectoryWindow::sorter_funcs); @@ -1675,16 +1691,28 @@ public: break; case WID_ID_INDUSTRY_LIST: { - int n = 0; Rect ir = r.Shrink(WidgetDimensions::scaled.framerect); + + /* Setup a clipping rectangle... */ + DrawPixelInfo tmp_dpi; + if (!FillDrawPixelInfo(&tmp_dpi, ir.left, ir.top, ir.Width(), ir.Height())) return; + /* ...but keep coordinates relative to the window. */ + tmp_dpi.left += ir.left; + tmp_dpi.top += ir.top; + + AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi); + + ir.left -= this->hscroll->GetPosition(); + ir.right += this->hscroll->GetCapacity() - this->hscroll->GetPosition(); + if (this->industries.empty()) { DrawString(ir, STR_INDUSTRY_DIRECTORY_NONE); break; } - TextColour tc; + int n = 0; const CargoID acf_cid = this->cargo_filter[this->accepted_cargo_filter_criteria]; for (uint i = this->vscroll->GetPosition(); i < this->industries.size(); i++) { - tc = TC_FROMSTRING; + TextColour tc = TC_FROMSTRING; if (acf_cid != CF_ANY && acf_cid != CF_NONE) { Industry *ind = const_cast(this->industries[i]); if (IndustryTemporarilyRefusesCargo(ind, acf_cid)) { @@ -1725,9 +1753,6 @@ public: case WID_ID_INDUSTRY_LIST: { Dimension d = GetStringBoundingBox(STR_INDUSTRY_DIRECTORY_NONE); - for (uint i = 0; i < this->industries.size(); i++) { - d = maxdim(d, GetStringBoundingBox(this->GetIndustryString(this->industries[i]))); - } resize->height = d.height; d.height *= 5; d.width += padding.width; @@ -1801,6 +1826,7 @@ public: void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST); + this->hscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST); } void OnEditboxChanged(int wid) override @@ -1870,7 +1896,7 @@ CargoID IndustryDirectoryWindow::produced_cargo_filter = CF_ANY; /** Window definition of the industry directory gui */ -static WindowDesc _industry_directory_desc( +static WindowDesc _industry_directory_desc(__FILE__, __LINE__, WDP_AUTO, "list_industries", 428, 190, WC_INDUSTRY_DIRECTORY, WC_NONE, 0, @@ -1913,7 +1939,7 @@ static const NWidgetPart _nested_industry_cargoes_widgets[] = { }; /** Window description for the industry cargoes window. */ -static WindowDesc _industry_cargoes_desc( +static WindowDesc _industry_cargoes_desc(__FILE__, __LINE__, WDP_AUTO, "industry_cargoes", 300, 210, WC_INDUSTRY_CARGOES, WC_NONE, 0, diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index d7d2cfd8c9..1be74446b5 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -496,7 +496,7 @@ static const NWidgetPart _nested_select_game_widgets[] = { EndContainer(), }; -static WindowDesc _select_game_desc( +static WindowDesc _select_game_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_SELECT_GAME, WC_NONE, WDF_NO_CLOSE, diff --git a/src/lang/brazilian_portuguese.txt b/src/lang/brazilian_portuguese.txt index ed8c6bbba2..c78d558080 100644 --- a/src/lang/brazilian_portuguese.txt +++ b/src/lang/brazilian_portuguese.txt @@ -3385,6 +3385,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Salvar STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Salva o padrão com o nome selecionado # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Alterar parâmetros dos gráficos base STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Alterar parâmetros NewGRF STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Fechar STR_NEWGRF_PARAMETERS_RESET :{BLACK}Redefinir parâmetros @@ -5189,6 +5190,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Impossí STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Veículos só podem aguardar em estações STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Esse veículo não pára nesta estação STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... horário incompleto +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... o plano de horário ainda não começou # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... existem placas demais diff --git a/src/lang/danish.txt b/src/lang/danish.txt index dd1ff3b8a3..f8870f34b3 100644 --- a/src/lang/danish.txt +++ b/src/lang/danish.txt @@ -3384,6 +3384,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Gem STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Gem forudindstilling til det valgte navn # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Skift grundlæggende grafiske parametre STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Ændre NewGRF parameterne STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Luk STR_NEWGRF_PARAMETERS_RESET :{BLACK}Nulstil diff --git a/src/lang/dutch.txt b/src/lang/dutch.txt index 1734ccd0e9..9b393a2e1b 100644 --- a/src/lang/dutch.txt +++ b/src/lang/dutch.txt @@ -533,6 +533,7 @@ STR_ABOUT_MENU_ABOUT_OPENTTD :Over 'OpenTTD' STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite-uitlijner STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Selectiekaders in-uitschakelen STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Kleuren van vuile blokken in-uitschakelen +STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES :Widgetkaders in-uitschakelen # Place in highscore window ###length 15 @@ -3383,6 +3384,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Opslaan STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Sla de huidige voorkeursinstelling op onder de huidige gekozen naam # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Grafische basisinstellingen wijzigen STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}NewGRF-parameters wijzigen STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Sluiten STR_NEWGRF_PARAMETERS_RESET :{BLACK}Terugstellen @@ -5187,6 +5189,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Kan geen STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Voertuigen kunnen alleen wachten op stations STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Dit voertuig stopt niet op dit station STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... dienstregeling is niet compleet +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... dienstregeling is nog niet gestart # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... te veel bordjes diff --git a/src/lang/english.txt b/src/lang/english.txt index 69e4f3c989..baa40974e6 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3384,6 +3384,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Save STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Save the preset to the current selected name # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Change base graphics parameters STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Change NewGRF parameters STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Close STR_NEWGRF_PARAMETERS_RESET :{BLACK}Reset @@ -5188,6 +5189,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Can't ti STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Vehicles can only wait at stations STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}This vehicle is not stopping at this station STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... timetable is incomplete +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... timetable has not started yet # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... too many signs diff --git a/src/lang/english_AU.txt b/src/lang/english_AU.txt index 27e2cd00ec..2aed159f88 100644 --- a/src/lang/english_AU.txt +++ b/src/lang/english_AU.txt @@ -3384,6 +3384,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Save STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Save the preset to the current selected name # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Change base graphics parameters STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Change NewGRF parameters STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Close STR_NEWGRF_PARAMETERS_RESET :{BLACK}Reset @@ -5188,6 +5189,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Can't ti STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Vehicles can only wait at stations STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}This vehicle is not stopping at this station STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... timetable is incomplete +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... timetable has not started yet # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... too many signs diff --git a/src/lang/english_US.txt b/src/lang/english_US.txt index 25247bc434..71bb571f1c 100644 --- a/src/lang/english_US.txt +++ b/src/lang/english_US.txt @@ -533,6 +533,7 @@ STR_ABOUT_MENU_ABOUT_OPENTTD :About 'OpenTTD' STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite aligner STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Toggle bounding boxes STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Toggle coloring of dirty blocks +STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES :Toggle widget outlines # Place in highscore window ###length 15 @@ -3383,6 +3384,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Save STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Save the preset to the current selected name # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Change base graphics parameters STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Change NewGRF parameters STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Close STR_NEWGRF_PARAMETERS_RESET :{BLACK}Reset @@ -5187,6 +5189,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Can't ti STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Vehicles can only wait at stations STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}This vehicle is not stopping at this station STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... timetable is incomplete +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... timetable has not started yet # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... too many signs diff --git a/src/lang/finnish.txt b/src/lang/finnish.txt index 2732555dd3..6eff0ad21f 100644 --- a/src/lang/finnish.txt +++ b/src/lang/finnish.txt @@ -3384,7 +3384,8 @@ STR_SAVE_PRESET_SAVE :{BLACK}Tallenna STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Tallenna valmislista valitulle nimelle # NewGRF parameters window -STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Muuta NewGRF-parametrejä +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Muuta perusgrafiikan parametreja +STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Muuta NewGRF-parametreja STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Sulje STR_NEWGRF_PARAMETERS_RESET :{BLACK}Palauta STR_NEWGRF_PARAMETERS_RESET_TOOLTIP :{BLACK}Aseta kaikki parametrit oletusarvoihin @@ -5188,6 +5189,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Ei voi a STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Kulkuneuvo voi odottaa vain asemalla STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Tämä kulkuneuvo ei pysähdy tällä asemalla STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}… aikataulu on puutteellinen +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}… aikataulu ei ole vielä alkanut # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... liian monta kylttiä. diff --git a/src/lang/french.txt b/src/lang/french.txt index f690e21da6..493d63b711 100644 --- a/src/lang/french.txt +++ b/src/lang/french.txt @@ -3385,6 +3385,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Sauvegar STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Sauvegarder la présélection sous le nom actuellement sélectionné # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Modifier les paramètres des graphiques de base STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Modifier les paramètres NewGRF STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Fermer STR_NEWGRF_PARAMETERS_RESET :{BLACK}Réinitialiser @@ -5189,6 +5190,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Impossib STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Les véhicules ne peuvent attendre qu'aux stations STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Ce véhicule ne s'arrête pas à cette station STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... l'horaire est incomplet +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... cet horaire n'a pas encore démarré # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... trop de panneaux diff --git a/src/lang/korean.txt b/src/lang/korean.txt index 73840d2964..c67077bbc8 100644 --- a/src/lang/korean.txt +++ b/src/lang/korean.txt @@ -96,28 +96,28 @@ STR_CARGO_SINGULAR_FIZZY_DRINK :{G=f}탄산음 STR_QUANTITY_NOTHING : STR_QUANTITY_PASSENGERS :승객{NBSP}{COMMA}명 STR_QUANTITY_COAL :석탄 {WEIGHT_LONG} -STR_QUANTITY_MAIL :우편 {COMMA}{NBSP}자루 +STR_QUANTITY_MAIL :우편 {COMMA}자루 STR_QUANTITY_OIL :석유 {VOLUME_LONG} -STR_QUANTITY_LIVESTOCK :가축 {COMMA}{NBSP}마리 -STR_QUANTITY_GOODS :상품 {COMMA}{NBSP}상자 +STR_QUANTITY_LIVESTOCK :가축 {COMMA}마리 +STR_QUANTITY_GOODS :상품 {COMMA}상자 STR_QUANTITY_GRAIN :곡물 {WEIGHT_LONG} STR_QUANTITY_WOOD :목재 {WEIGHT_LONG} STR_QUANTITY_IRON_ORE :철광석 {WEIGHT_LONG} STR_QUANTITY_STEEL :철 {WEIGHT_LONG} -STR_QUANTITY_VALUABLES :귀금속 {COMMA}{NBSP}자루 +STR_QUANTITY_VALUABLES :귀금속 {COMMA}자루 STR_QUANTITY_COPPER_ORE :구리 광석 {WEIGHT_LONG} STR_QUANTITY_MAIZE :옥수수 {WEIGHT_LONG} STR_QUANTITY_FRUIT :과일 {WEIGHT_LONG} -STR_QUANTITY_DIAMONDS :다이아몬드 {COMMA}{NBSP}자루 +STR_QUANTITY_DIAMONDS :다이아몬드 {COMMA}자루 STR_QUANTITY_FOOD :식품 {WEIGHT_LONG} STR_QUANTITY_PAPER :종이 {WEIGHT_LONG} -STR_QUANTITY_GOLD :금 {COMMA}{NBSP}자루 +STR_QUANTITY_GOLD :금 {COMMA}자루 STR_QUANTITY_WATER :물 {VOLUME_LONG} STR_QUANTITY_WHEAT :밀 {WEIGHT_LONG} STR_QUANTITY_RUBBER :고무 {VOLUME_LONG} STR_QUANTITY_SUGAR :설탕 {WEIGHT_LONG} -STR_QUANTITY_TOYS :장난감 {COMMA}{NBSP}상자 -STR_QUANTITY_SWEETS :사탕 {COMMA}{NBSP}자루 +STR_QUANTITY_TOYS :장난감 {COMMA}상자 +STR_QUANTITY_SWEETS :사탕 {COMMA}자루 STR_QUANTITY_COLA :콜라 {VOLUME_LONG} STR_QUANTITY_CANDYFLOSS :솜사탕 {WEIGHT_LONG} STR_QUANTITY_BUBBLES :거품 {COMMA}개 @@ -165,11 +165,11 @@ STR_ABBREV_ALL :모두 # 'Mode' of transport for cargoes STR_PASSENGERS :{G=m}{COMMA}명 -STR_BAGS :{G=f}{COMMA}{NBSP}자루 -STR_TONS :{G=m}{COMMA}{NBSP}톤 -STR_LITERS :{G=f}{COMMA}{NBSP}리터 -STR_ITEMS :{G=m}{COMMA}{NBSP}마리 -STR_CRATES :{G=f}{COMMA}{NBSP}상자 +STR_BAGS :{G=f}{COMMA}자루 +STR_TONS :{G=m}{COMMA}톤 +STR_LITERS :{G=f}{COMMA}리터 +STR_ITEMS :{G=m}{COMMA}마리 +STR_CRATES :{G=f}{COMMA}상자 STR_COLOUR_DEFAULT :기본 ###length 17 @@ -534,6 +534,7 @@ STR_ABOUT_MENU_ABOUT_OPENTTD :'OpenTTD'에 STR_ABOUT_MENU_SPRITE_ALIGNER :스프라이트 정렬 도구 STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :박스 경계선 보기 전환 STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :시각적 업데이트 블록 표시 전환 +STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES :위젯 경계선 켜기/끄기 # Place in highscore window ###length 15 @@ -1779,7 +1780,7 @@ STR_CONFIG_SETTING_SERVINT_AIRCRAFT :항공기에 STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT :항공기에 따로 점검 기간이 설정되어있지 않은 경우에 사용할 기본 점검 기간을 설정합니다. STR_CONFIG_SETTING_SERVINT_SHIPS :선박에 대한 기본 점검 기준: {STRING} STR_CONFIG_SETTING_SERVINT_SHIPS_HELPTEXT :선박에 따로 점검 기간이 설정되어있지 않은 경우에 사용할 기본 점검 기간을 설정합니다. -STR_CONFIG_SETTING_SERVINT_VALUE :{COMMA}{NBSP}일/% +STR_CONFIG_SETTING_SERVINT_VALUE :{COMMA}일/% ###setting-zero-is-special STR_CONFIG_SETTING_SERVINT_DISABLED :사용 안 함 @@ -3384,6 +3385,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}저장 STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}이 프리셋을 선택한 이름으로 저장합니다 # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}기본 그래픽 매개 변수를 변경합니다 STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}NewGRF 매개 변숫값 변경 STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}닫기 STR_NEWGRF_PARAMETERS_RESET :{BLACK}초기화 @@ -5188,6 +5190,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}차량 STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}차량은 정거장에서만 기다릴 수 있습니다 STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}이 차량은 이 정거장에 서지 않습니다 STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... 시간표가 모두 작성되지 않았습니다 +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... 시간표가 아직 시작되지 않았습니다 # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... 팻말 수가 너무 많습니다 diff --git a/src/lang/polish.txt b/src/lang/polish.txt index 223416a0a5..4508e39e0f 100644 --- a/src/lang/polish.txt +++ b/src/lang/polish.txt @@ -3764,6 +3764,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Zapisz STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Zapisz schemat z wybraną nazwą # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Zmień parametry grafik podstawowych STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Zmień parametry NewGRF STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Zamknij STR_NEWGRF_PARAMETERS_RESET :{BLACK}Resetuj @@ -5574,6 +5575,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Nie moż STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Pojazdy mogą czekać tylko na stacjach STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Ten pojazd nie zatrzymuje się na tej stacji. STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... rozkład jazdy jest niekompletny +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... rozkład jazdy jeszcze się nie rozpoczął # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... zbyt wiele napisów diff --git a/src/lang/portuguese.txt b/src/lang/portuguese.txt index ee3a92f01b..ede0f03a08 100644 --- a/src/lang/portuguese.txt +++ b/src/lang/portuguese.txt @@ -3385,6 +3385,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Grava STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Grava a predefinição com o nome seleccionado # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Alterar os parâmetros dos gráficos base STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Alterar parâmetros de NewGRF STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Fechar STR_NEWGRF_PARAMETERS_RESET :{BLACK}Repor @@ -5189,6 +5190,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Impossí STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Veículos apenas podem esperar em estações. STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Este veículo não pára nesta estação. STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... horário incompleto +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... o horário ainda não começou # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... demasiados sinais diff --git a/src/lang/russian.txt b/src/lang/russian.txt index 3f4100355a..6a7384795b 100644 --- a/src/lang/russian.txt +++ b/src/lang/russian.txt @@ -3559,6 +3559,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Сохр STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Сохранить набор под выбранным именем # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Изменение параметров графического пакета STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Изменить параметры NewGRF STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Закрыть STR_NEWGRF_PARAMETERS_RESET :{BLACK}Сброс @@ -5375,6 +5376,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Не у STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Транспорт может ждать только на станции STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Это транспортное средство не останавливается на этой станции STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... график движения неполный +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... график движения не установлен # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... слишком много табличек diff --git a/src/lang/simplified_chinese.txt b/src/lang/simplified_chinese.txt index 821e910479..c0fb39f00d 100644 --- a/src/lang/simplified_chinese.txt +++ b/src/lang/simplified_chinese.txt @@ -533,6 +533,7 @@ STR_ABOUT_MENU_ABOUT_OPENTTD :关于 'OpenTTD STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite 对齐 STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :切换边界框 STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :切换脏方块的颜色 +STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES :调节小组件边框 # Place in highscore window ###length 15 @@ -924,6 +925,8 @@ STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE :{BLACK}新 {STR STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP :{BLACK}打开该运输工具所属的组 +STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_LIST :{WHITE}{STATION}不再接受:{CARGO_LIST} +STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST :{WHITE}{STATION}现在接受:{CARGO_LIST} STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED :{BIG_FONT}{BLACK}财政补贴项目到期:{}{}将 {STRING} 从 {STRING} 运送到 {STRING} 将不再获得财政补贴。 STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE :{BIG_FONT}{BLACK}财政补贴项目流标:{}{}将 {STRING} 从 {STRING} 运送到 {STRING} 将不是财政补贴项目。 @@ -2192,6 +2195,7 @@ STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT :{WHITE}修改 STR_CHEAT_CHANGE_DATE :{LTBLUE}改变日期:{ORANGE}{DATE_SHORT} STR_CHEAT_CHANGE_DATE_QUERY_CAPT :{WHITE}改变当前年份 STR_CHEAT_SETUP_PROD :{LTBLUE}开启可调整产量模式:{ORANGE}{STRING} +STR_CHEAT_STATION_RATING :{LTBLUE}车站评价固定为100%:{ORANGE}{STRING} # Livery window STR_LIVERY_CAPTION :{WHITE}{COMPANY} 的色彩方案 @@ -3380,6 +3384,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}保存 STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}以当前选定的名称保存预设值 # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}改变基本图形组参数 STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}调整 NewGRF 参数 STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}关闭 STR_NEWGRF_PARAMETERS_RESET :{BLACK}重置 diff --git a/src/league_gui.cpp b/src/league_gui.cpp index 09ad666bc6..3998f2e571 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -197,7 +197,7 @@ static const NWidgetPart _nested_performance_league_widgets[] = { EndContainer(), }; -static WindowDesc _performance_league_desc( +static WindowDesc _performance_league_desc(__FILE__, __LINE__, WDP_AUTO, "performance_league", 0, 0, WC_COMPANY_LEAGUE, WC_NONE, 0, @@ -430,7 +430,7 @@ static const NWidgetPart _nested_script_league_widgets[] = { EndContainer(), }; -static WindowDesc _script_league_desc( +static WindowDesc _script_league_desc(__FILE__, __LINE__, WDP_AUTO, "script_league", 0, 0, WC_COMPANY_LEAGUE, WC_NONE, 0, diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 3c92be3875..716bc06595 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -719,7 +719,7 @@ static const NWidgetPart _nested_linkgraph_legend_widgets[] = { static_assert(WID_LGL_SATURATION_LAST - WID_LGL_SATURATION_FIRST == lengthof(LinkGraphOverlay::LINK_COLOURS[0]) - 1); -static WindowDesc _linkgraph_legend_desc( +static WindowDesc _linkgraph_legend_desc(__FILE__, __LINE__, WDP_AUTO, "toolbar_linkgraph", 0, 0, WC_LINKGRAPH_LEGEND, WC_NONE, 0, diff --git a/src/main_gui.cpp b/src/main_gui.cpp index b0539acaf8..636dd29914 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -611,7 +611,7 @@ static Hotkey global_hotkeys[] = { }; HotkeyList MainWindow::hotkeys("global", global_hotkeys); -static WindowDesc _main_window_desc( +static WindowDesc _main_window_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_MAIN_WINDOW, WC_NONE, WDF_NO_CLOSE, diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 9b88368fb9..42cc8e4d62 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -59,7 +59,7 @@ static const NWidgetPart _nested_land_info_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_LI_BACKGROUND), EndContainer(), }; -static WindowDesc _land_info_desc( +static WindowDesc _land_info_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_LAND_INFO, WC_NONE, 0, @@ -430,7 +430,7 @@ static const NWidgetPart _nested_about_widgets[] = { EndContainer(), }; -static WindowDesc _about_desc( +static WindowDesc _about_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_GAME_OPTIONS, WC_NONE, 0, @@ -696,7 +696,7 @@ static const NWidgetPart _nested_tooltips_widgets[] = { NWidget(WWT_EMPTY, INVALID_COLOUR, WID_TT_BACKGROUND), }; -static WindowDesc _tool_tips_desc( +static WindowDesc _tool_tips_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, // Coordinates and sizes are not used, WC_TOOLTIPS, WC_NONE, WDF_NO_FOCUS | WDF_NO_CLOSE, @@ -1153,7 +1153,7 @@ static const NWidgetPart _nested_query_string_widgets[] = { EndContainer(), }; -static WindowDesc _query_string_desc( +static WindowDesc _query_string_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_QUERY_STRING, WC_NONE, 0, @@ -1330,7 +1330,7 @@ static const NWidgetPart _nested_query_widgets[] = { EndContainer(), }; -static WindowDesc _query_desc( +static WindowDesc _query_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_CONFIRM_POPUP_QUERY, WC_NONE, WDF_MODAL, @@ -1463,7 +1463,7 @@ struct ModifierKeyToggleWindow : Window { } }; -static WindowDesc _modifier_key_toggle_desc( +static WindowDesc _modifier_key_toggle_desc(__FILE__, __LINE__, WDP_AUTO, "modifier_key_toggle", 0, 0, WC_MODIFIER_KEY_TOGGLE, WC_NONE, WDF_NO_FOCUS, diff --git a/src/music/midi.h b/src/music/midi.h index 6de8b856c9..0a6198bc12 100644 --- a/src/music/midi.h +++ b/src/music/midi.h @@ -1,9 +1,9 @@ /* -* This file is part of OpenTTD. -* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. -* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . -*/ + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ /* @file midi.h Declarations for MIDI data */ diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp index c25557de10..f6844f3e1e 100644 --- a/src/music/midifile.cpp +++ b/src/music/midifile.cpp @@ -1,9 +1,9 @@ /* -* This file is part of OpenTTD. -* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. -* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . -*/ + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ /* @file midifile.cpp Parser for standard MIDI files */ diff --git a/src/music/midifile.hpp b/src/music/midifile.hpp index 90355e0fdf..d21267e60b 100644 --- a/src/music/midifile.hpp +++ b/src/music/midifile.hpp @@ -1,9 +1,9 @@ /* -* This file is part of OpenTTD. -* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. -* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . -*/ + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ /* @file midifile.hpp Parser for standard MIDI files */ diff --git a/src/music_gui.cpp b/src/music_gui.cpp index 0ba3dab23d..5250bf44ac 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -175,7 +175,7 @@ void MusicSystem::ChangePlaylist(PlaylistChoices pl) void MusicSystem::ChangeMusicSet(const std::string &set_name) { if (set_name != "NoMusic") InitMusicDriver(true); - BaseMusic::SetSet(set_name); + BaseMusic::SetSetByName(set_name); BaseMusic::ini_set = set_name; this->BuildPlaylists(); @@ -649,7 +649,7 @@ static const NWidgetPart _nested_music_track_selection_widgets[] = { EndContainer(), }; -static WindowDesc _music_track_selection_desc( +static WindowDesc _music_track_selection_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_MUSIC_TRACK_SELECTION, WC_NONE, 0, @@ -908,7 +908,7 @@ static const NWidgetPart _nested_music_window_widgets[] = { EndContainer(), }; -static WindowDesc _music_window_desc( +static WindowDesc _music_window_desc(__FILE__, __LINE__, WDP_AUTO, "music", 0, 0, WC_MUSIC_WINDOW, WC_NONE, 0, diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 5562c60643..fe2decdda4 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -65,7 +65,7 @@ static std::chrono::steady_clock::time_point _chatmessage_dirty_time; * the left and pixels from the bottom. The height is the maximum height. */ static PointDimension _chatmsg_box; -static uint8 *_chatmessage_backup = nullptr; ///< Backup in case text is moved. +static ReusableBuffer _chatmessage_backup; ///< Backup in case text is moved. /** * Test if there are any chat messages to display. @@ -112,7 +112,6 @@ void NetworkReInitChatBoxSize() { _chatmsg_box.y = 3 * FONT_HEIGHT_NORMAL; _chatmsg_box.height = MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + ScaleGUITrad(NETWORK_CHAT_LINE_SPACING)) + ScaleGUITrad(4); - _chatmessage_backup = ReallocT(_chatmessage_backup, static_cast(_chatmsg_box.width) * _chatmsg_box.height * BlitterFactory::GetCurrentBlitter()->GetBytesPerPixel()); } /** Initialize all buffers of the chat visualisation. */ @@ -165,7 +164,7 @@ void NetworkUndrawChatMessage() _chatmessage_visible = false; /* Put our 'shot' back to the screen */ - blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height); + blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup.GetBuffer(), width, height); /* And make sure it is updated next time */ VideoDriver::GetInstance()->MakeDirty(x, y, width, height); @@ -218,10 +217,9 @@ void NetworkDrawChatMessage() } if (width <= 0 || height <= 0) return; - assert(blitter->BufferSize(width, height) <= static_cast(_chatmsg_box.width) * _chatmsg_box.height * blitter->GetBytesPerPixel()); - /* Make a copy of the screen as it is before painting (for undraw) */ - blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height); + uint8_t *buffer = _chatmessage_backup.Allocate(BlitterFactory::GetCurrentBlitter()->BufferSize(width, height)); + blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), buffer, width, height); _cur_dpi = &_screen; // switch to _screen painting @@ -520,7 +518,7 @@ static const NWidgetPart _nested_chat_window_widgets[] = { }; /** The description of the chat window. */ -static WindowDesc _chat_window_desc( +static WindowDesc _chat_window_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_SEND_NETWORK_MSG, WC_NONE, WDF_NETWORK, diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 89a5856395..1283387cf1 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -200,9 +200,9 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::CloseConnection(NetworkRecvSta ShutdownSocket(this->sock, false, true, 2); /* Wait a number of ticks so our leave message can reach the server. - * This is especially needed for Windows servers as they seem to get - * the "socket is closed" message before receiving our leave message, - * which would trigger the server to close the connection as well. */ + * This is especially needed for Windows servers as they seem to get + * the "socket is closed" message before receiving our leave message, + * which would trigger the server to close the connection as well. */ CSleep(3 * MILLISECONDS_PER_TICK); } diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index ccfdd1bfee..531d5171a0 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -93,7 +93,7 @@ static const NWidgetPart _nested_network_content_download_status_window_widgets[ }; /** Window description for the download window */ -static WindowDesc _network_content_download_status_window_desc( +static WindowDesc _network_content_download_status_window_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL, @@ -1068,7 +1068,7 @@ static const NWidgetPart _nested_network_content_list_widgets[] = { NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, WID_NCL_SCROLLBAR), EndContainer(), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(0, 8, 0), - NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NCL_SEL_ALL_UPDATE), SetResize(1, 0), SetFill(1, 0), + NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NCL_SEL_ALL_UPDATE), NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_SELECT_UPDATE), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_CONTENT_SELECT_UPDATES_CAPTION, STR_CONTENT_SELECT_UPDATES_CAPTION_TOOLTIP), NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_SELECT_ALL), SetResize(1, 0), SetFill(1, 0), @@ -1113,7 +1113,7 @@ static const NWidgetPart _nested_network_content_list_widgets[] = { }; /** Window description of the content list */ -static WindowDesc _network_content_list_desc( +static WindowDesc _network_content_list_desc(__FILE__, __LINE__, WDP_CENTER, "list_content", 630, 460, WC_NETWORK_WINDOW, WC_NONE, 0, diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index c9a6b5545d..72886bec32 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -133,7 +133,7 @@ public: this->smallest_x = this->head->smallest_x + this->tail->smallest_x; // First and last are always shown, rest not } - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override { assert(given_width >= this->smallest_x && given_height >= this->smallest_y); @@ -962,7 +962,7 @@ static const NWidgetPart _nested_network_game_widgets[] = { EndContainer(), }; -static WindowDesc _network_game_window_desc( +static WindowDesc _network_game_window_desc(__FILE__, __LINE__, WDP_CENTER, "list_servers", 1000, 730, WC_NETWORK_WINDOW, WC_NONE, WDF_NETWORK, @@ -1229,7 +1229,7 @@ static const NWidgetPart _nested_network_start_server_window_widgets[] = { EndContainer(), }; -static WindowDesc _network_start_server_window_desc( +static WindowDesc _network_start_server_window_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_NETWORK_WINDOW, WC_NONE, WDF_NETWORK, @@ -1308,7 +1308,7 @@ static const NWidgetPart _nested_client_list_widgets[] = { EndContainer(), }; -static WindowDesc _client_list_desc( +static WindowDesc _client_list_desc(__FILE__, __LINE__, WDP_AUTO, "list_clients", 220, 300, WC_CLIENT_LIST, WC_NONE, WDF_NETWORK, @@ -2218,7 +2218,7 @@ static const NWidgetPart _nested_network_join_status_window_widgets[] = { EndContainer(), }; -static WindowDesc _network_join_status_window_desc( +static WindowDesc _network_join_status_window_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL | WDF_NETWORK, @@ -2340,7 +2340,7 @@ static const NWidgetPart _nested_network_company_password_window_widgets[] = { EndContainer(), }; -static WindowDesc _network_company_password_window_desc( +static WindowDesc _network_company_password_window_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_COMPANY_PASSWORD_WINDOW, WC_NONE, WDF_NETWORK, @@ -2449,7 +2449,7 @@ static const NWidgetPart _nested_network_ask_relay_widgets[] = { EndContainer(), }; -static WindowDesc _network_ask_relay_desc( +static WindowDesc _network_ask_relay_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_NETWORK_ASK_RELAY, WC_NONE, WDF_MODAL | WDF_NETWORK, @@ -2547,7 +2547,7 @@ static const NWidgetPart _nested_network_ask_survey_widgets[] = { EndContainer(), }; -static WindowDesc _network_ask_survey_desc( +static WindowDesc _network_ask_survey_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_NETWORK_ASK_SURVEY, WC_NONE, WDF_MODAL, diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 1de71f4d13..4830beea46 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3628,13 +3628,13 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, it.ti.x = (int8)GB(it.ti.x, 0, 8); it.ti.y = (int8)GB(it.ti.y, 0, 8); - /* When there were only 256x256 maps, TileIndex was a uint16 and - * it.ti was just a TileIndexDiff that was added to it. - * As such negative "x" values were shifted into the "y" position. - * x = -1, y = 1 -> x = 255, y = 0 - * Since GRF version 8 the position is interpreted as pair of independent int8. - * For GRF version < 8 we need to emulate the old shifting behaviour. - */ + /* When there were only 256x256 maps, TileIndex was a uint16_t and + * it.ti was just a TileIndexDiff that was added to it. + * As such negative "x" values were shifted into the "y" position. + * x = -1, y = 1 -> x = 255, y = 0 + * Since GRF version 8 the position is interpreted as pair of independent int8. + * For GRF version < 8 we need to emulate the old shifting behaviour. + */ if (_cur.grffile->grf_version < 8 && it.ti.x < 0) it.ti.y += 1; } } @@ -10999,8 +10999,8 @@ static void FinaliseIndustriesArray() StringID strid; /* process the conversion of text at the end, so to be sure everything will be fine - * and available. Check if it does not return undefind marker, which is a very good sign of a - * substitute industry who has not changed the string been examined, thus using it as such */ + * and available. Check if it does not return undefind marker, which is a very good sign of a + * substitute industry who has not changed the string been examined, thus using it as such */ strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->name); if (strid != STR_UNDEFINED) indsp->name = strid; @@ -11018,7 +11018,7 @@ static void FinaliseIndustriesArray() if (indsp->station_name != STR_NULL) { /* STR_NULL (0) can be set by grf. It has a meaning regarding assignation of the - * station's name. Don't want to lose the value, therefore, do not process. */ + * station's name. Don't want to lose the value, therefore, do not process. */ strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->station_name); if (strid != STR_UNDEFINED) indsp->station_name = strid; } diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 5c1b4672e7..d6e2a7bdf8 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -74,6 +74,12 @@ GRFConfig::GRFConfig(const GRFConfig &config) : { } +void GRFConfig::SetParams(const std::vector &pars) +{ + this->num_params = static_cast(std::min(this->param.size(), pars.size())); + std::copy(pars.begin(), pars.begin() + this->num_params, this->param.begin()); +} + /** * Return whether this NewGRF can replace an older version of the same NewGRF. */ diff --git a/src/newgrf_config.h b/src/newgrf_config.h index bf6dceabe4..39927fc2c5 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -180,6 +180,7 @@ struct GRFConfig : ZeroedMemoryAllocator { struct GRFConfig *next; ///< NOSAVE: Next item in the linked list bool IsCompatible(uint32_t old_version) const; + void SetParams(const std::vector &pars); void CopyParams(const GRFConfig &src); const char *GetTextfile(TextfileType type) const; @@ -238,6 +239,7 @@ std::string GRFBuildParamList(const GRFConfig *c); /* In newgrf_gui.cpp */ void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config); +void OpenGRFParameterWindow(bool is_baseset, GRFConfig *c, bool editable); void UpdateNewGRFScanStatus(uint num, const char *name); void UpdateNewGRFConfigPalette(int32 new_value = 0); diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 8e4eb283bd..37774c2b76 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -1105,14 +1105,14 @@ static const NWidgetPart _nested_newgrf_inspect_widgets[] = { EndContainer(), }; -static WindowDesc _newgrf_inspect_chain_desc( +static WindowDesc _newgrf_inspect_chain_desc(__FILE__, __LINE__, WDP_AUTO, "newgrf_inspect_chain", 400, 300, WC_NEWGRF_INSPECT, WC_NONE, 0, std::begin(_nested_newgrf_inspect_chain_widgets), std::end(_nested_newgrf_inspect_chain_widgets) ); -static WindowDesc _newgrf_inspect_desc( +static WindowDesc _newgrf_inspect_desc(__FILE__, __LINE__, WDP_AUTO, "newgrf_inspect", 400, 300, WC_NEWGRF_INSPECT, WC_NONE, 0, @@ -1572,7 +1572,7 @@ static const NWidgetPart _nested_sprite_aligner_widgets[] = { EndContainer(), }; -static WindowDesc _sprite_aligner_desc( +static WindowDesc _sprite_aligner_desc(__FILE__, __LINE__, WDP_AUTO, "sprite_aligner", 400, 300, WC_SPRITE_ALIGNER, WC_NONE, 0, diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index f6f068b5d6..ce49a927f6 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -160,7 +160,7 @@ struct NewGRFParametersWindow : public Window { bool action14present; ///< True if action14 information is present. bool editable; ///< Allow editing parameters. - NewGRFParametersWindow(WindowDesc *desc, GRFConfig *c, bool editable) : Window(desc), + NewGRFParametersWindow(WindowDesc *desc, bool is_baseset, GRFConfig *c, bool editable) : Window(desc), grf_config(c), clicked_button(UINT_MAX), clicked_dropdown(false), @@ -171,6 +171,7 @@ struct NewGRFParametersWindow : public Window { this->action14present = (c->num_valid_params != c->param.size() || !c->param_info.empty()); this->CreateNestedTree(); + this->GetWidget(WID_NP_CAPTION)->SetDataTip(is_baseset ? STR_BASEGRF_PARAMETERS_CAPTION : STR_NEWGRF_PARAMETERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS); this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR); this->GetWidget(WID_NP_SHOW_NUMPAR)->SetDisplayedPlane(this->action14present ? SZSP_HORIZONTAL : 0); this->GetWidget(WID_NP_SHOW_DESCRIPTION)->SetDisplayedPlane(this->action14present ? 0 : SZSP_HORIZONTAL); @@ -522,7 +523,7 @@ GRFParameterInfo NewGRFParametersWindow::dummy_parameter_info(0); static const NWidgetPart _nested_newgrf_parameter_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_MAUVE), - NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_PARAMETERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), + NWidget(WWT_CAPTION, COLOUR_MAUVE, WID_NP_CAPTION), NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NP_SHOW_NUMPAR), @@ -552,17 +553,17 @@ static const NWidgetPart _nested_newgrf_parameter_widgets[] = { }; /** Window definition for the change grf parameters window */ -static WindowDesc _newgrf_parameters_desc( +static WindowDesc _newgrf_parameters_desc(__FILE__, __LINE__, WDP_CENTER, "settings_newgrf_config", 500, 208, WC_GRF_PARAMETERS, WC_NONE, 0, std::begin(_nested_newgrf_parameter_widgets), std::end(_nested_newgrf_parameter_widgets) ); -static void OpenGRFParameterWindow(GRFConfig *c, bool editable) +void OpenGRFParameterWindow(bool is_baseset, GRFConfig *c, bool editable) { CloseWindowByClass(WC_GRF_PARAMETERS); - new NewGRFParametersWindow(&_newgrf_parameters_desc, c, editable); + new NewGRFParametersWindow(&_newgrf_parameters_desc, is_baseset, c, editable); } /** Window for displaying the textfile of a NewGRF. */ @@ -1155,7 +1156,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WID_NS_SET_PARAMETERS: { // Edit parameters if (this->active_sel == nullptr || !this->show_params || this->active_sel->num_valid_params == 0) break; - OpenGRFParameterWindow(this->active_sel, this->editable); + OpenGRFParameterWindow(false, this->active_sel, this->editable); this->InvalidateData(GOID_NEWGRF_CHANGES_MADE); break; } @@ -1688,7 +1689,7 @@ public: this->smallest_y = ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y); } - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override { this->StoreSizePosition(sizing, x, y, given_width, given_height); @@ -1996,7 +1997,7 @@ static const NWidgetPart _nested_newgrf_widgets[] = { }; /* Window definition of the manage newgrfs window */ -static WindowDesc _newgrf_desc( +static WindowDesc _newgrf_desc(__FILE__, __LINE__, WDP_CENTER, "settings_newgrf", 300, 263, WC_GAME_OPTIONS, WC_NONE, 0, @@ -2087,7 +2088,7 @@ static const NWidgetPart _nested_save_preset_widgets[] = { }; /** Window description of the preset save window. */ -static WindowDesc _save_preset_desc( +static WindowDesc _save_preset_desc(__FILE__, __LINE__, WDP_CENTER, "save_preset", 140, 110, WC_SAVE_PRESET, WC_GAME_OPTIONS, WDF_MODAL, @@ -2228,7 +2229,7 @@ static const NWidgetPart _nested_scan_progress_widgets[] = { }; /** Description of the widgets and other settings of the window. */ -static WindowDesc _scan_progress_desc( +static WindowDesc _scan_progress_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_MODAL_PROGRESS, WC_NONE, 0, diff --git a/src/newgrf_roadstop.cpp b/src/newgrf_roadstop.cpp index 91c1daa92a..2aae8d0bfa 100644 --- a/src/newgrf_roadstop.cpp +++ b/src/newgrf_roadstop.cpp @@ -371,7 +371,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, } } } else { - /* Drive-in stop */ + /* Bay stop */ if ((draw_mode & ROADSTOP_DRAW_MODE_ROAD) && rti->UsesOverlay()) { SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_ROADSTOP); DrawSprite(ground + view, PAL_NONE, x, y); diff --git a/src/newgrf_roadtype.h b/src/newgrf_roadtype.h index 71593777b9..6ffd2a3f57 100644 --- a/src/newgrf_roadtype.h +++ b/src/newgrf_roadtype.h @@ -21,12 +21,12 @@ struct RoadTypeScopeResolver : public ScopeResolver { const RoadTypeInfo *rti; /** - * Constructor of the roadtype scope resolvers. - * @param ro Surrounding resolver. - * @param rti Associated RoadTypeInfo. - * @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead. - * @param context Are we resolving sprites for the upper halftile, or on a bridge? - */ + * Constructor of the roadtype scope resolvers. + * @param ro Surrounding resolver. + * @param rti Associated RoadTypeInfo. + * @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead. + * @param context Are we resolving sprites for the upper halftile, or on a bridge? + */ RoadTypeScopeResolver(ResolverObject &ro, const RoadTypeInfo *rti, TileIndex tile, TileContext context) : ScopeResolver(ro), tile(tile), context(context), rti(rti) { diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 2e5f33ed7e..225e94f242 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -820,8 +820,6 @@ struct TextRefStack { this->grffile = grffile; this->used = true; } - - void RewindStack() { this->position = 0; } }; /** The stack that is used for TTDP compatible string code parsing */ @@ -895,11 +893,6 @@ void StopTextRefStackUsage() _newgrf_textrefstack.used = false; } -void RewindTextRefStack() -{ - _newgrf_textrefstack.RewindStack(); -} - /** * FormatString for NewGRF specific "magic" string control codes * @param scc the string control code that has been read diff --git a/src/newgrf_text.h b/src/newgrf_text.h index 60cee68124..d867c5ccc8 100644 --- a/src/newgrf_text.h +++ b/src/newgrf_text.h @@ -49,7 +49,6 @@ bool CheckGrfLangID(byte lang_id, byte grf_version); void StartTextRefStackUsage(const struct GRFFile *grffile, byte numEntries, const uint32 *values = nullptr); void StopTextRefStackUsage(); -void RewindTextRefStack(); bool UsingNewGRFTextStack(); struct TextRefStack *CreateTextRefStackBackup(); void RestoreTextRefStackBackup(struct TextRefStack *backup); diff --git a/src/news_gui.cpp b/src/news_gui.cpp index f5543da46a..0d676e18a1 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -94,7 +94,7 @@ static const NWidgetPart _nested_normal_news_widgets[] = { EndContainer(), }; -static WindowDesc _normal_news_desc( +static WindowDesc _normal_news_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, @@ -121,7 +121,7 @@ static const NWidgetPart _nested_vehicle_news_widgets[] = { EndContainer(), }; -static WindowDesc _vehicle_news_desc( +static WindowDesc _vehicle_news_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, @@ -149,7 +149,7 @@ static const NWidgetPart _nested_company_news_widgets[] = { EndContainer(), }; -static WindowDesc _company_news_desc( +static WindowDesc _company_news_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, @@ -172,7 +172,7 @@ static const NWidgetPart _nested_thin_news_widgets[] = { EndContainer(), }; -static WindowDesc _thin_news_desc( +static WindowDesc _thin_news_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, @@ -198,7 +198,7 @@ static const NWidgetPart _nested_small_news_widgets[] = { EndContainer(), }; -static WindowDesc _small_news_desc( +static WindowDesc _small_news_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, @@ -1235,7 +1235,7 @@ static const NWidgetPart _nested_message_history[] = { EndContainer(), }; -static WindowDesc _message_history_desc( +static WindowDesc _message_history_desc(__FILE__, __LINE__, WDP_AUTO, "list_news", 400, 140, WC_MESSAGE_HISTORY, WC_NONE, 0, diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 4b30fd3629..f138cd0b08 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -85,16 +85,6 @@ class BuildObjectWindow : public Window { return objclass->GetSpec(_selected_object_index)->IsAvailable(); } - /** - * Calculate the number of columns of the #WID_BO_SELECT_MATRIX widget. - * @return Number of columns in the matrix. - */ - uint GetMatrixColumnCount() - { - const NWidgetBase *matrix = this->GetWidget(WID_BO_SELECT_MATRIX); - return 1 + (matrix->current_x - matrix->smallest_x) / matrix->resize_x; - } - public: BuildObjectWindow(WindowDesc *desc, WindowNumber number) : Window(desc), info_height(1), filter_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE) { @@ -743,7 +733,7 @@ static const NWidgetPart _nested_build_object_widgets[] = { EndContainer(), NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BO_SELECT_SCROLL), NWidget(NWID_HORIZONTAL), - NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BO_SELECT_MATRIX), SetFill(0, 1), SetPIP(0, 2, 0), + NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BO_SELECT_MATRIX), SetPIP(0, 2, 0), NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BO_SELECT_IMAGE), SetMinimalSize(66, 60), SetDataTip(0x0, STR_OBJECT_BUILD_TOOLTIP), SetFill(0, 0), SetResize(0, 0), SetScrollbar(WID_BO_SELECT_SCROLL), EndContainer(), @@ -762,7 +752,7 @@ static const NWidgetPart _nested_build_object_widgets[] = { EndContainer(), }; -static WindowDesc _build_object_desc( +static WindowDesc _build_object_desc(__FILE__, __LINE__, WDP_AUTO, "build_object", 0, 0, WC_BUILD_OBJECT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/openttd.cpp b/src/openttd.cpp index a98945f8f1..4955ba1d44 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -945,15 +945,31 @@ int openttd_main(int argc, char *argv[]) InitWindowSystem(); BaseGraphics::FindSets(); - if (graphics_set.empty() && !BaseGraphics::ini_set.empty()) graphics_set = BaseGraphics::ini_set; - if (!BaseGraphics::SetSet(graphics_set)) { - if (!graphics_set.empty()) { - BaseGraphics::SetSet({}); - - ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_GRAPHICS_NOT_FOUND); - msg.SetDParamStr(0, graphics_set); - ScheduleErrorMessage(msg); + bool valid_graphics_set; + if (!graphics_set.empty()) { + valid_graphics_set = BaseGraphics::SetSetByName(graphics_set); + } else if (BaseGraphics::ini_data.shortname != 0) { + graphics_set = BaseGraphics::ini_data.name; + valid_graphics_set = BaseGraphics::SetSetByShortname(BaseGraphics::ini_data.shortname); + if (valid_graphics_set && !BaseGraphics::ini_data.extra_params.empty()) { + GRFConfig &extra_cfg = BaseGraphics::GetUsedSet()->GetOrCreateExtraConfig(); + if (extra_cfg.IsCompatible(BaseGraphics::ini_data.extra_version)) { + extra_cfg.SetParams(BaseGraphics::ini_data.extra_params); + } } + } else if (!BaseGraphics::ini_data.name.empty()) { + graphics_set = BaseGraphics::ini_data.name; + valid_graphics_set = BaseGraphics::SetSetByName(BaseGraphics::ini_data.name); + } else { + valid_graphics_set = true; + BaseGraphics::SetSet(nullptr); // ignore error, continue to bootstrap GUI + } + if (!valid_graphics_set) { + BaseGraphics::SetSet(nullptr); + + ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_GRAPHICS_NOT_FOUND); + msg.SetDParamStr(0, graphics_set); + ScheduleErrorMessage(msg); } /* Initialize game palette */ @@ -1007,7 +1023,7 @@ int openttd_main(int argc, char *argv[]) BaseSounds::FindSets(); if (sounds_set.empty() && !BaseSounds::ini_set.empty()) sounds_set = BaseSounds::ini_set; - if (!BaseSounds::SetSet(sounds_set)) { + if (!BaseSounds::SetSetByName(sounds_set)) { if (sounds_set.empty() || !BaseSounds::SetSet({})) { usererror("Failed to find a sounds set. Please acquire a sounds set for OpenTTD. See section 1.4 of README.md."); } else { @@ -1019,7 +1035,7 @@ int openttd_main(int argc, char *argv[]) BaseMusic::FindSets(); if (music_set.empty() && !BaseMusic::ini_set.empty()) music_set = BaseMusic::ini_set; - if (!BaseMusic::SetSet(music_set)) { + if (!BaseMusic::SetSetByName(music_set)) { if (music_set.empty() || !BaseMusic::SetSet({})) { usererror("Failed to find a music set. Please acquire a music set for OpenTTD. See section 1.4 of README.md."); } else { @@ -2265,7 +2281,7 @@ void GameLoopSpecial() extern std::string _switch_baseset; if (!_switch_baseset.empty()) { if (BaseGraphics::GetUsedSet()->name != _switch_baseset) { - BaseGraphics::SetSet(_switch_baseset); + BaseGraphics::SetSetByName(_switch_baseset); ReloadNewGRFData(); } diff --git a/src/order_base.h b/src/order_base.h index 624caddcab..c5612c6396 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -939,9 +939,6 @@ public: */ inline uint GetNumVehicles() const { return this->num_vehicles; } - bool IsVehicleInSharedOrdersList(const Vehicle *v) const; - int GetPositionInSharedOrderList(const Vehicle *v) const; - /** * Adds the given vehicle to this shared order list. * @note This is supposed to be called after the vehicle has been inserted diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 1f6082d5fc..8e9845afe3 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -825,31 +825,6 @@ void OrderList::RemoveVehicle(Vehicle *v) if (v == this->first_shared) this->first_shared = v->NextShared(); } -/** - * Checks whether a vehicle is part of the shared vehicle chain. - * @param v is the vehicle to search in the shared vehicle chain. - */ -bool OrderList::IsVehicleInSharedOrdersList(const Vehicle *v) const -{ - for (const Vehicle *v_shared = this->first_shared; v_shared != nullptr; v_shared = v_shared->NextShared()) { - if (v_shared == v) return true; - } - - return false; -} - -/** - * Gets the position of the given vehicle within the shared order vehicle list. - * @param v is the vehicle of which to get the position - * @return position of v within the shared vehicle chain. - */ -int OrderList::GetPositionInSharedOrderList(const Vehicle *v) const -{ - int count = 0; - for (const Vehicle *v_shared = v->PreviousShared(); v_shared != nullptr; v_shared = v_shared->PreviousShared()) count++; - return count; -} - /** * Checks whether all orders of the list have a filled timetable. * @return whether all orders have a filled timetable. diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 2ca06eca34..cff3562ad1 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -407,7 +407,7 @@ static const NWidgetPart _nested_cargo_type_orders_widgets[] = { }; /** Window description for the 'load' variant of CargoTypeOrdersWindow. */ -static WindowDesc _cargo_type_load_orders_widgets ( +static WindowDesc _cargo_type_load_orders_widgets (__FILE__, __LINE__, WDP_AUTO, "view_cargo_type_load_order", 195, 186, WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS, WC_VEHICLE_ORDERS, WDF_CONSTRUCTION, @@ -415,7 +415,7 @@ static WindowDesc _cargo_type_load_orders_widgets ( ); /** Window description for the 'unload' variant of CargoTypeOrdersWindow. */ -static WindowDesc _cargo_type_unload_orders_widgets ( +static WindowDesc _cargo_type_unload_orders_widgets (__FILE__, __LINE__, WDP_AUTO, "view_cargo_type_unload_order", 195, 186, WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS, WC_VEHICLE_ORDERS, WDF_CONSTRUCTION, @@ -3746,7 +3746,7 @@ static const NWidgetPart _nested_orders_train_widgets[] = { EndContainer(), }; -static WindowDesc _orders_train_desc( +static WindowDesc _orders_train_desc(__FILE__, __LINE__, WDP_AUTO, "view_vehicle_orders_train", 384, 100, WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, @@ -3898,7 +3898,7 @@ static const NWidgetPart _nested_orders_widgets[] = { EndContainer(), }; -static WindowDesc _orders_desc( +static WindowDesc _orders_desc(__FILE__, __LINE__, WDP_AUTO, "view_vehicle_orders", 384, 100, WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, @@ -3935,7 +3935,7 @@ static const NWidgetPart _nested_other_orders_widgets[] = { EndContainer(), }; -static WindowDesc _other_orders_desc( +static WindowDesc _other_orders_desc(__FILE__, __LINE__, WDP_AUTO, "view_vehicle_orders_competitor", 384, 86, WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp index 4a719d74a4..a8e16b140a 100644 --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -340,6 +340,31 @@ int MacOSStringCompare(std::string_view s1, std::string_view s2) return (int)CFStringCompareWithOptionsAndLocale(cf1.get(), cf2.get(), CFRangeMake(0, CFStringGetLength(cf1.get())), flags, _osx_locale.get()) + 2; } +/** + * Search if a string is contained in another string using the current locale. + * + * @param str String to search in. + * @param value String to search for. + * @param case_insensitive Search case-insensitive. + * @return 1 if value was found, 0 if it was not found, or -1 if not supported by the OS. + */ +int MacOSStringContains(const std::string_view str, const std::string_view value, bool case_insensitive) +{ + static bool supported = MacOSVersionIsAtLeast(10, 5, 0); + if (!supported) return -1; + + CFStringCompareFlags flags = kCFCompareLocalized | kCFCompareWidthInsensitive; + if (case_insensitive) flags |= kCFCompareCaseInsensitive; + + CFAutoRelease cf_str(CFStringCreateWithBytes(kCFAllocatorDefault, (const UInt8 *)str.data(), str.size(), kCFStringEncodingUTF8, false)); + CFAutoRelease cf_value(CFStringCreateWithBytes(kCFAllocatorDefault, (const UInt8 *)value.data(), value.size(), kCFStringEncodingUTF8, false)); + + /* If any CFString could not be created (e.g., due to UTF8 invalid chars), return OS unsupported functionality */ + if (cf_str == nullptr || cf_value == nullptr) return -1; + + return CFStringFindWithOptionsAndLocale(cf_str.get(), cf_value.get(), CFRangeMake(0, CFStringGetLength(cf_str.get())), flags, _osx_locale.get(), nullptr) ? 1 : 0; +} + /* virtual */ void OSXStringIterator::SetString(const char *s) { diff --git a/src/os/macosx/string_osx.h b/src/os/macosx/string_osx.h index c4dae6bb49..d85c1691da 100644 --- a/src/os/macosx/string_osx.h +++ b/src/os/macosx/string_osx.h @@ -85,6 +85,7 @@ public: void MacOSResetScriptCache(FontSize size); void MacOSSetCurrentLocaleName(const char *iso_code); int MacOSStringCompare(std::string_view s1, std::string_view s2); +int MacOSStringContains(const std::string_view str, const std::string_view value, bool case_insensitive); void MacOSRegisterExternalFont(const char *file_path); diff --git a/src/os/unix/font_unix.cpp b/src/os/unix/font_unix.cpp index 4940ff0ca4..72745e92e4 100644 --- a/src/os/unix/font_unix.cpp +++ b/src/os/unix/font_unix.cpp @@ -79,8 +79,8 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) if (!font_style.empty() && !StrEqualsIgnoreCase(font_style, (char *)style)) continue; /* Font config takes the best shot, which, if the family name is spelled - * wrongly a 'random' font, so check whether the family name is the - * same as the supplied name */ + * wrongly a 'random' font, so check whether the family name is the + * same as the supplied name */ if (StrEqualsIgnoreCase(font_family, (char *)family)) { err = FT_New_Face(_library, (char *)file, index, face); } diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index f44b5786e9..53520044c5 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -866,7 +866,7 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARA /* Convert unix -> dos newlines because the edit box only supports that properly :( */ const char *unix_nl = CrashLogWindows::current->crashlog; char *p = dos_nl; - WChar c; + char32_t c; while ((c = Utf8Consume(&unix_nl)) && p < (dos_nl + dos_nl_length - 1) - 4) { // 4 is max number of bytes per character if (c == '\n') p += Utf8Encode(p, '\r'); p += Utf8Encode(p, c); diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp index 726ae8bb1c..5d10510a63 100644 --- a/src/os/windows/font_win32.cpp +++ b/src/os/windows/font_win32.cpp @@ -276,7 +276,7 @@ void Win32FontCache::ClearFontCache() return new_glyph.sprite; } -/* virtual */ GlyphID Win32FontCache::MapCharToGlyph(WChar key) +/* virtual */ GlyphID Win32FontCache::MapCharToGlyph(char32_t key) { assert(IsPrintable(key)); diff --git a/src/os/windows/font_win32.h b/src/os/windows/font_win32.h index 8261dc7b4a..27a9c7f180 100644 --- a/src/os/windows/font_win32.h +++ b/src/os/windows/font_win32.h @@ -33,7 +33,7 @@ public: Win32FontCache(FontSize fs, const LOGFONT &logfont, int pixels); ~Win32FontCache(); void ClearFontCache() override; - GlyphID MapCharToGlyph(WChar key) override; + GlyphID MapCharToGlyph(char32_t key) override; std::string GetFontName() override { return this->fontname; } const void *GetOSHandle() override { return &this->logfont; } }; diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp index 4318be6b86..81bea579d1 100644 --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -111,7 +111,7 @@ public: int CountRuns() const override { return (uint)this->size(); } const VisualRun &GetVisualRun(int run) const override { return this->at(run); } - int GetInternalCharLength(WChar c) const override + int GetInternalCharLength(char32_t c) const override { /* Uniscribe uses UTF-16 internally which means we need to account for surrogate pairs. */ return c >= 0x010000U ? 2 : 1; @@ -537,7 +537,7 @@ const int *UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() con while (*s != '\0') { size_t idx = s - string_base; - WChar c = Utf8Consume(&s); + char32_t c = Utf8Consume(&s); if (c < 0x10000) { utf16_str.push_back((wchar_t)c); } else { diff --git a/src/os/windows/string_uniscribe.h b/src/os/windows/string_uniscribe.h index a41b76bdb0..1178838aec 100644 --- a/src/os/windows/string_uniscribe.h +++ b/src/os/windows/string_uniscribe.h @@ -29,22 +29,22 @@ public: static const bool SUPPORTS_RTL = true; /** - * Get the actual ParagraphLayout for the given buffer. - * @param buff The begin of the buffer. - * @param buff_end The location after the last element in the buffer. - * @param fontMapping THe mapping of the fonts. - * @return The ParagraphLayout instance. - */ + * Get the actual ParagraphLayout for the given buffer. + * @param buff The begin of the buffer. + * @param buff_end The location after the last element in the buffer. + * @param fontMapping THe mapping of the fonts. + * @return The ParagraphLayout instance. + */ static ParagraphLayouter *GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping); /** - * Append a wide character to the internal buffer. - * @param buff The buffer to append to. - * @param buffer_last The end of the buffer. - * @param c The character to add. - * @return The number of buffer spaces that were used. - */ - static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, WChar c) + * Append a wide character to the internal buffer. + * @param buff The buffer to append to. + * @param buffer_last The end of the buffer. + * @param c The character to add. + * @return The number of buffer spaces that were used. + */ + static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, char32_t c) { assert(buff < buffer_last); if (c >= 0x010000U) { diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index b6f1b6d8cc..709b8fec88 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -19,6 +19,7 @@ #define NO_SHOBJIDL_SORTDIRECTION // Avoid multiple definition of SORT_ASCENDING #include /* SHGetFolderPath */ #include +#include #include "win32.h" #include "../../fios.h" #include "../../core/alloc_func.hpp" @@ -715,6 +716,43 @@ int OTTDStringCompare(std::string_view s1, std::string_view s2) return CompareString(MAKELCID(_current_language->winlangid, SORT_DEFAULT), NORM_IGNORECASE, s1_buf, -1, s2_buf, -1); } +/** + * Search if a string is contained in another string using the current locale. + * + * @param str String to search in. + * @param value String to search for. + * @param case_insensitive Search case-insensitive. + * @return 1 if value was found, 0 if it was not found, or -1 if not supported by the OS. + */ +int Win32StringContains(const std::string_view str, const std::string_view value, bool case_insensitive) +{ + typedef int (WINAPI *PFNFINDNLSSTRINGEX)(LPCWSTR, DWORD, LPCWSTR, int, LPCWSTR, int, LPINT, LPNLSVERSIONINFO, LPVOID, LPARAM); + static PFNFINDNLSSTRINGEX _FindNLSStringEx = nullptr; + static bool first_time = true; + + if (first_time) { + _FindNLSStringEx = GetProcAddressT(GetModuleHandle(L"Kernel32"), "FindNLSStringEx"); + first_time = false; + } + + if (_FindNLSStringEx != nullptr) { + int len_str = MultiByteToWideChar(CP_UTF8, 0, str.data(), (int)str.size(), nullptr, 0); + int len_value = MultiByteToWideChar(CP_UTF8, 0, value.data(), (int)value.size(), nullptr, 0); + + if (len_str != 0 && len_value != 0) { + std::wstring str_str(len_str, L'\0'); // len includes terminating null + std::wstring str_value(len_value, L'\0'); + + MultiByteToWideChar(CP_UTF8, 0, str.data(), (int)str.size(), str_str.data(), len_str); + MultiByteToWideChar(CP_UTF8, 0, value.data(), (int)value.size(), str_value.data(), len_value); + + return _FindNLSStringEx(_cur_iso_locale, FIND_FROMSTART | (case_insensitive ? LINGUISTIC_IGNORECASE : 0), str_str.data(), -1, str_value.data(), -1, nullptr, nullptr, nullptr, 0) >= 0 ? 1 : 0; + } + } + + return -1; // Failure indication. +} + static DWORD main_thread_id; static DWORD game_thread_id; diff --git a/src/os/windows/win32.h b/src/os/windows/win32.h index 814a321430..9a354bf168 100644 --- a/src/os/windows/win32.h +++ b/src/os/windows/win32.h @@ -25,6 +25,7 @@ wchar_t *convert_to_fs(const std::string_view name, wchar_t *utf16_buf, size_t b void Win32SetCurrentLocaleName(const char *iso_code); int OTTDStringCompare(std::string_view s1, std::string_view s2); +int Win32StringContains(const std::string_view str, const std::string_view value, bool case_insensitive); #ifdef __MINGW32__ /* GCC doesn't understand the expected usage of GetProcAddress(). */ diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 32a9f6d8b0..033dc7db89 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -336,7 +336,7 @@ static const NWidgetPart _nested_osk_widgets[] = { EndContainer(), }; -static WindowDesc _osk_desc( +static WindowDesc _osk_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_OSK, WC_NONE, 0, diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp index 5e9915c30f..8fc5323a0c 100644 --- a/src/pathfinder/yapf/yapf_road.cpp +++ b/src/pathfinder/yapf/yapf_road.cpp @@ -525,12 +525,6 @@ public: return next_trackdir; } - static uint stDistanceToTile(const RoadVehicle *v, TileIndex tile) - { - Tpf pf; - return pf.DistanceToTile(v, tile); - } - inline uint DistanceToTile(const RoadVehicle *v, TileIndex dst_tile) { /* handle special case - when current tile is the destination tile */ diff --git a/src/plans_gui.cpp b/src/plans_gui.cpp index 9e3237c051..d38753195d 100644 --- a/src/plans_gui.cpp +++ b/src/plans_gui.cpp @@ -65,7 +65,7 @@ static const NWidgetPart _nested_plans_widgets[] = { EndContainer(), }; -static WindowDesc _plans_desc( +static WindowDesc _plans_desc(__FILE__, __LINE__, WDP_AUTO, "plans", 350, 100, WC_PLANS, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/programmable_signals_gui.cpp b/src/programmable_signals_gui.cpp index c92e3a27a7..d6d3afa3b5 100644 --- a/src/programmable_signals_gui.cpp +++ b/src/programmable_signals_gui.cpp @@ -965,7 +965,7 @@ static const NWidgetPart _nested_program_widgets[] = { EndContainer(), }; -static WindowDesc _program_desc( +static WindowDesc _program_desc(__FILE__, __LINE__, WDP_AUTO, "signal_program", 384, 100, WC_SIGNAL_PROGRAM, WC_BUILD_SIGNAL, WDF_CONSTRUCTION, diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 198fbf9b7b..6a48eaf37f 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1043,7 +1043,7 @@ static const NWidgetPart _nested_build_rail_widgets[] = { EndContainer(), }; -static WindowDesc _build_rail_desc( +static WindowDesc _build_rail_desc(__FILE__, __LINE__, WDP_ALIGN_TOOLBAR, "toolbar_rail", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -1823,7 +1823,7 @@ static const NWidgetPart _nested_station_builder_widgets[] = { /* We need an additional background for the matrix, as the matrix cannot handle the scrollbar due to not being an NWidgetCore. */ NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BRAS_MATRIX_SCROLL), NWidget(NWID_HORIZONTAL), - NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BRAS_MATRIX), SetScrollbar(WID_BRAS_MATRIX_SCROLL), SetPIP(0, 2, 0), + NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BRAS_MATRIX), SetPIP(0, 2, 0), NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BRAS_IMAGE), SetMinimalSize(66, 60), SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BRAS_MATRIX_SCROLL), EndContainer(), @@ -1846,7 +1846,7 @@ static const NWidgetPart _nested_station_builder_widgets[] = { }; /** High level window description of the station-build window (default & newGRF) */ -static WindowDesc _station_builder_desc( +static WindowDesc _station_builder_desc(__FILE__, __LINE__, WDP_AUTO, "build_station_rail", 350, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -2274,16 +2274,16 @@ static const NWidgetPart _nested_signal_builder_widgets[] = { NWidget(NWID_VERTICAL, NC_EQUALSIZE), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_SEMAPHORE_NORM_SEL), - NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_NORM_TOOLTIP), EndContainer(), SetFill(1, 1), + NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_NORM_TOOLTIP), EndContainer(), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_SEMAPHORE_ENTRY_SEL), - NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TOOLTIP), EndContainer(), SetFill(1, 1), + NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TOOLTIP), EndContainer(), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_SEMAPHORE_EXIT_SEL), - NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TOOLTIP), EndContainer(), SetFill(1, 1), + NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TOOLTIP), EndContainer(), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_SEMAPHORE_COMBO_SEL), - NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TOOLTIP), EndContainer(), SetFill(1, 1), + NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TOOLTIP), EndContainer(), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_SEMAPHORE_PROG_SEL), NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_PROG), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_PROG_TOOLTIP), EndContainer(), SetFill(1, 1), @@ -2298,16 +2298,16 @@ static const NWidgetPart _nested_signal_builder_widgets[] = { EndContainer(), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_ELECTRIC_NORM_SEL), - NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_NORM_TOOLTIP), EndContainer(), SetFill(1, 1), + NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_NORM_TOOLTIP), EndContainer(), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_ELECTRIC_ENTRY_SEL), - NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TOOLTIP), EndContainer(), SetFill(1, 1), + NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TOOLTIP), EndContainer(), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_ELECTRIC_EXIT_SEL), - NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_EXIT_TOOLTIP), EndContainer(), SetFill(1, 1), + NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_EXIT_TOOLTIP), EndContainer(), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_ELECTRIC_COMBO_SEL), - NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_COMBO_TOOLTIP), EndContainer(), SetFill(1, 1), + NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_COMBO_TOOLTIP), EndContainer(), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_ELECTRIC_PROG_SEL), NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_PROG), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PROG_TOOLTIP), EndContainer(), SetFill(1, 1), @@ -2339,7 +2339,7 @@ static const NWidgetPart _nested_signal_builder_widgets[] = { }; /** Signal selection window description */ -static WindowDesc _signal_builder_desc( +static WindowDesc _signal_builder_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -2407,31 +2407,20 @@ static const NWidgetPart _nested_build_depot_widgets[] = { NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), EndContainer(), NWidget(WWT_PANEL, COLOUR_DARK_GREEN), - NWidget(NWID_SPACER), SetMinimalSize(0, 3), - NWidget(NWID_HORIZONTAL_LTR), - NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0), - NWidget(NWID_VERTICAL), - NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP), - EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 2), - NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP), - EndContainer(), + NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1), SetPadding(WidgetDimensions::unscaled.picker), + NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(2, 0), - NWidget(NWID_VERTICAL), - NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP), - EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 2), - NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP), - EndContainer(), + NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 3), EndContainer(), }; -static WindowDesc _build_depot_desc( +static WindowDesc _build_depot_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -2655,7 +2644,7 @@ static const NWidgetPart _nested_build_waypoint_widgets[] = { EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BRW_SCROLL), - NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BRW_WAYPOINT_MATRIX), SetPIP(0, 2, 0), SetPadding(3), SetScrollbar(WID_BRW_SCROLL), + NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BRW_WAYPOINT_MATRIX), SetPIP(0, 2, 0), SetPadding(3), NWidget(WWT_PANEL, COLOUR_GREY, WID_BRW_WAYPOINT), SetDataTip(0x0, STR_WAYPOINT_GRAPHICS_TOOLTIP), SetScrollbar(WID_BRW_SCROLL), EndContainer(), EndContainer(), EndContainer(), @@ -2669,7 +2658,7 @@ static const NWidgetPart _nested_build_waypoint_widgets[] = { EndContainer(), }; -static WindowDesc _build_waypoint_desc( +static WindowDesc _build_waypoint_desc(__FILE__, __LINE__, WDP_AUTO, "build_waypoint", 0, 0, WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/road.cpp b/src/road.cpp index 78fd1ebb7b..f6239b26db 100644 --- a/src/road.cpp +++ b/src/road.cpp @@ -307,42 +307,6 @@ RoadType GetRoadTypeByLabel(RoadTypeLabel label, bool allow_alternate_labels) return INVALID_ROADTYPE; } -/** - * Returns the available RoadSubTypes for the provided RoadType - * If the given company is valid then will be returned a list of the available sub types at the current date, while passing - * a deity company will make all the sub types available - * @param rt the RoadType to filter - * @param c the company ID to check the roadtype against - * @param any_date whether to return only currently introduced roadtypes or also future ones - * @returns the existing RoadSubTypes - */ -RoadTypes ExistingRoadTypes(CompanyID c) -{ - /* Check only players which can actually own vehicles, editor and gamescripts are considered deities */ - if (c < OWNER_END) { - const Company *company = Company::GetIfValid(c); - if (company != nullptr) return company->avail_roadtypes; - } - - RoadTypes known_roadtypes = ROADTYPES_NONE; - - /* Find used roadtypes */ - for (Engine *e : Engine::IterateType(VEH_ROAD)) { - /* Check if the roadtype can be used in the current climate */ - if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue; - - /* Check whether available for all potential companies */ - if (e->company_avail != MAX_UVALUE(CompanyMask)) continue; - - known_roadtypes |= GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes; - } - - /* Get the date introduced roadtypes as well. */ - known_roadtypes = AddDateIntroducedRoadTypes(known_roadtypes, MAX_DAY); - - return known_roadtypes; -} - /* ========================================================================= */ /* PUBLIC ROADS */ diff --git a/src/road.h b/src/road.h index 3d82de7650..4ca4ba85da 100644 --- a/src/road.h +++ b/src/road.h @@ -92,7 +92,7 @@ enum RoadTypeSpriteGroup { ROTSG_reserved2, ///< Placeholder, if we need specific level crossing sprites. ROTSG_DEPOT, ///< Optional: Depot images ROTSG_reserved3, ///< Placeholder, if we add road fences (for highways). - ROTSG_ROADSTOP, ///< Required: Drive-in stop surface + ROTSG_ROADSTOP, ///< Required: Bay stop surface ROTSG_ONEWAY, ///< Optional: One-way indicator images ROTSG_END, }; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 49b26852bd..251aa7fb30 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -974,7 +974,7 @@ static const NWidgetPart _nested_build_road_widgets[] = { EndContainer(), }; -static WindowDesc _build_road_desc( +static WindowDesc _build_road_desc(__FILE__, __LINE__, WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -1017,7 +1017,7 @@ static const NWidgetPart _nested_build_tramway_widgets[] = { EndContainer(), }; -static WindowDesc _build_tramway_desc( +static WindowDesc _build_tramway_desc(__FILE__, __LINE__, WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -1072,7 +1072,7 @@ static const NWidgetPart _nested_build_road_scen_widgets[] = { EndContainer(), }; -static WindowDesc _build_road_scen_desc( +static WindowDesc _build_road_scen_desc(__FILE__, __LINE__, WDP_AUTO, "toolbar_road_scen", 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -1107,7 +1107,7 @@ static const NWidgetPart _nested_build_tramway_scen_widgets[] = { EndContainer(), }; -static WindowDesc _build_tramway_scen_desc( +static WindowDesc _build_tramway_scen_desc(__FILE__, __LINE__, WDP_AUTO, "toolbar_tram_scen", 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -1188,31 +1188,21 @@ static const NWidgetPart _nested_build_road_depot_widgets[] = { NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROD_CAPTION), SetDataTip(STR_BUILD_DEPOT_ROAD_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), EndContainer(), NWidget(WWT_PANEL, COLOUR_DARK_GREEN), - NWidget(NWID_SPACER), SetMinimalSize(0, 3), - NWidget(NWID_HORIZONTAL_LTR), - NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0), - NWidget(NWID_VERTICAL), - NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), - EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 2), - NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), - EndContainer(), + NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1), SetPadding(WidgetDimensions::unscaled.picker), + NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_NW), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_SW), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(2, 0), - NWidget(NWID_VERTICAL), - NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), - EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 2), - NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), - EndContainer(), + NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_NE), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_SE), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0), EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(0, 3), EndContainer(), }; -static WindowDesc _build_road_depot_desc( +static WindowDesc _build_road_depot_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -1841,7 +1831,7 @@ static const NWidgetPart _nested_road_station_picker_widgets[] = { /* We need an additional background for the matrix, as the matrix cannot handle the scrollbar due to not being an NWidgetCore. */ NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BROS_MATRIX_SCROLL), NWidget(NWID_HORIZONTAL), - NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BROS_MATRIX), SetScrollbar(WID_BROS_MATRIX_SCROLL), SetPIP(0, 2, 0), + NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BROS_MATRIX), SetPIP(0, 2, 0), NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_IMAGE), SetMinimalSize(66, 60), SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BROS_MATRIX_SCROLL), EndContainer(), @@ -1863,7 +1853,7 @@ static const NWidgetPart _nested_road_station_picker_widgets[] = { EndContainer(), }; -static WindowDesc _road_station_picker_desc( +static WindowDesc _road_station_picker_desc(__FILE__, __LINE__, WDP_AUTO, "build_station_road", 0, 0, WC_BUS_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -1927,7 +1917,7 @@ static const NWidgetPart _nested_tram_station_picker_widgets[] = { /* We need an additional background for the matrix, as the matrix cannot handle the scrollbar due to not being an NWidgetCore. */ NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BROS_MATRIX_SCROLL), NWidget(NWID_HORIZONTAL), - NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BROS_MATRIX), SetScrollbar(WID_BROS_MATRIX_SCROLL), SetPIP(0, 2, 0), SetPadding(2, 0, 0, 0), + NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BROS_MATRIX), SetPIP(0, 2, 0), SetPadding(2, 0, 0, 0), NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_IMAGE), SetMinimalSize(66, 60), SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BROS_MATRIX_SCROLL), EndContainer(), @@ -1949,7 +1939,7 @@ static const NWidgetPart _nested_tram_station_picker_widgets[] = { EndContainer(), }; -static WindowDesc _tram_station_picker_desc( +static WindowDesc _tram_station_picker_desc(__FILE__, __LINE__, WDP_AUTO, "build_station_tram", 0, 0, WC_BUS_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -2185,7 +2175,7 @@ static const NWidgetPart _nested_build_waypoint_widgets[] = { EndContainer(), }; -static WindowDesc _build_waypoint_desc( +static WindowDesc _build_waypoint_desc(__FILE__, __LINE__, WDP_AUTO, "build_road_waypoint", 0, 0, WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/schdispatch_gui.cpp b/src/schdispatch_gui.cpp index b83710c871..b7bad08975 100644 --- a/src/schdispatch_gui.cpp +++ b/src/schdispatch_gui.cpp @@ -1057,7 +1057,7 @@ static const NWidgetPart _nested_schdispatch_widgets[] = { EndContainer(), }; -static WindowDesc _schdispatch_desc( +static WindowDesc _schdispatch_desc(__FILE__, __LINE__, WDP_AUTO, "scheduled_dispatch_slots", 400, 130, WC_SCHDISPATCH_SLOTS, WC_VEHICLE_TIMETABLE, WDF_CONSTRUCTION, @@ -1264,7 +1264,7 @@ static const NWidgetPart _nested_scheduled_dispatch_add_widgets[] = { EndContainer() }; -static WindowDesc _scheduled_dispatch_add_desc( +static WindowDesc _scheduled_dispatch_add_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_SET_DATE, WC_NONE, 0, diff --git a/src/screenshot_gui.cpp b/src/screenshot_gui.cpp index 3ef9e7823d..5c8e1cfc4f 100644 --- a/src/screenshot_gui.cpp +++ b/src/screenshot_gui.cpp @@ -65,7 +65,7 @@ static const NWidgetPart _nested_screenshot[] = { EndContainer(), }; -static WindowDesc _screenshot_window_desc( +static WindowDesc _screenshot_window_desc(__FILE__, __LINE__, WDP_AUTO, "take_a_screenshot", 200, 100, WC_SCREENSHOT, WC_NONE, 0, diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 053a30fb9a..4c45c20a97 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -268,7 +268,7 @@ static const NWidgetPart _nested_script_list_widgets[] = { }; /** Window definition for the ai list window. */ -static WindowDesc _script_list_desc( +static WindowDesc _script_list_desc(__FILE__, __LINE__, WDP_CENTER, "settings_script_list", 200, 234, WC_SCRIPT_LIST, WC_NONE, 0, @@ -623,7 +623,7 @@ static const NWidgetPart _nested_script_settings_widgets[] = { }; /** Window definition for the Script settings window. */ -static WindowDesc _script_settings_desc( +static WindowDesc _script_settings_desc(__FILE__, __LINE__, WDP_CENTER, "settings_script", 500, 208, WC_SCRIPT_SETTINGS, WC_NONE, 0, @@ -1128,7 +1128,7 @@ CompanyID ScriptDebugWindow::script_debug_company = INVALID_COMPANY; std::string ScriptDebugWindow::break_string; bool ScriptDebugWindow::break_check_enabled = true; bool ScriptDebugWindow::case_sensitive_break_check = false; -StringFilter ScriptDebugWindow::break_string_filter(&ScriptDebugWindow::case_sensitive_break_check); +StringFilter ScriptDebugWindow::break_string_filter(&ScriptDebugWindow::case_sensitive_break_check, false); /** Make a number of rows with buttons for each company for the Script debug window. */ NWidgetBase *MakeCompanyButtonRowsScriptDebug(int *biggest_index) @@ -1222,7 +1222,7 @@ EndContainer(), }; /** Window definition for the Script debug window. */ -static WindowDesc _script_debug_desc( +static WindowDesc _script_debug_desc(__FILE__, __LINE__, WDP_AUTO, "script_debug", 600, 450, WC_SCRIPT_DEBUG, WC_NONE, 0, diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index 0469eee29f..144b2c8e57 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -34,7 +34,7 @@ * If changing the call paths into the scripting engine, define this symbol to enable full debugging of allocations. * This lets you track whether the allocator context is being switched correctly in all call paths. #define SCRIPT_DEBUG_ALLOCATIONS -*/ + */ struct ScriptAllocator { size_t allocated_size; ///< Sum of allocated data size diff --git a/src/settings.cpp b/src/settings.cpp index 8a3b89badc..54331f19c2 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -65,6 +65,7 @@ #include "ship.h" #include "smallmap_gui.h" #include "roadveh.h" +#include "newgrf_config.h" #include "fios.h" #include "load_check.h" #include "strings_func.h" @@ -477,7 +478,7 @@ size_t OneOfManySettingDesc::ParseValue(const char *str) const { size_t r = OneOfManySettingDesc::ParseSingleValue(str, strlen(str), this->many); /* if the first attempt of conversion from string to the appropriate value fails, - * look if we have defined a converter from old value to new value. */ + * look if we have defined a converter from old value to new value. */ if (r == (size_t)-1 && this->many_cnvt != nullptr) r = this->many_cnvt(str); if (r != (size_t)-1) return r; // and here goes converted value @@ -2095,6 +2096,40 @@ static bool DecodeHexText(const char *pos, uint8 *dest, size_t dest_size) return *pos == '|'; } +/** + * Load BaseGraphics set selection and configuration. + */ +static void GraphicsSetLoadConfig(IniFile &ini) +{ + if (const IniGroup *group = ini.GetGroup("misc"); group != nullptr) { + /* Load old setting first. */ + if (const IniItem *item = group->GetItem("graphicsset"); item != nullptr && item->value) BaseGraphics::ini_data.name = *item->value; + } + + if (const IniGroup *group = ini.GetGroup("graphicsset"); group != nullptr) { + /* Load new settings. */ + if (const IniItem *item = group->GetItem("name"); item != nullptr && item->value) BaseGraphics::ini_data.name = *item->value; + + if (const IniItem *item = group->GetItem("shortname"); item != nullptr && item->value && item->value->size() == 8) { + BaseGraphics::ini_data.shortname = BSWAP32(std::strtoul(item->value->c_str(), nullptr, 16)); + } + + if (const IniItem *item = group->GetItem("extra_version"); item != nullptr && item->value) BaseGraphics::ini_data.extra_version = std::strtoul(item->value->c_str(), nullptr, 10); + + if (const IniItem *item = group->GetItem("extra_params"); item != nullptr && item->value) { + auto &extra_params = BaseGraphics::ini_data.extra_params; + extra_params.resize(lengthof(GRFConfig::param)); + int count = ParseIntList(item->value->c_str(), &extra_params.front(), extra_params.size()); + if (count < 0) { + SetDParamStr(0, BaseGraphics::ini_data.name); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_ARRAY, WL_CRITICAL); + count = 0; + } + extra_params.resize(count); + } + } +} + /** * Load a GRF configuration * @param ini The configuration to read from. @@ -2267,6 +2302,27 @@ static void SaveVersionInConfig(IniFile &ini) group.GetOrCreateItem("ini_version").SetValue(std::to_string(INIFILE_VERSION)); } +/** + * Save BaseGraphics set selection and configuration. + */ +static void GraphicsSetSaveConfig(IniFile &ini) +{ + const GraphicsSet *used_set = BaseGraphics::GetUsedSet(); + if (used_set == nullptr) return; + + IniGroup &group = ini.GetOrCreateGroup("graphicsset"); + group.Clear(); + + group.GetOrCreateItem("name").SetValue(used_set->name); + group.GetOrCreateItem("shortname").SetValue(stdstr_fmt("%08X", BSWAP32(used_set->shortname))); + + const GRFConfig *extra_cfg = used_set->GetExtraConfig(); + if (extra_cfg != nullptr && extra_cfg->num_params > 0) { + group.GetOrCreateItem("extra_version").SetValue(stdstr_fmt("%u", extra_cfg->version)); + group.GetOrCreateItem("extra_params").SetValue(GRFBuildParamList(extra_cfg)); + } +} + /* Save a GRF configuration to the given group name */ static void GRFSaveConfig(IniFile &ini, const char *grpname, const GRFConfig *list) { @@ -2411,6 +2467,10 @@ void LoadFromConfig(bool startup) IniFileVersion generic_version = LoadVersionFromConfig(generic_ini); + if (startup) { + GraphicsSetLoadConfig(generic_ini); + } + HandleSettingDescs(generic_ini, IniLoadSettings, IniLoadSettingList, startup); /* Before the split of private/secrets, we have to look in the generic for these settings. */ @@ -2590,7 +2650,7 @@ void SaveToConfig(SaveToConfigFlags flags) } HandleSettingDescs(generic_ini, IniSaveSettings, IniSaveSettingList); - + GraphicsSetSaveConfig(generic_ini); GRFSaveConfig(generic_ini, "newgrf", _grfconfig_newgame); GRFSaveConfig(generic_ini, "newgrf-static", _grfconfig_static); AISaveConfig(generic_ini, "ai_players"); diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index e71db5eed2..f63f26d897 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -41,6 +41,7 @@ #include "music/music_driver.hpp" #include "gui.h" #include "mixer.h" +#include "newgrf_config.h" #include "scope.h" #include "network/core/config.h" #include "network/network_gui.h" @@ -633,6 +634,16 @@ struct GameOptionsWindow : Window { break; } + case WID_GO_BASE_GRF_PARAMETERS: { + auto *used_set = BaseGraphics::GetUsedSet(); + if (used_set == nullptr || !used_set->IsConfigurable()) break; + GRFConfig &extra_cfg = used_set->GetOrCreateExtraConfig(); + if (extra_cfg.num_params == 0) extra_cfg.SetParameterDefaults(); + OpenGRFParameterWindow(true, &extra_cfg, _game_mode == GM_MENU); + if (_game_mode == GM_MENU) this->reload = true; + break; + } + case WID_GO_BASE_SFX_VOLUME: case WID_GO_BASE_MUSIC_VOLUME: { byte &vol = (widget == WID_GO_BASE_MUSIC_VOLUME) ? _settings_client.music.music_vol : _settings_client.music.effect_vol; @@ -681,25 +692,6 @@ struct GameOptionsWindow : Window { } } - /** - * Set the base media set. - * @param index the index of the media set - * @tparam T class of media set - */ - template - void SetMediaSet(int index) - { - if (_game_mode == GM_MENU) { - auto name = T::GetSet(index)->name; - - T::ini_set = name; - - T::SetSet(name); - this->reload = true; - this->InvalidateData(); - } - } - void OnDropdownSelect(int widget, int index) override { switch (widget) { @@ -749,11 +741,23 @@ struct GameOptionsWindow : Window { } case WID_GO_BASE_GRF_DROPDOWN: - this->SetMediaSet(index); + if (_game_mode == GM_MENU) { + CloseWindowByClass(WC_GRF_PARAMETERS); + auto* set = BaseGraphics::GetSet(index); + BaseGraphics::SetSet(set); + this->reload = true; + this->InvalidateData(); + } break; case WID_GO_BASE_SFX_DROPDOWN: - this->SetMediaSet(index); + if (_game_mode == GM_MENU) { + auto* set = BaseSounds::GetSet(index); + BaseSounds::ini_set = set->name; + BaseSounds::SetSet(set); + this->reload = true; + this->InvalidateData(); + } break; case WID_GO_BASE_MUSIC_DROPDOWN: @@ -814,6 +818,8 @@ struct GameOptionsWindow : Window { bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0; this->GetWidget(WID_GO_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL); + this->SetWidgetDisabledState(WID_GO_BASE_GRF_PARAMETERS, BaseGraphics::GetUsedSet() == nullptr || !BaseGraphics::GetUsedSet()->IsConfigurable()); + for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) { this->SetWidgetDisabledState(WID_GO_BASE_GRF_TEXTFILE + tft, BaseGraphics::GetUsedSet() == nullptr || BaseGraphics::GetUsedSet()->GetTextfile(tft) == nullptr); this->SetWidgetDisabledState(WID_GO_BASE_SFX_TEXTFILE + tft, BaseSounds::GetUsedSet() == nullptr || BaseSounds::GetUsedSet()->GetTextfile(tft) == nullptr); @@ -930,6 +936,7 @@ static const NWidgetPart _nested_game_options_widgets[] = { NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0), NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_GRF_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP), NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_STATUS), SetMinimalSize(100, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_PARAMETERS), SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL), EndContainer(), NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_DESCRIPTION), SetMinimalSize(200, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 6, 0), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(7, 0, 7), @@ -990,7 +997,7 @@ static const NWidgetPart _nested_game_options_widgets[] = { EndContainer(), }; -static WindowDesc _game_options_desc( +static WindowDesc _game_options_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_GAME_OPTIONS, WC_NONE, 0, @@ -3192,7 +3199,7 @@ static const NWidgetPart _nested_settings_selection_widgets[] = { EndContainer(), }; -static WindowDesc _settings_selection_desc( +static WindowDesc _settings_selection_desc(__FILE__, __LINE__, WDP_CENTER, "settings", 510, 450, WC_GAME_OPTIONS, WC_NONE, 0, @@ -3491,7 +3498,7 @@ static const NWidgetPart _nested_cust_currency_widgets[] = { EndContainer(), }; -static WindowDesc _cust_currency_desc( +static WindowDesc _cust_currency_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_CUSTOM_CURRENCY, WC_NONE, 0, diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index fd4f875a08..167b5f3791 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -378,15 +378,13 @@ static const NWidgetPart _nested_sign_list_widgets[] = { EndContainer(), EndContainer(), NWidget(NWID_VERTICAL), - NWidget(NWID_VERTICAL), SetFill(0, 1), - NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_SIL_SCROLLBAR), - EndContainer(), + NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_SIL_SCROLLBAR), NWidget(WWT_RESIZEBOX, COLOUR_BROWN), EndContainer(), EndContainer(), }; -static WindowDesc _sign_list_desc( +static WindowDesc _sign_list_desc(__FILE__, __LINE__, WDP_AUTO, "list_signs", 358, 138, WC_SIGN_LIST, WC_NONE, 0, @@ -552,7 +550,7 @@ static const NWidgetPart _nested_query_sign_edit_widgets[] = { EndContainer(), }; -static WindowDesc _query_sign_edit_desc( +static WindowDesc _query_sign_edit_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_QUERY_STRING, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 4762592290..44bc1190c4 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1065,7 +1065,7 @@ void SmallMapWindow::SetupWidgetData() SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc), refresh(GUITimer()) { _smallmap_industry_highlight = INVALID_INDUSTRYTYPE; - this->overlay = new LinkGraphOverlay(this, WID_SM_MAP, 0, this->GetOverlayCompanyMask(), 1); + this->overlay = std::make_unique(this, WID_SM_MAP, 0, this->GetOverlayCompanyMask(), 1); this->InitNested(window_number); this->LowerWidget(this->map_type + WID_SM_CONTOUR); @@ -1083,11 +1083,6 @@ SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(des this->refresh.SetInterval(this->GetRefreshPeriod()); } -SmallMapWindow::~SmallMapWindow() -{ - delete this->overlay; -} - /* virtual */ void SmallMapWindow::Close([[maybe_unused]] int data) { this->BreakIndustryChainLink(); @@ -1768,7 +1763,7 @@ public: this->resize_y = std::min(display->resize_y, bar->resize_y); } - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override { this->pos_x = x; this->pos_y = y; @@ -1879,7 +1874,7 @@ static const NWidgetPart _nested_smallmap_widgets[] = { EndContainer(), }; -static WindowDesc _smallmap_desc( +static WindowDesc _smallmap_desc(__FILE__, __LINE__, WDP_AUTO, "smallmap", 484, 314, WC_SMALLMAP, WC_NONE, 0, diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index 5af983cb03..f0c36e80ea 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -108,7 +108,7 @@ protected: int zoom = 1; ///< Zoom level. Bigger number means more zoom-out (further away). GUITimer refresh; ///< Refresh timer. - LinkGraphOverlay *overlay; + std::unique_ptr overlay; static void BreakIndustryChainLink(); @@ -200,7 +200,6 @@ public: friend class NWidgetSmallmapDisplay; SmallMapWindow(WindowDesc *desc, int window_number); - virtual ~SmallMapWindow(); static void RebuildColourIndexIfNecessary(); diff --git a/src/sound/xaudio2_s.cpp b/src/sound/xaudio2_s.cpp index 5a16ee06de..3ef30bc461 100644 --- a/src/sound/xaudio2_s.cpp +++ b/src/sound/xaudio2_s.cpp @@ -41,9 +41,9 @@ typedef HRESULT(__stdcall *API_XAudio2Create)(_Outptr_ IXAudio2** ppXAudio2, UIN static FSoundDriver_XAudio2 iFSoundDriver_XAudio2; /** -* Implementation of the IXAudio2VoiceCallback interface. -* Provides buffered audio to XAudio2 from the OpenTTD mixer. -*/ + * Implementation of the IXAudio2VoiceCallback interface. + * Provides buffered audio to XAudio2 from the OpenTTD mixer. + */ class StreamingVoiceContext : public IXAudio2VoiceCallback { private: @@ -132,12 +132,12 @@ static HRESULT CreateXAudio(API_XAudio2Create xAudio2Create) } /** -* Initialises the XAudio2 driver. -* -* @param parm Driver parameters. -* @return An error message if unsuccessful, or nullptr otherwise. -* -*/ + * Initialises the XAudio2 driver. + * + * @param parm Driver parameters. + * @return An error message if unsuccessful, or nullptr otherwise. + * + */ const char *SoundDriver_XAudio2::Start(const StringList &parm) { HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); @@ -261,8 +261,8 @@ const char *SoundDriver_XAudio2::Start(const StringList &parm) } /** -* Terminates the XAudio2 driver. -*/ + * Terminates the XAudio2 driver. + */ void SoundDriver_XAudio2::Stop() { // Clean up XAudio2 diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 2524c507a6..d5006af352 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3663,7 +3663,7 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y); } } else { - /* Drive-in stop */ + /* Bay stop */ if (RoadTypeIsRoad(roadtype) && roadtype_info->UsesOverlay()) { SpriteID ground = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_ROADSTOP); DrawSprite(ground + image, PAL_NONE, x, y); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index ed8957f714..2cd0f3b96e 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -866,7 +866,7 @@ static const NWidgetPart _nested_company_stations_widgets[] = { EndContainer(), }; -static WindowDesc _company_stations_desc( +static WindowDesc _company_stations_desc(__FILE__, __LINE__, WDP_AUTO, "list_stations", 358, 162, WC_STATION_LIST, WC_NONE, 0, @@ -2384,7 +2384,7 @@ const StringID StationViewWindow::_group_names[] = { INVALID_STRING_ID }; -static WindowDesc _station_view_desc( +static WindowDesc _station_view_desc(__FILE__, __LINE__, WDP_AUTO, "view_station", 249, 117, WC_STATION_VIEW, WC_NONE, 0, @@ -2661,7 +2661,7 @@ struct SelectStationWindow : Window { } }; -static WindowDesc _select_station_desc( +static WindowDesc _select_station_desc(__FILE__, __LINE__, WDP_AUTO, "build_station_join", 200, 180, WC_SELECT_STATION, WC_NONE, WDF_CONSTRUCTION, @@ -2745,7 +2745,7 @@ static const NWidgetPart _nested_station_rating_tooltip_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_TT_BACKGROUND), SetMinimalSize(64, 32), EndContainer(), }; -static WindowDesc _station_rating_tooltip_desc( +static WindowDesc _station_rating_tooltip_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_STATION_RATING_TOOLTIP, WC_NONE, 0, diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 1ea4f7151b..70d761b515 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -239,7 +239,7 @@ static const NWidgetPart _nested_main_status_widgets[] = { EndContainer(), }; -static WindowDesc _main_status_desc( +static WindowDesc _main_status_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_STATUS_BAR, WC_NONE, WDF_NO_FOCUS | WDF_NO_CLOSE, diff --git a/src/story_gui.cpp b/src/story_gui.cpp index a6b39c3e7d..426191b822 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -958,7 +958,7 @@ static const NWidgetPart _nested_story_book_widgets[] = { NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN), NWidget(WWT_STICKYBOX, COLOUR_BROWN), EndContainer(), - NWidget(NWID_HORIZONTAL), SetFill(1, 1), + NWidget(NWID_HORIZONTAL), NWidget(WWT_PANEL, COLOUR_BROWN, WID_SB_PAGE_PANEL), SetResize(1, 1), SetScrollbar(WID_SB_SCROLLBAR), EndContainer(), NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_SB_SCROLLBAR), EndContainer(), @@ -971,7 +971,7 @@ static const NWidgetPart _nested_story_book_widgets[] = { EndContainer(), }; -static WindowDesc _story_book_desc( +static WindowDesc _story_book_desc(__FILE__, __LINE__, WDP_CENTER, "view_story", 400, 300, WC_STORY_BOOK, WC_NONE, 0, diff --git a/src/string.cpp b/src/string.cpp index ae4d8ba9fe..2b8870312f 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -458,12 +458,12 @@ struct CaseInsensitiveCharTraits : public std::char_traits { return 0; } - static const char *find(const char *s, int n, char a) + static const char *find(const char *s, size_t n, char a) { - while (n-- > 0 && toupper(*s) != toupper(a)) { - ++s; + for (; n > 0; --n, ++s) { + if (toupper(*s) == toupper(a)) return s; } - return s; + return nullptr; } }; @@ -958,6 +958,98 @@ int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garb return _strnatcmpIntl(s1.data(), s2.data()); } +#ifdef WITH_ICU_I18N + +#include + +/** + * Search if a string is contained in another string using the current locale. + * + * @param str String to search in. + * @param value String to search for. + * @param case_insensitive Search case-insensitive. + * @return 1 if value was found, 0 if it was not found, or -1 if not supported by the OS. + */ +static int ICUStringContains(const std::string_view str, const std::string_view value, bool case_insensitive) +{ + if (_current_collator) { + std::unique_ptr coll(dynamic_cast(_current_collator->clone())); + if (coll) { + UErrorCode status = U_ZERO_ERROR; + coll->setStrength(case_insensitive ? icu::Collator::SECONDARY : icu::Collator::TERTIARY); + coll->setAttribute(UCOL_NUMERIC_COLLATION, UCOL_OFF, status); + + auto u_str = icu::UnicodeString::fromUTF8(icu::StringPiece(str.data(), str.size())); + auto u_value = icu::UnicodeString::fromUTF8(icu::StringPiece(value.data(), value.size())); + icu::StringSearch u_searcher(u_value, u_str, coll.get(), nullptr, status); + if (U_SUCCESS(status)) { + auto pos = u_searcher.first(status); + if (U_SUCCESS(status)) return pos != USEARCH_DONE ? 1 : 0; + } + } + } + + return -1; +} +#endif /* WITH_ICU_I18N */ + +/** + * Checks if a string is contained in another string with a locale-aware comparison that is case sensitive. + * + * @param str The string to search in. + * @param value The string to search for. + * @return True if a match was found. + */ +[[nodiscard]] bool StrNaturalContains(const std::string_view str, const std::string_view value) +{ +#ifdef WITH_ICU_I18N + int res_u = ICUStringContains(str, value, false); + if (res_u >= 0) return res_u > 0; +#endif /* WITH_ICU_I18N */ + +#if defined(_WIN32) && !defined(STRGEN) && !defined(SETTINGSGEN) + int res = Win32StringContains(str, value, false); + if (res >= 0) return res > 0; +#endif + +#if defined(WITH_COCOA) && !defined(STRGEN) && !defined(SETTINGSGEN) + int res = MacOSStringContains(str, value, false); + if (res >= 0) return res > 0; +#endif + + return str.find(value) != std::string_view::npos; +} + +/** + * Checks if a string is contained in another string with a locale-aware comparison that is case insensitive. + * + * @param str The string to search in. + * @param value The string to search for. + * @return True if a match was found. + */ +[[nodiscard]] bool StrNaturalContainsIgnoreCase(const std::string_view str, const std::string_view value) +{ +#ifdef WITH_ICU_I18N + int res_u = ICUStringContains(str, value, true); + if (res_u >= 0) return res_u > 0; +#endif /* WITH_ICU_I18N */ + +#if defined(_WIN32) && !defined(STRGEN) && !defined(SETTINGSGEN) + int res = Win32StringContains(str, value, true); + if (res >= 0) return res > 0; +#endif + +#if defined(WITH_COCOA) && !defined(STRGEN) && !defined(SETTINGSGEN) + int res = MacOSStringContains(str, value, true); + if (res >= 0) return res > 0; +#endif + + CaseInsensitiveStringView ci_str{ str.data(), str.size() }; + CaseInsensitiveStringView ci_value{ value.data(), value.size() }; + return ci_str.find(ci_value) != CaseInsensitiveStringView::npos; +} + + #ifdef WITH_UNISCRIBE /* static */ std::unique_ptr StringIterator::Create() diff --git a/src/string_func.h b/src/string_func.h index e106aad5a3..66c9972813 100644 --- a/src/string_func.h +++ b/src/string_func.h @@ -65,6 +65,8 @@ void StrTrimInPlace(std::string &str); [[nodiscard]] int StrCompareIgnoreCase(const std::string_view str1, const std::string_view str2); [[nodiscard]] bool StrEqualsIgnoreCase(const std::string_view str1, const std::string_view str2); [[nodiscard]] int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front = false); +[[nodiscard]] bool StrNaturalContains(const std::string_view str, const std::string_view value); +[[nodiscard]] bool StrNaturalContainsIgnoreCase(const std::string_view str, const std::string_view value); /** Case insensitive comparator for strings, for example for use in std::map. */ struct CaseInsensitiveComparator { diff --git a/src/stringfilter.cpp b/src/stringfilter.cpp index ab74bc7525..20696d1c95 100644 --- a/src/stringfilter.cpp +++ b/src/stringfilter.cpp @@ -118,9 +118,16 @@ void StringFilter::AddLine(const char *str) bool match_case = this->case_sensitive != nullptr && *this->case_sensitive; for (WordState &ws : this->word_index) { if (!ws.match) { - if ((match_case ? strstr(str, ws.start) : strcasestr(str, ws.start)) != nullptr) { - ws.match = true; - this->word_matches++; + if (this->locale_aware) { + if (match_case ? StrNaturalContains(str, ws.start) : StrNaturalContainsIgnoreCase(str, ws.start)) { + ws.match = true; + this->word_matches++; + } + } else { + if ((match_case ? strstr(str, ws.start) : strcasestr(str, ws.start)) != nullptr) { + ws.match = true; + this->word_matches++; + } } } } diff --git a/src/stringfilter_type.h b/src/stringfilter_type.h index b4df174f2e..62ab1df3a8 100644 --- a/src/stringfilter_type.h +++ b/src/stringfilter_type.h @@ -41,13 +41,14 @@ private: uint word_matches; ///< Summary of filter state: Number of words matched. const bool *case_sensitive; ///< Match case-sensitively (usually a static variable). + bool locale_aware; ///< Match words using the current locale. public: /** * Constructor for filter. * @param case_sensitive Pointer to a (usually static) variable controlling the case-sensitivity. nullptr means always case-insensitive. */ - StringFilter(const bool *case_sensitive = nullptr) : filter_buffer(nullptr), word_matches(0), case_sensitive(case_sensitive) {} + StringFilter(const bool *case_sensitive = nullptr, bool locale_aware = true) : filter_buffer(nullptr), word_matches(0), case_sensitive(case_sensitive), locale_aware(locale_aware) {} ~StringFilter() { free(this->filter_buffer); } void SetFilterTerm(const char *str); diff --git a/src/strings.cpp b/src/strings.cpp index ce61900715..13933bced7 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -2341,16 +2341,6 @@ const char *GetCurrentLocale(const char *param) const char *GetCurrentLocale(const char *param); #endif /* !(defined(_WIN32) || defined(__APPLE__)) */ -bool StringIDSorter(const StringID &a, const StringID &b) -{ - char stra[DRAW_STRING_BUFFER]; - char strb[DRAW_STRING_BUFFER]; - char *lasta = GetString(stra, a, lastof(stra)); - char *lastb = GetString(strb, b, lastof(strb)); - - return StrNaturalCompare({ stra, (size_t)(lasta - stra) }, { strb, (size_t)(lastb - strb) }) < 0; -} - /** * Get the language with the given NewGRF language ID. * @param newgrflangid NewGRF languages ID to check. diff --git a/src/strings_func.h b/src/strings_func.h index a1a29c9b0b..e8551074bd 100644 --- a/src/strings_func.h +++ b/src/strings_func.h @@ -124,8 +124,6 @@ extern TextDirection _current_text_dir; ///< Text direction of the currently sel void InitializeLanguagePacks(); const char *GetCurrentLanguageIsoCode(); -bool StringIDSorter(const StringID &a, const StringID &b); - /** * A searcher for missing glyphs. */ diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 5307acd5f8..b7d0b72299 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -231,7 +231,7 @@ static const NWidgetPart _nested_subsidies_list_widgets[] = { EndContainer(), }; -static WindowDesc _subsidies_list_desc( +static WindowDesc _subsidies_list_desc(__FILE__, __LINE__, WDP_AUTO, "list_subsidies", 500, 127, WC_SUBSIDIES_LIST, WC_NONE, 0, diff --git a/src/table/roadtypes.h b/src/table/roadtypes.h index a582d05db1..c4a779c0fa 100644 --- a/src/table/roadtypes.h +++ b/src/table/roadtypes.h @@ -88,7 +88,7 @@ static const RoadTypeInfo _original_roadtypes[] = { 0x01, /* introduction date */ - MIN_YEAR, + MIN_DATE, /* roadtypes required for this to be introduced */ ROADTYPES_NONE, diff --git a/src/table/settings/misc_settings.ini b/src/table/settings/misc_settings.ini index c4da718ccf..da425a9aa6 100644 --- a/src/table/settings/misc_settings.ini +++ b/src/table/settings/misc_settings.ini @@ -104,13 +104,6 @@ max = 2 full = _support8bppmodes cat = SC_BASIC -[SDTG_SSTR] -name = ""graphicsset"" -type = SLE_STRQ -var = BaseGraphics::ini_set -def = nullptr -cat = SC_BASIC - [SDTG_SSTR] name = ""soundsset"" type = SLE_STRQ diff --git a/src/tbtr_template_gui_create.cpp b/src/tbtr_template_gui_create.cpp index 518618bea9..b59d523a37 100644 --- a/src/tbtr_template_gui_create.cpp +++ b/src/tbtr_template_gui_create.cpp @@ -95,7 +95,7 @@ static const NWidgetPart _widgets[] = { EndContainer(), }; -static WindowDesc _template_create_window_desc( +static WindowDesc _template_create_window_desc(__FILE__, __LINE__, WDP_AUTO, // window position "template create window", // const char* ini_key 456, 100, // window size diff --git a/src/tbtr_template_gui_main.cpp b/src/tbtr_template_gui_main.cpp index d155ade021..52731206b6 100644 --- a/src/tbtr_template_gui_main.cpp +++ b/src/tbtr_template_gui_main.cpp @@ -177,7 +177,7 @@ static const NWidgetPart _widgets[] = { EndContainer(), }; -static WindowDesc _replace_rail_vehicle_desc( +static WindowDesc _replace_rail_vehicle_desc(__FILE__, __LINE__, WDP_AUTO, "template replace window", 456, 156, diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index caa2f11fd6..5b4be27da3 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -419,7 +419,7 @@ static const NWidgetPart _nested_terraform_widgets[] = { EndContainer(), }; -static WindowDesc _terraform_desc( +static WindowDesc _terraform_desc(__FILE__, __LINE__, WDP_MANUAL, "toolbar_landscape", 0, 0, WC_SCEN_LAND_GEN, WC_NONE, WDF_CONSTRUCTION, @@ -848,7 +848,7 @@ static Hotkey terraform_editor_hotkeys[] = { HotkeyList ScenarioEditorLandscapeGenerationWindow::hotkeys("terraform_editor", terraform_editor_hotkeys, TerraformToolbarEditorGlobalHotkeys); -static WindowDesc _scen_edit_land_gen_desc( +static WindowDesc _scen_edit_land_gen_desc(__FILE__, __LINE__, WDP_AUTO, "toolbar_landscape_scen", 0, 0, WC_SCEN_LAND_GEN, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index 5e37d516d5..d061afac87 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -75,7 +75,7 @@ static const NWidgetPart _nested_textfile_widgets[] = { }; /** Window definition for the textfile window */ -static WindowDesc _textfile_desc( +static WindowDesc _textfile_desc(__FILE__, __LINE__, WDP_CENTER, "textfile", 630, 460, WC_TEXTFILE, WC_NONE, 0, diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index c27bad1c08..875c60220f 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -389,6 +389,10 @@ CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, Vehicle *v = Vehicle::GetIfValid(veh); if (v == nullptr || !v->IsPrimaryVehicle() || v->orders == nullptr) return CMD_ERROR; + /* A vehicle can't be late if its timetable hasn't started. + * If we're setting all vehicles in the group, we handle that below. */ + if (!apply_to_group && !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) return CommandCost(STR_ERROR_TIMETABLE_NOT_STARTED); + CommandCost ret = CheckOwnership(v->owner); if (ret.Failed()) return ret; @@ -396,12 +400,18 @@ CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, if (apply_to_group) { int32 most_late = 0; for (Vehicle *u = v->FirstShared(); u != nullptr; u = u->NextShared()) { + /* A vehicle can't be late if its timetable hasn't started. */ + if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) continue; + if (u->lateness_counter > most_late) { most_late = u->lateness_counter; } } if (most_late > 0) { for (Vehicle *u = v->FirstShared(); u != nullptr; u = u->NextShared()) { + /* A vehicle can't be late if its timetable hasn't started. */ + if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) continue; + u->lateness_counter -= most_late; SetWindowDirty(WC_VEHICLE_TIMETABLE, u->index); } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index f5721d8d83..c249a3b569 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -1236,7 +1236,7 @@ static const NWidgetPart _nested_timetable_widgets[] = { EndContainer(), }; -static WindowDesc _timetable_desc( +static WindowDesc _timetable_desc(__FILE__, __LINE__, WDP_AUTO, "view_vehicle_timetable", 400, 130, WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 878e458006..dca6e220d4 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1582,7 +1582,7 @@ public: _toolbar_width = nbuttons * this->smallest_x; } - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override { assert(given_width >= this->smallest_x && given_height >= this->smallest_y); @@ -2443,7 +2443,7 @@ static const NWidgetPart _nested_toolbar_normal_widgets[] = { NWidgetFunction(MakeMainToolbar), }; -static WindowDesc _toolb_normal_desc( +static WindowDesc _toolb_normal_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_MAIN_TOOLBAR, WC_NONE, WDF_NO_FOCUS | WDF_NO_CLOSE, @@ -2808,7 +2808,7 @@ static const NWidgetPart _nested_toolb_scen_widgets[] = { NWidgetFunction(MakeScenarioToolbar), }; -static WindowDesc _toolb_scen_desc( +static WindowDesc _toolb_scen_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_MAIN_TOOLBAR, WC_NONE, WDF_NO_FOCUS | WDF_NO_CLOSE, diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 1cfac0f1a7..d4e3c06814 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -499,7 +499,7 @@ public: } }; -static WindowDesc _town_authority_desc( +static WindowDesc _town_authority_desc(__FILE__, __LINE__, WDP_AUTO, "view_town_authority", 317, 222, WC_TOWN_AUTHORITY, WC_NONE, 0, @@ -798,7 +798,7 @@ static const NWidgetPart _nested_town_game_view_widgets[] = { EndContainer(), }; -static WindowDesc _town_game_view_desc( +static WindowDesc _town_game_view_desc(__FILE__, __LINE__, WDP_AUTO, "view_town", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL, WC_TOWN_VIEW, WC_NONE, 0, @@ -830,7 +830,7 @@ static const NWidgetPart _nested_town_editor_view_widgets[] = { EndContainer(), }; -static WindowDesc _town_editor_view_desc( +static WindowDesc _town_editor_view_desc(__FILE__, __LINE__, WDP_AUTO, "view_town_scen", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL, WC_TOWN_VIEW, WC_NONE, 0, @@ -1209,7 +1209,7 @@ GUITownList::SortFunction * const TownDirectoryWindow::sorter_funcs[] = { &TownRatingSorter, }; -static WindowDesc _town_directory_desc( +static WindowDesc _town_directory_desc(__FILE__, __LINE__, WDP_AUTO, "list_towns", 208, 202, WC_TOWN_DIRECTORY, WC_NONE, 0, @@ -1460,7 +1460,7 @@ public: } }; -static WindowDesc _found_town_desc( +static WindowDesc _found_town_desc(__FILE__, __LINE__, WDP_AUTO, "build_town", 160, 162, WC_FOUND_TOWN, WC_NONE, WDF_CONSTRUCTION, @@ -2032,7 +2032,7 @@ static const NWidgetPart _nested_house_picker_widgets[] = { EndContainer(), }; -static WindowDesc _house_picker_desc( +static WindowDesc _house_picker_desc(__FILE__, __LINE__, WDP_AUTO, "build_house", 0, 0, WC_BUILD_HOUSE, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -2133,7 +2133,7 @@ static const NWidgetPart _nested_select_town_widgets[] = { EndContainer(), }; -static WindowDesc _select_town_desc( +static WindowDesc _select_town_desc(__FILE__, __LINE__, WDP_AUTO, "select_town", 100, 0, WC_SELECT_TOWN, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index 4cad3ed866..d15cb15199 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -3615,7 +3615,7 @@ static const NWidgetPart _nested_program_widgets[] = { EndContainer(), }; -static WindowDesc _program_desc( +static WindowDesc _program_desc(__FILE__, __LINE__, WDP_AUTO, "trace_restrict_gui", 384, 100, WC_TRACE_RESTRICT, WC_BUILD_SIGNAL, WDF_CONSTRUCTION, @@ -4283,7 +4283,7 @@ public: } }; -static WindowDesc _slot_window_desc( +static WindowDesc _slot_window_desc(__FILE__, __LINE__, WDP_AUTO, "list_groups_train", 525, 246, WC_TRACE_RESTRICT_SLOTS, WC_NONE, 0, @@ -4649,7 +4649,7 @@ public: } }; -static WindowDesc _counter_window_desc( +static WindowDesc _counter_window_desc(__FILE__, __LINE__, WDP_AUTO, "list_tr_counters", 525, 246, WC_TRACE_RESTRICT_COUNTERS, WC_NONE, 0, diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index ab11cb8a84..02b5143695 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -174,7 +174,7 @@ static const NWidgetPart _nested_transparency_widgets[] = { EndContainer(), }; -static WindowDesc _transparency_desc( +static WindowDesc _transparency_desc(__FILE__, __LINE__, WDP_MANUAL, "toolbar_transparency", 0, 0, WC_TRANSPARENCY_TOOLBAR, WC_NONE, 0, diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 9a13bb76ef..0f5f568ef6 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -311,7 +311,7 @@ static const NWidgetPart _nested_build_trees_widgets[] = { EndContainer(), }; -static WindowDesc _build_trees_desc( +static WindowDesc _build_trees_desc(__FILE__, __LINE__, WDP_AUTO, "build_tree", 0, 0, WC_BUILD_TREES, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index e95ba8e0a1..aab806cf12 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1406,7 +1406,7 @@ static const NWidgetPart _nested_vehicle_refit_widgets[] = { EndContainer(), }; -static WindowDesc _vehicle_refit_desc( +static WindowDesc _vehicle_refit_desc(__FILE__, __LINE__, WDP_AUTO, "view_vehicle_refit", 240, 174, WC_VEHICLE_REFIT, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, @@ -2643,14 +2643,14 @@ public: } }; -static WindowDesc _vehicle_list_other_desc( +static WindowDesc _vehicle_list_other_desc(__FILE__, __LINE__, WDP_AUTO, "list_vehicles", 260, 246, WC_INVALID, WC_NONE, 0, std::begin(_nested_vehicle_list), std::end(_nested_vehicle_list) ); -static WindowDesc _vehicle_list_train_desc( +static WindowDesc _vehicle_list_train_desc(__FILE__, __LINE__, WDP_AUTO, "list_vehicles_train", 325, 246, WC_TRAINS_LIST, WC_NONE, 0, @@ -3373,7 +3373,7 @@ struct VehicleDetailsWindow : Window { }; /** Vehicle details window descriptor. */ -static WindowDesc _train_vehicle_details_desc( +static WindowDesc _train_vehicle_details_desc(__FILE__, __LINE__, WDP_AUTO, "view_vehicle_details_train", 405, 178, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, @@ -3381,7 +3381,7 @@ static WindowDesc _train_vehicle_details_desc( ); /** Vehicle details window descriptor for other vehicles than a train. */ -static WindowDesc _nontrain_vehicle_details_desc( +static WindowDesc _nontrain_vehicle_details_desc(__FILE__, __LINE__, WDP_AUTO, "view_vehicle_details", 405, 113, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, @@ -4201,7 +4201,7 @@ static Hotkey vehicleview_hotkeys[] = { HotkeyList VehicleViewWindow::hotkeys("vehicleview", vehicleview_hotkeys); /** Vehicle view window descriptor for all vehicles but trains. */ -static WindowDesc _vehicle_view_desc( +static WindowDesc _vehicle_view_desc(__FILE__, __LINE__, WDP_AUTO, "view_vehicle", 250, 116, WC_VEHICLE_VIEW, WC_NONE, 0, @@ -4213,7 +4213,7 @@ static WindowDesc _vehicle_view_desc( * Vehicle view window descriptor for trains. Only minimum_height and * default_height are different for train view. */ -static WindowDesc _train_view_desc( +static WindowDesc _train_view_desc(__FILE__, __LINE__, WDP_AUTO, "view_vehicle_train", 250, 134, WC_VEHICLE_VIEW, WC_NONE, 0, diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index 17d8c86e5e..bdd1981084 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -335,7 +335,7 @@ void VideoDriver_Cocoa::GameSizeChanged() ::GameSizeChanged(); /* We need to store the window size as non-Retina size in - * the config file to get same windows size on next start. */ + * the config file to get same windows size on next start. */ _cur_resolution.width = [ this->cocoaview frame ].size.width; _cur_resolution.height = [ this->cocoaview frame ].size.height; } diff --git a/src/viewport.cpp b/src/viewport.cpp index cf21fa7b28..354dad5840 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1888,8 +1888,8 @@ static void ViewportAddKdtreeSigns(ViewportDrawerDynamic *vdd, DrawPixelInfo *dp const Sign *si = Sign::Get(item.id.sign); /* Don't draw if sign is owned by another company and competitor signs should be hidden. - * Note: It is intentional that also signs owned by OWNER_NONE are hidden. Bankrupt - * companies can leave OWNER_NONE signs after them. */ + * Note: It is intentional that also signs owned by OWNER_NONE are hidden. Bankrupt + * companies can leave OWNER_NONE signs after them. */ if (!show_competitors && si->IsCompetitorOwned()) break; signs.push_back(si); diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 49d041ab20..defd0c6004 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -180,7 +180,7 @@ public: } }; -static WindowDesc _extra_viewport_desc( +static WindowDesc _extra_viewport_desc(__FILE__, __LINE__, WDP_AUTO, "extra_viewport", 300, 268, WC_EXTRA_VIEWPORT, WC_NONE, 0, diff --git a/src/viewport_kdtree.h b/src/viewport_kdtree.h index 18cbd3af01..56254b4148 100644 --- a/src/viewport_kdtree.h +++ b/src/viewport_kdtree.h @@ -1,9 +1,9 @@ /* -* This file is part of OpenTTD. -* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. -* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . -*/ + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ /** @file town_kdtree.h Declarations for accessing the k-d tree of towns */ diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index d065a1eb14..024e9fe9a8 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -245,7 +245,7 @@ static const NWidgetPart _nested_waypoint_view_widgets[] = { }; /** The description of the waypoint view. */ -static WindowDesc _waypoint_view_desc( +static WindowDesc _waypoint_view_desc(__FILE__, __LINE__, WDP_AUTO, "view_waypoint", 260, 118, WC_WAYPOINT_VIEW, WC_NONE, 0, diff --git a/src/widget.cpp b/src/widget.cpp index bbf151b010..7a0b4bd50c 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -151,7 +151,9 @@ const WidgetDimensions WidgetDimensions::unscaled = { {WD_CAPTIONTEXT_LEFT, WD_CAPTIONTEXT_TOP, WD_CAPTIONTEXT_RIGHT, WD_CAPTIONTEXT_BOTTOM}, ///< captiontext {WD_DROPDOWNTEXT_LEFT, WD_DROPDOWNTEXT_TOP, WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_BOTTOM}, ///< dropdowntext {20, 10, 20, 10}, ///< modalpopup + {3, 3, 3, 3}, ///< picker 1, ///< pressed + 1, ///< vsep_picker WD_PAR_VSEP_NORMAL, ///< vsep_normal WD_PAR_VSEP_WIDE, ///< vsep_wide 2, ///< hsep_normal @@ -1008,7 +1010,7 @@ NWidgetBase::NWidgetBase(WidgetType tp) : ZeroedMemoryAllocator() */ /** - * @fn void NWidgetBase::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) + * @fn void NWidgetBase::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) * Assign size and position to the widget. * @param sizing Type of resizing to perform. * @param x Horizontal offset of the widget relative to the left edge of the window. @@ -1162,7 +1164,7 @@ bool NWidgetResizeBase::UpdateVerticalSize(uint min_y) return true; } -void NWidgetResizeBase::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool) +void NWidgetResizeBase::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool) { this->StoreSizePosition(sizing, x, y, given_width, given_height); } @@ -1418,7 +1420,7 @@ void NWidgetStacked::SetupSmallestSize(Window *w, bool init_array) } } -void NWidgetStacked::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) +void NWidgetStacked::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) { assert(given_width >= this->smallest_x && given_height >= this->smallest_y); this->StoreSizePosition(sizing, x, y, given_width, given_height); @@ -1536,6 +1538,22 @@ void NWidgetPIPContainer::SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post) this->pip_post = ScaleGUITrad(this->uz_pip_post); } +/** + * Set additional pre/inter/post space for the container. + * + * @param pip_ratio_pre Ratio of additional space in front of the first child widget (above + * for the vertical container, at the left for the horizontal container). + * @param pip_ratio_inter Ratio of additional space between two child widgets. + * @param pip_ratio_post Ratio of additional space after the last child widget (below for the + * vertical container, at the right for the horizontal container). + */ +void NWidgetPIPContainer::SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_ratio_post) +{ + this->pip_ratio_pre = pip_ratio_pre; + this->pip_ratio_inter = pip_ratio_inter; + this->pip_ratio_post = pip_ratio_post; +} + /** Horizontal container widget. */ NWidgetHorizontal::NWidgetHorizontal(NWidContainerFlags flags) : NWidgetPIPContainer(NWID_HORIZONTAL, flags) { @@ -1549,6 +1567,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w, bool init_array) this->fill_y = 1; // smallest common child fill step. this->resize_x = 0; // smallest non-zero child widget resize step. this->resize_y = 1; // smallest common child resize step. + this->gaps = 0; /* 1a. Forward call, collect biggest nested array index, and longest/widest child length. */ uint longest = 0; // Longest child found. @@ -1558,7 +1577,9 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w, bool init_array) longest = std::max(longest, child_wid->smallest_x); max_vert_fill = std::max(max_vert_fill, child_wid->GetVerticalStepSize(ST_SMALLEST)); this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.Vertical()); + if (child_wid->smallest_x != 0 || child_wid->fill_x != 0) this->gaps++; } + if (this->gaps > 0) this->gaps--; // Number of gaps is number of widgets less one. /* 1b. Make the container higher if needed to accommodate all children nicely. */ [[maybe_unused]] uint max_smallest = this->smallest_y + 3 * max_vert_fill; // Upper limit to computing smallest height. uint cur_height = this->smallest_y; @@ -1584,15 +1605,8 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w, bool init_array) if (child_wid->fill_x == 1) child_wid->smallest_x = longest; } } - /* 3. Move PIP space to the children, compute smallest, fill, and resize values of the container. */ - if (this->head != nullptr) this->head->padding.left += this->pip_pre; + /* 3. Compute smallest, fill, and resize values of the container. */ for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { - if (child_wid->next != nullptr) { - child_wid->padding.right += this->pip_inter; - } else { - child_wid->padding.right += this->pip_post; - } - this->smallest_x += child_wid->smallest_x + child_wid->padding.Horizontal(); if (child_wid->fill_x > 0) { if (this->fill_x == 0 || this->fill_x > child_wid->fill_x) this->fill_x = child_wid->fill_x; @@ -1604,20 +1618,22 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w, bool init_array) } this->resize_y = LeastCommonMultiple(this->resize_y, child_wid->resize_y); } - /* We need to zero the PIP settings so we can re-initialize the tree. */ - this->pip_pre = this->pip_inter = this->pip_post = 0; + if (this->fill_x == 0 && this->pip_ratio_pre + this->pip_ratio_inter + this->pip_ratio_post > 0) this->fill_x = 1; + /* 4. Increase by required PIP space. */ + this->smallest_x += this->pip_pre + this->gaps * this->pip_inter + this->pip_post; } -void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) +void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) { assert(given_width >= this->smallest_x && given_height >= this->smallest_y); /* Compute additional width given to us. */ uint additional_length = given_width; - if (sizing == ST_SMALLEST && (this->flags & NC_EQUALSIZE)) { + if (this->pip_ratio_pre + this->pip_ratio_inter + this->pip_ratio_post != 0 || (sizing == ST_SMALLEST && (this->flags & NC_EQUALSIZE))) { /* For EQUALSIZE containers this does not sum to smallest_x during initialisation */ + additional_length -= this->pip_pre + this->gaps * this->pip_inter + this->pip_post; for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { - additional_length -= child_wid->smallest_x + child_wid->padding.Horizontal(); + if (child_wid->smallest_x != 0 || child_wid->fill_x != 0) additional_length -= child_wid->smallest_x + child_wid->padding.Horizontal(); } } else { additional_length -= this->smallest_x; @@ -1694,8 +1710,21 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, ui } assert(num_changing_childs == 0); + uint pre = this->pip_pre; + uint inter = this->pip_inter; + + if (additional_length > 0) { + /* Allocate remaining space by pip ratios. If this doesn't round exactly, the unused space will fall into pip_post + * which is never explicitly needed. */ + int r = this->pip_ratio_pre + this->gaps * this->pip_ratio_inter + this->pip_ratio_post; + if (r > 0) { + pre += this->pip_ratio_pre * additional_length / r; + if (this->gaps > 0) inter += this->pip_ratio_inter * additional_length / r; + } + } + /* Third loop: Compute position and call the child. */ - uint position = rtl ? this->current_x : 0; // Place to put next child relative to origin of the container. + uint position = rtl ? this->current_x - pre : pre; // Place to put next child relative to origin of the container. NWidgetBase *child_wid = this->head; while (child_wid != nullptr) { uint child_width = child_wid->current_x; @@ -1703,8 +1732,10 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, ui uint child_y = y + child_wid->padding.top; child_wid->AssignSizePosition(sizing, child_x, child_y, child_width, child_wid->current_y, rtl); - uint padded_child_width = child_width + child_wid->padding.Horizontal(); - position = rtl ? position - padded_child_width : position + padded_child_width; + if (child_wid->current_x != 0) { + uint padded_child_width = child_width + child_wid->padding.Horizontal() + inter; + position = rtl ? position - padded_child_width : position + padded_child_width; + } child_wid = child_wid->next; } @@ -1716,7 +1747,7 @@ NWidgetHorizontalLTR::NWidgetHorizontalLTR(NWidContainerFlags flags) : NWidgetHo this->type = NWID_HORIZONTAL_LTR; } -void NWidgetHorizontalLTR::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool) +void NWidgetHorizontalLTR::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool) { NWidgetHorizontal::AssignSizePosition(sizing, x, y, given_width, given_height, false); } @@ -1734,6 +1765,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w, bool init_array) this->fill_y = 0; // smallest non-zero child widget fill step. this->resize_x = 1; // smallest common child resize step. this->resize_y = 0; // smallest non-zero child widget resize step. + this->gaps = 0; /* 1a. Forward call, collect biggest nested array index, and longest/widest child length. */ uint highest = 0; // Highest child found. @@ -1743,7 +1775,9 @@ void NWidgetVertical::SetupSmallestSize(Window *w, bool init_array) highest = std::max(highest, child_wid->smallest_y); max_hor_fill = std::max(max_hor_fill, child_wid->GetHorizontalStepSize(ST_SMALLEST)); this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal()); + if (child_wid->smallest_y != 0 || child_wid->fill_y != 0) this->gaps++; } + if (this->gaps > 0) this->gaps--; // Number of gaps is number of widgets less one. /* 1b. Make the container wider if needed to accommodate all children nicely. */ [[maybe_unused]] uint max_smallest = this->smallest_x + 3 * max_hor_fill; // Upper limit to computing smallest height. uint cur_width = this->smallest_x; @@ -1769,15 +1803,8 @@ void NWidgetVertical::SetupSmallestSize(Window *w, bool init_array) if (child_wid->fill_y == 1) child_wid->smallest_y = highest; } } - /* 3. Move PIP space to the child, compute smallest, fill, and resize values of the container. */ - if (this->head != nullptr) this->head->padding.top += this->pip_pre; + /* 3. Compute smallest, fill, and resize values of the container. */ for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { - if (child_wid->next != nullptr) { - child_wid->padding.bottom += this->pip_inter; - } else { - child_wid->padding.bottom += this->pip_post; - } - this->smallest_y += child_wid->smallest_y + child_wid->padding.Vertical(); if (child_wid->fill_y > 0) { if (this->fill_y == 0 || this->fill_y > child_wid->fill_y) this->fill_y = child_wid->fill_y; @@ -1789,20 +1816,22 @@ void NWidgetVertical::SetupSmallestSize(Window *w, bool init_array) } this->resize_x = LeastCommonMultiple(this->resize_x, child_wid->resize_x); } - /* We need to zero the PIP settings so we can re-initialize the tree. */ - this->pip_pre = this->pip_inter = this->pip_post = 0; + if (this->fill_y == 0 && this->pip_ratio_pre + this->pip_ratio_inter + this->pip_ratio_post > 0) this->fill_y = 1; + /* 4. Increase by required PIP space. */ + this->smallest_y += this->pip_pre + this->gaps * this->pip_inter + this->pip_post; } -void NWidgetVertical::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) +void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) { assert(given_width >= this->smallest_x && given_height >= this->smallest_y); /* Compute additional height given to us. */ uint additional_length = given_height; - if (sizing == ST_SMALLEST && (this->flags & NC_EQUALSIZE)) { + if (this->pip_ratio_pre + this->pip_ratio_inter + this->pip_ratio_post != 0 || (sizing == ST_SMALLEST && (this->flags & NC_EQUALSIZE))) { /* For EQUALSIZE containers this does not sum to smallest_y during initialisation */ + additional_length -= this->pip_pre + this->gaps * this->pip_inter + this->pip_post; for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { - additional_length -= child_wid->smallest_y + child_wid->padding.Vertical(); + if (child_wid->smallest_y != 0 || child_wid->fill_y != 0) additional_length -= child_wid->smallest_y + child_wid->padding.Vertical(); } } else { additional_length -= this->smallest_y; @@ -1870,14 +1899,29 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, uint x, uint y, uint } assert(num_changing_childs == 0); + uint pre = this->pip_pre; + uint inter = this->pip_inter; + + if (additional_length > 0) { + /* Allocate remaining space by pip ratios. If this doesn't round exactly, the unused space will fall into pip_post + * which is never explicitly needed. */ + int r = this->pip_ratio_pre + this->gaps * this->pip_ratio_inter + this->pip_ratio_post; + if (r > 0) { + pre += this->pip_ratio_pre * additional_length / r; + if (this->gaps > 0) inter += this->pip_ratio_inter * additional_length / r; + } + } + /* Third loop: Compute position and call the child. */ - uint position = 0; // Place to put next child relative to origin of the container. + uint position = pre; // Place to put next child relative to origin of the container. for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { uint child_x = x + (rtl ? child_wid->padding.right : child_wid->padding.left); uint child_height = child_wid->current_y; child_wid->AssignSizePosition(sizing, child_x, y + position + child_wid->padding.top, child_wid->current_x, child_height, rtl); - position += child_height + child_wid->padding.Vertical(); + if (child_wid->current_y != 0) { + position += child_height + child_wid->padding.Vertical() + inter; + } } } @@ -2024,7 +2068,7 @@ void NWidgetMatrix::SetupSmallestSize(Window *w, bool init_array) this->resize_y = resize.height; } -void NWidgetMatrix::AssignSizePosition(SizingType, uint x, uint y, uint given_width, uint given_height, bool) +void NWidgetMatrix::AssignSizePosition(SizingType, int x, int y, uint given_width, uint given_height, bool) { assert(given_width >= this->smallest_x && given_height >= this->smallest_y); @@ -2229,6 +2273,24 @@ void NWidgetBackground::SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post) this->child->SetPIP(pip_pre, pip_inter, pip_post); } +/** + * Set additional pre/inter/post space ratios for the background widget. + * + * @param pip_ratio_pre Ratio of additional space in front of the first child widget (above + * for the vertical container, at the left for the horizontal container). + * @param pip_ratio_inter Ratio of additional space between two child widgets. + * @param pip_ratio_post Ratio of additional space after the last child widget (below for the + * vertical container, at the right for the horizontal container). + * @note Using this function implies that the widget has (or will have) child widgets. + */ +void NWidgetBackground::SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_ratio_post) +{ + if (this->child == nullptr) { + this->child = new NWidgetVertical(); + } + this->child->SetPIPRatio(pip_ratio_pre, pip_ratio_inter, pip_ratio_post); +} + void NWidgetBackground::AdjustPaddingForZoom() { if (child != nullptr) child->AdjustPaddingForZoom(); @@ -2302,7 +2364,7 @@ void NWidgetBackground::SetupSmallestSize(Window *w, bool init_array) } } -void NWidgetBackground::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) +void NWidgetBackground::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) { this->StoreSizePosition(sizing, x, y, given_width, given_height); @@ -3262,6 +3324,15 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg break; } + case WPT_PIPRATIO: { + NWidgetPIPContainer *nwc = dynamic_cast(*dest); + if (nwc != nullptr) nwc->SetPIPRatio(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post); + + NWidgetBackground *nwb = dynamic_cast(*dest); + if (nwb != nullptr) nwb->SetPIPRatio(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post); + break; + } + case WPT_SCROLLBAR: { NWidgetCore *nwc = dynamic_cast(*dest); if (nwc != nullptr) { @@ -3309,6 +3380,17 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg return nwid_begin; } +/** + * Test if WidgetType is a container widget. + * @param tp WidgetType to test. + * @return True iff WidgetType is a container widget. + */ +bool IsContainerWidgetType(WidgetType tp) +{ + return tp == NWID_HORIZONTAL || tp == NWID_HORIZONTAL_LTR || tp == NWID_VERTICAL || tp == NWID_MATRIX + || tp == WWT_PANEL || tp == WWT_FRAME || tp == WWT_INSET || tp == NWID_SELECTION; +} + /** * Build a nested widget tree by recursively filling containers with nested widgets read from their parts. * @param nwid_begin Pointer to beginning of nested widget parts. @@ -3335,9 +3417,7 @@ static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NW if (sub_widget == nullptr) break; /* If sub-widget is a container, recursively fill that container. */ - WidgetType tp = sub_widget->type; - if (fill_sub && (tp == NWID_HORIZONTAL || tp == NWID_HORIZONTAL_LTR || tp == NWID_VERTICAL || tp == NWID_MATRIX - || tp == WWT_PANEL || tp == WWT_FRAME || tp == WWT_INSET || tp == NWID_SELECTION)) { + if (fill_sub && IsContainerWidgetType(sub_widget->type)) { NWidgetBase *sub_ptr = sub_widget; nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, &sub_ptr, biggest_index); } diff --git a/src/widget_type.h b/src/widget_type.h index 11f6c92c85..feb11b73df 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -90,6 +90,7 @@ enum WidgetType : uint8 { WPT_DATATIP, ///< Widget part for specifying data and tooltip. WPT_PADDING, ///< Widget part for specifying a padding. WPT_PIPSPACE, ///< Widget part for specifying pre/inter/post space for containers. + WPT_PIPRATIO, ///< Widget part for specifying pre/inter/post ratio for containers. WPT_TEXTSTYLE, ///< Widget part for specifying text colour. WPT_ALIGNMENT, ///< Widget part for specifying text/image alignment. WPT_ENDCONTAINER, ///< Widget part to denote end of a container. @@ -138,7 +139,7 @@ public: virtual void AdjustPaddingForZoom(); virtual void SetupSmallestSize(Window *w, bool init_array) = 0; - virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) = 0; + virtual void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) = 0; virtual void FillNestedArray(NWidgetBase **array, uint length) = 0; @@ -224,7 +225,7 @@ public: } protected: - inline void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height); + inline void StoreSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height); }; /** @@ -253,7 +254,7 @@ inline uint NWidgetBase::GetVerticalStepSize(SizingType sizing) const * @param given_width Width allocated to the widget. * @param given_height Height allocated to the widget. */ -inline void NWidgetBase::StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height) +inline void NWidgetBase::StoreSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height) { this->pos_x = x; this->pos_y = y; @@ -283,7 +284,7 @@ public: bool UpdateVerticalSize(uint min_y); - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override; + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; uint min_x; ///< Minimal horizontal size of only this widget. uint min_y; ///< Minimal vertical size of only this widget. @@ -472,7 +473,7 @@ public: void AdjustPaddingForZoom() override; void SetupSmallestSize(Window *w, bool init_array) override; - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override; + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; void FillNestedArray(NWidgetBase **array, uint length) override; void Draw(const Window *w) override; @@ -503,17 +504,23 @@ public: NWidgetPIPContainer(WidgetType tp, NWidContainerFlags flags = NC_NONE); void AdjustPaddingForZoom() override; - void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post); + void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post); + void SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_rato_post); protected: NWidContainerFlags flags; ///< Flags of the container. - uint8 pip_pre; ///< Amount of space before first widget. - uint8 pip_inter; ///< Amount of space between widgets. - uint8 pip_post; ///< Amount of space after last widget. - - uint8 uz_pip_pre; ///< Unscaled space before first widget. - uint8 uz_pip_inter; ///< Unscaled space between widgets. - uint8 uz_pip_post; ///< Unscaled space after last widget. + uint8_t pip_pre; ///< Amount of space before first widget. + uint8_t pip_inter; ///< Amount of space between widgets. + uint8_t pip_post; ///< Amount of space after last widget. + uint8_t pip_ratio_pre; ///< Ratio of remaining space before first widget. + uint8_t pip_ratio_inter; ///< Ratio of remaining space between widgets. + uint8_t pip_ratio_post; ///< Ratio of remaining space after last widget. + + uint8_t uz_pip_pre; ///< Unscaled space before first widget. + uint8_t uz_pip_inter; ///< Unscaled space between widgets. + uint8_t uz_pip_post; ///< Unscaled space after last widget. + + uint8_t gaps; ///< Number of gaps between widgets. }; /** @@ -525,7 +532,7 @@ public: NWidgetHorizontal(NWidContainerFlags flags = NC_NONE); void SetupSmallestSize(Window *w, bool init_array) override; - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override; + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; }; /** @@ -536,7 +543,7 @@ class NWidgetHorizontalLTR : public NWidgetHorizontal { public: NWidgetHorizontalLTR(NWidContainerFlags flags = NC_NONE); - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override; + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; }; /** @@ -548,7 +555,7 @@ public: NWidgetVertical(NWidContainerFlags flags = NC_NONE); void SetupSmallestSize(Window *w, bool init_array) override; - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override; + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; }; /** @@ -570,7 +577,7 @@ public: void SetScrollbar(Scrollbar *sb); void SetupSmallestSize(Window *w, bool init_array) override; - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override; + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; void FillNestedArray(NWidgetBase **array, uint length) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; @@ -619,11 +626,12 @@ public: ~NWidgetBackground(); void Add(NWidgetBase *nwid); - void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post); + void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post); + void SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_ratio_post); void AdjustPaddingForZoom() override; void SetupSmallestSize(Window *w, bool init_array) override; - void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override; + void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; void FillNestedArray(NWidgetBase **array, uint length) override; @@ -1273,6 +1281,25 @@ static inline NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post) return part; } +/** + * Widget part function for setting a pre/inter/post ratio. + * @param pre The ratio of space before the first widget. + * @param inter The ratio of space between widgets. + * @param post The ratio of space after the last widget. + * @ingroup NestedWidgetParts + */ +static inline NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post) +{ + NWidgetPart part; + + part.type = WPT_PIPRATIO; + part.u.pip.pre = ratio_pre; + part.u.pip.inter = ratio_inter; + part.u.pip.post = ratio_post; + + return part; +} + /** * Attach a scrollbar to a widget. * The scrollbar is controlled when using the mousewheel on the widget. @@ -1341,6 +1368,7 @@ static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr) return part; } +bool IsContainerWidgetType(WidgetType tp); NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetContainer *container); NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetStacked **shade_select); diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 4227220af5..e169c5cc84 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -106,7 +106,7 @@ static const NWidgetPart _nested_dropdown_menu_widgets[] = { EndContainer(), }; -static WindowDesc _dropdown_desc( +static WindowDesc _dropdown_desc(__FILE__, __LINE__, WDP_MANUAL, nullptr, 0, 0, WC_DROPDOWN_MENU, WC_NONE, WDF_NO_FOCUS, @@ -467,9 +467,9 @@ void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, if ((nwi->type & WWT_MASK) == NWID_BUTTON_DROPDOWN) { nwi->disp_flags |= ND_DROPDOWN_ACTIVE; } else { - w->LowerWidget(button); + nwi->SetLowered(true); } - w->SetWidgetDirty(button); + nwi->SetDirty(w); if (width != 0) { if (_current_text_dir == TD_RTL) { diff --git a/src/widgets/industry_widget.h b/src/widgets/industry_widget.h index 9f5762a534..ee74d90d54 100644 --- a/src/widgets/industry_widget.h +++ b/src/widgets/industry_widget.h @@ -39,7 +39,8 @@ enum IndustryDirectoryWidgets { WID_ID_FILTER_BY_PROD_CARGO, ///< Produced cargo filter dropdown list. WID_ID_FILTER, ///< Textbox to filter industry name. WID_ID_INDUSTRY_LIST, ///< Industry list. - WID_ID_SCROLLBAR, ///< Scrollbar of the list. + WID_ID_HSCROLLBAR, ///< Horizontal scrollbar of the list. + WID_ID_VSCROLLBAR, ///< Vertical scrollbar of the list. }; /** Widgets of the #IndustryCargoesWindow class */ diff --git a/src/widgets/newgrf_widget.h b/src/widgets/newgrf_widget.h index 2d39665447..da4e4d584d 100644 --- a/src/widgets/newgrf_widget.h +++ b/src/widgets/newgrf_widget.h @@ -15,6 +15,7 @@ /** Widgets of the #NewGRFParametersWindow class. */ enum NewGRFParametersWidgets { + WID_NP_CAPTION, ///< Caption of the window. WID_NP_SHOW_NUMPAR, ///< #NWID_SELECTION to optionally display #WID_NP_NUMPAR. WID_NP_NUMPAR_DEC, ///< Button to decrease number of parameters. WID_NP_NUMPAR_INC, ///< Button to increase number of parameters. diff --git a/src/widgets/settings_widget.h b/src/widgets/settings_widget.h index 5439e6eb79..a7378ab4d1 100644 --- a/src/widgets/settings_widget.h +++ b/src/widgets/settings_widget.h @@ -27,6 +27,7 @@ enum GameOptionsWidgets { WID_GO_GUI_SCALE_BEVEL_BUTTON, ///< Toggle for chunky bevels. WID_GO_GUI_SCALE_MAIN_TOOLBAR, ///< Toggle for bigger main toolbar. WID_GO_BASE_GRF_DROPDOWN, ///< Use to select a base GRF. + WID_GO_BASE_GRF_PARAMETERS, ///< Base GRF parameters. WID_GO_BASE_GRF_STATUS, ///< Info about missing files etc. WID_GO_BASE_GRF_TEXTFILE, ///< Open base GRF readme, changelog (+1) or license (+2). WID_GO_BASE_GRF_DESCRIPTION = WID_GO_BASE_GRF_TEXTFILE + TFT_CONTENT_END, ///< Description of selected base GRF. diff --git a/src/window.cpp b/src/window.cpp index 33a6304eb0..a91ff3c499 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -100,9 +100,11 @@ static std::vector *_window_descs = nullptr; std::string _windows_file; /** Window description constructor. */ -WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad, +WindowDesc::WindowDesc(const char * const file, const int line, WindowPosition def_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad, WindowClass window_class, WindowClass parent_class, uint32 flags, const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, HotkeyList *hotkeys, WindowDesc *ini_parent) : + file(file), + line(line), default_pos(def_pos), cls(window_class), parent_cls(parent_class), @@ -232,7 +234,7 @@ void Window::DisableAllWidgetHighlight() if (nwid->IsHighlighted()) { nwid->SetHighlighted(TC_INVALID); - this->SetWidgetDirty(i); + nwid->SetDirty(this); } } @@ -252,7 +254,7 @@ void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour if (nwid == nullptr) return; nwid->SetHighlighted(highlighted_colour); - this->SetWidgetDirty(widget_index); + nwid->SetDirty(this); if (highlighted_colour != TC_INVALID) { /* If we set a highlight, the window has a highlight */ diff --git a/src/window_gui.h b/src/window_gui.h index a3e48f3791..34d828655d 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -54,8 +54,10 @@ struct WidgetDimensions { RectPadding captiontext; ///< Offsets of text within a caption. RectPadding dropdowntext; ///< Offsets of text within a dropdown widget. RectPadding modalpopup; ///< Padding for a modal popup. + RectPadding picker; ///< Padding for a picker (dock, station, etc) window. int pressed; ///< Offset for contents of depressed widget. + int vsep_picker; ///< Vertical spacing of picker-window widgets. int vsep_normal; ///< Normal vertical spacing. int vsep_wide; ///< Wide vertical spacing. int hsep_normal; ///< Normal horizontal spacing. @@ -118,12 +120,14 @@ struct WindowDescPreferences { */ struct WindowDesc { - WindowDesc(WindowPosition default_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad, + WindowDesc(const char * const file, const int line, WindowPosition default_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad, WindowClass window_class, WindowClass parent_class, uint32 flags, const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, HotkeyList *hotkeys = nullptr, WindowDesc *ini_parent = nullptr); ~WindowDesc(); + const char * const file; ///< Source file of this definition + const int line; ///< Source line of this definition WindowPosition default_pos; ///< Preferred position of the window. @see WindowPosition() WindowClass cls; ///< Class of the window, @see WindowClass. WindowClass parent_cls; ///< Class of the parent window. @see WindowClass diff --git a/src/zoning_gui.cpp b/src/zoning_gui.cpp index e83f01fa71..8f9bb0b7c0 100644 --- a/src/zoning_gui.cpp +++ b/src/zoning_gui.cpp @@ -172,7 +172,7 @@ static const NWidgetPart _nested_zoning_widgets[] = { EndContainer() }; -static WindowDesc _zoning_desc ( +static WindowDesc _zoning_desc (__FILE__, __LINE__, WDP_CENTER, "zoning_gui", 0, 0, WC_ZONING_TOOLBAR, WC_NONE, 0,