diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 0c1c64d578..981921124a 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -112,7 +112,7 @@ jobs: name: Linux (${{ matrix.name }}) - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: CC: ${{ matrix.compiler }} CXX: ${{ matrix.cxxcompiler }} @@ -128,6 +128,14 @@ jobs: with: ref: ${{ github.event.inputs.ref }} + - name: Setup vcpkg caching + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') + - name: Install dependencies run: | echo "::group::Update apt" @@ -147,6 +155,16 @@ jobs: ${{ matrix.libraries }} \ zlib1g-dev \ # EOF + + echo "::group::Install vcpkg dependencies" + + # Disable vcpkg integration, as we mostly use system libraries. + mv vcpkg.json vcpkg-disabled.json + + # We only use breakpad from vcpkg, as its CMake files + # are a bit special. So the Ubuntu's variant doesn't work. + #vcpkg install breakpad + echo "::endgroup::" env: DEBIAN_FRONTEND: noninteractive @@ -185,10 +203,15 @@ jobs: - name: Test run: | - cd build - ctest -j $(nproc) --timeout 120 + ( + cd build + ctest -j $(nproc) --timeout 120 + ) + + # Re-enable vcpkg. + mv vcpkg-disabled.json vcpkg.json - # Check no tracked files have been modified + # Check no tracked files have been modified. git diff --exit-code macos: @@ -216,38 +239,13 @@ jobs: with: ref: ${{ github.event.inputs.ref }} - - name: Install dependencies - env: - HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_NO_INSTALL_CLEANUP: 1 - run: | - brew install \ - pkg-config \ - # EOF - - - name: Prepare cache key - id: key - run: | - echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 with: - path: /usr/local/share/vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} - - - name: Prepare vcpkg - run: | - vcpkg install --triplet=${{ matrix.arch }}-osx \ - curl \ - liblzma \ - libpng \ - lzo \ - zlib \ - zstd \ - # EOF + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - name: Install OpenGFX run: | @@ -312,33 +310,13 @@ jobs: with: ref: ${{ github.event.inputs.ref }} - - name: Prepare cache key - id: key - shell: powershell - run: | - # Work around caching failure with GNU tar - New-Item -Type Junction -Path vcpkg -Target c:\vcpkg - - Write-Output "image=$env:ImageOS-$env:ImageVersion" >> $env:GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 with: - path: vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} - - - name: Prepare vcpkg - shell: bash - run: | - vcpkg install --triplet=${{ matrix.arch }}-windows-static \ - liblzma \ - libpng \ - lzo \ - zlib \ - zstd \ - # EOF + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - name: Install OpenGFX shell: bash diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index d94b25c409..c398e6c0e3 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -12,16 +12,11 @@ jobs: linux: name: Linux (Generic) - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest container: # manylinux2014 is based on CentOS 7, but already has a lot of things # installed and preconfigured. It makes it easier to build OpenTTD. image: quay.io/pypa/manylinux2014_x86_64 - volumes: - - /usr/local/share/vcpkg:/vcpkg - env: - ImageOS: ${{ env.ImageOS }} - ImageVersion: ${{ env.ImageVersion }} steps: - name: Download source @@ -33,18 +28,37 @@ jobs: run: | tar -xf source.tar.gz --strip-components=1 - - name: Prepare cache key - id: key + # curl is too old for most of the tools to work properly. For example, + # rust-toolchain doesn't work properly, neither vcpkg caching. + # The easier solution here is to upgrade curl. + - name: Update curl run: | - echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT + yum install -y \ + openssl-devel \ + # EOF + + mkdir /curl + cd /curl + curl -o curl-7.81.0.zip https://curl.se/download/curl-7.81.0.zip + unzip curl-7.81.0.zip + cd curl-7.81.0 + ./configure --with-ssl --with-zlib --prefix=/usr --libdir=/usr/lib64 + make -j $(nproc) + make install + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable - - name: Enable vcpkg cache - uses: actions/cache@v3 + - name: Enable Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Setup vcpkg caching + uses: actions/github-script@v6 with: - path: /vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-release-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-release + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - name: Install dependencies run: | @@ -84,6 +98,14 @@ jobs: cmake --build . -j $(nproc) cmake --install . ) + + # The container we use is old enough, that it doesn't know SHF_COMPRESSED. + # But, breakpad needs this symbol to exist. So we patch it in our system + # libraries. + ( + cd / + patch -p1 < ${GITHUB_WORKSPACE}/os/linux/shf-compressed.patch + ) echo "::endgroup::" echo "::group::Install audio drivers" @@ -100,29 +122,22 @@ jobs: # We use vcpkg for our dependencies, to get more up-to-date version. echo "::group::Install vcpkg and dependencies" - # Make Python3 available for other packages. - /vcpkg/vcpkg install python3 - ln -sf /vcpkg/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3 - - # SDL2 needs dbus, but dbus default install comes with libsystemd - # and some of libsystemd deps fail to build on our quite old linux. - # So just install basic dbus without any extra deps. - /vcpkg/vcpkg install dbus[core] - - # Now we can install OpenTTD dependencies - /vcpkg/vcpkg install \ - curl[http2] \ - fontconfig \ - freetype \ - harfbuzz \ - icu \ - liblzma \ - libpng \ - lzo \ - sdl2 \ - zlib \ - zstd \ - # EOF + git clone https://github.com/microsoft/vcpkg /vcpkg + + ( + cd /vcpkg + ./bootstrap-vcpkg.sh -disableMetrics + ) + + # Make Python3 available for other packages. This needs to be done + # first, as otherwise dependencies fail to build because Python3 is + # not available. + ( + cd / + + /vcpkg/vcpkg install python3 + ln -sf /vcpkg/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3 + ) echo "::endgroup::" - name: Install GCC problem matcher diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index f4efa77816..87f57a6866 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -12,7 +12,7 @@ jobs: macos: name: MacOS - runs-on: macos-12 + runs-on: macos-latest env: MACOSX_DEPLOYMENT_TARGET: 10.13 @@ -26,6 +26,20 @@ jobs: run: | tar -xf source.tar.gz --strip-components=1 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Enable Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Setup vcpkg caching + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') + - name: Install dependencies env: HOMEBREW_NO_AUTO_UPDATE: 1 @@ -33,38 +47,6 @@ jobs: run: | brew install \ pandoc \ - pkg-config \ - # EOF - - - name: Prepare cache key - id: key - run: | - echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 - with: - path: /usr/local/share/vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-release-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-release - ${{ steps.key.outputs.image }}-vcpkg-x64 - - - name: Prepare vcpkg - run: | - vcpkg install \ - curl:x64-osx \ - curl:arm64-osx \ - liblzma:x64-osx \ - liblzma:arm64-osx \ - libpng:x64-osx \ - libpng:arm64-osx \ - lzo:x64-osx \ - lzo:arm64-osx \ - zlib:x64-osx \ - zlib:arm64-osx \ - zstd:x64-osx \ - zstd:arm64-osx \ # EOF - name: Install GCC problem matcher diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 6e4c1d871a..2df2fe8ec7 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -39,45 +39,24 @@ jobs: run: | tar -xf source.tar.gz --strip-components=1 - - name: Install dependencies - shell: bash - run: | - choco install pandoc + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable - - name: Prepare cache key - id: key - shell: powershell - run: | - # Work around caching failure with GNU tar - New-Item -Type Junction -Path vcpkg -Target c:\vcpkg + - name: Enable Rust cache + uses: Swatinem/rust-cache@v2 - Write-Output "image=$env:ImageOS-$env:ImageVersion" >> $env:GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 with: - path: vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - - name: Prepare vcpkg + - name: Install dependencies shell: bash run: | - vcpkg install --triplet=${{ matrix.arch }}-windows-static \ - liblzma \ - libpng \ - lzo \ - zlib \ - zstd \ - # EOF - - # arm64-windows-static is not (yet) supported for breakpad. - if [ "${{ matrix.arch }}" != "arm64" ]; then - vcpkg install --triplet=${{ matrix.arch }}-windows-static \ - breakpad \ - # EOF - fi + choco install pandoc - name: Install MSVC problem matcher uses: ammaraskar/msvc-problem-matcher@master diff --git a/.gitignore b/.gitignore index e6e98437ce..2092b6ec50 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ docs/aidocs/* docs/gamedocs/* docs/source/* /out +/vcpkg_installed *.tmp diff --git a/COMPILING.md b/COMPILING.md index c9e02ea12e..86108cf42b 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -59,8 +59,8 @@ the `static` versions, and OpenTTD currently needs the following dependencies: To install both the x64 (64bit) and x86 (32bit) variants (though only one is necessary), you can use: ```ps -.\vcpkg install liblzma:x64-windows-static zstd:x64-windows-static libpng:x64-windows-static lzo:x64-windows-static zlib:x64-windows-static -.\vcpkg install liblzma:x86-windows-static zstd:x86-windows-static libpng:x86-windows-static lzo:x86-windows-static zlib:x86-windows-static +.\vcpkg install --triplet=x64-windows-static +.\vcpkg install --triplet=x86-windows-static ``` You can open the folder (as a CMake project). CMake will be detected, and you can compile from there. diff --git a/os/linux/shf-compressed.patch b/os/linux/shf-compressed.patch new file mode 100644 index 0000000000..6ec7865b31 --- /dev/null +++ b/os/linux/shf-compressed.patch @@ -0,0 +1,10 @@ +--- a/usr/include/elf.h 2023-12-30 13:46:27.038645199 +0100 ++++ b/usr/include/elf.h 2023-12-30 13:46:42.278641893 +0100 +@@ -365,6 +365,7 @@ + required */ + #define SHF_GROUP (1 << 9) /* Section is member of a group. */ + #define SHF_TLS (1 << 10) /* Section hold thread-local data. */ ++#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */ + #define SHF_MASKOS 0x0ff00000 /* OS-specific. */ + #define SHF_MASKPROC 0xf0000000 /* Processor-specific */ + #define SHF_ORDERED (1 << 30) /* Special ordering requirement diff --git a/regression/regression/main.nut b/regression/regression/main.nut index 7621c49c6f..c829fc33f4 100644 --- a/regression/regression/main.nut +++ b/regression/regression/main.nut @@ -1812,10 +1812,17 @@ function Regression::Vehicle() print(" GetLastErrorString(): " + AIError.GetLastErrorString()); local list = AIVehicleList(); + local in_depot = AIVehicleList(AIVehicle.IsInDepot); + local IsType = function(vehicle_id, type) { + return AIVehicle.GetVehicleType(vehicle_id) == type; + } + local rv_list = AIVehicleList(IsType, AIVehicle.VT_ROAD); print(""); print("--VehicleList--"); print(" Count(): " + list.Count()); + print(" InDepot Count(): " + in_depot.Count()); + print(" RoadVehicle Count(): " + rv_list.Count()); list.Valuate(AIVehicle.GetLocation); print(" Location ListDump:"); for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) { diff --git a/regression/regression/result.txt b/regression/regression/result.txt index 3dd8b60746..0aaf488bbb 100644 --- a/regression/regression/result.txt +++ b/regression/regression/result.txt @@ -9389,6 +9389,8 @@ ERROR: IsEnd() is invalid as Begin() is never called --VehicleList-- Count(): 5 + InDepot Count(): 4 + RoadVehicle Count(): 2 Location ListDump: 13 => 33417 12 => 33417 diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 12a7fcaac2..e53045bf1e 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -114,7 +114,7 @@ struct AIConfigWindow : public Window { this->Window::Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_AIC_NUMBER: @@ -127,7 +127,7 @@ struct AIConfigWindow : public Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_AIC_DECREASE_NUMBER: @@ -164,7 +164,7 @@ struct AIConfigWindow : public Window { return slot < max_slot; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_AIC_LIST: { @@ -189,7 +189,7 @@ struct AIConfigWindow : public Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget >= WID_AIC_TEXTFILE && widget < WID_AIC_TEXTFILE + TFT_CONTENT_END) { if (this->selected_slot == INVALID_COMPANY || AIConfig::GetConfig(this->selected_slot) == nullptr) return; diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 21f8135e5c..d43fbab240 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -106,7 +106,7 @@ struct BuildAirToolbarWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_AT_AIRPORT: @@ -283,7 +283,7 @@ public: this->PickerWindowBase::Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_AP_CLASS_DROPDOWN: @@ -308,7 +308,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_AP_CLASS_DROPDOWN: { @@ -369,7 +369,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_AP_AIRPORT_LIST: { @@ -479,7 +479,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_AP_CLASS_DROPDOWN: @@ -554,7 +554,7 @@ public: this->SelectOtherAirport(-1); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget == WID_AP_CLASS_DROPDOWN) { _selected_airport_class = (AirportClassID)index; diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 1bc4949e94..154cc6110e 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -315,7 +315,7 @@ public: this->sel_group = id_g; } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_RV_SORT_ASCENDING_DESCENDING: { @@ -402,7 +402,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_RV_CAPTION: @@ -457,7 +457,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_RV_SORT_ASCENDING_DESCENDING: @@ -541,7 +541,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_RV_SORT_ASCENDING_DESCENDING: @@ -656,7 +656,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_RV_SORT_DROPDOWN: @@ -698,7 +698,7 @@ public: } } - bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { if (widget != WID_RV_TRAIN_WAGONREMOVE_TOGGLE) return false; diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index 4aa3f74156..d5633c4760 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -56,7 +56,7 @@ public: ResizeWindow(this, _screen.width, _screen.height); } - void DrawWidget(const Rect &r, int) const override + void DrawWidget(const Rect &r, WidgetID) const override { GfxFillRect(r.left, r.top, r.right, r.bottom, 4, FILLRECT_OPAQUE); GfxFillRect(r.left, r.top, r.right, r.bottom, 0, FILLRECT_CHECKER); @@ -96,7 +96,7 @@ public: this->Window::Close(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_BEM_MESSAGE) { *size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR); @@ -105,14 +105,14 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_BEM_MESSAGE) { DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext), STR_MISSING_GRAPHICS_ERROR, TC_FROMSTRING, SA_CENTER); } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget == WID_BEM_QUIT) { _exit_game = true; @@ -210,7 +210,7 @@ public: this->Window::Close(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { /* We cache the button size. This is safe as no reinit can happen here. */ if (this->button_size.width == 0) { @@ -233,14 +233,14 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_BAFD_QUESTION) return; DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext), STR_MISSING_GRAPHICS_SET_MESSAGE, TC_FROMSTRING, SA_CENTER); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_BAFD_YES: diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index af836dec64..1c968a3c22 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -189,7 +189,7 @@ public: this->Window::Close(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_BBS_DROPDOWN_ORDER: { @@ -236,7 +236,7 @@ public: return corner; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_BBS_DROPDOWN_ORDER: @@ -270,7 +270,7 @@ public: return ES_NOT_HANDLED; } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { default: break; @@ -294,7 +294,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget == WID_BBS_DROPDOWN_CRITERIA && this->bridges.SortType() != index) { this->bridges.SetSortType(index); diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index b8e90c0c4e..23bd2fa084 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1858,7 +1858,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase { return list; } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_BV_SORT_ASCENDING_DESCENDING: @@ -1987,7 +1987,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase { this->eng_list.ForceRebuild(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_BV_CAPTION: @@ -2022,7 +2022,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_BV_LIST: @@ -2063,7 +2063,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_BV_LIST: @@ -2124,7 +2124,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase { DoCommandP(0, this->rename_engine, 0, CMD_RENAME_ENGINE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type), nullptr, str); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_BV_SORT_DROPDOWN: @@ -2154,7 +2154,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase { this->vscroll->SetCapacityFromWidget(this, WID_BV_LIST); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_BV_FILTER) { this->string_filter.SetFilterTerm(this->vehicle_editbox.text.buf); @@ -2730,7 +2730,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { } } - bool OnClickList(Point pt, int widget, PanelState &state, bool column) + bool OnClickList(Point pt, WidgetID widget, PanelState &state, bool column) { const uint i = state.vscroll->GetScrolledRowFromWidget(pt.y, this, widget); const size_t num_items = state.eng_list.size(); @@ -2757,7 +2757,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { return false; } - void OnClick(Point pt, int widget, int click_count) override + void OnClick(Point pt, WidgetID widget, int click_count) override { if (widget == WID_BV_COMB_BUILD) { widget = !this->wagon_selected ? WID_BV_BUILD_LOCO : WID_BV_BUILD_WAGON; @@ -2918,7 +2918,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_BV_CAPTION: { @@ -2994,7 +2994,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { } } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_BV_LIST_LOCO: { @@ -3052,7 +3052,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_BV_LIST_LOCO: { @@ -3146,7 +3146,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_BV_SORT_DROPDOWN_LOCO: { @@ -3199,7 +3199,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { this->wagon.vscroll->SetCapacityFromWidget(this, WID_BV_LIST_WAGON); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_BV_FILTER_LOCO) { this->loco.string_filter.SetFilterTerm(this->loco.vehicle_editbox.text.buf); diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index b9782d34f6..fa1101d0d5 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -251,7 +251,7 @@ struct CheatWindow : Window { this->icon = GetSpriteSize(SPR_COMPANY_ICON); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_C_PANEL) return; @@ -326,7 +326,7 @@ struct CheatWindow : Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_C_PANEL) return; @@ -379,7 +379,7 @@ struct CheatWindow : Window { size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lines; } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget != WID_C_PANEL) return; diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 44442d3264..3cce6e7803 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -344,7 +344,7 @@ struct CompanyFinancesWindow : Window { this->owner = (Owner)this->window_number; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CF_CAPTION: @@ -385,7 +385,7 @@ struct CompanyFinancesWindow : Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_CF_EXPS_CATEGORY: @@ -412,7 +412,7 @@ struct CompanyFinancesWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_CF_EXPS_CATEGORY: @@ -481,7 +481,7 @@ struct CompanyFinancesWindow : Window { this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_CF_TOGGLE_SIZE: // toggle size @@ -550,7 +550,7 @@ struct CompanyFinancesWindow : Window { } } - bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { switch (widget) { case WID_CF_INCREASE_LOAN: { @@ -796,7 +796,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_SCL_SPACER_DROPDOWN: { @@ -862,7 +862,7 @@ public: this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SCL_CAPTION: @@ -902,7 +902,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_SCL_MATRIX) return; @@ -974,7 +974,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { /* Livery Class buttons */ @@ -1053,7 +1053,7 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_SCL_MATRIX); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { bool local = (CompanyID)this->window_number == _local_company; if (!local) return; @@ -1392,7 +1392,7 @@ class SelectCompanyManagerFaceWindow : public Window * @param val the value which will be displayed * @param is_bool_widget is it a bool button */ - void SetFaceStringParameters(byte widget_index, uint8 val, bool is_bool_widget) const + void SetFaceStringParameters(WidgetID widget_index, uint8_t val, bool is_bool_widget) const { const NWidgetCore *nwi_widget = this->GetWidget(widget_index); if (nwi_widget->IsDisabled()) { @@ -1476,7 +1476,7 @@ public: this->number_dim = number_dim; } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT: @@ -1579,7 +1579,7 @@ public: this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SCMF_HAS_MOUSTACHE_EARRING: @@ -1640,7 +1640,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SCMF_FACE: @@ -1649,7 +1649,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { /* Toggle size, advanced/simple face selection */ @@ -1895,7 +1895,7 @@ struct CompanyInfrastructureWindow : Window return total; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CI_CAPTION: @@ -1904,7 +1904,7 @@ struct CompanyInfrastructureWindow : Window } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { const Company *c = Company::Get((CompanyID)this->window_number); @@ -2026,7 +2026,7 @@ struct CompanyInfrastructureWindow : Window } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_CI_DESC && widget != WID_CI_COUNT) return; @@ -2384,7 +2384,7 @@ struct CompanyWindow : Window this->DrawWidgets(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_C_FACE: @@ -2523,7 +2523,7 @@ struct CompanyWindow : Window } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { const Company *c = Company::Get((CompanyID)this->window_number); switch (widget) { @@ -2576,7 +2576,7 @@ struct CompanyWindow : Window } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_C_CAPTION: @@ -2594,7 +2594,7 @@ struct CompanyWindow : Window } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_C_NEW_FACE: DoSelectCompanyManagerFace(this); break; @@ -2823,7 +2823,7 @@ struct BuyCompanyWindow : Window { this->Window::Close(); } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_BC_FACE: @@ -2839,7 +2839,7 @@ struct BuyCompanyWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_BC_CAPTION: @@ -2849,7 +2849,7 @@ struct BuyCompanyWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_BC_FACE: { @@ -2868,7 +2868,7 @@ struct BuyCompanyWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_BC_NO: diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 51c6b624ef..68d88058b5 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -281,7 +281,7 @@ struct IConsoleWindow : Window return ES_HANDLED; } - void InsertTextString(int, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) override + void InsertTextString(WidgetID, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) override { if (_iconsole_cmdline.InsertString(str, marked, caret, insert_location, replacement_end)) { IConsoleWindow::scroll = 0; diff --git a/src/date_gui.cpp b/src/date_gui.cpp index efc9156010..e3e066ce86 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -71,7 +71,7 @@ struct SetDateWindow : Window { * Helper function to construct the dropdown. * @param widget the dropdown widget to create the dropdown for */ - virtual void ShowDateDropDown(int widget) + virtual void ShowDateDropDown(WidgetID widget) { int selected; DropDownList list; @@ -105,7 +105,7 @@ struct SetDateWindow : Window { ShowDropDownList(this, std::move(list), selected, widget); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { Dimension d = {0, 0}; switch (widget) { @@ -134,7 +134,7 @@ struct SetDateWindow : Window { *size = d; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SD_DAY: SetDParam(0, this->date.day - 1 + STR_DAY_NUMBER_1ST); break; @@ -143,7 +143,7 @@ struct SetDateWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_SD_DAY: @@ -160,7 +160,7 @@ struct SetDateWindow : Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_SD_DAY: @@ -195,7 +195,7 @@ struct SetMinutesWindow : SetDateWindow * Helper function to construct the dropdown. * @param widget the dropdown widget to create the dropdown for */ - virtual void ShowDateDropDown(int widget) override + virtual void ShowDateDropDown(WidgetID widget) override { int selected; DropDownList list; @@ -224,7 +224,7 @@ struct SetMinutesWindow : SetDateWindow ShowDropDownList(this, std::move(list), selected, widget); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { Dimension d = {0, 0}; switch (widget) { @@ -250,7 +250,7 @@ struct SetMinutesWindow : SetDateWindow *size = d; } - virtual void SetStringParameters(int widget) const override + virtual void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SD_DAY: SetDParam(0, this->minutes.ClockMinute()); break; @@ -258,7 +258,7 @@ struct SetMinutesWindow : SetDateWindow } } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_SD_DAY: @@ -276,7 +276,7 @@ struct SetMinutesWindow : SetDateWindow } } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { const TickMinutes now = _settings_time.NowInTickMinutes(); TickMinutes current = 0; diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index fe6f258772..69335164e6 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -116,7 +116,7 @@ protected: virtual void DrawDeparturesListItems(const Rect &r) const; void DeleteDeparturesList(DepartureList* list); - void ToggleCargoFilter(int widget, bool &flag) + void ToggleCargoFilter(WidgetID widget, bool &flag) { flag = !flag; this->SetWidgetLoweredState(widget, flag); @@ -302,7 +302,7 @@ public: } } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_DB_LIST: @@ -313,7 +313,7 @@ public: } } - virtual void SetStringParameters(int widget) const override + virtual void SetStringParameters(WidgetID widget) const override { if (widget == WID_DB_CAPTION) { const Station *st = Station::Get(this->station); @@ -321,7 +321,7 @@ public: } } - virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override + virtual bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { switch (widget) { case WID_DB_SHOW_TRAINS: @@ -337,7 +337,7 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_DB_SHOW_TRAINS: // Show trains to this station @@ -532,7 +532,7 @@ public: this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_DB_LIST: diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 477d8aef93..72e9b58646 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -260,7 +260,7 @@ struct DepotWindow : Window { VehicleID vehicle_over; ///< Rail vehicle over which another one is dragged, \c INVALID_VEHICLE if none. VehicleType type; bool generate_list; - int hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress. + WidgetID hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress. VehicleList vehicle_list; VehicleList wagon_list; uint unitnumber_digits; @@ -365,7 +365,7 @@ struct DepotWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_D_MATRIX) return; @@ -423,7 +423,7 @@ struct DepotWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_D_CAPTION) return; @@ -655,7 +655,7 @@ struct DepotWindow : Window { this->flag_size = maxdim(GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED), GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING)); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_D_MATRIX: { @@ -759,7 +759,7 @@ struct DepotWindow : Window { this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_D_MATRIX: // List @@ -841,7 +841,7 @@ struct DepotWindow : Window { DoCommandP(0, this->GetDepotIndex(), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), nullptr, str); } - bool OnRightClick([[maybe_unused]] Point pt, int widget) override + bool OnRightClick([[maybe_unused]] Point pt, WidgetID widget) override { if (widget != WID_D_MATRIX) return false; @@ -991,7 +991,7 @@ struct DepotWindow : Window { } } - void OnMouseDrag(Point pt, int widget) override + void OnMouseDrag(Point pt, WidgetID widget) override { if (this->sel == INVALID_VEHICLE) return; if (widget != this->hovered_widget) { @@ -1042,7 +1042,7 @@ struct DepotWindow : Window { this->SetWidgetDirty(widget); } - void OnDragDrop(Point pt, int widget) override + void OnDragDrop(Point pt, WidgetID widget) override { switch (widget) { case WID_D_MATRIX: { diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 32b25c9e6b..1e55336307 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -146,7 +146,7 @@ struct BuildDocksToolbarWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_DT_CANAL: // Build canal button @@ -457,7 +457,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case BDSW_LT_OFF: @@ -529,7 +529,7 @@ public: UpdateDocksDirection(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_BDD_X: @@ -540,7 +540,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { DrawPixelInfo tmp_dpi; @@ -564,7 +564,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_BDD_X: diff --git a/src/engine.cpp b/src/engine.cpp index 91a1973f4f..845a2759f0 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -736,7 +736,7 @@ void SetYearEngineAgingStops() * @param aging_date The date used for age calculations. * @param seed Random seed. */ -void StartupOneEngine(Engine *e, Date aging_date, uint32 seed, Date no_introduce_after_date) +void StartupOneEngine(Engine *e, Date aging_date, const YearMonthDay &aging_ymd, uint32 seed, Date no_introduce_after_date) { const EngineInfo *ei = &e->info; @@ -760,7 +760,11 @@ void StartupOneEngine(Engine *e, Date aging_date, uint32 seed, Date no_introduce * Note: TTDP uses fixed 1922 */ e->intro_date = ei->base_intro <= ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (DateDelta)GB(r, 0, 9) + ei->base_intro; if (e->intro_date <= _date && e->intro_date <= no_introduce_after_date) { - e->age = (aging_date - e->intro_date).base() >> 5; + YearMonthDay intro_ymd = ConvertDateToYMD(e->intro_date); + int aging_months = aging_ymd.year * 12 + aging_ymd.month; + int intro_months = intro_ymd.year * 12 + intro_ymd.month; + if (intro_ymd.day > 1) intro_months++; // Engines are introduced at the first month start at/after intro date. + e->age = aging_months - intro_months; e->company_avail = MAX_UVALUE(CompanyMask); e->flags |= ENGINE_AVAILABLE; } @@ -821,6 +825,7 @@ void StartupEngines() aging_stop_year = std::min(aging_stop_year, std::max(_settings_game.vehicle.no_introduce_vehicles_after, _settings_game.vehicle.no_expire_vehicles_after)); } const Date aging_date = std::min(_date, ConvertYMDToDate(aging_stop_year, 0, 1)); + const YearMonthDay aging_ymd = ConvertDateToYMD(aging_date); Date no_introduce_after_date = INT_MAX; if (_settings_game.vehicle.no_introduce_vehicles_after > 0) { @@ -830,7 +835,7 @@ void StartupEngines() uint32 seed = Random(); for (Engine *e : Engine::Iterate()) { - StartupOneEngine(e, aging_date, seed, no_introduce_after_date); + StartupOneEngine(e, aging_date, aging_ymd, seed, no_introduce_after_date); } for (Engine *e : Engine::Iterate()) { CalcEngineReliability(e, false); diff --git a/src/engine_func.h b/src/engine_func.h index e8658312e1..174622c0de 100644 --- a/src/engine_func.h +++ b/src/engine_func.h @@ -27,7 +27,7 @@ bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company); bool IsEngineRefittable(EngineID engine); void SetYearEngineAgingStops(); void CalcEngineReliability(Engine *e, bool new_month); -void StartupOneEngine(Engine *e, Date aging_date, uint32 seed, Date no_introduce_after_date); +void StartupOneEngine(Engine *e, Date aging_date, const YearMonthDay &aging_ymd, uint32 seed, Date no_introduce_after_date); uint GetTotalCapacityOfArticulatedParts(EngineID engine); diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index d56782d125..250dfcaaaa 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -77,7 +77,7 @@ struct EnginePreviewWindow : Window { this->flags |= WF_STICKY; } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_EP_QUESTION) return; @@ -104,7 +104,7 @@ struct EnginePreviewWindow : Window { size->height += GetStringHeight(GetEngineInfoString(engine), size->width); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_EP_QUESTION) return; @@ -122,7 +122,7 @@ struct EnginePreviewWindow : Window { DrawStringMultiLine(r.left, r.right, y, r.bottom, GetEngineInfoString(engine), TC_FROMSTRING, SA_CENTER); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_EP_YES: diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 18f4a078e5..fa6304af1f 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -178,7 +178,7 @@ public: this->InitNested(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_EM_MESSAGE: { @@ -245,12 +245,12 @@ public: if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) this->Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_EM_CAPTION) CopyInDParam(this->params); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_EM_FACE: { diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 5153a51266..a96d178b71 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -418,7 +418,7 @@ public: this->Window::Close(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SL_SORT_BYNAME: @@ -587,7 +587,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_SL_BACKGROUND: @@ -620,7 +620,7 @@ public: this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_SL_SORT_BYNAME: // Sort save names by name @@ -742,7 +742,7 @@ public: } } - void OnMouseOver([[maybe_unused]] Point pt, int widget) override + void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override { if (widget == WID_SL_DRIVES_DIRECTORIES_LIST) { auto it = this->vscroll->GetScrolledItemFromWidget(this->display_list, pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WidgetDimensions::scaled.inset.top); @@ -920,7 +920,7 @@ public: } } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_SL_FILTER) { this->string_filter.SetFilterTerm(this->filter_editbox.text.buf); diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index 6547af1700..710d7bb861 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -507,7 +507,7 @@ struct FramerateWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_FRW_CAPTION: @@ -535,7 +535,7 @@ struct FramerateWindow : Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_FRW_RATE_GAMELOOP: @@ -646,7 +646,7 @@ struct FramerateWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_FRW_TIMES_NAMES: { @@ -688,7 +688,7 @@ struct FramerateWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_FRW_TIMES_NAMES: @@ -761,7 +761,7 @@ struct FrametimeGraphWindow : Window { this->InitNested(number); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_FGW_CAPTION: @@ -776,7 +776,7 @@ struct FrametimeGraphWindow : Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_FGW_GRAPH) { SetDParam(0, 100); @@ -893,7 +893,7 @@ struct FrametimeGraphWindow : Window { return (value - src_min) * dst_diff / src_diff + dst_min; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_FGW_GRAPH) { const TimingMeasurement *durations = _pf_data[this->element].durations; diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index 2a04d30fcc..cd3b010364 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -142,7 +142,7 @@ struct GSConfigWindow : public Window { this->vscroll->SetCount(this->visible_settings.size()); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_GSC_SETTINGS: @@ -168,7 +168,7 @@ struct GSConfigWindow : public Window { return UserIsAllowedToChangeGameScript() || Game::GetInstance() != nullptr; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_GSC_GSLIST: { @@ -250,7 +250,7 @@ struct GSConfigWindow : public Window { this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget >= WID_GSC_TEXTFILE && widget < WID_GSC_TEXTFILE + TFT_CONTENT_END) { if (GameConfig::GetConfig() == nullptr) return; @@ -380,14 +380,14 @@ struct GSConfigWindow : public Window { SetValue(value); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_GSC_SETTING_DROPDOWN) return; assert(this->clicked_dropdown); SetValue(index); } - void OnDropdownClose(Point, int widget, int, bool) override + void OnDropdownClose(Point, WidgetID widget, int, bool) override { if (widget != WID_GSC_SETTING_DROPDOWN) return; /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 3713272a2f..1a1a5ef54b 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -438,7 +438,7 @@ static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, static_assert(lengthof(_num_inds) == ID_END + 1); struct GenerateLandscapeWindow : public Window { - uint widget_id; + WidgetID widget_id; uint x; uint y; std::string name; @@ -479,7 +479,7 @@ struct GenerateLandscapeWindow : public Window { } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_GL_START_DATE_TEXT: SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); break; @@ -643,7 +643,7 @@ struct GenerateLandscapeWindow : public Window { this->SetDirty(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)}; const StringID *strs = nullptr; @@ -752,7 +752,7 @@ struct GenerateLandscapeWindow : public Window { *size = maxdim(*size, d); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_GL_TEMPERATE: @@ -1002,7 +1002,7 @@ struct GenerateLandscapeWindow : public Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_GL_MAPSIZE_X_PULLDOWN: @@ -1217,7 +1217,7 @@ void StartNewGameWithoutGUI(uint32 seed) struct CreateScenarioWindow : public Window { - uint widget_id; + WidgetID widget_id; void SetDropDownColor() { @@ -1234,7 +1234,7 @@ struct CreateScenarioWindow : public Window SetDropDownColor(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CS_START_DATE_TEXT: @@ -1270,7 +1270,7 @@ struct CreateScenarioWindow : public Window this->DrawWidgets(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { StringID str = STR_JUST_INT; switch (widget) { @@ -1303,7 +1303,7 @@ struct CreateScenarioWindow : public Window *size = maxdim(*size, d); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_CS_TEMPERATE: @@ -1375,7 +1375,7 @@ struct CreateScenarioWindow : public Window this->RaiseWidgetsWhenLowered(WID_CS_START_DATE_DOWN, WID_CS_START_DATE_UP, WID_CS_FLAT_LAND_HEIGHT_DOWN, WID_CS_FLAT_LAND_HEIGHT_UP); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_CS_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break; @@ -1544,7 +1544,7 @@ struct GenerateProgressWindow : public Window { this->InitNested(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_GP_ABORT: @@ -1559,7 +1559,7 @@ struct GenerateProgressWindow : public Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_GP_PROGRESS_BAR: { @@ -1580,7 +1580,7 @@ struct GenerateProgressWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_GP_PROGRESS_BAR: { diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index 0f065980ea..0f84a2265d 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -51,7 +51,7 @@ struct GoalListWindow : public Window { this->OnInvalidateData(0); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_GOAL_CAPTION) return; @@ -63,7 +63,7 @@ struct GoalListWindow : public Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_GOAL_GLOBAL_BUTTON: @@ -168,7 +168,7 @@ struct GoalListWindow : public Window { return num; } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_GOAL_LIST) return; Dimension d = GetStringBoundingBox(STR_GOALS_NONE); @@ -351,7 +351,7 @@ struct GoalQuestionWindow : public Window { } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_GQ_BUTTON_1: @@ -368,7 +368,7 @@ struct GoalQuestionWindow : public Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_GQ_BUTTON_1: @@ -388,7 +388,7 @@ struct GoalQuestionWindow : public Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_GQ_QUESTION) return; @@ -396,7 +396,7 @@ struct GoalQuestionWindow : public Window { size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_GQ_QUESTION) return; diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 3b2ace8724..7601df1592 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -59,7 +59,7 @@ struct GraphLegendWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return; @@ -79,7 +79,7 @@ struct GraphLegendWindow : Window { DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, GetCharacterHeight(FS_NORMAL)), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return; @@ -110,25 +110,22 @@ struct GraphLegendWindow : Window { /** * Construct a vertical list of buttons, one for each company. - * @param biggest_index Storage for collecting the biggest index used in the returned tree. * @return Panel with company buttons. - * @post \c *biggest_index contains the largest used index in the tree. */ -static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index) +static std::unique_ptr MakeNWidgetCompanyLines() { - NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE); + auto vert = std::make_unique(NC_EQUALSIZE); vert->SetPadding(2, 2, 2, 2); uint sprite_height = GetSpriteSize(SPR_COMPANY_ICON, nullptr, ZOOM_LVL_OUT_4X).height; - for (int widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) { - NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum); + for (WidgetID widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) { + auto panel = std::make_unique(WWT_PANEL, COLOUR_BROWN, widnum); panel->SetMinimalSize(246, sprite_height + WidgetDimensions::unscaled.framerect.Vertical()); panel->SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical(), FS_NORMAL); panel->SetFill(1, 1); panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP); - vert->Add(panel); + vert->Add(std::move(panel)); } - *biggest_index = WID_GL_LAST_COMPANY; return vert; } @@ -197,7 +194,7 @@ protected: uint16 x_values_start; uint16 x_values_increment; - int graph_widget; + WidgetID graph_widget; StringID format_str_y_axis; byte colours[GRAPH_MAX_DATASETS]; OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS]; ///< Stored costs for the last #GRAPH_NUM_MONTHS months @@ -489,7 +486,7 @@ protected: } - BaseGraphWindow(WindowDesc *desc, int widget, StringID format_str_y_axis) : + BaseGraphWindow(WindowDesc *desc, WidgetID widget, StringID format_str_y_axis) : Window(desc), format_str_y_axis(format_str_y_axis) { @@ -513,7 +510,7 @@ protected: } public: - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != this->graph_widget) return; @@ -549,7 +546,7 @@ public: size->height = std::max(size->height, size->width / 3); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != this->graph_widget) return; @@ -561,7 +558,7 @@ public: return INVALID_DATAPOINT; } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { /* Clicked on legend? */ if (widget == WID_CV_KEY_BUTTON) ShowGraphLegend(); @@ -747,7 +744,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow { Scrollbar *vscroll; ///< Cargo list scrollbar. uint legend_width; ///< Width of legend 'blob'. - ExcludingCargoBaseGraphWindow(WindowDesc *desc, int widget, StringID format_str_y_axis): + ExcludingCargoBaseGraphWindow(WindowDesc *desc, WidgetID widget, StringID format_str_y_axis): BaseGraphWindow(desc, widget, format_str_y_axis) {} @@ -757,7 +754,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow { this->legend_width = (GetCharacterHeight(FS_SMALL) - ScaleGUITrad(1)) * 9 / 6; } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget != WID_ECBG_MATRIX) { BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize); @@ -779,7 +776,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow { resize->height = this->line_height; } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_ECBG_MATRIX) { BaseGraphWindow::DrawWidget(r, widget); @@ -816,7 +813,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow { } } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_CV_KEY_BUTTON: @@ -897,7 +894,7 @@ struct DeliveredCargoGraphWindow : ExcludingCargoBaseGraphWindow { this->SetDirty(); } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_DCG_BY_COMPANY: @@ -1060,7 +1057,7 @@ struct PerformanceHistoryGraphWindow : BaseGraphWindow { return c->old_economy[j].performance_history; } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget == WID_PHG_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail(); this->BaseGraphWindow::OnClick(pt, widget, click_count); @@ -1266,7 +1263,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_CPR_MATRIX) { BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize); @@ -1290,7 +1287,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { resize->height = this->line_height; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_CPR_MATRIX) { BaseGraphWindow::DrawWidget(r, widget); @@ -1327,7 +1324,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_CPR_ENABLE_CARGOES: @@ -1412,7 +1409,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { this->num_dataset = i; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CPR_FOOTER: @@ -1534,7 +1531,7 @@ struct PerformanceRatingDetailWindow : Window { uint score_detail_left; uint score_detail_right; - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_PRD_SCORE_FIRST: @@ -1592,7 +1589,7 @@ struct PerformanceRatingDetailWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { /* No need to draw when there's nothing to draw */ if (this->company == INVALID_COMPANY) return; @@ -1670,7 +1667,7 @@ struct PerformanceRatingDetailWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { /* Check which button is clicked */ if (IsInsideMM(widget, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST + 1)) { @@ -1729,11 +1726,9 @@ CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY; /** * Make a vertical list of panels for outputting score details. - * @param biggest_index Storage for collecting the biggest index used in the returned tree. * @return Panel with performance details. - * @post \c *biggest_index contains the largest used index in the tree. */ -static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index) +static std::unique_ptr MakePerformanceDetailPanels() { const StringID performance_tips[] = { STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP, @@ -1750,21 +1745,20 @@ static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index) static_assert(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN); - NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE); - for (int widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) { - NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum); + auto vert = std::make_unique(NC_EQUALSIZE); + for (WidgetID widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) { + auto panel = std::make_unique(WWT_PANEL, COLOUR_BROWN, widnum); panel->SetFill(1, 1); panel->SetDataTip(0x0, performance_tips[widnum - WID_PRD_SCORE_FIRST]); - vert->Add(panel); + vert->Add(std::move(panel)); } - *biggest_index = WID_PRD_SCORE_LAST; return vert; } /** Make a number of rows with buttons for each company for the performance rating detail window. */ -NWidgetBase *MakeCompanyButtonRowsGraphGUI(int *biggest_index) +std::unique_ptr MakeCompanyButtonRowsGraphGUI() { - return MakeCompanyButtonRows(biggest_index, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST, COLOUR_BROWN, 8, STR_PERFORMANCE_DETAIL_SELECT_COMPANY_TOOLTIP); + return MakeCompanyButtonRows(WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST, COLOUR_BROWN, 8, STR_PERFORMANCE_DETAIL_SELECT_COMPANY_TOOLTIP); } static const NWidgetPart _nested_performance_rating_detail_widgets[] = { @@ -1836,7 +1830,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow { this->legend_excluded_cargo = 0; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_SCG_CAPTION) { SetDParam(0, this->station_id); @@ -1858,7 +1852,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow { } } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget < WID_SCG_MATRIX) { BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize); @@ -1880,7 +1874,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow { resize->height = this->line_height; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget < WID_SCG_MATRIX) { BaseGraphWindow::DrawWidget(r, widget); @@ -1921,7 +1915,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow { } } - void OnClick(Point pt, int widget, int click_count) override + void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_SCG_ENABLE_CARGOES: diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 27515d4279..1df5869697 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -450,7 +450,7 @@ public: this->Window::Close(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_GL_LIST_GROUP: @@ -533,7 +533,7 @@ public: this->SetDirty(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { @@ -622,7 +622,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_GL_ALL_VEHICLES: @@ -707,7 +707,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_GL_SORT_BY_ORDER: // Flip sorting method ascending/descending @@ -899,7 +899,7 @@ public: } } - void OnDragDrop_Group(Point pt, int widget) + void OnDragDrop_Group(Point pt, WidgetID widget) { const Group *g = Group::GetIfValid(this->group_sel); if (g == nullptr) { @@ -937,7 +937,7 @@ public: } } - void OnDragDrop_Vehicle(Point pt, int widget) + void OnDragDrop_Vehicle(Point pt, WidgetID widget) { switch (widget) { case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles @@ -1016,7 +1016,7 @@ public: } } - void OnDragDrop(Point pt, int widget) override + void OnDragDrop(Point pt, WidgetID widget) override { if (this->vehicle_sel != INVALID_VEHICLE) OnDragDrop_Vehicle(pt, widget); if (this->group_sel != INVALID_GROUP) OnDragDrop_Group(pt, widget); @@ -1036,7 +1036,7 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_GL_LIST_VEHICLE); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_GL_GROUP_BY_DROPDOWN: @@ -1142,7 +1142,7 @@ public: } } - void OnMouseDrag(Point pt, int widget) override + void OnMouseDrag(Point pt, WidgetID widget) override { if (this->vehicle_sel == INVALID_VEHICLE && this->group_sel == INVALID_GROUP) return; diff --git a/src/help_gui.cpp b/src/help_gui.cpp index ea318dbda7..60fde1db92 100644 --- a/src/help_gui.cpp +++ b/src/help_gui.cpp @@ -73,7 +73,7 @@ struct GameManualTextfileWindow : public TextfileWindow { this->OnClick({ 0, 0 }, WID_TF_WRAPTEXT, 1); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TF_CAPTION) { SetDParamStr(0, this->filename); @@ -85,7 +85,7 @@ struct GameManualTextfileWindow : public TextfileWindow { if (this->filename == CHANGELOG_FILENAME) { this->link_anchors.clear(); this->AfterLoadChangelog(); - this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0); + if (this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0)) this->ReInit(); } else { this->TextfileWindow::AfterLoadText(); } @@ -129,7 +129,7 @@ struct HelpWindow : public Window { this->EnableTextfileButton(LICENSE_FILENAME, WID_HW_LICENSE); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_HW_README: diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 8ca3bedd6e..4a890473be 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -62,7 +62,7 @@ struct EndGameHighScoreBaseWindow : Window { return pt; } - void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] int click_count) override { this->Close(); } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index d68ed12146..379ecaba02 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -428,7 +428,7 @@ public: this->SetupArrays(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_DPI_MATRIX_WIDGET: { @@ -500,7 +500,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_DPI_FUND_WIDGET: @@ -521,7 +521,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_DPI_MATRIX_WIDGET: { @@ -632,7 +632,7 @@ public: MarkWholeScreenDirty(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_DPI_CREATE_RANDOM_INDUSTRIES_WIDGET: { @@ -985,17 +985,17 @@ public: return ir.top - 1 + WidgetDimensions::scaled.framerect.bottom; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_IV_CAPTION) SetDParam(0, this->window_number); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_IV_INFO) size->height = this->info_height; } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_IV_INFO: { @@ -1651,7 +1651,7 @@ public: this->SetCargoFilterArray(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_ID_DROPDOWN_CRITERIA: @@ -1668,7 +1668,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_ID_DROPDOWN_ORDER: @@ -1714,7 +1714,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_ID_DROPDOWN_ORDER: { @@ -1766,7 +1766,7 @@ public: return list; } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_ID_DROPDOWN_ORDER: @@ -1800,7 +1800,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_ID_DROPDOWN_CRITERIA: { @@ -1831,7 +1831,7 @@ public: this->hscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_ID_FILTER) { this->string_filter.SetFilterTerm(this->industry_editbox.text.buf); @@ -2644,7 +2644,7 @@ struct IndustryCargoesWindow : public Window { CargoesField::cargo_field_width = CargoesField::cargo_border.width * 2 + CargoesField::cargo_line.width * CargoesField::max_cargoes + CargoesField::cargo_space.width * (CargoesField::max_cargoes - 1); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_IC_PANEL: @@ -2665,7 +2665,7 @@ struct IndustryCargoesWindow : public Window { CargoesFieldType type; ///< Type of field. - void SetStringParameters (int widget) const override + void SetStringParameters (WidgetID widget) const override { if (widget != WID_IC_CAPTION) return; @@ -3002,7 +3002,7 @@ struct IndustryCargoesWindow : public Window { this->ComputeIndustryDisplay(data); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_IC_PANEL) return; @@ -3087,7 +3087,7 @@ struct IndustryCargoesWindow : public Window { return true; } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_IC_PANEL: { @@ -3175,7 +3175,7 @@ struct IndustryCargoesWindow : public Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (index < 0) return; @@ -3198,7 +3198,7 @@ struct IndustryCargoesWindow : public Window { } } - bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { if (widget != WID_IC_PANEL) return false; diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index c23fdaf7c9..1ca0bc2ee8 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -283,7 +283,7 @@ struct SelectGameWindow : public Window { this->GetWidget(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SGI_BASESET: @@ -298,7 +298,7 @@ struct SelectGameWindow : public Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_SGI_TEMPERATE_LANDSCAPE: case WID_SGI_ARCTIC_LANDSCAPE: @@ -326,7 +326,7 @@ struct SelectGameWindow : public Window { if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { /* Do not create a network server when you (just) have closed one of the game * creation/load windows for the network server. */ diff --git a/src/lang/catalan.txt b/src/lang/catalan.txt index 545bff89ab..6ea013392b 100644 --- a/src/lang/catalan.txt +++ b/src/lang/catalan.txt @@ -256,6 +256,9 @@ STR_UNITS_HEIGHT_IMPERIAL :{DECIMAL}{NBSP} STR_UNITS_HEIGHT_METRIC :{DECIMAL}{NBSP}m STR_UNITS_HEIGHT_SI :{G=Masculin}{DECIMAL}{NBSP}m +STR_UNITS_DAYS :{COMMA}{NBSP}di{P a es} +STR_UNITS_SECONDS :{COMMA}{NBSP}segon{P "" s} +STR_UNITS_TICKS :{COMMA}{NBSP}tic{P "" s} # Common window strings STR_LIST_FILTER_TITLE :{BLACK}Filtre: @@ -720,6 +723,7 @@ STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Clica la STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Clica la pista de música per treure-la de la llista actual (només en llistes personalitzables) # Highscore window +STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}Millors companyies STR_HIGHSCORE_POSITION :{BIG_FONT}{BLACK}{COMMA}. STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN :Empresari STR_HIGHSCORE_PERFORMANCE_TITLE_ENTREPRENEUR :Emprenedor @@ -1488,7 +1492,7 @@ STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL :Original STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS :TerraGenesis STR_CONFIG_SETTING_TERRAIN_TYPE :Tipus de terreny: {STRING} -STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :(Només TerraGenesis) Escollir el tipus de terreny: des de molt pla fins a escarpat +STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :Escolliu l'altura dels turons i muntanyes del paisatge. STR_CONFIG_SETTING_INDUSTRY_DENSITY :Densitat d'indústries: {STRING} STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :Fixa el nombre d'indústries que s'haurien de generar i mantenir durant la partida @@ -1497,18 +1501,18 @@ STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :Distància màx STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Limita a quina distància del mapa es poden construir refineries de petroli i plataformes petrolíferes. En mapes amb illes, serveix per assegurar que estan prop de la costa. En mapes de més de 256 caselles, aquest valor s'escala automàticament. STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Alçada dels estatges amb neu: {STRING} -STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Controla a partir de quina alçada apareix la neu en el paisatge subàrtic. La neu també afecta la generació d'indústries i els requisits per al creixement de les poblacions. Només es pot modificar a l'editor d'escenaris; altrament, es calcula fent servir la proporció de terreny nevat. +STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Tria a quina altura comença a aparèixer neu al paisatge subàrtic. La neu també afecta a la generació d'indústries i els requisits per al creixement de les poblacions. Només es pot modificar a l'editor d'escenaris; altrament, es calcula fent servir la proporció de terreny nevat. STR_CONFIG_SETTING_SNOW_COVERAGE :Terreny nevat: {STRING} -STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Controla la quantitat aproximada de terreny nevat que hi ha en els paisatges subàrtics. La neu afecta a la generació d'indústries i el creixement de les poblacions. Només s'usa durant la generació de mapes. El terreny d'alçada propera al nivell del mar mai està nevat. +STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Escolliu la quantitat aproximada de neu als paisatges subàrtics. La neu també afecta a la generació d'indústries i els requisits per al creixement de les poblacions. Només es fa servir durant la generació de mapes. A nivell de mar i a les caselles costeres mai hi haurà neu. STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE :{NUM}{NBSP}% STR_CONFIG_SETTING_DESERT_COVERAGE :Terreny desèrtic: {STRING} -STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Controla la quantitat aproximada de terreny desèrtic que hi ha en els paisatges tropicals. Els deserts afecten a la generació d'indústries. Només s'usa durant la generació de mapes. +STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Escolliu la quantitat aproximada de desert dels paisatges tropicals. El desert afecta a la generació d'indústries i els requisits de creixement de les poblacions. Només es fa servir durant la generació de mapes. STR_CONFIG_SETTING_DESERT_COVERAGE_VALUE :{NUM}{NBSP}% STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :Geografia del terreny: {STRING} -STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(Només TerraGenesis) Escollir la suavitat del paisatge: els terrenys suaus tenen menys turons i són regulars; els terrenys més rugosos són irregulars i tenen molts turons +STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :Trieu la forma i quantitat de turons. Els terrenys més suaus tenen menys turons i són més amples, mentre que els terrenys més irregulars tenen més turons i són més petits. ###length 4 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :Molt suau STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH :Suau @@ -1516,7 +1520,7 @@ STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH :Escarpat STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH :Molt escarpat STR_CONFIG_SETTING_VARIETY :Varietat: {STRING} -STR_CONFIG_SETTING_VARIETY_HELPTEXT :(Només TerraGenesis) Controla la varietat en la distribució de les zones muntanyoses i planes. Aquesta opció controla la distribució d'aquestes zones; si es vol modificar si el terreny és més o menys muntanyós s'han de modificar altres opcions +STR_CONFIG_SETTING_VARIETY_HELPTEXT :Trieu si el mapa ha de contenir muntanyes o àrees planes. Com més varietat, més diferències hi haurà entre l'elevació de les àrees muntanyoses i planes. STR_CONFIG_SETTING_RIVER_AMOUNT :Quantitat de rius: {STRING} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :Escollir la quantitat de rius a generar @@ -1536,6 +1540,7 @@ STR_CONFIG_SETTING_ROAD_SIDE_LEFT :Conducció per STR_CONFIG_SETTING_ROAD_SIDE_RIGHT :Conducció per la dreta STR_CONFIG_SETTING_HEIGHTMAP_ROTATION :Rotació del mapa d'alçades: {STRING} +STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP :Escolliu de quina manera s'ha de rotar el mapa d'alçades per a encaixar-lo al món de la partida. ###length 2 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE :Antihorari STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE :Horari @@ -1656,7 +1661,12 @@ STR_CONFIG_SETTING_ADVANCED_VEHICLE_LISTS_HELPTEXT :Activa la utili STR_CONFIG_SETTING_LOADING_INDICATORS :Utilitza indicadors de càrrega: {STRING} STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Selecciona si els indicadors de càrrega seran mostrats sobre els vehicles en càrrega o descàrrega +STR_CONFIG_SETTING_TIMETABLE_MODE :Unitats de temps per als horaris: {STRING} +STR_CONFIG_SETTING_TIMETABLE_MODE_HELPTEXT :Seleccioneu les unitats de temps que es faran servir per als horaris. ###length 3 +STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS :Dies +STR_CONFIG_SETTING_TIMETABLE_MODE_SECONDS :Segons +STR_CONFIG_SETTING_TIMETABLE_MODE_TICKS :Tics STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Mostra l'arribada i la sortida als horaris: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Mostra als horaris l'arribada anticipadament i les hores de sortida @@ -2187,12 +2197,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Mostra e STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Mostra els esquemes de colors dels automòbils STR_LIVERY_SHIP_TOOLTIP :{BLACK}Mostra els esquemes de colors dels vaixells STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Mostra esquemes de colors dels avions +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Mostra els colors dels grups de trens. +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Mostra els colors dels grups de vehicles de carretera. +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Mostra els colors dels grups de vaixells. +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Mostra els colors dels grups d'aeronaus STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Escolleix el color primari per l'esquema triat. Ctr+Click establirà el color per a cada esquema STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Escolleix el color secundari per l'esquema triat. Ctrl+Click establirà el color per a cada esquema STR_LIVERY_PANEL_TOOLTIP :{BLACK}Selecciona un esquema de colors per canviar-lo, o diversos esquemes amb CTRL+Clic. Clica a la casella per canviar l'esquema +STR_LIVERY_TRAIN_GROUP_EMPTY :No hi ha grups de trens establerts +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :No hi ha grups de vehicles de carretera establerts +STR_LIVERY_SHIP_GROUP_EMPTY :No hi ha grups de vaixells establerts +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :No hi ha grups d'aeronaus establerts ###length 23 -STR_LIVERY_DEFAULT :Decoració estàndard +STR_LIVERY_DEFAULT :Decoració per defecte STR_LIVERY_STEAM :Locomotora a Vapor STR_LIVERY_DIESEL :Locomotora Dièsel STR_LIVERY_ELECTRIC :Locomotora Elèctrica @@ -2345,7 +2363,7 @@ STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP :{BLACK}El nom d STR_NETWORK_START_SERVER_SET_PASSWORD :{BLACK}Posa una contrasenya STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP :{BLACK}Protegeix la teva partida amb una contrasenya si no vols que sigui accessible a desconeguts -STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Visibilitat +STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Visibilitat: STR_NETWORK_START_SERVER_VISIBILITY_TOOLTIP :{BLACK}Permet establir si altres persones poden veure el vostre servidor a la llista pública. STR_NETWORK_START_SERVER_CLIENTS_SELECT :{BLACK}{NUM} client{P "" s} STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS :{BLACK}Màxim nombre de clients: @@ -3200,11 +3218,15 @@ STR_MAPGEN_MAPSIZE :{BLACK}Mida del STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK}Selecciona la mida del mapa en cel·les. El nombre de cel·les disponibles serà lleugerament més petit STR_MAPGEN_BY :{BLACK}* STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Nombre de poblacions: +STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP :{BLACK}Trieu la densitat de les poblacions o un nombre personalitzat. STR_MAPGEN_TOWN_NAME_LABEL :{BLACK}Estil dels noms de les poblacions: STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP :{BLACK}Selecciona l'estil dels noms de poblacions STR_MAPGEN_DATE :{BLACK}Data: +STR_MAPGEN_DATE_TOOLTIP :{BLACK}Trieu la data d'inici. STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}Nombre d'indústries: +STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP :{BLACK}Trieu la densitat de les indústries o un nombre personalitzat. STR_MAPGEN_HEIGHTMAP_HEIGHT :{BLACK}Alçada del cim més alt: +STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP :{BLACK}Trieu l'altura del cim més alt que el joc mirarà de crear, mesurat respecte el nivell de mar. STR_MAPGEN_HEIGHTMAP_HEIGHT_UP :{BLACK}Augmenta l'alçada màxima o l'alçada màxima dels cims en una unitat STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN :{BLACK}Redueix l'alçada màxima o l'alçada màxima dels cims en una unitat STR_MAPGEN_SNOW_COVERAGE :{BLACK}Proporció de terreny nevat: @@ -3217,10 +3239,12 @@ STR_MAPGEN_DESERT_COVERAGE_DOWN :{BLACK}Redueix STR_MAPGEN_DESERT_COVERAGE_TEXT :{BLACK}{NUM}{NBSP}% STR_MAPGEN_TERRAIN_TYPE :{BLACK}Tipus de terreny: STR_MAPGEN_SEA_LEVEL :{BLACK}Nivell de mar: +STR_MAPGEN_SEA_LEVEL_TOOLTIP :{BLACK}Seleccioneu el nivell de la mar STR_MAPGEN_QUANTITY_OF_RIVERS :{BLACK}Quantitat de rius: STR_MAPGEN_SMOOTHNESS :{BLACK}Suavitat: STR_MAPGEN_VARIETY :{BLACK}Varietat: STR_MAPGEN_GENERATE :{WHITE}Genera +STR_MAPGEN_GENERATE_TOOLTIP :{BLACK}Creeu el món i jugueu a l'OpenTTD! STR_MAPGEN_NEWGRF_SETTINGS :{BLACK}Configuració del NewGRF STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP :{BLACK}Mostra la configuració de NewGRF STR_MAPGEN_AI_SETTINGS :{BLACK}Configuració d'IA @@ -3253,6 +3277,7 @@ STR_MAPGEN_TOWN_NAME_CATALAN :Català # Strings for map borders at game generation STR_MAPGEN_BORDER_TYPE :{BLACK}Vores del mapa: +STR_MAPGEN_BORDER_TYPE_TOOLTIP :{BLACK}Escolliu les vores del món de la partida. STR_MAPGEN_NORTHWEST :{BLACK}Nord-oest STR_MAPGEN_NORTHEAST :{BLACK}Nord-est STR_MAPGEN_SOUTHEAST :{BLACK}Sud-est @@ -3265,7 +3290,9 @@ STR_MAPGEN_BORDER_MANUAL :{BLACK}Manual STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}Rotació del mapa d'alçades: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}Nom del mapa d'alçades: +STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP :{BLACK}El nom del fitxer imatge del mapa d'alçades STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}Mida: +STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP :{BLACK}La mida de la imatge d'origen del mapa d'alçades. Per a obtenir bons resultats, cada costat hauria de coincidir amb una mida disponible de l'OpenTTD, com ara 256, 512 o 1024. STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT :{WHITE}Alçada desitjada dels cims @@ -3280,6 +3307,7 @@ STR_SE_MAPGEN_FLAT_WORLD :{WHITE}Terreny STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP :{BLACK}Generar un terreny pla STR_SE_MAPGEN_RANDOM_LAND :{WHITE}Terreny aleatori STR_SE_MAPGEN_FLAT_WORLD_HEIGHT :{BLACK}Alçada del terreny pla: +STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP :{BLACK}Trieu l'altura de la terra per damunt del nivell de la mar. STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN :{BLACK}Mou l'alçada del terreny pla un pas avall STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP :{BLACK}Mou l'alçada del terreny pla un pas amunt @@ -4573,8 +4601,13 @@ STR_TIMETABLE_STATUS_ON_TIME :{BLACK}Actualme STR_TIMETABLE_STATUS_LATE :{BLACK}Actualment aquest vehicle va {STRING} tard STR_TIMETABLE_STATUS_EARLY :{BLACK}Actualment aquest vehicle va {STRING} d'hora STR_TIMETABLE_STATUS_NOT_STARTED :{BLACK}Aquest horari encara no ha començat +STR_TIMETABLE_STATUS_START_AT_DATE :{BLACK}Aquest horari començarà a {STRING} +STR_TIMETABLE_STATUS_START_IN_SECONDS :{BLACK}Aquest horari començarà en {COMMA}{NBSP}segons +STR_TIMETABLE_START :{BLACK}Comença l'horari +STR_TIMETABLE_START_TOOLTIP :{BLACK}Trieu quan ha de començar l'horari. Amb Ctrl+clic es distribuirà l'inici de tots els vehicles que comparteixen les ordres segons el seu ordre relatiu, si s'ha establert completament l'horari. +STR_TIMETABLE_START_SECONDS_QUERY :Segons fins que comenci l'horari STR_TIMETABLE_CHANGE_TIME :{BLACK}Canvia Temps STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Canvia el emps que l'ordre marcada hauria de prendre. Amb Ctrl+clic estableix el temps per a totes les ordres. @@ -4598,6 +4631,10 @@ STR_TIMETABLE_EXPECTED :{BLACK}Esperat STR_TIMETABLE_SCHEDULED :{BLACK}Planificat STR_TIMETABLE_EXPECTED_TOOLTIP :{BLACK}Canvia entre esperat i planificat +STR_TIMETABLE_ARRIVAL_DATE :A: {COLOUR}{DATE_TINY} +STR_TIMETABLE_DEPARTURE_DATE :S: {COLOUR}{DATE_TINY} +STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE :A: {COLOUR}{COMMA}{NBSP}s +STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE :S: {COLOUR}{COMMA}{NBSP}s # Date window (for timetable) @@ -4625,9 +4662,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Distinge STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Commuta la distinció entre majúscules i minúscules quan es comparin els missatges de registre d'IA amb la cadena de parada. STR_AI_DEBUG_CONTINUE :{BLACK}Continua STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Reprèn i continua l'execució de la IA. -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Mostra la sortida de depuració d'aquesta IA. +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Mostra la sortida de depuració d'aquesta IA. Feu Ctrl+clic per a mostrar-la en una finestra nova. STR_AI_GAME_SCRIPT :{BLACK}Script de partida -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Mostra el registre de l'script de partida. +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Mostra el registre de l'script de partida. Feu Ctrl+clic per a obrir-lo en una finestra nova. STR_ERROR_AI_NO_AI_FOUND :No s'ha trobat una IA adequada per carregar.{}Aquesta IA és una IA que no fa res.{}Podeu descarregar diverses IA via el sistema de «Contingut en línia». STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Un dels scripts que s'executava ha fallat. Si us plau, informeu l'autor de l'script amb una captura de pantalla de la finestra de depuració de l'script d'IA/partida. diff --git a/src/lang/danish.txt b/src/lang/danish.txt index af5f1af464..0cfccb6724 100644 --- a/src/lang/danish.txt +++ b/src/lang/danish.txt @@ -257,6 +257,7 @@ STR_UNITS_HEIGHT_SI :{DECIMAL} m STR_UNITS_DAYS :{COMMA}{NBSP}dag{P "" s} STR_UNITS_SECONDS :{COMMA}{NBSP}sekund{P "" er} +STR_UNITS_TICKS :{COMMA}{NBSP}tick{P "" s} # Common window strings STR_LIST_FILTER_TITLE :{BLACK}Filtrer udtryk: @@ -1664,6 +1665,7 @@ STR_CONFIG_SETTING_TIMETABLE_MODE_HELPTEXT :Vælg de tidsen ###length 3 STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS :Dage STR_CONFIG_SETTING_TIMETABLE_MODE_SECONDS :Sekunder +STR_CONFIG_SETTING_TIMETABLE_MODE_TICKS :Ticks STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Vis ankomst og afgang i tidsplaner: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Vis forventede ankomst-og afgangstider i tidsplaner @@ -2201,6 +2203,7 @@ STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Vis farv STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Vælg den primære farve for det valgte farveskema. Ctrl+Click vil sætte denne farve for alle farveskemaer STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Vælg den sekundære farve for det valgte farveskema. Ctrl+Click vil sætte denne farve for alle farveskemaer STR_LIVERY_PANEL_TOOLTIP :{BLACK}Vælg et farveskema, som skal ændres, eller flere farveskemaer vha. CTRL+klik. Klik på boksen for at slå brug af farveskemaet til/fra +STR_LIVERY_TRAIN_GROUP_EMPTY :Der er ikke oprettet toggrupper STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Der er ikke oprettet grupper af vejkøretøjer STR_LIVERY_SHIP_GROUP_EMPTY :Der er ikke oprettet skibsgrupper STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Der er ikke oprettet flygrupper diff --git a/src/lang/dutch.txt b/src/lang/dutch.txt index 60fead6ee5..7a485a9b37 100644 --- a/src/lang/dutch.txt +++ b/src/lang/dutch.txt @@ -2196,9 +2196,17 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Kleurens STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Kleurenschema's voor wegvoertuigen weergeven STR_LIVERY_SHIP_TOOLTIP :{BLACK}Kleurenschema's voor schepen weergeven STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Kleurenschema's voor vliegtuigen weergeven +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Kleuren van treingroepen weergeven +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Kleuren van wegvoertuiggroepen weergeven +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Kleuren van scheepsgroepen weergeven +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Kleuren van vliegtuiggroepen weergeven STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Selecteer de hoofdkleur voor het geselecteerde schema. Ctrl+klik zal deze kleur instellen voor elk schema STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Selecteer de secundaire kleur voor het geselecteerde schema. Met Ctrl+klik stel je deze kleur in voor alle schema's STR_LIVERY_PANEL_TOOLTIP :{BLACK}Selecteer een kleurenschema om te wijzigen of meerdere schema's met Ctrl+klik. Vink de keuzevakjes aan-uit om het schema aan-uit te zetten +STR_LIVERY_TRAIN_GROUP_EMPTY :Geen treingroepen ingesteld +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Geen wegvoertuiggroepen ingesteld +STR_LIVERY_SHIP_GROUP_EMPTY :Geen scheepsgroepen ingesteld +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Geen vliegtuiggroepen ingesteld ###length 23 STR_LIVERY_DEFAULT :Standaard kleurenschema @@ -4653,9 +4661,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Hoofdlet STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Hoofdlettergevoeligheid aan-uitzetten bij het vergelijken van AI-logberichten t.o.v. de afbreektekst STR_AI_DEBUG_CONTINUE :{BLACK}Doorgaan STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Het spel vervolgen en de AI voortzetten -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Probleemgegevens van deze AI weergeven +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Probleemgegevens van deze AI weergeven. Ctrl+klik opent in een nieuw venster STR_AI_GAME_SCRIPT :{BLACK}Spelscript -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Controleer het logboek van het spelscript +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Controleer het logboek van het spelscript. Ctrl+klik opent in een nieuw venster STR_ERROR_AI_NO_AI_FOUND :Geen geschikte AI gevonden.{} Deze AI is een 'dummy' en voert niets uit.{}Verschillende AI's kunnen worden gedownload via het 'Online Content' systeem STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Eén van de actieve scripts is vastgelopen. Meld dit a.u.b. bij de auteur van dit script met een schermafdruk van het AI-/spelscript-probleemvenster. diff --git a/src/lang/english_US.txt b/src/lang/english_US.txt index 4f34c40b26..d22d9b13a1 100644 --- a/src/lang/english_US.txt +++ b/src/lang/english_US.txt @@ -2196,12 +2196,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Show tra STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Show road vehicle color schemes STR_LIVERY_SHIP_TOOLTIP :{BLACK}Show ship color schemes STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Show aircraft color schemes +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Show colors of train groups +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Show colors of road vehicle groups +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Show colors of ship groups +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Show colors of aircraft groups STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Choose the primary color for the selected scheme. Ctrl+Click will set this color for every scheme STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Choose the secondary color for the selected scheme. Ctrl+Click will set this color for every scheme STR_LIVERY_PANEL_TOOLTIP :{BLACK}Select a color scheme to change, or multiple schemes with Ctrl+Click. Click on the box to toggle use of the scheme +STR_LIVERY_TRAIN_GROUP_EMPTY :No train groups are set up +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :No road vehicle groups are set up +STR_LIVERY_SHIP_GROUP_EMPTY :No ship groups are set up +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :No aircraft groups are set up ###length 23 -STR_LIVERY_DEFAULT :Standard Livery +STR_LIVERY_DEFAULT :Default Livery STR_LIVERY_STEAM :Steam Engine STR_LIVERY_DIESEL :Diesel Engine STR_LIVERY_ELECTRIC :Electric Engine @@ -4653,9 +4661,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Match ca STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Toggle matching case when comparing AI log messages against the break string STR_AI_DEBUG_CONTINUE :{BLACK}Continue STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Unpause and continue the AI -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}View debug output of this AI +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}View debug output of this AI. Ctrl-Click to open in a new window STR_AI_GAME_SCRIPT :{BLACK}Game Script -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Check the Game Script log +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Check the Game Script log. Ctrl-Click to open in a new window STR_ERROR_AI_NO_AI_FOUND :No suitable AI found to load.{}This AI is a dummy AI and won't do anything.{}You can download several AIs via the 'Online Content' system STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}One of the running scripts crashed. Please report this to the script author with a screenshot of the AI/Game Script Debug Window diff --git a/src/lang/finnish.txt b/src/lang/finnish.txt index d161ecb8c3..72aff10a6b 100644 --- a/src/lang/finnish.txt +++ b/src/lang/finnish.txt @@ -2196,12 +2196,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Näytä STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Näytä tieajoneuvojen väriteemat STR_LIVERY_SHIP_TOOLTIP :{BLACK}Näytä laivojen väriteemat STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Näytä ilma-alusten väriteemat +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Näytä junaryhmien värit +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Näytä ajoneuvoryhmien värit +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Näytä laivaryhmien värit +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Näytä ilma-alusryhmien värit STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Valitse valitun kaavan ensisijainen väri. Ctrl+napsautus asettaa tämän värin kaikille kaavoille. STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Valitse valitun kaavan toissijainen väri. Ctrl+napsautus asettaa tämän värin kaikille kaavoille. STR_LIVERY_PANEL_TOOLTIP :{BLACK}Valitse muutettava väriteema, tai valitse useita Ctrl pohjassa. Paina valintalaatikkoa valitaksesi teeman +STR_LIVERY_TRAIN_GROUP_EMPTY :Junaryhmiä ei ole muodostettu +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Ajoneuvoryhmiä ei ole muodostettu +STR_LIVERY_SHIP_GROUP_EMPTY :Laivaryhmiä ei ole muodostettu +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Ilma-alusryhmiä ei ole muodostettu ###length 23 -STR_LIVERY_DEFAULT :Normaalit tunnusvärit +STR_LIVERY_DEFAULT :Oletusväritys STR_LIVERY_STEAM :Höyryveturi STR_LIVERY_DIESEL :Dieselveturi STR_LIVERY_ELECTRIC :Sähköveturi @@ -2711,7 +2719,7 @@ STR_RAIL_TOOLBAR_TOOLTIP_BUILD_AUTORAIL :{BLACK}Rakenna STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT_FOR_BUILDING :{BLACK}Rakenna veturitalli (junien ostamista ja huoltoa varten). Shift vaihtaa rakennustilan ja kustannusarvion välillä STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_TO_WAYPOINT :{BLACK}Muunna raide reittipisteeksi. Ctrl liittää reittipisteet. Shift vaihtaa muuntotilan ja kustannusarvion välillä STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_STATION :{BLACK}Rakenna rautatieasema. Ctrl liittää asemat. Shift vaihtaa rakennustilan ja kustannusarvion välillä -STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS :{BLACK}Rakenna opastimia. Ctrl vaihtaa joko siipiopastimet tai valo-opastimet{}Vetäminen rakentaa opastimia suoralle rautatielle. Ctrl rakentaa opastimia seuraavaan risteykseen saakka{}Ctrl+Click avaa opastimenvalintaikkunan. Shift vaihtaa rakennustilan ja kustannusarvion välillä +STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS :{BLACK}Rakenna opastimia. Ctrl vaihtaa siipi- ja valo-opastimien välillä{}Vetäminen rakentaa opastimia suoralle rataosuudelle. Ctrl rakentaa opastimia seuraavaan risteykseen tai opastimeen saakka{}Ctrl+napsautus avaa opastimenvalintaikkunan. Shift vaihtaa rakennustilan ja kustannusarvion välillä STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_BRIDGE :{BLACK}Rakenna rautatiesilta. Shift vaihtaa rakennustilan ja kustannusarvion välillä STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TUNNEL :{BLACK}Rakenna rautatietunneli. Shift vaihtaa rakennustilan ja kustannusarvion välillä STR_RAIL_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR :{BLACK}Rautatien, opastimien, reittipisteiden ja asemien rakentaminen/poisto päälle/pois. Pidä pohjassa Ctrl-näppäintä poistaaksesi myös aseman tai reittipisteen alla olevat raiteet @@ -4653,9 +4661,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Kirjaink STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Kytke kirjainkoon täsmäys, kun verrataan tekoälyn viestejä pysäytysmerkkijonoon STR_AI_DEBUG_CONTINUE :{BLACK}Jatka STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Jatka tekoälyn suorittamista -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Näytä tämän tekoälyn virheenkorjaustiedot +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Näytä tämän tekoälyn virheenkorjaustiedot. Ctrl+napsautus avaa uuteen ikkunaan STR_AI_GAME_SCRIPT :{BLACK}Peliskripti -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Tarkista peliskriptin loki +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Tarkista peliskriptin loki. Ctrl+napsautus avaa uuteen ikkunaan STR_ERROR_AI_NO_AI_FOUND :Sopivaa tekoälyä ei löydetty.{}Tämä tekoäly ei tee mitään.{}Voit ladata useita tekoälyjä ”online-sisältö” -järjestelmän kautta STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Yksi käynnissä olevista skripteistä kaatui. Ilmoita tästä skriptin kehittäjälle liittäen mukaan kuvankaappaus Tekoälyn/peliskriptin virheenjäljitys -ikkunasta diff --git a/src/lang/french.txt b/src/lang/french.txt index 18444b3d74..19dded592e 100644 --- a/src/lang/french.txt +++ b/src/lang/french.txt @@ -2197,12 +2197,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Montrer STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Montrer les livrées de véhicules routiers STR_LIVERY_SHIP_TOOLTIP :{BLACK}Montrer les livrées de navires STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Montrer les livrées d'aéronefs +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Afficher les couleurs des groupes de trains +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Afficher les couleurs des groupes de véhicules +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Afficher les couleurs des groupes de bateaux +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Afficher les couleurs des groupes d'avions STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Choisir la couleur primaire de la livrée sélectionnée. Ctrl-clic appliquera cette couleur à toutes les livrées. STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Choisir la couleur secondaire de la livrée sélectionnée. Ctrl-clic appliquera cette couleur à toutes les livrées. STR_LIVERY_PANEL_TOOLTIP :{BLACK}Sélectionner la livrée à modifier ou plusieurs d'entre elles par Ctrl-clic. Cliquer sur la case à cocher pour en activer l'utilisation ou non. +STR_LIVERY_TRAIN_GROUP_EMPTY :Aucun groupe de trains +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Aucun groupe de véhicules +STR_LIVERY_SHIP_GROUP_EMPTY :Aucun groupe de bateaux +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Aucun groupe d'avions ###length 23 -STR_LIVERY_DEFAULT :Livrée standard +STR_LIVERY_DEFAULT :Livrée par défaut STR_LIVERY_STEAM :Locomotive à vapeur STR_LIVERY_DIESEL :Locomotive Diesel STR_LIVERY_ELECTRIC :Locomotive électrique @@ -4654,9 +4662,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Respecte STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Activer/Désactiver le respect de la casse pour comparer les messages d'IA avec la chaîne d'arrêt STR_AI_DEBUG_CONTINUE :{BLACK}Continuer STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Reprendre la partie et continuer l'IA -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Afficher la sortie de débogage de cette IA +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Afficher la sortie de débogage de cette IA. Ctrl+Click pour ouvrir dans une nouvelle fenêtre STR_AI_GAME_SCRIPT :{BLACK}Script de jeu -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Examiner le journal du script de jeu +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Examiner le journal du script de jeu. Ctrl+Click pour ouvrir dans une nouvelle fenêtre STR_ERROR_AI_NO_AI_FOUND :Aucune IA n'a été trouvée.{}Cette IA est factice et ne fera rien.{}Vous pouvez télécharger diverses IA via le système de «{NBSP}Contenu en ligne{NBSP}». STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}L'un des scripts a rencontré un problème. Merci de rapporter ceci à l'auteur du script avec une capture d'écran de la fenêtre de débogage de scripts. diff --git a/src/lang/galician.txt b/src/lang/galician.txt index 57b61945f1..a3e5aa123f 100644 --- a/src/lang/galician.txt +++ b/src/lang/galician.txt @@ -256,6 +256,7 @@ STR_UNITS_HEIGHT_IMPERIAL :{DECIMAL} pés STR_UNITS_HEIGHT_METRIC :{DECIMAL} m STR_UNITS_HEIGHT_SI :{DECIMAL} m +STR_UNITS_TICKS :{COMMA}{NBSP}tick{P "" s} # Common window strings STR_LIST_FILTER_TITLE :{BLACK}Filtrar: @@ -1657,6 +1658,8 @@ STR_CONFIG_SETTING_LOADING_INDICATORS :Usar indicadore STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Escolle se os indicadores de carga se amosan sobre os vehículos en carga/descarga ###length 3 +STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS :Días +STR_CONFIG_SETTING_TIMETABLE_MODE_SECONDS :Segundos STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Mostrar chegada e saída nos horarios: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Amosar chegadas e saídas anticipadas nos horarios @@ -2187,9 +2190,14 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Mostra-l STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Mostra-los esquemas de cor dos vehículos de estrada STR_LIVERY_SHIP_TOOLTIP :{BLACK}Mostra-los esquemas de cor dos barcos STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Mostra-los esquemas de cor das aeronaves +STR_LIVERY_TRAIN_GROUP_TOOLTIP :Amosa as cores dos grupos de trens +STR_LIVERY_SHIP_GROUP_TOOLTIP :Amosa as cores dos grupos de barcos STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Elixe a cor primaria para o esquema seleccionado. Ctrl+Click aplicará esta cor a tódolos esquemas STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Elixe a cor secundaria para o esquema seleccionado. Ctrl+Click aplicará esta cor a tódolos esquemas STR_LIVERY_PANEL_TOOLTIP :{BLACK}Selecciona un esquema de cor para cambialo, ou múltiples esquemas con CTRL+click. Pincha na caixa para cambia lo uso do esquema +STR_LIVERY_TRAIN_GROUP_EMPTY :Non se creou ningún grupo de trens +STR_LIVERY_SHIP_GROUP_EMPTY :Non se creou ningún grupo de barcos +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Non se crearon grupos de aeronaves ###length 23 STR_LIVERY_DEFAULT :Esquemas de cor estándar @@ -3200,6 +3208,7 @@ STR_MAPGEN_MAPSIZE :{BLACK}Tamaño STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK} Selecciona o tamaño do mapa en cadros. O número de cadros dispoñíbeis será sensiblemente menor STR_MAPGEN_BY :{BLACK}* STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Nº de cidades: +STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP :Selecciona a densidade das cidades ou un número á túa escolla STR_MAPGEN_TOWN_NAME_LABEL :{BLACK}Nomes das localidades: STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP :{BLACK}Selecciona o estilo dos nomes das cidades STR_MAPGEN_DATE :{BLACK}Data: @@ -3265,6 +3274,7 @@ STR_MAPGEN_BORDER_MANUAL :{BLACK}Manual STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}Rotación do mapa de alturas: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}Nome do mapa de alturas: +STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP :O nome do arquivo de imaxe do mapa de alturas. STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}Tamaño: STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} @@ -4573,8 +4583,11 @@ STR_TIMETABLE_STATUS_ON_TIME :{BLACK}Este veh STR_TIMETABLE_STATUS_LATE :{BLACK}Este vehículo está retrasado {STRING} STR_TIMETABLE_STATUS_EARLY :{BLACK}Este vehículo vai adiantado {STRING} STR_TIMETABLE_STATUS_NOT_STARTED :{BLACK}Este horario aínda non comezóu +STR_TIMETABLE_STATUS_START_AT_DATE :{BLACK}Este horario comezará no seguinte horario{STRING} +STR_TIMETABLE_START :Empezar táboa de horarios +STR_TIMETABLE_START_SECONDS_QUERY :Segundos até empezar a táboa de horarios STR_TIMETABLE_CHANGE_TIME :{BLACK}Cambiar Tempo STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Cambiar o tempo que debería levar a orde seleccionada. Ctrl+Click cambia o tempo para todas as ordes diff --git a/src/lang/korean.txt b/src/lang/korean.txt index d965b4c8c9..8d61fd2bef 100644 --- a/src/lang/korean.txt +++ b/src/lang/korean.txt @@ -403,8 +403,8 @@ STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR :{BLACK}툴바 STR_SCENEDIT_TOOLBAR_TOOLTIP_SAVE_SCENARIO_LOAD_SCENARIO :{BLACK}시나리오를 저장하거나, 불러오거나, 시나리오 에디터를 종료하거나, 게임을 종료합니다 STR_SCENEDIT_TOOLBAR_OPENTTD :{YELLOW}OpenTTD STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR :{YELLOW}시나리오 에디터 -STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD :{BLACK}시작년도를 1년 앞당깁니다. -STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD :{BLACK}시작년도를 1년 늦춥니다. +STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD :{BLACK}시작 일시를 1년 앞당깁니다. +STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD :{BLACK}시작 일시를 1년 늦춥니다. STR_SCENEDIT_TOOLBAR_TOOLTIP_SET_DATE :{BLACK}시작 연도를 입력하세요. STR_SCENEDIT_TOOLBAR_TOOLTIP_DISPLAY_MAP_TOWN_DIRECTORY :{BLACK}지도, 도시 목록 보여주기 STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION :{BLACK}지형을 생성합니다. @@ -1492,7 +1492,7 @@ STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL :오리지널 STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS :천지창조 STR_CONFIG_SETTING_TERRAIN_TYPE :지형 종류: {STRING} -STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :(천지창조 전용) 지형의 언덕 모양을 결정합니다. +STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :지형의 언덕과 산지 모양을 결정합니다 STR_CONFIG_SETTING_INDUSTRY_DENSITY :산업시설 수: {STRING} STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :게임을 플레이하는 동안 얼마나 많은 산업시설이 생성되고 유지되어야 할 지를 설정합니다. @@ -1501,18 +1501,18 @@ STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :석유 관련 STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :정유 공장과 유전이 맵 가장자리에서 얼마나 멀리 떨어진 곳까지 건설될 수 있는지를 나타냅니다. 섬 맵에서는 이 설정을 이용해서 해당 산업시설이 해안에 가까이 있도록 조정할 수 있습니다. 256칸보다 큰 맵의 경우에는 이 값은 더 크게 조정됩니다. STR_CONFIG_SETTING_SNOWLINE_HEIGHT :설선 고도: {STRING} -STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :아한대 기후의 설선 고도를 조절합니다. 눈은 산업시설의 생성과 도시 성장에 영향을 미칩니다. 시나리오 에디터에서 수정할 수 있고 설정하지 않은 경우 "눈 비율" 설정을 따릅니다. +STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :아한대 기후의 설선 고도를 선택합니다. 눈은 산업시설의 생성과 도시 성장에 영향을 미칩니다. 시나리오 에디터에서 수정할 수 있고 설정하지 않은 경우 "눈 비율" 설정을 따릅니다. STR_CONFIG_SETTING_SNOW_COVERAGE :눈 비율: {STRING} -STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :아한대 기후에서 눈 지역의 양을 대략적으로 조절할 수 있습니다. 눈은 산업시설 생성과 도시 성장 요구사항에도 영향을 미칩니다. 지도를 생성할 때에만 사용하는 설정입니다. 해수면 바로 위에 있는 땅은 무조건 눈이 없을 것입니다. +STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :아한대 기후에서 눈 지역의 양을 대략적으로 선택합니다. 눈은 산업시설 생성과 도시 성장 요구 조건에도 영향을 미칩니다. 지도를 생성할 때에만 사용하는 설정입니다. 해수면 바로 위에 있는 땅은 무조건 눈이 없을 것입니다. STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_DESERT_COVERAGE :사막 비율: {STRING} -STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :아열대 기후에서 사막 지역의 양을 대략적으로 조절할 수 있습니다. 사막은 산업시설 생성에도 영향을 미칩니다. 지도를 생성할 때에만 사용하는 설정입니다 +STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :아열대 기후에서 사막 지역의 양을 대략적으로 선택합니다. 사막은 산업시설 생성과 도시 성장 요구 조건에도 영향을 미칩니다. 지도를 생성할 때에만 사용하는 설정입니다 STR_CONFIG_SETTING_DESERT_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :지형의 거친 정도: {STRING} -STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(천지창조 전용) 언덕의 빈도수를 선택합니다. 평탄한 지형은 개수가 적고 넓게 퍼진 언덕을 만듭니다. 거친 지형은 똑같아 보일 수 있는 많은 언덕이 생기게 됩니다. +STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :언덕의 모양과 빈도 수를 선택합니다. 평탄한 지형은 개수가 적고 넓게 퍼진 언덕을 만들고, 거친 지형은 작은 언덕이 많이 만듭니다. ###length 4 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :매우 부드럽게 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH :부드럽게 @@ -1520,7 +1520,7 @@ STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH :거칠게 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH :매우 거칠게 STR_CONFIG_SETTING_VARIETY :산세 험준도: {STRING} -STR_CONFIG_SETTING_VARIETY_HELPTEXT :(천지창조 전용) 지도가 산지와 평지를 모두 갖도록 만들 것인 지를 결정합니다. 이 설정은 지형을 더 평평하게 만드므로, 다른 설정은 '산'으로 설정하시기 바랍니다. +STR_CONFIG_SETTING_VARIETY_HELPTEXT :지도가 산지와 평지를 모두 갖도록 만들 것인 지를 결정합니다. 더 높은 값을 사용할 수록, 산지와 평지 사이의 고도 차이가 더 많아집니다. STR_CONFIG_SETTING_RIVER_AMOUNT :강의 양: {STRING} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :강을 얼마나 만들지 선택하세요 @@ -1540,6 +1540,7 @@ STR_CONFIG_SETTING_ROAD_SIDE_LEFT :좌측통행 STR_CONFIG_SETTING_ROAD_SIDE_RIGHT :우측통행 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION :높이맵 회전: {STRING} +STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP :높이맵을 게임 세계에 맞추기 위해 어느 방향으로 회전시킬지 선택합니다 ###length 2 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE :반시계방향 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE :시계방향 @@ -2196,9 +2197,17 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}열차 STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}차량 색상 선택 STR_LIVERY_SHIP_TOOLTIP :{BLACK}선박 색상 선택 STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}항공기 색상 선택 +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}열차 그룹 색상 선택 +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}자동차 그룹 색상 선택 +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}선박 그룹 색상 선택 +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}항공기 그룹 색상 선택 STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}선택한 색상을 1차 색상으로 선택합니다. CTRL+클릭하면 모든 항목에 적용됩니다 STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}선택한 색상을 2차 색상으로 선택합니다. CTRL+클릭하면 모든 항목에 적용됩니다 STR_LIVERY_PANEL_TOOLTIP :{BLACK}색상 조합을 바꾸려면 선택하세요. 2개 이상 선택하려면 CTRL+클릭하세요. 네모를 클릭하여 체크하면 해당 색상 조합을 사용하게 됩니다 +STR_LIVERY_TRAIN_GROUP_EMPTY :열차 그룹을 설정하지 않았습니다 +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :자동차 그룹을 설정하지 않았습니다 +STR_LIVERY_SHIP_GROUP_EMPTY :선박 그룹을 설정하지 않았습니다 +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :항공기 그룹을 설정하지 않았습니다 ###length 23 STR_LIVERY_DEFAULT :기본 색상 @@ -3209,11 +3218,15 @@ STR_MAPGEN_MAPSIZE :{BLACK}지도 STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK}지도의 크기를 칸 수 기준으로 선택하세요. 사용 가능한 지도의 칸 수는 설정한 값보다 조금 작을 것입니다 STR_MAPGEN_BY :{BLACK}x STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}도시의 수: +STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP :{BLACK}도시의 수를 선택하거나, 직접 그 개수를 입력합니다 STR_MAPGEN_TOWN_NAME_LABEL :{BLACK}도시 이름: STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP :{BLACK}도시 이름 스타일을 선택하세요 STR_MAPGEN_DATE :{BLACK}날짜: +STR_MAPGEN_DATE_TOOLTIP :{BLACK}시작 일시를 선택합니다. STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}산업시설 수: +STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP :{BLACK}산업 시설의 수를 선택하거나, 직접 그 개수를 입력합니다 STR_MAPGEN_HEIGHTMAP_HEIGHT :{BLACK}가장 높은 지점의 높이: +STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP :{BLACK}해수면을 기준으로, 게임이 생성하려고 하는 가장 높은 곳의 높이를 선택합니다. STR_MAPGEN_HEIGHTMAP_HEIGHT_UP :{BLACK}지도에서 가장 높은 지점의 최대 높이를 1만큼 높입니다 STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN :{BLACK}지도에서 가장 높은 지점의 최대 높이를 1만큼 낮춥니다 STR_MAPGEN_SNOW_COVERAGE :{BLACK}눈 비율: @@ -3226,10 +3239,12 @@ STR_MAPGEN_DESERT_COVERAGE_DOWN :{BLACK}사막 STR_MAPGEN_DESERT_COVERAGE_TEXT :{BLACK}{NUM}% STR_MAPGEN_TERRAIN_TYPE :{BLACK}지형 종류: STR_MAPGEN_SEA_LEVEL :{BLACK}해수면: +STR_MAPGEN_SEA_LEVEL_TOOLTIP :{BLACK}해수면 높이를 선택합니다 STR_MAPGEN_QUANTITY_OF_RIVERS :{BLACK}강: STR_MAPGEN_SMOOTHNESS :{BLACK}지표면을 깎는 방식: STR_MAPGEN_VARIETY :{BLACK}산세 험준도: STR_MAPGEN_GENERATE :{WHITE}만들기 +STR_MAPGEN_GENERATE_TOOLTIP :{BLACK}세계를 만들고 OpenTTD를 플레이해보세요! STR_MAPGEN_NEWGRF_SETTINGS :{BLACK}NewGRF 설정 STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP :{BLACK}NewGRF 설정 창을 엽니다 STR_MAPGEN_AI_SETTINGS :{BLACK}인공지능 설정 @@ -3262,6 +3277,7 @@ STR_MAPGEN_TOWN_NAME_CATALAN :카탈로니아 # Strings for map borders at game generation STR_MAPGEN_BORDER_TYPE :{BLACK}지도 가장자리: +STR_MAPGEN_BORDER_TYPE_TOOLTIP :{BLACK}게임 세계의 지도 가장자리를 선택합니다 STR_MAPGEN_NORTHWEST :{BLACK}북서 STR_MAPGEN_NORTHEAST :{BLACK}북동 STR_MAPGEN_SOUTHEAST :{BLACK}남동 @@ -3274,7 +3290,9 @@ STR_MAPGEN_BORDER_MANUAL :{BLACK}사용 STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}높이맵 방향: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}높이맵 이름: +STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP :{BLACK}높이맵 이미지 파일의 이름입니다 STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}크기: +STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP :{BLACK}원본 높이맵 이미지의 크기입니다. 최상의 조건을 위해서는, 이미지의 가로/세로 크기를 OpenTTD의 지도 크기와 같은 256, 512, 1024 등으로 맞추는 것이 좋습니다. STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT :{WHITE}목표 정상 높이 @@ -3289,6 +3307,7 @@ STR_SE_MAPGEN_FLAT_WORLD :{WHITE}평평 STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP :{BLACK}평평한 땅 만들기 STR_SE_MAPGEN_RANDOM_LAND :{WHITE}무작위 지형 STR_SE_MAPGEN_FLAT_WORLD_HEIGHT :{BLACK}평지의 높이: +STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP :{BLACK}해수면 위의 땅 높이를 선택합니다 STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN :{BLACK}평지의 높이를 1칸 낮춥니다 STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP :{BLACK}평지의 높이를 1칸 높입니다 @@ -4643,9 +4662,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}대소 STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}인공지능 기록 메시지에서 중단 문구를 검색할 때 대소문자를 구분할지 여부를 선택합니다 STR_AI_DEBUG_CONTINUE :{BLACK}계속 STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}중단된 인공지능의 연산을 재개합니다 -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}이 인공지능에서 출력된 기록 메시지를 보여줍니다 +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}이 인공지능에서 출력된 기록 메시지를 보여줍니다. CTRL + 클릭하면 새 창으로 엽니다 STR_AI_GAME_SCRIPT :{BLACK}게임 스크립트 -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}게임 스크립트 기록 체크 +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}게임 스크립트 기록을 확인합니다. CTRL + 클릭하면 새 창으로 엽니다 STR_ERROR_AI_NO_AI_FOUND :사용할 수 있는 인공지능이 없습니다.{}따라서 이 경쟁사는 아무 것도 하지 못하는 회사입니다.{}'온라인 컨텐츠 다운로드'에서 새로운 인공지능을 다운로드받으세요 STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}작동 중이던 스크립트 중 하나에서 오류가 발생하여 중단되었습니다. 인공지능/게임 스크립트 디버그 창에서 스크린샷을 찍어 스크립트 제작자에게 보고하십시오 diff --git a/src/lang/latvian.txt b/src/lang/latvian.txt index e616355e56..9d58818a3e 100644 --- a/src/lang/latvian.txt +++ b/src/lang/latvian.txt @@ -176,7 +176,7 @@ STR_COLOUR_DEFAULT :Noklusējuma ###length 17 STR_COLOUR_DARK_BLUE :Tumši zila STR_COLOUR_PALE_GREEN :Gaiši zaļa -STR_COLOUR_PINK :Sārta +STR_COLOUR_PINK :Rozā STR_COLOUR_YELLOW :Dzeltena STR_COLOUR_RED :Sarkana STR_COLOUR_LIGHT_BLUE :Gaiši zila @@ -185,7 +185,7 @@ STR_COLOUR_DARK_GREEN :Tumši zaļa STR_COLOUR_BLUE :Zila STR_COLOUR_CREAM :Krēmkrāsa STR_COLOUR_MAUVE :Gaišsārti violeta -STR_COLOUR_PURPLE :Purpura +STR_COLOUR_PURPLE :Violets STR_COLOUR_ORANGE :Oranža STR_COLOUR_BROWN :Brūna STR_COLOUR_GREY :Pelēka @@ -193,6 +193,23 @@ STR_COLOUR_WHITE :Balta STR_COLOUR_RANDOM :Nejaušs ###length 17 +STR_COLOUR_SECONDARY_DARK_BLUE :Tumši Zila +STR_COLOUR_SECONDARY_PALE_GREEN :Gaiši Zaļa +STR_COLOUR_SECONDARY_SECONDARY_PINK :Rozā +STR_COLOUR_SECONDARY_YELLOW :Dzeltena +STR_COLOUR_SECONDARY_RED :Sarkana +STR_COLOUR_SECONDARY_LIGHT_BLUE :Gaiši Zila +STR_COLOUR_SECONDARY_GREEN :Zaļa +STR_COLOUR_SECONDARY_DARK_GREEN :Tumši zaļa +STR_COLOUR_SECONDARY_BLUE :Zila +STR_COLOUR_SECONDARY_CREAM :Krēmkrāsa +STR_COLOUR_SECONDARY_MAUVE :Purpursarkana +STR_COLOUR_SECONDARY_PURPLE :Violets +STR_COLOUR_SECONDARY_ORANGE :Oranžs +STR_COLOUR_SECONDARY_BROWN :Brūna +STR_COLOUR_SECONDARY_GREY :Pelēka +STR_COLOUR_SECONDARY_WHITE :Balta +STR_COLOUR_SECONDARY_SAME_AS_PRIMARY :Tāds, ka primārais # Units used in OpenTTD @@ -200,6 +217,7 @@ STR_UNITS_VELOCITY_IMPERIAL :{DECIMAL}{NBSP} STR_UNITS_VELOCITY_METRIC :{DECIMAL}{NBSP}km/h STR_UNITS_VELOCITY_SI :{DECIMAL}{NBSP}m/s STR_UNITS_VELOCITY_GAMEUNITS :{DECIMAL}{NBSP}lauciņi/diena +STR_UNITS_VELOCITY_KNOTS :{DECIMAL}{NBSP}mezgli STR_UNITS_POWER_IMPERIAL :{DECIMAL}{NBSP}ZS STR_UNITS_POWER_METRIC :{DECIMAL}{NBSP}ZS @@ -239,6 +257,9 @@ STR_UNITS_HEIGHT_IMPERIAL :{DECIMAL}{NBSP} STR_UNITS_HEIGHT_METRIC :{DECIMAL}{NBSP}m STR_UNITS_HEIGHT_SI :{DECIMAL}{NBSP}m +STR_UNITS_DAYS :{COMMA}{NBSP}dien{P a as ""} +STR_UNITS_SECONDS :{COMMA}{NBSP}sekund{P e s ''''} +STR_UNITS_TICKS :{COMMA}{NBSP}tick{P šķi šķi s} # Common window strings STR_LIST_FILTER_TITLE :{BLACK}Filters: @@ -279,7 +300,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_SHIP_TOOLTIP :{BLACK}Ieslēdz STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}Ieslēdzot šo iestatījumu tiks parādīti arī paslēptie lidaparāti # Query window -STR_BUTTON_DEFAULT :{BLACK}Noklusējums +STR_BUTTON_DEFAULT :{BLACK}Noklusējuma STR_BUTTON_CANCEL :{BLACK}Atcelt STR_BUTTON_OK :{BLACK}Labi STR_WARNING_PASSWORD_SECURITY :{YELLOW}Brīdinājums: servera administrators var izlasīt jebkuru tekstu, kas šeit tiek ievadīts. @@ -349,9 +370,9 @@ STR_GOTO_ORDER_VIEW_TOOLTIP :{BLACK}Atvērt ###length 31 STR_TOOLBAR_TOOLTIP_PAUSE_GAME :{BLACK}Pauzēt spēli STR_TOOLBAR_TOOLTIP_FORWARD :{BLACK}Paātrināta spēle -STR_TOOLBAR_TOOLTIP_OPTIONS :{BLACK}Opcijas -STR_TOOLBAR_TOOLTIP_SAVE_GAME_ABANDON_GAME :{BLACK}Saglabāt spēli, pamest spēli, iziet -STR_TOOLBAR_TOOLTIP_DISPLAY_MAP :{BLACK}Rādīt karti, papildu skatvietu vai zīmju sarakstu +STR_TOOLBAR_TOOLTIP_OPTIONS :{BLACK}Opcijas un iestatījumi +STR_TOOLBAR_TOOLTIP_SAVE_GAME_ABANDON_GAME :{BLACK}Saglabājiet, ielādējiet vai pametiet spēli, iziet no programmas +STR_TOOLBAR_TOOLTIP_DISPLAY_MAP :{BLACK}Rādīt karti, papildu skata logu, kravas plūsmu vai zīmju sarakstu STR_TOOLBAR_TOOLTIP_DISPLAY_TOWN_DIRECTORY :{BLACK}Rādīt pilsētu sarakstu STR_TOOLBAR_TOOLTIP_DISPLAY_SUBSIDIES :{BLACK}Rādīt subsīdijas STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_STATIONS :{BLACK}Rādīt uzņēmuma staciju sarakstu @@ -359,9 +380,9 @@ STR_TOOLBAR_TOOLTIP_DISPLAY_COMPANY_FINANCES :{BLACK}Rādīt STR_TOOLBAR_TOOLTIP_DISPLAY_COMPANY_GENERAL :{BLACK}Rādīt uzņēmuma vispārējo informāciju STR_TOOLBAR_TOOLTIP_DISPLAY_STORY_BOOK :{BLACK}Rādīt stāstu grāmatu STR_TOOLBAR_TOOLTIP_DISPLAY_GOALS_LIST :{BLACK}Rādīt mērķu sarakstu -STR_TOOLBAR_TOOLTIP_DISPLAY_GRAPHS :{BLACK}Rādīt diagrammas +STR_TOOLBAR_TOOLTIP_DISPLAY_GRAPHS :{BLACK}Rādīt uzņēmumu grafikus un kravas maksājumu likmes STR_TOOLBAR_TOOLTIP_DISPLAY_COMPANY_LEAGUE :{BLACK}Rādīt uzņēmumu rangu sarakstu -STR_TOOLBAR_TOOLTIP_FUND_CONSTRUCTION_OF_NEW :{BLACK}Finansēt jaunas ražotnes būvniecību vai uzskaitīt visas ražotnes +STR_TOOLBAR_TOOLTIP_FUND_CONSTRUCTION_OF_NEW :{BLACK}Izpētiet nozares vai finansējiet jaunas nozares celtniecību STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_TRAINS :{BLACK}Rādīt uzņēmuma vilcienu sarakstu. Ctrl+klikšķis pārslēdz grupu/transportlīdzekļu saraksta atvēršanu STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_ROAD_VEHICLES :{BLACK}Rādīt uzņēmuma autotransporta sarakstu. Ctrl+klikšķis pārslēdz grupu/transportlīdzekļu saraksta atvēršanu STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_SHIPS :{BLACK}Rādīt uzņēmuma kuģu sarakstu. Ctrl+klikšķis pārslēdz grupu/transportlīdzekļu saraksta atvēršanu @@ -375,8 +396,8 @@ STR_TOOLBAR_TOOLTIP_BUILD_SHIP_DOCKS :{BLACK}Būvēt STR_TOOLBAR_TOOLTIP_BUILD_AIRPORTS :{BLACK}Būvēt lidostas STR_TOOLBAR_TOOLTIP_LANDSCAPING :{BLACK}Atvērt ainavas rīkjoslu, lai paceltu/nolaistu zemes līmeni, stādītu kokus utt. STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW :{BLACK}Rādīt skaņas/mūzikas logu -STR_TOOLBAR_TOOLTIP_SHOW_LAST_MESSAGE_NEWS :{BLACK}Rādīt pēdējos ziņojumus/avīžu ziņas, ziņojumu rādīšanas opcijas -STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION :{BLACK}Informācija par zemes platību, konsole, skriptu atkļūdošana, ekrānuzņēmumi, par OpenTTD +STR_TOOLBAR_TOOLTIP_SHOW_LAST_MESSAGE_NEWS :{BLACK}Rādīt pēdējo ziņojumu/ziņu pārskatu, ziņojumu vēsturi vai dzēst visus ziņojumus +STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION :{BLACK}Informācija par zemi, ekrānuzņēmums par OpenTTD un izstrādātāju rīkiem STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR :{BLACK}Pārslēgt rīkjoslas # Extra tooltips for the scenario editor toolbar @@ -392,7 +413,7 @@ STR_SCENEDIT_TOOLBAR_TOWN_GENERATION :{BLACK}Pilsētu STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION :{BLACK}Ražotņu radīšana STR_SCENEDIT_TOOLBAR_ROAD_CONSTRUCTION :{BLACK}Ceļu būvēšana STR_SCENEDIT_TOOLBAR_TRAM_CONSTRUCTION :{BLACK}Tramvaju sliežu ceļu būvniecība -STR_SCENEDIT_TOOLBAR_PLANT_TREES :{BLACK}Stādīt kokus. Shift pārslēdz būvēšanu/izmaksu tāmes rādīšanu +STR_SCENEDIT_TOOLBAR_PLANT_TREES :{BLACK}Iestādiet kokus. Ctrl atlasa apgabalu pa diagonāli. Shift pārslēdz celt/parādīt izmaksas STR_SCENEDIT_TOOLBAR_PLACE_SIGN :{BLACK}Novietot zīmi STR_SCENEDIT_TOOLBAR_PLACE_OBJECT :{BLACK}Novietojiet objektu. Ctrl atlasa apgabalu pa diagonāli. Shift pārslēdz ēku/rāda izmaksu tāmi @@ -433,7 +454,7 @@ STR_FILE_MENU_EXIT :Iziet # Map menu STR_MAP_MENU_MAP_OF_WORLD :Pasaules karte STR_MAP_MENU_EXTRA_VIEWPORT :Papildu skatvieta -STR_MAP_MENU_LINGRAPH_LEGEND :Kravu plūsmas apzīmējumi +STR_MAP_MENU_LINGRAPH_LEGEND :Kravas plūsmas apzīmējums STR_MAP_MENU_SIGN_LIST :Zīmju saraksts # Town menu @@ -492,6 +513,7 @@ STR_NEWS_MENU_DELETE_ALL_MESSAGES :Dzēst visus zi # About menu STR_ABOUT_MENU_LAND_BLOCK_INFO :Zemes platības informācija +STR_ABOUT_MENU_HELP :Palīdzība un rokasgrāmatas STR_ABOUT_MENU_TOGGLE_CONSOLE :Atvērt/aizvērt konsoli STR_ABOUT_MENU_AI_DEBUG :MI/spēles skriptu atkļūdošana STR_ABOUT_MENU_SCREENSHOT :Ekrānuzņēmums @@ -500,6 +522,7 @@ STR_ABOUT_MENU_ABOUT_OPENTTD :Par 'OpenTTD' STR_ABOUT_MENU_SPRITE_ALIGNER :Gariņu līdzinātājs STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Pārslēgt saistītās kastes STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Pārslēgt netīru bloku krāsojumu +STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES :Pārslēgt logrīku kontūras # Place in highscore window ###length 15 @@ -592,7 +615,7 @@ STR_GRAPH_OPERATING_PROFIT_CAPTION :{WHITE}Darbība STR_GRAPH_INCOME_CAPTION :{WHITE}Ienākumu diagramma STR_GRAPH_CARGO_DELIVERED_CAPTION :{WHITE}Pārvadātās kravas vienības STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION :{WHITE}Uzņēmuma darbības vērtējumi (maksimālais ir 1000) -STR_GRAPH_COMPANY_VALUES_CAPTION :{WHITE}Uzņēmuma vērtības +STR_GRAPH_COMPANY_VALUES_CAPTION :{WHITE}Uzņēmuma vērtības diagramma STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION :{WHITE}Kravas apmaksas cenas STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL :{TINY_FONT}{BLACK}Dienas pārvadājumos @@ -701,6 +724,7 @@ STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Klikšķ STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Klikšķināt uz mūzikas celiņa, lai to izdzēstu no pašreizējās programmas (tikai Pielāgotā1 un Pielāgotā2) # Highscore window +STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}Lielākie uzņēmumi STR_HIGHSCORE_POSITION :{BIG_FONT}{BLACK}{COMMA}. STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN :Darījumu cilvēks STR_HIGHSCORE_PERFORMANCE_TITLE_ENTREPRENEUR :Uzņēmējs @@ -832,7 +856,7 @@ STR_NEWS_COMPANY_BANKRUPT_TITLE :{BIG_FONT}{BLAC STR_NEWS_COMPANY_BANKRUPT_DESCRIPTION :{BIG_FONT}{BLACK}{STRING} kreditori slēdza un visi īpašumi tika izpārdoti! STR_NEWS_COMPANY_LAUNCH_TITLE :{BIG_FONT}{BLACK}Darbu sāk jauns transporta uzņēmums! STR_NEWS_COMPANY_LAUNCH_DESCRIPTION :{BIG_FONT}{BLACK}{STRING} sāk būvdarbus netālu no {TOWN}! -STR_NEWS_MERGER_TAKEOVER_TITLE :{BIG_FONT}{BLACK}{STRING} tiek pārņemts {STRING} izpildījumā! +STR_NEWS_MERGER_TAKEOVER_TITLE :{BIG_FONT}{BLACK}{STRING} ir pārņēmis {STRING} par neizpaužamu summu! STR_PRESIDENT_NAME_MANAGER :{BLACK}{PRESIDENT_NAME}{}(vadītājs) STR_NEWS_NEW_TOWN :{BLACK}{BIG_FONT}{STRING} pabalstīja jaunas pilsētas - {TOWN} dibināšanu! @@ -889,6 +913,8 @@ STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE :{BLACK}Tagad ir STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP :{BLACK}Atvērt grupas logu, fokusēts uz transportlīdzekļu grupu +STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_LIST :{WHITE}{STATION} vairs nepieņem: {CARGO_LIST} +STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST :{WHITE}{STATION} tagad pieņem: {CARGO_LIST} STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED :{BIG_FONT}{BLACK}Subsīdijas piedāvājums beidzies:{}{}{STRING} no {STRING} uz {STRING} subsidēšana ir atcelta STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE :{BIG_FONT}{BLACK}Subsidēšana atcelta:{}{}{STRING} pārvadājumi no {STRING} uz {STRING} turpmāk vairs netiek subsidēti @@ -913,12 +939,27 @@ STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW_TT :{BLACK}Kopēt # Game options window STR_GAME_OPTIONS_CAPTION :{WHITE}Spēles opcijas +STR_GAME_OPTIONS_TAB_GENERAL :Vispārīgi +STR_GAME_OPTIONS_TAB_GENERAL_TT :{BLACK}Izvēlieties vispārīgos iestatījumus +STR_GAME_OPTIONS_TAB_GRAPHICS :Grafika +STR_GAME_OPTIONS_TAB_GRAPHICS_TT :{BLACK}Izvēlieties grafikas iestatījumus +STR_GAME_OPTIONS_TAB_SOUND :Skaņa +STR_GAME_OPTIONS_TAB_SOUND_TT :{BLACK}Izvēlieties skaņas un mūzikas iestatījumus +STR_GAME_OPTIONS_VOLUME :Skaļums +STR_GAME_OPTIONS_SFX_VOLUME :Skaņas efekti +STR_GAME_OPTIONS_MUSIC_VOLUME :Mūzika +STR_GAME_OPTIONS_VOLUME_0 :0% +STR_GAME_OPTIONS_VOLUME_25 :25% +STR_GAME_OPTIONS_VOLUME_50 :50% +STR_GAME_OPTIONS_VOLUME_75 :75% +STR_GAME_OPTIONS_VOLUME_100 :100% STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME :{BLACK}Naudas vienības STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP :{BLACK}Naudas vienību izvēle +STR_GAME_OPTIONS_CURRENCY_CODE :{STRING} ({STRING}) ###length 42 STR_GAME_OPTIONS_CURRENCY_GBP :Lielbritānijas sterliņu mārciņas @@ -940,7 +981,7 @@ STR_GAME_OPTIONS_CURRENCY_ISK :Īslandes krona STR_GAME_OPTIONS_CURRENCY_ITL :Itālijas liras STR_GAME_OPTIONS_CURRENCY_NLG :Nīderlandes guldeņi STR_GAME_OPTIONS_CURRENCY_NOK :Norvēģijas kronas -STR_GAME_OPTIONS_CURRENCY_PLN :Polijas zloti +STR_GAME_OPTIONS_CURRENCY_PLN :Polijas Zlots STR_GAME_OPTIONS_CURRENCY_RON :Rumānijas lejas STR_GAME_OPTIONS_CURRENCY_RUR :Krievijas rubļi STR_GAME_OPTIONS_CURRENCY_SIT :Slovēnijas tolāri @@ -970,6 +1011,10 @@ STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_TOOLTIP :{BLACK}Izvēlē # Autosave dropdown ###length 5 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF :Izslēgta +STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_10_MINUTES :Ik pēc 10 minūtēm +STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_30_MINUTES :Ik pēc 30 minūtēm +STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_60_MINUTES :Ik pēc 60 minūtēm +STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_120_MINUTES :Ik pēc 120 minūtēm STR_GAME_OPTIONS_LANGUAGE :{BLACK}Valoda STR_GAME_OPTIONS_LANGUAGE_TOOLTIP :{BLACK}Saskarnes valodas izvēle @@ -1006,6 +1051,13 @@ STR_GAME_OPTIONS_GUI_SCALE_3X :3x STR_GAME_OPTIONS_GUI_SCALE_4X :4x STR_GAME_OPTIONS_GUI_SCALE_5X :5x +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_FRAME :{BLACK}Automatizēta aptauja +STR_GAME_OPTIONS_PARTICIPATE_SURVEY :{BLACK}Piedalieties automatizētā aptaujā +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_TOOLTIP :{BLACK}Ja ieslēgts, OpenTTD pārsūtīs aptauju, izejot no spēles +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_LINK :{BLACK}Par aptauju un privātumu +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_LINK_TOOLTIP :{BLACK}Tiek atvērts pārlūks ar plašāku informāciju par automatizēto aptauju +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_PREVIEW :{BLACK}Priekšskatīt aptaujas rezultātus +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_PREVIEW_TOOLTIP :{BLACK}Rādīt pašreizējās spēles aptaujas rezultātus STR_GAME_OPTIONS_GRAPHICS :{BLACK}Grafika @@ -1015,17 +1067,18 @@ STR_GAME_OPTIONS_REFRESH_RATE_ITEM :{NUM}Hz STR_GAME_OPTIONS_REFRESH_RATE_WARNING :{WHITE}Atsvaidzes intensitāte, kas lielāka par 60 Hz, var ietekmēt veiktspēju. STR_GAME_OPTIONS_BASE_GRF :{BLACK}Pamata grafikas kopa -STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Atlasīt lietošanai pamata grafikas kopu +STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Atlasiet izmantojamo pamata grafiku (to nevar mainīt spēlē, tikai no galvenās izvēlnes) STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP :{BLACK}Papildinformācija par pamata grafikas kopu STR_GAME_OPTIONS_BASE_SFX :{BLACK}Pamata skaņas kopa -STR_GAME_OPTIONS_BASE_SFX_TOOLTIP :{BLACK}Atlasīt lietošanai pamata skaņas kopu +STR_GAME_OPTIONS_BASE_SFX_TOOLTIP :{BLACK}Atlasiet izmantojamās pamata skaņas (nevar mainīt spēlē, tikai galvenajā izvēlnē) STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP :{BLACK}Papildinformācija par pamata skaņas kopu STR_GAME_OPTIONS_BASE_MUSIC :{BLACK}Pamata mūzikas kopa STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP :{BLACK}Atlasīt lietošanai pamata mūzikas kopu STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP :{BLACK}Papildinformācija par pamata mūzikas kopu +STR_BASESET_STATUS :{STRING} {RED}({NUM} trūkst/bojāts fail{P s i ""}) STR_ERROR_RESOLUTION_LIST_FAILED :{WHITE}Neizdevās saņemt sarakstu ar atbalstītajām izšķirtspējām STR_ERROR_FULLSCREEN_FAILED :{WHITE}Pilnekrāna spēles iestatīšana neizdevās @@ -1135,6 +1188,7 @@ STR_CONFIG_SETTING_EXPAND_ALL :{BLACK}Izvērst STR_CONFIG_SETTING_COLLAPSE_ALL :{BLACK}Sakļaut visu STR_CONFIG_SETTING_RESET_ALL :{BLACK}Atiestatīt visas vērtības STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT :(skaidrojums nav pieejams) +STR_CONFIG_SETTING_VALUE :{PUSH_COLOUR}{ORANGE}{STRING}{POP_COLOUR} STR_CONFIG_SETTING_DEFAULT_VALUE :{LTBLUE}Noklusējuma vērtība: {ORANGE}{STRING} STR_CONFIG_SETTING_TYPE :{LTBLUE}Iestatījuma veids: {ORANGE}{STRING} STR_CONFIG_SETTING_TYPE_CLIENT :lietotāja iestatījums (netiek iekļauts saglabājumos, ietekmē visas spēles) @@ -1188,6 +1242,7 @@ STR_CONFIG_SETTING_HORIZONTAL_POS_LEFT :pa kreisi STR_CONFIG_SETTING_HORIZONTAL_POS_CENTER :centrā STR_CONFIG_SETTING_HORIZONTAL_POS_RIGHT :pa labi +STR_CONFIG_SETTING_SECONDS_VALUE :{COMMA}{NBSP}sekund{P 0 i es ""} STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN :Maksimālais sākotnējais aizdevums: {STRING} STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN_HELPTEXT :Maksimālais aizdevuma daudzums, ko uzņēmums var izsniegt (neskaitot inflāciju) @@ -1246,7 +1301,7 @@ STR_CONFIG_SETTING_CATCHMENT :Atļaut realist STR_CONFIG_SETTING_CATCHMENT_HELPTEXT :Atšķirīga lieluma apkalpojamās platības dažādu veidu stacijām un lidostām STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES :Uzņēmumu stacijas var apkalpot industrijas, kurām ir pievienotas neitrālas stacijas: {STRING} -STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :Ja ieslēgts, industrijas ar pievienotām stacijām (piemēram, naftas ieguves platformas) var apkalpot arī netālu esošās uzņēmumumam piederošās stacijas. Ja izslēgts, šīs industrijas var apkalpot tikai to pašu stacijas. Tuvumā esošās uzņēmumu stacijas nevarēs tās apkalpot, un pievienotās stacijas neapkalpos preču veidus, kas nav atbilstošas attiecīgajai industrijai. +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :Kad ieslēgts, nozares ar pievienotajām stacijām (piemēram, naftas ieguves platformām) var apkalpot arī uzņēmumam piederošas stacijas, kas uzbūvētas tuvumā. Ja tas ir atspējots, šīs nozares var apkalpot tikai tām pievienotās stacijas. Nevienas tuvumā esošās uzņēmuma stacijas nevarēs tos apkalpot, kā arī pievienotā stacija apkalpos neko citu kā tikai nozari STR_CONFIG_SETTING_EXTRADYNAMITE :Atļaut pilsētai piederošo ceļu, tiltu un tuneļu nojaukšanu: {STRING} STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT :Padara vieglāku pilsētai piederošas infrastruktūras un ēku nojaukšanu @@ -1316,7 +1371,7 @@ STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT :Jaunie rīkojum STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT_HELPTEXT :Transportlīdzeklis parasti pietur pie katras caurbraucamās stacijas. Ieslēdzot šo iestatījumu, tas dosies cauri visām ceļa stacijām uz savu galamērķi bez pieturām. Ņemiet vērā, ka šis iestatījums nosaka noklusējuma vērtību tikai jaunajiem rīkojumiem. Tomēr ir iespējams katru rīkojumu iestatīt arī atsevišķi STR_CONFIG_SETTING_STOP_LOCATION :Jaunie vilcienu rīkojumi noklusējumā liek apstāties perona {STRING} -STR_CONFIG_SETTING_STOP_LOCATION_HELPTEXT :Vieta, kur vilciens apstāsies pie perona noklusējumā. 'Sākumā' ir pie ieejas stacijā, 'vidū' nozīmē perona vidū, un 'beigās' ir tālu prom no ieejas. Ņemiet vērā, ka šis iestatījums nosaka noklusējuma vērtību tikai jaunajiem rīkojumiem. Taču individuālos rīkojumos var noteikt atšķirīgu rīcību +STR_CONFIG_SETTING_STOP_LOCATION_HELPTEXT :Vieta, kur vilciens pēc noklusējuma apstāsies pie perona. “Tuvākais gals” nozīmē tuvu ieejas punktam, “vidējais” nozīmē platformas vidu un “tālais gals” nozīmē tālu no ieejas punkta. Ņemiet vērā, ka šis iestatījums nosaka tikai noklusējuma vērtību jauniem pasūtījumiem. Atsevišķu pasūtījumu pieturas vietu var iestatīt, noklikšķinot uz pasūtījuma teksta ###length 3 STR_CONFIG_SETTING_STOP_LOCATION_NEAR_END :sākumā STR_CONFIG_SETTING_STOP_LOCATION_MIDDLE :vidū @@ -1359,9 +1414,11 @@ STR_CONFIG_SETTING_PLANE_CRASHES_NONE :Nav* STR_CONFIG_SETTING_PLANE_CRASHES_REDUCED :samazināts STR_CONFIG_SETTING_PLANE_CRASHES_NORMAL :parasts +STR_CONFIG_SETTING_CROSSING_WITH_COMPETITOR :Atļaut dzelzceļa pārbrauktuves ar ceļiem vai sliedēm, kas pieder sāncenšiem: {STRING} +STR_CONFIG_SETTING_CROSSING_WITH_COMPETITOR_HELPTEXT :Atļaut būvēt dzelzceļa pārbrauktuves uz sāncenšu piederošiem ceļiem vai sliedēm -STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD :Atļaut caurbraucamas pieturvietas uz pilsētai piederošiem ceļiem: {STRING} -STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD_HELPTEXT :Ļauj būvēt caurbraucamas pieturvietas uz pilsētai piederošiem ceļiem +STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD :Atļaut caurbraucamo ceļu pieturas uz ceļiem, kas pieder pilsētām: {STRING} +STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD_HELPTEXT :Atļaut būvēt caurbraucamo ceļu pieturas uz ceļiem, kas pieder pilsētām STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD :Atļaut caurbraucamas pieturvietas uz sāncenšu ceļiem: {STRING} STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD_HELPTEXT :Ļauj būvēt caurbraucamas pieturvietas uz citiem uzņēmumiem piederošiem ceļiem STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES :{WHITE}Šo iestatījumu nav iespējams mainīt, kad tur ir transportlīdzekļi @@ -1372,6 +1429,8 @@ STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT :Kad ieslēgts, STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR :Sākotnējā uzņēmuma krāsa: {STRING} STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_HELPTEXT :Izvēlieties uzņēmuma sākotnējo krāsu +STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_SECONDARY :Uzņēmuma sākuma sekundārā krāsa: {STRING} +STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_SECONDARY_HELPTEXT :Izvēlieties uzņēmuma sākuma sekundāro krāsu, ja izmantojat NewGRF, kas to ļauj. STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS :Lidostas darbosies mūžīgi: {STRING} STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT :Ieslēdzot šo iestatījumu, katrs lidostas veids pēc tā ieviešanas vienmēr ir pieejams @@ -1434,7 +1493,7 @@ STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL :Sākotnējais STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS :TerraGenesis STR_CONFIG_SETTING_TERRAIN_TYPE :Reljefa veids: {STRING} -STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :(Tikai TerraGenesis) Ainavas kalnainība +STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :Izvēlieties ainavas pauguru un kalnu augstumu STR_CONFIG_SETTING_INDUSTRY_DENSITY :Industriju blīvums: {STRING} STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :Iestatiet, cik industrijas jāģenerē un kāds līmenis jāuztur spēles laikā @@ -1443,18 +1502,18 @@ STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :Naftas industri STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Limits, cik tālu no kartes malām drīkst taisīt naftas pārstrādes rūpnīcas un un naftas ieguves platformas. Uz salu kartēm tas nodrošina, ka šīs konstrukcijas tiek būvētas piekrastēs. Uz kartēm, kas ir lielākas par 256 lauciņiem šī vērtība tiek palielināta. STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Sniega līnijas augstums: {STRING} -STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Kontrolē, kādā augstumā sākas sniegs subarktiskajā ainavā. Sniegs ietekmē arī nozares ražošanas un pilsētu izaugsmes prasības. Var mainīt tikai, izmantojot scenāriju redaktoru, vai citādi aprēķināts, izmantojot “sniega segumu” +STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Izvēlieties, kādā augstumā sākas sniegs subarktiskajā ainavā. Sniegs ietekmē arī nozares ražošanas un pilsētu izaugsmi. Var mainīt tikai, izmantojot scenāriju redaktoru, vai citādi aprēķināt, izmantojot "sniega segumu" STR_CONFIG_SETTING_SNOW_COVERAGE :Sniega pārklājums: {STRING} -STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Kontrolē aptuveno sniega daudzumu subarktiskajā ainavā. Sniegs ietekmē arī nozares ražošanas un pilsētu izaugsmes prasības. Izmanto tikai karšu ģenerēšanas laikā. Zeme tieši virs jūras līmeņa vienmēr ir bez sniega +STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Izvēlieties aptuveno sniega daudzumu subarktiskajā ainavā. Sniegs ietekmē arī nozares ražošanas un pilsētu izaugsmei. Izmanto tikai kartes ģenerēšanas laikā. Uz jūras līmeņa un piekrastes abpagaliem nekad nav sniega. STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_DESERT_COVERAGE :Tuksneša pārklājums: {STRING} -STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Kontrolējiet aptuveno tuksneša daudzumu tropiskajā ainavā. Tuksnesis ietekmē arī nozaru veidošanos. Izmanto tikai karšu ģenerēšanas laikā +STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Izvēlieties aptuveno tuksneša daudzumu tropiskajā ainavā. Tuksnesis ietekmē arī nozares ražošanas un pilsētu izaugsmi. Izmanto tikai kartes ģenerēšanas laikā STR_CONFIG_SETTING_DESERT_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :Apvidus nelīdzenums: {STRING} -STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(Tikai TerraGenesis) Izvēlieties pauguru biežumu — gludās ainavās ir mazāk pauguru, bet tie ir plaši izvērsti. Nelīdzenā ainavā ir daudz pauguru, kas var izskatīties vienveidīgi. +STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :Izvēlieties pauguru formu un skaitu. Gludās ainavās ir mazāk, bet platāku pauguru, savukārt nelīdzenās ainavās ir vairāk, mazāku kalnu. ###length 4 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :Ļoti gluda STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH :Gluda @@ -1462,7 +1521,7 @@ STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH :Nelīdzena STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH :Ļoti nelīdzena STR_CONFIG_SETTING_VARIETY :Dažādības sadalījums: {STRING} -STR_CONFIG_SETTING_VARIETY_HELPTEXT :(Tikai TerraGenesis) Nosaka, vai karte satur gan kalnus, gan līdzenumus. Tā kā šis padara karti tikai plakanāku, citus iestatījumus vajadzētu pārslēgt uz kalnainumu +STR_CONFIG_SETTING_VARIETY_HELPTEXT :Izvēlieties, vai kartē ir gan kalni, gan līdzenas vietas. Jo augstāka atšķirība, jo lielākas atšķirības kalnu un līdzenu apgabalu augstumā. STR_CONFIG_SETTING_RIVER_AMOUNT :Upju daudzums: {STRING} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :Izvēlieties, cik daudz upju ģenerēt @@ -1482,6 +1541,7 @@ STR_CONFIG_SETTING_ROAD_SIDE_LEFT :Brauc pa kreiso STR_CONFIG_SETTING_ROAD_SIDE_RIGHT :Brauc pa labo pusi STR_CONFIG_SETTING_HEIGHTMAP_ROTATION :Augstumu kartes pagriešana: {STRING} +STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP :Izvēlieties, kādā veidā augstuma kartes attēls tiek pagriezts, lai tas iekļautos spēles pasaulē ###length 2 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE :Pret pulksteņa rādītāja virzienu STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE :Pulksteņa rādītāja virzienā @@ -1516,7 +1576,7 @@ STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREY_TO_RED :Pelēks uz sark STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREYSCALE :Pelēktonis STR_CONFIG_SETTING_SCROLLMODE :Skatvietas ritināšanas uzvedība: {STRING} -STR_CONFIG_SETTING_SCROLLMODE_HELPTEXT :Uzvedība, kad ritina karti +STR_CONFIG_SETTING_SCROLLMODE_HELPTEXT :Uzvedība, ritinot karti. Opcijas “peles pozīcija bloķēta” nedarbojas visās sistēmās, piemēram, tīmekļa versijās, skārienekrānos, Linux ar Wayland un citās ###length 4 STR_CONFIG_SETTING_SCROLLMODE_DEFAULT :Pārvietot skatvietu ar labo peles pogu, peles pozīcija ir fiksēta STR_CONFIG_SETTING_SCROLLMODE_RMB_LOCKED :Pārvietot karti ar labo peles pogu, peles pozīcija ir fiksēta @@ -1574,6 +1634,9 @@ STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_OFF :Izslēgta STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE :Aizvērt logu ar labo klikšķi: {STRING} STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_HELPTEXT :Labais klikšķis logā aizver logu. Izslēdz paskaidres parādīšanu ar labo klikšķi! ###length 3 +STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_NO :Nē +STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_YES :Jā +STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_YES_EXCEPT_STICKY :Jā, izņemot lipīgo STR_CONFIG_SETTING_DATE_FORMAT_IN_SAVE_NAMES :Lietot {STRING} datuma formātu saglabāto spēļu nosaukumos STR_CONFIG_SETTING_DATE_FORMAT_IN_SAVE_NAMES_HELPTEXT :Datuma formāts spēļu saglabājuma failu nosaukumos @@ -1599,7 +1662,12 @@ STR_CONFIG_SETTING_ADVANCED_VEHICLE_LISTS_HELPTEXT :Ieslēgt papild STR_CONFIG_SETTING_LOADING_INDICATORS :Lietot piekraušanas rādītājus: {STRING} STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Izvēlēties piekraušanas rādītāju attēlošanu virs iekraujamiem un izkraujamiem transportlīdzekļiem +STR_CONFIG_SETTING_TIMETABLE_MODE :Laika vienības laika grafikiem: {STRING} +STR_CONFIG_SETTING_TIMETABLE_MODE_HELPTEXT :Izvēlieties transportlīdzekļu kustības sarakstos izmantotās laika vienības ###length 3 +STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS :Dienas +STR_CONFIG_SETTING_TIMETABLE_MODE_SECONDS :Sekundes +STR_CONFIG_SETTING_TIMETABLE_MODE_TICKS :Tiki STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Kustības sarakstos rādīt pienākšanu un atiešanu: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Kustības sarakstos rādīt paredzamos pienākšanas un atiešanas laikus @@ -1694,7 +1762,7 @@ STR_CONFIG_SETTING_SCRIPT_MAX_MEMORY_HELPTEXT :Cik daudz atmi STR_CONFIG_SETTING_SCRIPT_MAX_MEMORY_VALUE :{COMMA} MiB STR_CONFIG_SETTING_SERVINT_ISPERCENT :Apkopju starplaiki procentos: {STRING} -STR_CONFIG_SETTING_SERVINT_ISPERCENT_HELPTEXT :Izvēlieties, vai transportlīdzekļu apkopi veikt pēc fiksēta laika kopš iepriekšējās apkopes vai, kad uzticamība nokrīt zem kāda noteiktas daļas no maksimālās uzticamības +STR_CONFIG_SETTING_SERVINT_ISPERCENT_HELPTEXT :Ja tas ir ieslēgts, transportlīdzekļi mēģina veikt apkopi, kad to uzticamība samazinās par noteiktu procentuālo daļu no maksimālās uzticamības.{}{}Piemēram, ja transportlīdzekļa maksimālā uzticamība ir 90% un apkopes intervāls ir 20%, transportlīdzeklis mēģinās veikt apkopi, kad tas sasniedz 72% ticamību. STR_CONFIG_SETTING_SERVINT_TRAINS :Vilcienu apkopju noklusējuma starplaiks: {STRING} STR_CONFIG_SETTING_SERVINT_TRAINS_HELPTEXT :Izvēlēties jaunajiem sliežu transportlīdzekļiem apkopju noklusējuma starplaiku, ja tiem tas nav noteikts @@ -1824,8 +1892,8 @@ STR_CONFIG_SETTING_ALLOW_TOWN_ROADS_HELPTEXT :Ļauj pilsētā STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS :Pilsētam ir atļauts būvēt vienlīmeņa krustojumus: {STRING} STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS_HELPTEXT :Šā iestatījuma ieslēgšana pilsētām atļauj būvēt vienlīmeņa krustojumus -STR_CONFIG_SETTING_NOISE_LEVEL :Atļaut pilsētām kontrolēt trokšņu līmeni lidostās: {STRING} -STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT :Ja šis iestatījums ir izslēgts, tad katrā pilsētā var būt divas lidostas. Ja šis iestatījums ir ieslēgts, tad lidostu daudzums pilsētā ir ierobežots ar pilsētas piekrišanu troksnim, kas ir atkarīga no iedzīvotāju skaita, lidostas lieluma un attāluma +STR_CONFIG_SETTING_NOISE_LEVEL :Lidostas izvietojuma ierobežojums, pamatojoties uz trokšņa līmeni: {STRING} +STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT :Ļaujiet pilsētām bloķēt lidostu būvniecību, pamatojoties uz to trokšņa pieļaujamo līmeni, kas ir balstīts uz pilsētas iedzīvotāju skaitu un lidostas lielumu un attālumu. Ja šis iestatījums ir izslēgts, pilsētās tiek atļautas tikai divas lidostas, ja vien vietējās iestādes attieksme nav "Atļaujoša" STR_CONFIG_SETTING_TOWN_FOUNDING :Pilsētu dibināšana: {STRING} STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT :Šā iestatījuma ieslēgšana atļauj spēlētājiem spēlē nodibināt jaunas pilsētas @@ -1899,13 +1967,17 @@ STR_CONFIG_SETTING_LARGER_TOWNS_DISABLED :neviena STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER :Pilsētu sākuma lieluma reizinātājs: {STRING} STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER_HELPTEXT :Pilsētu vidējais lielums attiecībā pret parastām apdzīvotām vietām spēles sākumā +STR_CONFIG_SETTING_LINKGRAPH_RECALC_INTERVAL :Atjaunināt sadalījuma grafu ik pēc {STRING} +STR_CONFIG_SETTING_LINKGRAPH_RECALC_INTERVAL_HELPTEXT :Laiks starp turpmākajiem saišu grafa pārrēķiniem. Katrs pārrēķins aprēķina viena grafa komponentes plānus. Tas nozīmē, ka vērtība X šim iestatījumam nenozīmē, ka visa diagramma tiks atjaunināta ik pēc X sekundēm. Būs tikai daži komponenti. Jo īsāku to iestatīsit, jo vairāk CPU laika būs nepieciešams tā aprēķināšanai. Jo ilgāk to iestatīsit, jo ilgāks laiks paies, līdz sāksies kravu sadale jaunos maršrutos. +STR_CONFIG_SETTING_LINKGRAPH_RECALC_TIME :Izplatības grafa pārrēķināšanai izmantojiet {STRING} +STR_CONFIG_SETTING_LINKGRAPH_RECALC_TIME_HELPTEXT :Laiks, kas nepieciešams katram saišu grafa komponenta pārrēķinam. Kad tiek sākts pārrēķins, tiek izveidots pavediens, kuram ir atļauts darboties šo sekunžu skaitu. Jo īsāku iestatījumu iestatāt, jo lielāka iespēja, ka pavediens nebūs pabeigts paredzētajā laikā. Tad spēle apstājas, līdz pāriet ielāde. Jo ilgāk jūs to iestatāt, jo ilgāks laiks nepieciešams, līdz izplatīšana tiek atjaunināta, mainoties maršrutiem. STR_CONFIG_SETTING_DISTRIBUTION_PAX :Pasažieru izplatīšanas režīms: {STRING} -STR_CONFIG_SETTING_DISTRIBUTION_PAX_HELPTEXT :"simetriska" nozīmē, ka apmēram vienāds daudzums pasažieri vēlēsies doties virzienā no stacijas A uz B, cik no B uz A. "asimetriska" nozīmē, ka patvaļīgs pasažieru daudzums var vēlēties nokļūt katrā no virzieniem. "manuāli" nozīmē, ka pasažieriem netiks veikta automātiska izplatīšana. +STR_CONFIG_SETTING_DISTRIBUTION_PAX_HELPTEXT :"Simetrisks" nozīmē, ka aptuveni tikpat daudz pasažieru dosies no stacijas A uz staciju B kā no B uz A. "Asimetrisks" nozīmē, ka abos virzienos var doties patvaļīgs pasažieru skaits. "Manuāli" nozīmē, ka pasažieriem nenotiks automātiska sadale. STR_CONFIG_SETTING_DISTRIBUTION_MAIL :Pasta izplatīšanas režīms: {STRING} -STR_CONFIG_SETTING_DISTRIBUTION_MAIL_HELPTEXT :"simetriska" nozīmē, ka apmēram vienāds daudzums pasta tiks nosūtīts virzienā no stacijas A uz B, cik no B uz A. "asimetriska" nozīmē, ka patvaļīgs pasta daudzums var tikt nosūtīts katrā no virzieniem. "manuāli" nozīmē, ka pastam netiks veikta automātiska izplatīšana. +STR_CONFIG_SETTING_DISTRIBUTION_MAIL_HELPTEXT :"Simetrisks" nozīmē, ka no stacijas A uz staciju B tiks nosūtīts aptuveni tāds pats pasta daudzums kā no B uz A. "Asimetrisks" nozīmē, ka jebkurā virzienā var nosūtīt patvaļīgu pasta daudzumu. "Manuāli" nozīmē, ka pasta automātiska izplatīšana netiks veikta. STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED :Izplatīšanas režīms APSARGĀJAMAI preču klasei: {STRING} -STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED_HELPTEXT :APSARGĀJAMĀ kravas klase satur vērtslietas mērenajā joslā, dimantus subtropu joslā un zeltu subarktiskajā joslā. NewGRF paplašinājumi var to mainīt. "simetriska" nozīmē, ka apmēram vienāds daudzums kravas tiks nosūtīts virzienā no stacijas A uz B, cik no B uz A. "asimetriska" nozīmē, ka patvaļīgs kravas daudzums var tikt nosūtīts katrā no virzieniem. "manuāli" nozīmē, ka pastam netiks veikta automātiska izplatīšana. Šo vērtību vēlams iestatīt kā asimetrisku vai manuālu, kad spēlē subarktiskajā joslā, jo bankas nesūta zeltu atpakaļ uz zelta raktuvēm. Mērenajā un subtropu joslā var izvēlēties simetrisku, jo bankas sūtīs vērtslietas atpakaļ uz izcelsmes banku, kad saņems vērtslietu pievedumu. +STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED_HELPTEXT :APSARGĀJAMĀ kravu klasē ir vērtslietas mērenā klimatā, dimanti subtropu klimatā vai zelts subarktiskajā klimatā. NewGRF to var mainīt. "Simetrisks" nozīmē, ka no stacijas A uz staciju B tiks nosūtīts aptuveni tāds pats šīs kravas daudzums kā no B uz A. "Asimetrisks" nozīmē, ka šīs kravas var nosūtīt jebkurā virzienā patvaļīgi. "Manuāli" nozīmē, ka šai kravai automātiskā sadale nenotiks. Spēlējot subarktisko vai subtropu, ieteicams to iestatīt uz asimetrisku vai manuālu, jo bankas saņem kravas tikai šādos klimatiskajos apstākļos. Mērenam klimatam varat izvēlēties arī simetrisko, jo bankas nosūtīs vērtslietas atpakaļ uz izcelsmes banku. STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT :Izplatīšanas modelis citām kravu klasēm: {STRING} STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT_HELPTEXT :"Asimetrisks" nozīmē, ka jebkurā virzienā var nosūtīt patvaļīgu daudzumu kravas. "Manuāli" nozīmē, ka šīm kravām automātiska sadale nenotiks ###length 3 @@ -1924,13 +1996,15 @@ STR_CONFIG_SETTING_DEMAND_SIZE_HELPTEXT :Uzstādod šo m STR_CONFIG_SETTING_SHORT_PATH_SATURATION :Īso ceļu piesātinājums pirms sākt izmantot augstas ietilpības ceļus: {STRING} STR_CONFIG_SETTING_SHORT_PATH_SATURATION_HELPTEXT :Nereti starp divām stacijām ir vairāki ceļi. Kravu sadale vispirms piesātinās īsāko maršrutu, pēc tam izmantos nākamo īsāko maršrutu līdz tas būs piesātināts, un tā tālāk. Piesātinājumu nosaka novērtējot ietilpību un plānoto izmantojumu. Kad visi ceļi ir piesātināti un vēl ir palicis pieprasījumus, tas pārslogos visus ceļus, dodot priekšroku ceļiem ar lielāko ietilpību. Algoritms visbiežāk nepareizi novērtēs ietilpību. Šis iestatījums jums atļaus norādīt, līdz cik procentiem īsākais ceļš ir jāpiesātina pirmajā piegājienā pirms izvēlēties garāku ceļu. Iestatiet to uz mazāk kā 100%, lai izvairītos no pārpildītām stacijām, ja kapacitāte ir pārvērtēta. -STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY :Ātruma mērvienības: {STRING} +STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY :Ātruma vienības (sauszemes): {STRING} +STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_NAUTICAL :Ātruma vienības (jūras): {STRING} STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_HELPTEXT :Vai lietotāja saskarnē rāda ātrumu, rādīt norādītajās mērvienībās ###length 5 STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_IMPERIAL :impērijas, britu (jūdzes stundā) STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_METRIC :metriskās (km/h) STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_SI :SI, starptautiskās (m/s) STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_GAMEUNITS :Spēles vienības (lauciņi/dienas) +STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_KNOTS :Mezgli STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER :Transportlīdzekļu jaudas mērvienības: {STRING} STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER_HELPTEXT :Vai lietotāja saskarnē rāda transporta līdzekļa jaudu, rādīt norādītajās mērvienībās @@ -2031,6 +2105,7 @@ STR_CONFIG_ERROR_SPRITECACHE_TOO_BIG :{WHITE}Neizdev # Video initalization errors STR_VIDEO_DRIVER_ERROR :{WHITE}Kļūda ar video iestatījumiem STR_VIDEO_DRIVER_ERROR_NO_HARDWARE_ACCELERATION :{WHITE}... nav atrasts saderīgs GPU. Aparatūras paātrinājums ir atspējots +STR_VIDEO_DRIVER_ERROR_HARDWARE_ACCELERATION_CRASH :{WHITE}... GPU dzinulis apturēja spēli. Aparatūras paātrinājums ir izslēgts # Intro window STR_INTRO_CAPTION :{WHITE}OpenTTD {REV} @@ -2044,6 +2119,7 @@ STR_INTRO_MULTIPLAYER :{BLACK}Vairāks STR_INTRO_GAME_OPTIONS :{BLACK}Spēles opcijas STR_INTRO_HIGHSCORE :{BLACK}Sasniegumu tabula +STR_INTRO_HELP :{BLACK}Palīdzība un rokasgrāmatas STR_INTRO_CONFIG_SETTINGS_TREE :{BLACK}Iestatījumi STR_INTRO_NEWGRF_SETTINGS :{BLACK}NewGRF iestatījumi STR_INTRO_ONLINE_CONTENT :{BLACK}Pārbaudīt tiešsaistes saturu @@ -2065,6 +2141,7 @@ STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE :{BLACK}Izvēlē STR_INTRO_TOOLTIP_GAME_OPTIONS :{BLACK}Rādīt spēles opcijas STR_INTRO_TOOLTIP_HIGHSCORE :{BLACK}Rādīt sasniegumu tabulu +STR_INTRO_TOOLTIP_HELP :{BLACK}Piekļūstiet dokumentācijai un tiešsaistes resursiem STR_INTRO_TOOLTIP_CONFIG_SETTINGS_TREE :{BLACK}Displeja iestatījumi STR_INTRO_TOOLTIP_NEWGRF_SETTINGS :{BLACK}Rādīt NewGRF iestatījumus STR_INTRO_TOOLTIP_ONLINE_CONTENT :{BLACK}Pārbaudīt vai lejupielādei nav pieejams jauns un atjaunināts saturs @@ -2087,6 +2164,17 @@ STR_ABANDON_GAME_QUERY :{YELLOW}Vai tie STR_ABANDON_SCENARIO_QUERY :{YELLOW}Vai tiešām vēlaties pamest šo scenāriju? # Help window +STR_HELP_WINDOW_CAPTION :{WHITE}Palīdzība un rokasgrāmatas +STR_HELP_WINDOW_WEBSITES :{BLACK}Vietnes +STR_HELP_WINDOW_DOCUMENTS :{BLACK}Dokumenti +STR_HELP_WINDOW_README :{BLACK}Lasi_Mani +STR_HELP_WINDOW_CHANGELOG :{BLACK}Izmaiņu žurnāls +STR_HELP_WINDOW_KNOWN_BUGS :{BLACK}Zināmās kļūdas +STR_HELP_WINDOW_LICENSE :{BLACK}Licence +STR_HELP_WINDOW_MAIN_WEBSITE :{BLACK}OpenTTD +STR_HELP_WINDOW_MANUAL_WIKI :{BLACK}Rokasgrāmata / Wiki +STR_HELP_WINDOW_BUGTRACKER :{BLACK}Ziņot par kļūdu +STR_HELP_WINDOW_COMMUNITY :{BLACK}Kopiena # Cheat window STR_CHEATS :{WHITE}Blēdības @@ -2102,6 +2190,7 @@ STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT :{WHITE}Izmainī STR_CHEAT_CHANGE_DATE :{LTBLUE}Nomainīt datumu: {ORANGE} {DATE_SHORT} STR_CHEAT_CHANGE_DATE_QUERY_CAPT :{WHITE}Mainīt pašreizējo gadu STR_CHEAT_SETUP_PROD :{LTBLUE}Ieslēgt ražojumu vērtības maiņu: {ORANGE}{STRING} +STR_CHEAT_STATION_RATING :{LTBLUE}Labot stacijas vērtējumus uz 100%: {ORANGE}{STRING} # Livery window STR_LIVERY_CAPTION :{WHITE}{COMPANY} - krāsu shēma @@ -2111,12 +2200,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Rādīt STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Rādīt autotransporta identitātes krāsu shēmas STR_LIVERY_SHIP_TOOLTIP :{BLACK}Rādīt kuģu identitātes krāsu shēmas STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Rādīt lidaparātu identitātes krāsu shēmas +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Rādīt vilcienu grupu krāsas +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Rādīt autotransporta grupu krāsas +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Rādīt kuģu grupu krāsas +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Rādīt lidaparātu grupu krāsas STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Izvēlēties galveno identitātes krāsu atlasītajai shēmai. Ctrl+klikšķis iestatīs šo krāsu katrai shēmai STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Izvēlēties papildu identitātes krāsu atlasītajai shēmai. Ctrl+klikšķis iestatīs šo krāsu katrai shēmai STR_LIVERY_PANEL_TOOLTIP :{BLACK}Izvēlēties kuru identitātes krāsu shēmu mainīt, vai vairākas ar Ctrl+klikšķi. Klikšķināt uz rūtiņas, lai pārslēgtu shēmas izmantošanu +STR_LIVERY_TRAIN_GROUP_EMPTY :Vilcienu grupas nav izveidotas +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Autotransporta līdzekļu grupas nav izveidotas +STR_LIVERY_SHIP_GROUP_EMPTY :Nav izveidotas kuģu grupas +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Nav izveidota neviena gaisa kuģu grupa ###length 23 -STR_LIVERY_DEFAULT :Vispārpieņemtā identitātes krāsa +STR_LIVERY_DEFAULT :Noklusējuma Nokrāsa STR_LIVERY_STEAM :Tvaika lokomotīve STR_LIVERY_DIESEL :Dīzeļlokomotīve STR_LIVERY_ELECTRIC :Elektrolokomotīve @@ -2269,7 +2366,7 @@ STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP :{BLACK}Spēles STR_NETWORK_START_SERVER_SET_PASSWORD :{BLACK}Uzstādīt paroli STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP :{BLACK}Aizsargā jūsu spēli ar paroli, ja nevēlaties lai tā būtu publiski pieejama -STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Redzamība +STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Redzamība: STR_NETWORK_START_SERVER_VISIBILITY_TOOLTIP :{BLACK} Vai citi lietotāji var redzēt jūsu serveri publiskajā sarakstā STR_NETWORK_START_SERVER_CLIENTS_SELECT :{BLACK}{NUM} spēlētāj{P s i u} STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS :{BLACK}Maksimālais spēlētāju skaits: @@ -2335,6 +2432,8 @@ STR_NETWORK_CLIENT_LIST_NEW_COMPANY :(Jauna kompāni STR_NETWORK_CLIENT_LIST_NEW_COMPANY_TOOLTIP :{BLACK}Izveidot jaunu kompāniju un pievienoties tai STR_NETWORK_CLIENT_LIST_PLAYER_ICON_SELF_TOOLTIP :{BLACK}Tas esat jūs STR_NETWORK_CLIENT_LIST_PLAYER_ICON_HOST_TOOLTIP :{BLACK}Šis ir spēles īpašnieks +STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT :{BLACK}Klientu: {NUM}; uzņēmumu: {NUM}/{NUM} +STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT_TOOLTIP :{BLACK}Pašlaik savienoto klientu skaits, uzņēmumu skaits un maksimālais servera administratora atļautais uzņēmumu skaits # Matches ConnectionType ###length 5 @@ -2361,6 +2460,12 @@ STR_NETWORK_ASK_RELAY_NO :{BLACK}Nē STR_NETWORK_ASK_RELAY_YES_ONCE :{BLACK}Jā, vienreiz STR_NETWORK_ASK_RELAY_YES_ALWAYS :{BLACK}Jā, vairs nejautāt +STR_NETWORK_ASK_SURVEY_CAPTION :Vai piedalīties automatizētā aptaujā? +STR_NETWORK_ASK_SURVEY_TEXT :Vai vēlaties piedalīties automatizētajā aptaujā?{}OpenTTD pārsūtīs aptauju, izejot no spēles.{}To jebkurā laikā varat mainīt sadaļā "Spēles opcijas". +STR_NETWORK_ASK_SURVEY_PREVIEW :Priekšskatīt aptaujas rezultātus +STR_NETWORK_ASK_SURVEY_LINK :Par aptauju un privātumu +STR_NETWORK_ASK_SURVEY_NO :Nē +STR_NETWORK_ASK_SURVEY_YES :Jā STR_NETWORK_SPECTATORS :Novērotāji @@ -2496,7 +2601,7 @@ STR_CONTENT_SEARCH_EXTERNAL_TOOLTIP :{BLACK}Meklēt STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER_CAPTION :{WHITE}Jūs aizejat no OpenTTD! STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER :{WHITE}Lietošanas noteikumi no ārpuses lejupielādētam saturam var būt dažāi.{}Jums būs jāskatās ārējās saites ārējā satura instalēšanai uz OpenTTD.{}Vai vēlaties turpināt? STR_CONTENT_FILTER_TITLE :{BLACK}Atzīmju/nosaukumu filtrs: -STR_CONTENT_OPEN_URL :{BLACK}Apmeklēt tīmekļa vietni +STR_CONTENT_OPEN_URL :{BLACK}Vietne STR_CONTENT_OPEN_URL_TOOLTIP :{BLACK}Apmeklēt tīmekļa vietni, lai tiktu pie šī satura STR_CONTENT_DOWNLOAD_CAPTION :{BLACK}Lejupielādēt STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP :{BLACK}Sākt atlasītā lejupielādi @@ -2567,6 +2672,7 @@ STR_TRANSPARENT_BUILDINGS_TOOLTIP :{BLACK}Pārslē STR_TRANSPARENT_BRIDGES_TOOLTIP :{BLACK}Pārslēgt tiltu caurspīdību. Ctrl+klikšķis, lai slēgtu STR_TRANSPARENT_STRUCTURES_TOOLTIP :{BLACK}Pārslēgt caurspīdību tādām celtnēm kā bākas un antenas. Ctrl+klikšķis, lai slēgtu STR_TRANSPARENT_CATENARY_TOOLTIP :{BLACK}Pārslēgt piekartroses caurspīdību. Ctrl+klikšķis, lai slēgtu +STR_TRANSPARENT_TEXT_TOOLTIP :{BLACK}Pārslēgt caurspīdīgumu ielādei un izmaksu/ienākumu tekstam. Ctrl+klikšķis, lai bloķētu STR_TRANSPARENT_INVISIBLE_TOOLTIP :{BLACK}Caurspīdības vietā objektus padarīt neredzamus # Linkgraph legend window @@ -2650,8 +2756,11 @@ STR_STATION_BUILD_DRAG_DROP_TOOLTIP :{BLACK}Būvēt STR_STATION_BUILD_STATION_CLASS_TOOLTIP :{BLACK}Izvēlēties kuru stacijas klasi rādīt STR_STATION_BUILD_STATION_TYPE_TOOLTIP :{BLACK}Izvēlēties kuru stacijas veidu būvēt -STR_STATION_CLASS_DFLT :Noklusējuma stacija +STR_STATION_CLASS_DFLT :Noklusējuma +STR_STATION_CLASS_DFLT_STATION :Noklusējuma stacija +STR_STATION_CLASS_DFLT_ROADSTOP :Noklusējuma pietura STR_STATION_CLASS_WAYP :Pieturas punkti +STR_STATION_CLASS_WAYP_WAYPOINT :Noklusējuma pieturas punkts # Signal window STR_BUILD_SIGNAL_CAPTION :{WHITE}Signāla izvēle @@ -2679,6 +2788,7 @@ STR_SELECT_ROAD_BRIDGE_CAPTION :{WHITE}Izvēlē STR_SELECT_BRIDGE_SELECTION_TOOLTIP :{BLACK}Tiltu izvēle - klikšķināt uz vēlamo tiltu, lai to uzbūvētu STR_SELECT_BRIDGE_INFO_NAME :{GOLD}{STRING} STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED :{GOLD}{STRING},{} {VELOCITY} +STR_SELECT_BRIDGE_INFO_NAME_COST :{GOLD}{0:STRING},{} {WHITE}{2:CURRENCY_LONG} STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED_COST :{GOLD}{STRING},{} {VELOCITY} {WHITE}{CURRENCY_LONG} STR_BRIDGE_NAME_SUSPENSION_STEEL :Vanšu, tērauda STR_BRIDGE_NAME_GIRDER_STEEL :Siju, tērauda @@ -2799,7 +2909,7 @@ STR_OBJECT_CLASS_TRNS :Raidītāji STR_PLANT_TREE_CAPTION :{WHITE}Koki STR_PLANT_TREE_TOOLTIP :{BLACK}Izvēlēties koka veidu stādīšanai. Ja lauciņš jau ir koks, tas pievienos vairāk jauktu veidu kokus neatkarīgi no izvēlētā veida STR_TREES_RANDOM_TYPE :{BLACK}Nejauši izvēlēta veida koki -STR_TREES_RANDOM_TYPE_TOOLTIP :{BLACK}Izvietot nejaušus kokus. Shift pārslēdz būve/rādīt izmaksu tāmi +STR_TREES_RANDOM_TYPE_TOOLTIP :{BLACK}Novietojiet jaukta veida kokus. Ctrl atlasa apgabalu pa diagonāli. Shift pārslēdz celtniecību/rāda izmaksas STR_TREES_RANDOM_TREES_BUTTON :{BLACK}Nejauši koki STR_TREES_RANDOM_TREES_TOOLTIP :{BLACK}Stādīt nejaušus kokus visā ainavā STR_TREES_MODE_NORMAL_BUTTON :{BLACK}Normāls @@ -2858,7 +2968,7 @@ STR_FOUND_TOWN_SELECT_LAYOUT_3X3_GRID :{BLACK}3x3 rež STR_FOUND_TOWN_SELECT_LAYOUT_RANDOM :{BLACK}Nejaušs # Fund new industry window -STR_FUND_INDUSTRY_CAPTION :{WHITE}Finansēt jaunu ražotni +STR_FUND_INDUSTRY_CAPTION :{WHITE}Industrijas Finansējums STR_FUND_INDUSTRY_SELECTION_TOOLTIP :{BLACK}Izvēlēties no saraksta atbilstošu ražotni STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES :{BLACK}Izveidot nejaušas nozares STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_TOOLTIP :{BLACK}Pārklāt karti ar nejauši izvietotām ražotnēm @@ -2874,14 +2984,14 @@ STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES_CAPTION :{WHITE} Noņemt STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES_QUERY :{YELLOW}Vai tiešām vēlaties noņemt visas nozares? # Industry cargoes window -STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION :{WHITE}Ražotnes '{STRING}' kravu ķēde -STR_INDUSTRY_CARGOES_CARGO_CAPTION :{WHITE}{STRING} kravas ražotņu ķēde +STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION :{WHITE}Nozares ķēde - {STRING} +STR_INDUSTRY_CARGOES_CARGO_CAPTION :{WHITE}Kravas ķēde - {STRING} STR_INDUSTRY_CARGOES_PRODUCERS :{WHITE}Ražotāji STR_INDUSTRY_CARGOES_CUSTOMERS :{WHITE}Patērētāji STR_INDUSTRY_CARGOES_HOUSES :{WHITE}Mājas STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP :{BLACK}Klikšķināt uz ražotnes, lai redzētu tās piegādātājus un patērētājus STR_INDUSTRY_CARGOES_CARGO_TOOLTIP :{BLACK}{STRING}{}Klikšķināt uz kravas, lai redzētu tās piegādātājus un patērētājus -STR_INDUSTRY_DISPLAY_CHAIN :{BLACK}Rādīt ķēdi +STR_INDUSTRY_DISPLAY_CHAIN :{BLACK}Nozares ķēde STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP :{BLACK}Rādīt kravas ražojošās un patērējošās ražotnes STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP :{BLACK}Piesaistīt minikartei STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP_TOOLTIP :{BLACK}Izvēlēties arī minikartē attēlotās rūpnīcas @@ -3019,7 +3129,7 @@ STR_ABOUT_VERSION :{BLACK}OpenTTD STR_ABOUT_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT} 2002-{STRING} OpenTTD darba grupa # Framerate display window -STR_FRAMERATE_CAPTION :{WHITE}Kadru biežums +STR_FRAMERATE_CAPTION :{WHITE}Kadru nomaiņas ātrums STR_FRAMERATE_CAPTION_SMALL :{STRING}{WHITE} ({DECIMAL}x) STR_FRAMERATE_RATE_GAMELOOP :{BLACK}Simulācijas ātrums: {STRING} STR_FRAMERATE_RATE_GAMELOOP_TOOLTIP :{BLACK}Spēles tikšķu skaits, ko simulēt vienā sekundē. @@ -3112,11 +3222,15 @@ STR_MAPGEN_MAPSIZE :{BLACK}Kartes i STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK}Izvēlieties kartes izmēru, izteikts lauciņos. Pieejamo lauciņu skaits var būt nedaudz mazāks STR_MAPGEN_BY :{BLACK}* STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Pilsētu daudzums: +STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP :{BLACK}Atlasiet pilsētu blīvumu vai pielāgojiet daudzumu STR_MAPGEN_TOWN_NAME_LABEL :{BLACK}Pilsētu nosaukumi: STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP :{BLACK}Pilsētu nosaukumu stila izvēle STR_MAPGEN_DATE :{BLACK}Datums: +STR_MAPGEN_DATE_TOOLTIP :{BLACK}Izvēlieties sākuma datumu STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}Ražotņu daudzums: +STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP :{BLACK}Atlasiet nozaru blīvumu vai pielāgojiet daudzumu STR_MAPGEN_HEIGHTMAP_HEIGHT :{BLACK}Augstākā virsotne: +STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP :{BLACK}Izvēlieties augstāko virsotni, ko spēle mēģinās izveidot, mērot augstumu virs jūras līmeņa STR_MAPGEN_HEIGHTMAP_HEIGHT_UP :{BLACK}Palielināt augstāko punktu virsotnes pa vienai STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN :{BLACK}Pa vienai samazināt kartes augstākās virsotnes maksimālo augstumu STR_MAPGEN_SNOW_COVERAGE :{BLACK}Sniega pārklājums: @@ -3129,10 +3243,12 @@ STR_MAPGEN_DESERT_COVERAGE_DOWN :{BLACK}Samazin STR_MAPGEN_DESERT_COVERAGE_TEXT :{BLACK}{NUM}% STR_MAPGEN_TERRAIN_TYPE :{BLACK}Apvidus reljefs: STR_MAPGEN_SEA_LEVEL :{BLACK}Jūras līmenis: +STR_MAPGEN_SEA_LEVEL_TOOLTIP :{BLACK}Izvēlieties jūras līmeni STR_MAPGEN_QUANTITY_OF_RIVERS :{BLACK}Upes: STR_MAPGEN_SMOOTHNESS :{BLACK}Gludums: STR_MAPGEN_VARIETY :{BLACK}Dažādības sadalījums: STR_MAPGEN_GENERATE :{WHITE}Radīt +STR_MAPGEN_GENERATE_TOOLTIP :{BLACK}Izveidojiet pasauli un spēlējiet OpenTTD! STR_MAPGEN_NEWGRF_SETTINGS :{BLACK}NewGRF Iestatījumi STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP :{BLACK}Rādīt NewGRF iestatījumus STR_MAPGEN_AI_SETTINGS :{BLACK}AI iestatījumi @@ -3165,6 +3281,7 @@ STR_MAPGEN_TOWN_NAME_CATALAN :Katalāņu # Strings for map borders at game generation STR_MAPGEN_BORDER_TYPE :{BLACK}Kartes malas: +STR_MAPGEN_BORDER_TYPE_TOOLTIP :{BLACK}Izvēlieties spēļu pasaules robežas STR_MAPGEN_NORTHWEST :{BLACK}Ziemeļrietumi STR_MAPGEN_NORTHEAST :{BLACK}Ziemeļaustrumi STR_MAPGEN_SOUTHEAST :{BLACK}Dienvidaustrumi @@ -3177,7 +3294,9 @@ STR_MAPGEN_BORDER_MANUAL :{BLACK}Manuāli STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}Augstumu kartes pagriešana: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}Augstumu kartes nosaukums: +STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP :{BLACK}Augstuma kartes attēla faila nosaukums STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}Lielums: +STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP :{BLACK}Avota augstuma kartes attēla izmērs. Lai iegūtu labākos rezultātus, katrai malai ir jāatbilst OpenTTD pieejamajam kartes malas garumam, piemēram, 256, 512, 1024 utt. STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT :{WHITE}Vēlamā augtākā virsotne @@ -3192,6 +3311,7 @@ STR_SE_MAPGEN_FLAT_WORLD :{WHITE}Līdzena STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP :{BLACK}Radīt līdzenu zemi STR_SE_MAPGEN_RANDOM_LAND :{WHITE}Nejauša zeme STR_SE_MAPGEN_FLAT_WORLD_HEIGHT :{BLACK}Līdzenas zemes augstums: +STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP :{BLACK}Izvēlieties zemes augstumu virs jūras līmeņa STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN :{BLACK}Par vienu līmeni samazināt līdzenas zemes augstumu STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP :{BLACK}Par vienu līmeni palielināt līdzenas zemes augstumu @@ -3278,6 +3398,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Saglabā STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}pašreizējos iestatījumus saglābāt kā sākontnējos iestatījumus # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Mainiet pamata grafikas parametrus STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Mainīt NewGRF parametrus STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Aizvērt STR_NEWGRF_PARAMETERS_RESET :{BLACK}Atjaunot @@ -3294,6 +3415,7 @@ STR_NEWGRF_INSPECT_PARENT_TOOLTIP :{BLACK}Pārbaud STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT :{STRING} adresē {HEX} STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT :Objekts STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE :Sliežu veids +STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_ROAD_TYPE :Ceļa tips STR_NEWGRF_INSPECT_QUERY_CAPTION :{WHITE}NewGRF mainīgā 60+x parametrs (heksadecimāls) @@ -3328,6 +3450,8 @@ STR_NEWGRF_ERROR_MSG_INFO :{SILVER}{STRING STR_NEWGRF_ERROR_MSG_WARNING :{RED}Brīdinājums: {SILVER}{STRING} STR_NEWGRF_ERROR_MSG_ERROR :{RED}Kļūda: {SILVER}{STRING} STR_NEWGRF_ERROR_MSG_FATAL :{RED}Fatāls: {SILVER}{STRING} +STR_NEWGRF_ERROR_FATAL_POPUP :{WHITE}NewGRF "{STRING}" apstrādājas dēl neatgrieziniskās kļūdas:{}{STRING} +STR_NEWGRF_ERROR_POPUP :{WHITE}NewGRF "{STRING}"uzrāda kļūdu:{}{STRING} STR_NEWGRF_ERROR_VERSION_NUMBER :{1:STRING} nedarbosies kopā ar TTDPatch versiju (par ko ziņoja OpenTTD). STR_NEWGRF_ERROR_DOS_OR_WINDOWS :{1:STRING} ir paredzēts TTD versijai {2:STRING} STR_NEWGRF_ERROR_UNSET_SWITCH :{1:STRING} ir paredzēts lietošanai ar {2:STRING} @@ -3478,8 +3602,8 @@ STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_LARGE_ADVERTISING :{PUSH_COLOUR}{Y STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_ROAD_RECONSTRUCTION :{PUSH_COLOUR}{YELLOW}Finansējiet pilsētas ceļu tīkla rekonstrukciju.{}Līdz 6 mēnešiem rada ievērojamus ceļu satiksmes traucējumus.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_STATUE_OF_COMPANY :{PUSH_COLOUR}{YELLOW}Uzceliet statuju par godu savam uzņēmumam.{}Nodrošina pastāvīgu staciju vērtējuma palielinājumu šajā pilsētā.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_NEW_BUILDINGS :{PUSH_COLOUR}{YELLOW}Finansējiet jaunu ēku celtniecību pilsētā.{}Nodrošina īslaicīgu stimulu pilsētas izaugsmei šajā pilsētā.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} -STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_EXCLUSIVE_TRANSPORT :{PUSH_COLOUR}{YELLOW}Iegādājieties 1 gada ekskluzīvas transporta tiesības pilsētā.{}Pašvaldība neļaus pasažieriem un kravai izmantot jūsu konkurentu stacijas.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} -STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_BRIBE :{PUSH_COLOUR}{YELLOW}Piekukuļojiet vietējo pašvaldību, lai paaugstinātu savu vērtējumu, riskējot saņemt bargu sodu.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} +STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_EXCLUSIVE_TRANSPORT :{PUSH_COLOUR}{YELLOW}Iegādājieties 1 gada ekskluzīvas transporta tiesības pilsētā.{}Pilsētas pašvaldība neļaus pasažieriem un kravai izmantot jūsu konkurentu stacijas. Veiksmīgs kukulis no konkurenta atcels šo līgumu.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} +STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_BRIBE :{PUSH_COLOUR}{YELLOW}Piekukuļot vietējo pašvaldību, lai paaugstinātu savu vērtējumu un atceltu konkurenta ekskluzīvās transporta tiesības, riskējot ar bargu sodu, ja tiksiet pieķerts.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} # Goal window STR_GOALS_CAPTION :{WHITE}{COMPANY} mērķi @@ -3703,6 +3827,8 @@ STR_COMPANY_VIEW_INFRASTRUCTURE_BUTTON :{BLACK}Sīkāk STR_COMPANY_VIEW_INFRASTRUCTURE_TOOLTIP :{BLACK}Skatīt detalizētāku infrastruktūras uzskaiti STR_COMPANY_VIEW_GIVE_MONEY_BUTTON :{BLACK}Iedot naudu STR_COMPANY_VIEW_GIVE_MONEY_TOOLTIP :{BLACK}Iedot naudu šai kompānijai +STR_COMPANY_VIEW_HOSTILE_TAKEOVER_BUTTON :{BLACK}Naidīga pārņemšana +STR_COMPANY_VIEW_HOSTILE_TAKEOVER_TOOLTIP :{BLACK}Veiciet naidīgu šī uzņēmuma pārņemšanu STR_COMPANY_VIEW_NEW_FACE_BUTTON :{BLACK}Jauna seja STR_COMPANY_VIEW_NEW_FACE_TOOLTIP :{BLACK}Izvēlēties jaunu seju vadītājam @@ -3718,6 +3844,7 @@ STR_COMPANY_VIEW_PRESIDENT_S_NAME_QUERY_CAPTION :Vadītāja vār STR_COMPANY_VIEW_GIVE_MONEY_QUERY_CAPTION :Ievadiet naudas daudzumu, kuru vēlaties atdot STR_BUY_COMPANY_MESSAGE :{WHITE}Mēs meklējam transporta uzņēmumu, kurš vēlētos pārņemt mūsējo.{}{}Vai Jūs vēlaties pirkt {COMPANY} par {CURRENCY_LONG}? +STR_BUY_COMPANY_HOSTILE_TAKEOVER :{WHITE}Naidīgā uzņēmuma {COMPANY} pārņemšanas gadījumā jūs iegādāsities visus aktīvus, atmaksāsit visus aizdevumus un maksāsiet divu gadu peļņu.{}{}Tiek lēsts, ka kopējā summa ir {CURRENCY_LONG}.{}{}Vai jūs vēlaties turpināt šo naidīgo pārņemšanu? # Company infrastructure window STR_COMPANY_INFRASTRUCTURE_VIEW_CAPTION :{WHITE}{COMPANY} infrastruktūra @@ -3790,12 +3917,15 @@ STR_VEHICLE_LIST_MANAGE_LIST :{BLACK}Pārvald STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP :{BLACK}Sūtīt norādījumus visiem transportlīdzekļiem, kas ir šajā sarakstā STR_VEHICLE_LIST_REPLACE_VEHICLES :Nomainīt transportlīdzekļus STR_VEHICLE_LIST_SEND_FOR_SERVICING :Sūtīt uz apkopi +STR_VEHICLE_LIST_CREATE_GROUP :Izveidot grupu STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR :{TINY_FONT}{BLACK}Peļņa šogad: {CURRENCY_LONG} (pērn: {CURRENCY_LONG}) +STR_VEHICLE_LIST_CARGO :[{CARGO_LIST}] +STR_VEHICLE_LIST_NAME_AND_CARGO :{STRING} {STRING} -STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT :Sūtīt uz depo -STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT :Sūtīt uz depo -STR_VEHICLE_LIST_SEND_SHIP_TO_DEPOT :Sūtīt uz depo -STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR :Sūtīt uz angāru +STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT :Nosūtīt uz depo +STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT :Nosūtīt uz depo +STR_VEHICLE_LIST_SEND_SHIP_TO_DEPOT :Nosūtīt uz depo +STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR :Nosūtīt uz angāru STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP :{BLACK}Klikšķināt, lai apstādinātu visas mašīnas, kas ir sarakstā STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP :{BLACK}Klikšķināt, lai iedarbinātu visas mašīnas, kas ir saraks @@ -4481,8 +4611,13 @@ STR_TIMETABLE_STATUS_ON_TIME :{BLACK}Šis tra STR_TIMETABLE_STATUS_LATE :{BLACK}Šis transportlīdzeklis pašlaik {STRING} kavē STR_TIMETABLE_STATUS_EARLY :{BLACK}Šis transportlīdzeklis pašlaik {STRING} par agru STR_TIMETABLE_STATUS_NOT_STARTED :{BLACK}Šis saraksts vēl nav sācies +STR_TIMETABLE_STATUS_START_AT_DATE :{BLACK}Šis grafiks sāksies plkst. {STRING} +STR_TIMETABLE_STATUS_START_IN_SECONDS :{BLACK}Šis grafiks sāksies pēc {COMMA} sekundēm +STR_TIMETABLE_START :{BLACK}Sākt Grafiku +STR_TIMETABLE_START_TOOLTIP :{BLACK}Atlasiet, kad sākas šis saraksts. Ctrl+klikšķis vienmērīgi sadala visu transportlīdzekļu sākumu, kas koplieto šo pasūtījumu, pamatojoties uz to relatīvo pasūtījumu, ja pasūtījumam ir pilnībā noteikts saraksts +STR_TIMETABLE_START_SECONDS_QUERY :Sekundes līdz grafika sākumam STR_TIMETABLE_CHANGE_TIME :{BLACK}Mainīt laiku STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Mainiet laiku, kas nepieciešams iezīmētajam pasūtījumam. Ctrl+Click iestata laiku visiem pasūtījumiem @@ -4497,7 +4632,7 @@ STR_TIMETABLE_CLEAR_SPEED :{BLACK}Nodzēst STR_TIMETABLE_CLEAR_SPEED_TOOLTIP :{BLACK}Dzēst iezīmētā pasūtījuma maksimālo braukšanas ātrumu. Ctrl+klikšķis notīra ātrumu visiem pasūtījumiem STR_TIMETABLE_RESET_LATENESS :{BLACK}Atiestatīt kavējuma skaitītāju -STR_TIMETABLE_RESET_LATENESS_TOOLTIP :{BLACK}Atslēgt skaitītāju, lai transportlīdzeklis būtu laikā +STR_TIMETABLE_RESET_LATENESS_TOOLTIP :{BLACK}Atiestatiet kavējuma skaitītāju, lai transportlīdzeklis būtu laikā. Nospiežot taustiņu kombināciju Ctrl+klikšķis, tiks atiestatīta visa grupa, lai jaunākais transportlīdzeklis būtu laicīgi un visi pārējie ātrāk STR_TIMETABLE_AUTOFILL :{BLACK}Automātiska aizpildīšana STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Automātiski aizpildiet kustības grafiku ar vērtībām no nākamā brauciena. Ctrl+noklikšķiniet, lai mēģinātu saglabāt gaidīšanas laiku @@ -4506,6 +4641,10 @@ STR_TIMETABLE_EXPECTED :{BLACK}Paredzē STR_TIMETABLE_SCHEDULED :{BLACK}Ieplānots STR_TIMETABLE_EXPECTED_TOOLTIP :{BLACK}Pārslēgties starp sagaidāmo un ieplānoto +STR_TIMETABLE_ARRIVAL_DATE :A: {COLOUR}{DATE_TINY} +STR_TIMETABLE_DEPARTURE_DATE :D: {COLOUR}{DATE_TINY} +STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE :iekš: {COLOUR}{COMMA} sek +STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE :D: {COLOUR}{COMMA} sek # Date window (for timetable) @@ -4533,23 +4672,25 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Ievērot STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Pārslēgt lielo/mazo burtu ievērošanu, kad salīdzināt MI ziņojumus ar slēgšanas tekstu STR_AI_DEBUG_CONTINUE :{BLACK}Turpināt STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Atsākt un turpināt šo MI -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Attēlot šī MI atkļūdošanas izvadu +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Skatīt šī AI atkļūdošanas izeju. Ctrl-klikšķis, lai atvērtu jaunā logā STR_AI_GAME_SCRIPT :{BLACK}Spēles skripts -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Pārbaudīt spēles skriptu žurnālu +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Pārbaudiet spēles skripta žurnālu. Ctrl-klikšķis, lai atvērtu jaunā logā STR_ERROR_AI_NO_AI_FOUND :Nav atrasts ielādei piemērots MI.{}Šis ir MI makets un spēlē tas neko nedarīs.{}Jūs varat lejupielādēt dažus MI no 'Tiešsaistes satura' sistēmas STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Viens no strādājošiem skriptiem nobruka. Lūdzu, paziņojiet par šo gadījumu skripta autoram, pievienojot ekrānuzņēmumu ar MI/spēles skriptu atkļūdošanas logu STR_ERROR_AI_DEBUG_SERVER_ONLY :{YELLOW}MI/spēles skriptu atkļūdošanas logs ir pieejams tikai serverim # AI configuration window -STR_AI_CONFIG_CAPTION_AI :{WHITE}AI Konfigurācija -STR_AI_CONFIG_CAPTION_GAMESCRIPT :{WHITE}Spēles skripta konfigurācija +STR_AI_CONFIG_CAPTION_AI :{WHITE}AI iestatījumi +STR_AI_CONFIG_CAPTION_GAMESCRIPT :{WHITE}Spēles Skripta Iestatījumi STR_AI_CONFIG_GAMELIST_TOOLTIP :{BLACK}Spēles skripts, kas tiks ielādēts nākamajā spēlē STR_AI_CONFIG_AILIST_TOOLTIP :{BLACK}MI, kas tiks ielādēts nākamajā spēlē STR_AI_CONFIG_HUMAN_PLAYER :Spēlētājs (cilvēks) STR_AI_CONFIG_RANDOM_AI :Nejaušs MI STR_AI_CONFIG_NONE :(nav) +STR_AI_CONFIG_NAME_VERSION :{STRING} {YELLOW}v{NUM} STR_AI_CONFIG_MAX_COMPETITORS :{LTBLUE}Maksimālais sāncenšu daudzums: {ORANGE}{COMMA} +STR_AI_CONFIG_COMPETITORS_INTERVAL :{LTBLUE}Intervāls starp konkurentu startiem: {ORANGE}{COMMA} minut{P e es ""} STR_AI_CONFIG_MOVE_UP :{BLACK}Pacelt uz augšu STR_AI_CONFIG_MOVE_UP_TOOLTIP :{BLACK}Pacelt izvēlētos MI sarakstā uz augšu @@ -4561,8 +4702,8 @@ STR_AI_CONFIG_GAMESCRIPT_PARAM :{SILVER}Paramet STR_AI_CONFIG_AI :{SILVER}MI STR_AI_CONFIG_CHANGE_AI :{BLACK}Izvēlēties MI -STR_AI_CONFIG_CHANGE_GAMESCRIPT :{BLACK}Atlasiet spēles skriptu -STR_AI_CONFIG_CHANGE_TOOLTIP :{BLACK}Ielādēt citu skriptu +STR_AI_CONFIG_CHANGE_GAMESCRIPT :{BLACK}Izvētaties spēles skriptu +STR_AI_CONFIG_CHANGE_TOOLTIP :{BLACK}Ielādēt citu skriptu. Ctrl+klikšķis, lai parādītu visas pieejamās versijas STR_AI_CONFIG_CONFIGURE :{BLACK}Konfigurēt STR_AI_CONFIG_CONFIGURE_TOOLTIP :{BLACK}Konfigurēt skripta parametrus @@ -4591,22 +4732,33 @@ STR_SCREENSHOT_MINIMAP_SCREENSHOT :{BLACK}Minikart # Script Parameters STR_AI_SETTINGS_CAPTION :{WHITE}{STRING} Iestatījumi -STR_AI_SETTINGS_CAPTION_AI :{WHITE}MI Parametri +STR_AI_SETTINGS_CAPTION_AI :AI +STR_AI_SETTINGS_CAPTION_GAMESCRIPT :Spēles skripts STR_AI_SETTINGS_CLOSE :{BLACK}Aizvērt STR_AI_SETTINGS_RESET :{BLACK}Atiestatīt STR_AI_SETTINGS_SETTING :{STRING}: {ORANGE}{STRING} # Textfile window +STR_TEXTFILE_JUMPLIST :{WHITE}Satura rādītājs +STR_TEXTFILE_JUMPLIST_TOOLTIP :{BLACK}Izmantojot šo sarakstu, ātri pārejiet uz parādītā faila sadaļu +STR_TEXTFILE_JUMPLIST_ITEM :{WHITE}{STRING} +STR_TEXTFILE_NAVBACK_TOOLTIP :{BLACK}Atgriezties navigācijas vēsturē +STR_TEXTFILE_NAVFORWARD_TOOLTIP :{BLACK}Atgriezties uz priekšu navigācijas vēsturē STR_TEXTFILE_WRAP_TEXT :{WHITE}Aplauzt tekstu STR_TEXTFILE_WRAP_TEXT_TOOLTIP :{BLACK}Aplauzt tekstu logā, lai tas viss iekļautos un nevajadzētu ritināt -STR_TEXTFILE_VIEW_README :{BLACK}Skatīt failu Lasi_mani +STR_TEXTFILE_VIEW_README :{BLACK}Lasi_Mani +STR_TEXTFILE_VIEW_README_TOOLTIP :Skatīt šī satura readme STR_TEXTFILE_VIEW_CHANGELOG :{BLACK}Izmaiņu žurnāls +STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP :Skatīt šī satura izmaiņu žurnālu STR_TEXTFILE_VIEW_LICENCE :{BLACK}Licence +STR_TEXTFILE_VIEW_LICENCE_TOOLTIP :Skatīt šī satura licenci ###length 5 STR_TEXTFILE_README_CAPTION :{WHITE}{STRING} kopas {STRING} fails Lasi_mani STR_TEXTFILE_CHANGELOG_CAPTION :{WHITE}{STRING} kopas {STRING} izmaiņu žurnāls STR_TEXTFILE_LICENCE_CAPTION :{WHITE}{STRING} kopas {STRING} licence +STR_TEXTFILE_SURVEY_RESULT_CAPTION :{WHITE}Priekšskatīt aptaujas rezultātus +STR_TEXTFILE_GAME_MANUAL_CAPTION :{WHITE}OpenTTD dokuments'{STRING}' # Vehicle loading indicators @@ -4788,7 +4940,7 @@ STR_ERROR_TOO_MANY_TRUCK_STOPS :{WHITE}Pārāk STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK :{WHITE}Pārāk tuvu citai piestātnei STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT :{WHITE}Pārāk tuvu citai lidostai STR_ERROR_CAN_T_RENAME_STATION :{WHITE}Nevar pārdēvēt staciju... -STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD :{WHITE}... šis ceļš pieder pilsētai +STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD :{WHITE}... ceļš pieder pilsētai STR_ERROR_DRIVE_THROUGH_DIRECTION :{WHITE}... ceļš novietots nepareizā virzienā STR_ERROR_DRIVE_THROUGH_CORNER :{WHITE}... caurbraucamās stacijās nevar būt stūru STR_ERROR_DRIVE_THROUGH_JUNCTION :{WHITE}... caurbraucamās stacijās nevar būt sazarojumu @@ -5045,11 +5197,25 @@ STR_ERROR_TOO_FAR_FROM_PREVIOUS_DESTINATION :{WHITE}... pār STR_ERROR_AIRCRAFT_NOT_ENOUGH_RANGE :{WHITE}... lidaparātam ir nepietiekams apgabals # Extra messages which go on the third line of errors, explaining why orders failed +STR_ERROR_NO_RAIL_STATION :{WHITE}Dzelzceļa stacijas nav +STR_ERROR_NO_BUS_STATION :{WHITE}Nav autoostas +STR_ERROR_NO_TRUCK_STATION :{WHITE}Nav kravas automašīnu stacijas +STR_ERROR_NO_DOCK :{WHITE}Nav piestātnes +STR_ERROR_NO_AIRPORT :{WHITE}Nav lidostas/heliportu +STR_ERROR_NO_STOP_COMPATIBLE_ROAD_TYPE :{WHITE}Nav pieturu ar saderīgu ceļa veidu +STR_ERROR_NO_STOP_COMPATIBLE_TRAM_TYPE :{WHITE}Saderīgam tramvaja veidam pieturu nav +STR_ERROR_NO_STOP_ARTICULATED_VEHICLE :{WHITE}Nav pieturu, kas būtu piemērotas posmainiem transportlīdzekļiem.{}Posmainiem transportlīdzekļiem ir nepieciešama caurbraucama pietura. +STR_ERROR_AIRPORT_NO_PLANES :{WHITE}Šī lidmašīna nevar nolaisties šajā helikopteru lidlaukā +STR_ERROR_AIRPORT_NO_HELICOPTERS :{WHITE}Šis helikopters nevar nolaisties šajā lidostā +STR_ERROR_NO_RAIL_WAYPOINT :{WHITE}Nav dzelzceļa pieturas punkta +STR_ERROR_NO_BUOY :{WHITE}Bojas nav # Timetable related errors STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Nevar panākt transportalīdzekļa iekļaušanos sarakstā STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Transportlīdzekļus var gaidīt tikai stacijās STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Šis transportlīdzeklis šajā stacijā nepieturēs +STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... saraksts ir nepilnīgs +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... grafiks vēl nav sācies # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... pārāk daudz zīmju @@ -5529,17 +5695,21 @@ STR_VEHICLE_NAME :{VEHICLE} STR_WAYPOINT_NAME :{WAYPOINT} STR_JUST_CARGO :{CARGO_LONG} +STR_JUST_RIGHT_ARROW :{RIGHT_ARROW} STR_JUST_CHECKMARK :{CHECKMARK} STR_JUST_COMMA :{COMMA} STR_JUST_CURRENCY_SHORT :{CURRENCY_SHORT} STR_JUST_CURRENCY_LONG :{CURRENCY_LONG} STR_JUST_CARGO_LIST :{CARGO_LIST} +STR_JUST_DECIMAL :{DECIMAL} STR_JUST_INT :{NUM} STR_JUST_DATE_TINY :{DATE_TINY} STR_JUST_DATE_SHORT :{DATE_SHORT} STR_JUST_DATE_LONG :{DATE_LONG} STR_JUST_DATE_ISO :{DATE_ISO} STR_JUST_STRING :{STRING} +STR_JUST_STRING1 :{STRING} +STR_JUST_STRING2 :{STRING} STR_JUST_STRING_STRING :{STRING}{STRING} STR_JUST_RAW_STRING :{STRING} STR_JUST_BIG_RAW_STRING :{BIG_FONT}{STRING} diff --git a/src/lang/portuguese.txt b/src/lang/portuguese.txt index f48132918e..936f9e80d9 100644 --- a/src/lang/portuguese.txt +++ b/src/lang/portuguese.txt @@ -256,6 +256,9 @@ STR_UNITS_HEIGHT_IMPERIAL :{DECIMAL} pé(s STR_UNITS_HEIGHT_METRIC :{DECIMAL} m STR_UNITS_HEIGHT_SI :{DECIMAL} m +STR_UNITS_DAYS :{COMMA}{NBSP}dia{P "" s} +STR_UNITS_SECONDS :{COMMA}{NBSP}segundo{P "" s} +STR_UNITS_TICKS :{COMMA}{NBSP}tique{P "" s} # Common window strings STR_LIST_FILTER_TITLE :{BLACK}Filtro: @@ -720,6 +723,7 @@ STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Clique n STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Faça clique numa faixa para a remover da lista (Personaliz. 1 ou Personaliz. 2 apenas) # Highscore window +STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}Melhores empresas STR_HIGHSCORE_POSITION :{BIG_FONT}{BLACK}{COMMA}. STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN :Negociante STR_HIGHSCORE_PERFORMANCE_TITLE_ENTREPRENEUR :Empresário @@ -1488,7 +1492,7 @@ STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL :Original STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS :TerraGenesis STR_CONFIG_SETTING_TERRAIN_TYPE :Tipo de terreno: {STRING} -STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :(Apenas TerraGenesis) Relevo do terreno +STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :Escolher a altura das colinas e montanhas da paisagem STR_CONFIG_SETTING_INDUSTRY_DENSITY :Densidade industrial: {STRING} STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :Define quantas indústrias devem ser geradas e que nível deve ser mantido durante o jogo @@ -1497,18 +1501,18 @@ STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :Distância máx STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Refinarias de petróleo são construídas apenas próximo da borda do mapa, isto é, na costa para mapas de ilha STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Altura da linha de neve: {STRING} -STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Controla a que altura começa a neve no clima sub-ártico. A neve também afeta a geração de indústrias e os requisitos de crescimento das localidades. Só pode ser modificado no Editor de Cenário ou então é calculado por via da "cobertura de neve" +STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Escolher a que altura a neve começa na paisagem subártica. A neve também afeta a geração de indústrias e os requisitos de crescimento das localidades. Só pode ser modificado através do Editor de Cenários ou é calculado através da "cobertura de neve" STR_CONFIG_SETTING_SNOW_COVERAGE :Cobertura de neve: {STRING} -STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Controla a quantidade aproximada de neve no clima sub-ártico. A neve também afeta a geração das indústrias e os requisitos de crescimento das localidades. Usado apenas durante a geração do mapa. A terra logo acima do nível do mar está sempre sem neve +STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Escolher a quantidade aproximada de neve no clima subártico. A neve também afeta a geração de indústrias e os requisitos de crescimento das localidades. Usado apenas durante a geração do mapa. O nível do mar e as suas encostas nunca têm neve. STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_DESERT_COVERAGE :Cobertura do deserto: {STRING} -STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Controla a quantidade aproximada de deserto no clima tropical. O deserto também afeta a geração das indústrias. Usado apenas durante a geração do mapa +STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Escolher a quantidade aproximada de deserto na paisagem tropical. O deserto também afeta a geração de indústrias e os requisitos de crescimento das localidades. Usado apenas durante a geração do mapa STR_CONFIG_SETTING_DESERT_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :Rudeza do terreno: {STRING} -STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(Apenas TerraGenesis) Escolhe a frequência de montes: paisagens macias têm menos montes e mais espalhados. Paisagens duras têm muitos montes, que podem parecer repetitivos +STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :Escolher a forma e o número de colinas. As paisagens suaves têm poucas colinas, largas, enquanto as paisagens acidentadas possuem mais, colinas pequenas. ###length 4 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :Muito suave STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH :Suave @@ -1516,7 +1520,7 @@ STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH :Acidentado STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH :Muito acidentado STR_CONFIG_SETTING_VARIETY :Distribuição de variedade: {STRING} -STR_CONFIG_SETTING_VARIETY_HELPTEXT :(Apenas TerraGenesis) Controla se o mapa contém áreas planas e montanhosas. Como isto apenas torna o mapa mais plano, outras definições devem ser definidas como montanhosas +STR_CONFIG_SETTING_VARIETY_HELPTEXT :Escolher se o mapa contém tanto áreas montanhosas como áreas planas. Quanto maior a variedade, maiores as diferenças de altitude entre essas as áreas. STR_CONFIG_SETTING_RIVER_AMOUNT :Quantidade de rios: {STRING} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :Escolhe quantos rios serão gerados @@ -1536,6 +1540,7 @@ STR_CONFIG_SETTING_ROAD_SIDE_LEFT :Circular pela e STR_CONFIG_SETTING_ROAD_SIDE_RIGHT :Circular pela direita STR_CONFIG_SETTING_HEIGHTMAP_ROTATION :Rotação mapa de alt.: {STRING} +STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP :Escolher de que forma a imagem topográfica será girada para caber no mundo do jogo ###length 2 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE :Sentido anti-horário STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE :Sentido horário @@ -1656,7 +1661,12 @@ STR_CONFIG_SETTING_ADVANCED_VEHICLE_LISTS_HELPTEXT :Ativar a utiliz STR_CONFIG_SETTING_LOADING_INDICATORS :Usar indicadores de carga: {STRING} STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Seleccionar se os indicadores de carga são mostrados acima de veículos em carga ou descarga +STR_CONFIG_SETTING_TIMETABLE_MODE :Unidades de tempo para horários: {STRING} +STR_CONFIG_SETTING_TIMETABLE_MODE_HELPTEXT :Selecionar as unidades de tempo usadas nos horários dos veículos ###length 3 +STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS :Dias +STR_CONFIG_SETTING_TIMETABLE_MODE_SECONDS :Segundos +STR_CONFIG_SETTING_TIMETABLE_MODE_TICKS :Tiques STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Mostrar chegada e partida nos horários: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Mostrar horários previstos de chegada e partida nas tabelas de horários @@ -2187,12 +2197,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Exibir e STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Exibir esquemas de cores dos veículos rodoviários STR_LIVERY_SHIP_TOOLTIP :{BLACK}Exibir esquemas de cores dos navios STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Exibir esquema de cores da aeronave +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Exibir cores de grupos de comboios +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Exibir cores de grupos de veículos rodoviários +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Exibir cores de grupos de navios +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Exibir cores de grupos de aeronaves STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Seleccione a cor primária para o veículo seleccionado. Ctrl+Clique vai usar esta cor para todos os esquemas STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Selecione a cor secundária para o esquema selecionado. Ctrl+Clique seleciona essa cor para todos os esquemas STR_LIVERY_PANEL_TOOLTIP :{BLACK}Seleccione o esquema de cores a alterar, ou esquemas múltiplos utilizando a tecla Ctrl com o botão esquerdo do rato. Marque a caixa para comutar a utilização do esquema de cores +STR_LIVERY_TRAIN_GROUP_EMPTY :Não estão configurados grupos de comboios +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Não estão configurados grupos de veículos rodoviários +STR_LIVERY_SHIP_GROUP_EMPTY :Não estão configurados grupos de navios +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Não estão configurados grupos de aeronaves ###length 23 -STR_LIVERY_DEFAULT :Estampagem Padrão +STR_LIVERY_DEFAULT :Pintura Padrão STR_LIVERY_STEAM :Locomotivas a Vapor STR_LIVERY_DIESEL :Locomotivas Diesel STR_LIVERY_ELECTRIC :Locomotivas Eléctricas @@ -2345,7 +2363,7 @@ STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP :{BLACK}O nome d STR_NETWORK_START_SERVER_SET_PASSWORD :{BLACK}Definir palavra-chave STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP :{BLACK}Proteja o jogo com uma senha se não desejar que pessoas indesejadas se juntem -STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Visibilidade +STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Visibilidade: STR_NETWORK_START_SERVER_VISIBILITY_TOOLTIP :{BLACK}Se as outras pessoas podem ver o seu servidor na lista pública STR_NETWORK_START_SERVER_CLIENTS_SELECT :{BLACK}{NUM} cliente{P "" s} STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS :{BLACK}Máximo de clientes: @@ -2580,7 +2598,7 @@ STR_CONTENT_SEARCH_EXTERNAL_TOOLTIP :{BLACK}Escolher STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER_CAPTION :{WHITE}Está a sair do OpenTTD! STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER :{WHITE}Os termos e condições para o download de conteúdo de sites externos variam.{}Terá que se referir aos sites externos para instruções em como instalar o conteúdo no OpenTTD.{}Pretende continuar? STR_CONTENT_FILTER_TITLE :{BLACK}Filtrar por etiqueta/nome: -STR_CONTENT_OPEN_URL :{BLACK}Visitar a página web +STR_CONTENT_OPEN_URL :{BLACK}Website STR_CONTENT_OPEN_URL_TOOLTIP :{BLACK}Visitar a página web para este conteúdo STR_CONTENT_DOWNLOAD_CAPTION :{BLACK}Descarregar STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP :{BLACK}Iniciar a descarga do conteúdo seleccionado @@ -3200,11 +3218,15 @@ STR_MAPGEN_MAPSIZE :{BLACK}Dim. do STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK}Seleccionar o tamanho do mapa em mosaicos. O numero de mosaicos disponiveis será ligeiramente menor STR_MAPGEN_BY :{BLACK}* STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Num. de localidades: +STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP :{BLACK}Selecionar a densidade das cidades, ou um número personalizado STR_MAPGEN_TOWN_NAME_LABEL :{BLACK}Nomes das localidades: STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP :{BLACK}Seleccionar o estilo dos nomes das localidades STR_MAPGEN_DATE :{BLACK}Data: +STR_MAPGEN_DATE_TOOLTIP :{BLACK}Selecionar a data inicial STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}Num. de indústrias: +STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP :{BLACK}Selecionar a densidade das indústrias, ou um número personalizado STR_MAPGEN_HEIGHTMAP_HEIGHT :{BLACK}Pico mais alto: +STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP :{BLACK}Escolher o pico mais alto que o jogo tentará criar, medido em elevação acima do nível do mar STR_MAPGEN_HEIGHTMAP_HEIGHT_UP :{BLACK}Subir a altura máxima do pico mais alto do mapa em um STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN :{BLACK}Baixar a altura máxima do pico mais alto do mapa em um STR_MAPGEN_SNOW_COVERAGE :{BLACK}Cobertura de neve: @@ -3217,10 +3239,12 @@ STR_MAPGEN_DESERT_COVERAGE_DOWN :{BLACK}Diminuir STR_MAPGEN_DESERT_COVERAGE_TEXT :{BLACK}{NUM}% STR_MAPGEN_TERRAIN_TYPE :{BLACK}Tipo de terreno: STR_MAPGEN_SEA_LEVEL :{BLACK}Nível do mar: +STR_MAPGEN_SEA_LEVEL_TOOLTIP :{BLACK}Selecione o nível do mar STR_MAPGEN_QUANTITY_OF_RIVERS :{BLACK}Rios: STR_MAPGEN_SMOOTHNESS :{BLACK}Suavidade: STR_MAPGEN_VARIETY :{BLACK}Variedade da distribuição: STR_MAPGEN_GENERATE :{WHITE}Gerar +STR_MAPGEN_GENERATE_TOOLTIP :{BLACK}Criar o mapa e jogar OpenTTD! STR_MAPGEN_NEWGRF_SETTINGS :{BLACK}Definições de NewGRF STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP :{BLACK}Mostrar definições de NewGRF STR_MAPGEN_AI_SETTINGS :{BLACK}Definições de IA @@ -3253,6 +3277,7 @@ STR_MAPGEN_TOWN_NAME_CATALAN :Catalão # Strings for map borders at game generation STR_MAPGEN_BORDER_TYPE :{BLACK}Limites do mapa: +STR_MAPGEN_BORDER_TYPE_TOOLTIP :{BLACK}Escolher as bordas do mundo do jogo STR_MAPGEN_NORTHWEST :{BLACK}Noroeste STR_MAPGEN_NORTHEAST :{BLACK}Nordeste STR_MAPGEN_SOUTHEAST :{BLACK}Sudeste @@ -3265,7 +3290,9 @@ STR_MAPGEN_BORDER_MANUAL :{BLACK}Manual STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}Rotação mapa de alt.: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}Nome mapa de alt.: +STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP :{BLACK}O nome do ficheiro de imagem topográfica STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}Tamanho: +STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP :{BLACK}As dimensões da imagem topográfica de origem. Para obter melhores resultados, cada aresta deve corresponder a um comprimento de aresta de mapa disponível no OpenTTD, tais como 256, 512, 1024, etc. STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT :{WHITE}Altura do pico alvo @@ -3280,6 +3307,7 @@ STR_SE_MAPGEN_FLAT_WORLD :{WHITE}Terra pl STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP :{BLACK}Criar terra plana STR_SE_MAPGEN_RANDOM_LAND :{WHITE}Terra aleatória STR_SE_MAPGEN_FLAT_WORLD_HEIGHT :{BLACK}Altura da terra plana: +STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP :{BLACK}Escolher a elevação do terreno acima do nível do mar STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN :{BLACK}Mover altura da terra plana um nível abaixo STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP :{BLACK}Mover altura da terra plana um nível acima @@ -4573,8 +4601,13 @@ STR_TIMETABLE_STATUS_ON_TIME :{BLACK}Este ve STR_TIMETABLE_STATUS_LATE :{BLACK}Este veículo está presentemente atrasado {STRING} STR_TIMETABLE_STATUS_EARLY :{BLACK}Este veículo está presentemente adiantado {STRING} STR_TIMETABLE_STATUS_NOT_STARTED :{BLACK}Este horário ainda não começou +STR_TIMETABLE_STATUS_START_AT_DATE :{BLACK}Este horário tem início às {STRING} +STR_TIMETABLE_STATUS_START_IN_SECONDS :{BLACK}Este horário tem início em {COMMA} segundos +STR_TIMETABLE_START :{BLACK}Iniciar Horário +STR_TIMETABLE_START_TOOLTIP :{BLACK}Selecionar quando este horário começa. Ctrl+Clique distribui uniformemente o arranque de todos os veículos que partilham esta ordem com base na sua ordem relativa, se a ordem estiver completamente programada +STR_TIMETABLE_START_SECONDS_QUERY :Segundos até o horário iniciar STR_TIMETABLE_CHANGE_TIME :{BLACK}Mudar Tempo STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Mudar a duração do tempo que a ordem selecionada deve durar. Ctrl+Clique define o tempo para todas as ordens @@ -4598,6 +4631,10 @@ STR_TIMETABLE_EXPECTED :{BLACK}Esperado STR_TIMETABLE_SCHEDULED :{BLACK}Marcado STR_TIMETABLE_EXPECTED_TOOLTIP :{BLACK}Alternar entre tempo esperado e marcado +STR_TIMETABLE_ARRIVAL_DATE :A: {COLOUR}{DATE_TINY} +STR_TIMETABLE_DEPARTURE_DATE :D: {COLOUR}{DATE_TINY} +STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE :A: {COLOUR}{COMMA} seg +STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE :D: {COLOUR}{COMMA} seg # Date window (for timetable) @@ -4625,9 +4662,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Caso de STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Alternar o caso de igualdade quando se compara o resgisto da IA contra a string de paragem STR_AI_DEBUG_CONTINUE :{BLACK}Continuar STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Sair da pausa e continuar a IA -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Ver saída de depuração desta IA +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Ver saída de depuração desta IA. Ctrl+Clique para abrir numa nova janela STR_AI_GAME_SCRIPT :{BLACK}Script de jogo -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Verifique o registo do Script de jogo +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Verifique o registo do Script de jogo. Ctrl+Clique para abrir numa nova janela STR_ERROR_AI_NO_AI_FOUND :Não foi encontrada IA adequada para carregar.{}Esta IA é um pacote vazio e não fará nada.{}Pode descarregar várias IA através do sistema 'Conteúdo Online' STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Houve um erro num script. Por favor reporte isto ao autor do script com uma imagem da janela Depuramento de IA/Scripts de Jogo. @@ -4700,9 +4737,12 @@ STR_TEXTFILE_NAVBACK_TOOLTIP :{BLACK}Recuar n STR_TEXTFILE_NAVFORWARD_TOOLTIP :{BLACK}Avançar no histórico de navegação STR_TEXTFILE_WRAP_TEXT :{WHITE}Envolver o texto STR_TEXTFILE_WRAP_TEXT_TOOLTIP :{BLACK}Envolve o texto da janela de forma que não é necessário deslizar listagem -STR_TEXTFILE_VIEW_README :{BLACK}Ver leia-me +STR_TEXTFILE_VIEW_README :{BLACK}Leia-me +STR_TEXTFILE_VIEW_README_TOOLTIP :Ver "readme" para este conteúdo STR_TEXTFILE_VIEW_CHANGELOG :{BLACK}Lista de alterações +STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP :Ver o "log" de alterações para este conteúdo STR_TEXTFILE_VIEW_LICENCE :{BLACK}Licença +STR_TEXTFILE_VIEW_LICENCE_TOOLTIP :Ver a licença para este conteúdo ###length 5 STR_TEXTFILE_README_CAPTION :{WHITE}Leiame {STRING} de {STRING} STR_TEXTFILE_CHANGELOG_CAPTION :{WHITE}Lista de alterações {STRING} de {STRING} diff --git a/src/lang/russian.txt b/src/lang/russian.txt index 05305c66c0..1b9cf46733 100644 --- a/src/lang/russian.txt +++ b/src/lang/russian.txt @@ -2347,12 +2347,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Наст STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Настройка цветовой схемы автотранспорта STR_LIVERY_SHIP_TOOLTIP :{BLACK}Настройка цветовой схемы судов STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Настройка цветовой схемы авиатранспорта +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}{BLACK}Показать цвета поездных групп +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Показать цвета автомобильных групп +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Показать цвета корабельных групп +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Показать цвета самолетных групп STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Настройка основного цвета выбранного вида транспорта. Ctrl+щелчок установит выбранный цвет для всех видов транспорта. STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Настройка дополнительного цвета выбранного вида транспорта. Ctrl+щелчок установит выбранный цвет для всех видов транспорта. STR_LIVERY_PANEL_TOOLTIP :{BLACK}Выберите цветовую схему для изменения, либо несколько схем с Ctrl. Щёлкните по флажку для использования выбранной схемы. +STR_LIVERY_TRAIN_GROUP_EMPTY :Группы поездов не настроены +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Группы автомобильных транспортных средств не настроены +STR_LIVERY_SHIP_GROUP_EMPTY :Группы кораблей не настроены +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Группы самолетов не созданы ###length 23 -STR_LIVERY_DEFAULT :Стандарт. окраска +STR_LIVERY_DEFAULT :Окраска по умолчанию STR_LIVERY_STEAM :Паровоз STR_LIVERY_DIESEL :Тепловоз STR_LIVERY_ELECTRIC :Электровоз @@ -4840,9 +4848,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Реги STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Переключить проверку регистра при сравнении строк STR_AI_DEBUG_CONTINUE :{BLACK}Продолжить STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Продолжить игру -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Просмотр отладочной информации модуля ИИ +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Просмотрите выходные данные отладки этого AI. Ctrl-щелчок, чтобы открыть в новом окне STR_AI_GAME_SCRIPT :{BLACK}Игровой скрипт -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Показать журнал работы игрового скрипта +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Проверьте журнал игровых сценариев. Ctrl-щелчок, чтобы открыть в новом окне STR_ERROR_AI_NO_AI_FOUND :Не найдено подходящих модулей ИИ, поэтому конкуренты ничего делать не будут.{}Вы можете скачать модули ИИ через систему онлайн-контента. STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Один из запущенных ИИ / скриптов завершил свою работу аварийно. Пожалуйста, сообщите об этом автору скрипта, приложив снимок окна отладки. diff --git a/src/league_gui.cpp b/src/league_gui.cpp index e113c29613..500ccce085 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -100,7 +100,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_PLT_BACKGROUND) return; @@ -127,7 +127,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_PLT_BACKGROUND) return; @@ -302,7 +302,7 @@ public: this->InitNested(table); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_SLT_CAPTION) return; SetDParamStr(0, this->title); @@ -313,7 +313,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_SLT_BACKGROUND) return; @@ -355,7 +355,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_SLT_BACKGROUND) return; @@ -395,7 +395,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget != WID_SLT_BACKGROUND) return; diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 7bd1d17f22..8441ff6738 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -642,56 +642,54 @@ void LinkGraphOverlay::SetCompanyMask(CompanyMask company_mask) } /** Make a number of rows with buttons for each company for the linkgraph legend window. */ -NWidgetBase *MakeCompanyButtonRowsLinkGraphGUI(int *biggest_index) +std::unique_ptr MakeCompanyButtonRowsLinkGraphGUI() { - return MakeCompanyButtonRows(biggest_index, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, COLOUR_GREY, 3, STR_NULL); + return MakeCompanyButtonRows(WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, COLOUR_GREY, 3, STR_NULL); } -NWidgetBase *MakeSaturationLegendLinkGraphGUI(int *biggest_index) +std::unique_ptr MakeSaturationLegendLinkGraphGUI() { - NWidgetVertical *panel = new NWidgetVertical(NC_EQUALSIZE); + auto panel = std::make_unique(NC_EQUALSIZE); for (uint i = 0; i < lengthof(LinkGraphOverlay::LINK_COLOURS[0]); ++i) { - NWidgetBackground * wid = new NWidgetBackground(WWT_PANEL, COLOUR_DARK_GREEN, i + WID_LGL_SATURATION_FIRST); + auto wid = std::make_unique(WWT_PANEL, COLOUR_DARK_GREEN, i + WID_LGL_SATURATION_FIRST); wid->SetMinimalSize(50, 0); wid->SetMinimalTextLines(1, 0, FS_SMALL); wid->SetFill(1, 1); wid->SetResize(0, 0); - panel->Add(wid); + panel->Add(std::move(wid)); } - *biggest_index = WID_LGL_SATURATION_LAST; return panel; } -NWidgetBase *MakeCargoesLegendLinkGraphGUI(int *biggest_index) +std::unique_ptr MakeCargoesLegendLinkGraphGUI() { uint num_cargo = static_cast(_sorted_cargo_specs.size()); static const uint ENTRIES_PER_COL = 5; - NWidgetHorizontal *panel = new NWidgetHorizontal(NC_EQUALSIZE); - NWidgetVertical *col = nullptr; + auto panel = std::make_unique(NC_EQUALSIZE); + std::unique_ptr col = nullptr; for (uint i = 0; i < num_cargo; ++i) { if (i % ENTRIES_PER_COL == 0) { - if (col != nullptr) panel->Add(col); - col = new NWidgetVertical(NC_EQUALSIZE); + if (col != nullptr) panel->Add(std::move(col)); + col = std::make_unique(NC_EQUALSIZE); } - NWidgetBackground * wid = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, i + WID_LGL_CARGO_FIRST); + auto wid = std::make_unique(WWT_PANEL, COLOUR_GREY, i + WID_LGL_CARGO_FIRST); wid->SetMinimalSize(25, 0); wid->SetMinimalTextLines(1, 0, FS_SMALL); wid->SetFill(1, 1); wid->SetResize(0, 0); - col->Add(wid); + col->Add(std::move(wid)); } /* Fill up last row */ for (uint i = num_cargo; i < Ceil(num_cargo, ENTRIES_PER_COL); ++i) { - NWidgetSpacer *spc = new NWidgetSpacer(25, 0); + auto spc = std::make_unique(25, 0); spc->SetMinimalTextLines(1, 0, FS_SMALL); spc->SetFill(1, 1); spc->SetResize(0, 0); - col->Add(spc); + col->Add(std::move(spc)); } /* If there are no cargo specs defined, then col won't have been created so don't add it. */ - if (col != nullptr) panel->Add(col); - *biggest_index = WID_LGL_CARGO_LAST; + if (col != nullptr) panel->Add(std::move(col)); return panel; } @@ -772,7 +770,7 @@ void LinkGraphLegendWindow::SetOverlay(LinkGraphOverlay *overlay) } } -void LinkGraphLegendWindow::UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) +void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) { if (IsInsideMM(widget, WID_LGL_SATURATION_FIRST, WID_LGL_SATURATION_LAST + 1)) { StringID str = STR_NULL; @@ -799,7 +797,7 @@ void LinkGraphLegendWindow::UpdateWidgetSize(int widget, Dimension *size, [[mayb } } -void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const +void LinkGraphLegendWindow::DrawWidget(const Rect &r, WidgetID widget) const { Rect br = r.Shrink(WidgetDimensions::scaled.bevel); if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) { @@ -830,7 +828,7 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const } } -bool LinkGraphLegendWindow::OnTooltip([[maybe_unused]] Point, int widget, TooltipCloseCondition close_cond) +bool LinkGraphLegendWindow::OnTooltip([[maybe_unused]] Point, WidgetID widget, TooltipCloseCondition close_cond) { if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) { if (this->IsWidgetDisabled(widget)) { @@ -878,7 +876,7 @@ void LinkGraphLegendWindow::UpdateOverlayCargoes() this->overlay->SetCargoMask(mask); } -void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) +void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) { /* Check which button is clicked */ if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) { diff --git a/src/linkgraph/linkgraph_gui.h b/src/linkgraph/linkgraph_gui.h index 8e4d6956e4..b56c413967 100644 --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -69,7 +69,7 @@ public: * @param company_mask Bitmask of companies to be shown. * @param scale Desired thickness of lines and size of station dots. */ - LinkGraphOverlay(Window *w, uint wid, CargoTypes cargo_mask, CompanyMask company_mask, uint scale) : + LinkGraphOverlay(Window *w, WidgetID wid, CargoTypes cargo_mask, CompanyMask company_mask, uint scale) : window(w), widget_id(wid), cargo_mask(cargo_mask), company_mask(company_mask), scale(scale), dirty(true) {} @@ -94,7 +94,7 @@ public: protected: Window *window; ///< Window to be drawn into. - const uint widget_id; ///< ID of Widget in Window to be drawn to. + const WidgetID widget_id; ///< ID of Widget in Window to be drawn to. CargoTypes cargo_mask; ///< Bitmask of cargos to be displayed. CompanyMask company_mask; ///< Bitmask of companies to be displayed. LinkList cached_links; ///< Cache for links to reduce recalculation. @@ -128,10 +128,10 @@ public: LinkGraphLegendWindow(WindowDesc *desc, int window_number); void SetOverlay(LinkGraphOverlay *overlay); - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; - void DrawWidget(const Rect &r, int widget) const override; - bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override; - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override; + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; + void DrawWidget(const Rect &r, WidgetID widget) const override; + bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override; + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override; void OnInvalidateData(int data = 0, bool gui_scope = true) override; private: diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 636dd29914..9a09ae87c2 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -80,7 +80,7 @@ void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 * @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground * @return true if the button is clicked, false if it's unclicked */ -bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode) +bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode) { if (w->IsWidgetDisabled(widget)) return false; @@ -520,7 +520,7 @@ struct MainWindow : Window } } - bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { if (widget != WID_M_VIEWPORT) return false; return this->viewport->overlay->ShowTooltip(pt, close_cond); @@ -538,7 +538,7 @@ struct MainWindow : Window InvalidateWindowData(WC_MAIN_TOOLBAR, 0, data, true); } - virtual void OnMouseOver(Point pt, int widget) override + virtual void OnMouseOver(Point pt, WidgetID widget) override { if (pt.x != -1 && _game_mode != GM_MENU && IsViewportMouseHoverActive()) { /* Show tooltip with last month production or town name */ diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 46c4a3bf32..7e9177e45e 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -73,7 +73,7 @@ class LandInfoWindow : public Window { public: TileIndex tile; - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_LI_BACKGROUND) return; @@ -89,7 +89,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_LI_BACKGROUND) return; @@ -375,7 +375,7 @@ public: ::ShowNewGRFInspectWindow(GetGrfSpecFeature(this->tile), this->tile); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_LI_LOCATION: @@ -522,7 +522,7 @@ struct AboutWindow : public Window { this->text_position = this->GetWidget(WID_A_SCROLLING_TEXT)->pos_y + this->GetWidget(WID_A_SCROLLING_TEXT)->current_y; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_A_WEBSITE) SetDParamStr(0, "Main project website: https://www.openttd.org"); if (widget == WID_A_WEBSITE1) SetDParamStr(0, "Patchpack thread: https://www.tt-forums.net/viewtopic.php?f=33&t=73469"); @@ -530,7 +530,7 @@ struct AboutWindow : public Window { if (widget == WID_A_COPYRIGHT) SetDParamStr(0, _openttd_revision_year); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_A_SCROLLING_TEXT) return; @@ -550,7 +550,7 @@ struct AboutWindow : public Window { this->timer.SetInterval(TIMER_INTERVAL / GetCharacterHeight(FS_NORMAL)); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_A_SCROLLING_TEXT) return; @@ -752,7 +752,7 @@ struct TooltipsWindow : public Window return pt; } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_TT_BACKGROUND) return; if (this->params.size() == 0) { @@ -769,7 +769,7 @@ struct TooltipsWindow : public Window size->height += WidgetDimensions::scaled.framerect.Vertical() + WidgetDimensions::scaled.fullbevel.Vertical(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_TT_BACKGROUND) return; GfxFillRect(r, PC_BLACK); @@ -837,7 +837,7 @@ void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_t new TooltipsWindow(parent, str, paramcount, close_tooltip); } -void QueryString::HandleEditBox(Window *w, int wid) +void QueryString::HandleEditBox(Window *w, WidgetID wid) { if (w->IsWidgetGloballyFocused(wid) && this->text.HandleCaret()) { w->SetWidgetDirty(wid); @@ -852,7 +852,7 @@ static int GetCaretWidth() return GetCharacterWidth(FS_NORMAL, '_'); } -void QueryString::DrawEditBox(const Window *w, int wid) const +void QueryString::DrawEditBox(const Window *w, WidgetID wid) const { const NWidgetLeaf *wi = w->GetWidget(wid); @@ -904,7 +904,7 @@ void QueryString::DrawEditBox(const Window *w, int wid) const * @param wid Widget index. * @return Top-left location of the caret, relative to the window. */ -Point QueryString::GetCaretPosition(const Window *w, int wid) const +Point QueryString::GetCaretPosition(const Window *w, WidgetID wid) const { const NWidgetLeaf *wi = w->GetWidget(wid); @@ -933,7 +933,7 @@ Point QueryString::GetCaretPosition(const Window *w, int wid) const * @param to End of the string range. * @return Rectangle encompassing the string range, relative to the window. */ -Rect QueryString::GetBoundingRect(const Window *w, int wid, const char *from, const char *to) const +Rect QueryString::GetBoundingRect(const Window *w, WidgetID wid, const char *from, const char *to) const { const NWidgetLeaf *wi = w->GetWidget(wid); @@ -964,7 +964,7 @@ Rect QueryString::GetBoundingRect(const Window *w, int wid, const char *from, co * @param pt Position to test. * @return Index of the character position or -1 if no character is at the position. */ -ptrdiff_t QueryString::GetCharAtPosition(const Window *w, int wid, const Point &pt) const +ptrdiff_t QueryString::GetCharAtPosition(const Window *w, WidgetID wid, const Point &pt) const { const NWidgetLeaf *wi = w->GetWidget(wid); @@ -986,7 +986,7 @@ ptrdiff_t QueryString::GetCharAtPosition(const Window *w, int wid, const Point & return ::GetCharAtPosition(tb->buf, pt.x - delta - r.left); } -void QueryString::ClickEditBox(Window *w, Point pt, int wid, int click_count, bool focus_changed) +void QueryString::ClickEditBox(Window *w, Point pt, WidgetID wid, int click_count, bool focus_changed) { const NWidgetLeaf *wi = w->GetWidget(wid); @@ -1070,7 +1070,7 @@ struct QueryStringWindow : public Window this->ReInit(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_QS_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) { /* We don't want this widget to show! */ @@ -1084,7 +1084,7 @@ struct QueryStringWindow : public Window } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_QS_WARNING) return; @@ -1094,7 +1094,7 @@ struct QueryStringWindow : public Window } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_QS_CAPTION) SetDParam(0, this->editbox.caption); } @@ -1109,7 +1109,7 @@ struct QueryStringWindow : public Window } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_QS_DEFAULT: @@ -1231,7 +1231,7 @@ struct QueryWindow : public Window { this->SetDirty(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_Q_CAPTION: @@ -1250,7 +1250,7 @@ struct QueryWindow : public Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_Q_TEXT) return; @@ -1262,7 +1262,7 @@ struct QueryWindow : public Window { *size = d; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_Q_TEXT) return; @@ -1272,7 +1272,7 @@ struct QueryWindow : public Window { this->message_str, TC_FROMSTRING, SA_CENTER); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_Q_YES: { diff --git a/src/music_gui.cpp b/src/music_gui.cpp index b6a9a76ef1..f16e802737 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -494,7 +494,7 @@ struct MusicTrackSelectionWindow : public Window { this->LowerWidget(WID_MTS_ALL + _settings_client.music.playlist); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_MTS_PLAYLIST: @@ -526,7 +526,7 @@ struct MusicTrackSelectionWindow : public Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_MTS_PLAYLIST: { @@ -561,7 +561,7 @@ struct MusicTrackSelectionWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_MTS_LIST_LEFT: { @@ -594,7 +594,7 @@ struct MusicTrackSelectionWindow : public Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_MTS_LIST_LEFT: { // add to playlist @@ -626,7 +626,7 @@ struct MusicTrackSelectionWindow : public Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_MTS_MUSICSET: @@ -708,7 +708,7 @@ struct MusicWindow : public Window { ); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { /* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size. @@ -750,7 +750,7 @@ struct MusicWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_M_TRACK_NR: { @@ -813,7 +813,7 @@ struct MusicWindow : public Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_M_PREV: // skip to prev diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 464e6b4880..418f56c373 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -452,7 +452,7 @@ struct NetworkChatWindow : public Window { return pt; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_NC_DESTINATION) return; @@ -461,7 +461,7 @@ struct NetworkChatWindow : public Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_NC_SENDBUTTON: /* Send */ @@ -484,7 +484,7 @@ struct NetworkChatWindow : public Window { return state; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_NC_TEXTBOX) { _chat_tab_completion_active = false; diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index db3aa6fb0c..38f7644354 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -619,6 +619,8 @@ void ClientNetworkContentSocketHandler::OnReceiveData(UniqueBuffer data) this->lastActivity = std::chrono::steady_clock::now(); + this->lastActivity = std::chrono::steady_clock::now(); + if (this->http_response_index == -1) { if (data != nullptr) { /* Append the rest of the response. */ diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index bd76488dd6..0e8326a226 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -65,7 +65,7 @@ struct ContentTextfileWindow : public TextfileWindow { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, this->GetTypeString()); @@ -115,7 +115,7 @@ void BaseNetworkContentDownloadStatusWindow::Close([[maybe_unused]] int data) this->Window::Close(); } -void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) +void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) { switch (widget) { case WID_NCDS_PROGRESS_BAR: @@ -134,7 +134,7 @@ void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(int widget, Dimens } } -void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const +void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, WidgetID widget) const { switch (widget) { case WID_NCDS_PROGRESS_BAR: { @@ -286,7 +286,7 @@ public: this->BaseNetworkContentDownloadStatusWindow::Close(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget == WID_NCDS_CANCELOK) { if (this->downloaded_bytes != this->total_bytes) { @@ -585,7 +585,7 @@ public: this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT)); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_NCL_CHECKBOX: @@ -609,7 +609,7 @@ public: } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NCL_DETAILS: @@ -792,7 +792,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget >= WID_NCL_TEXTFILE && widget < WID_NCL_TEXTFILE + TFT_CONTENT_END) { if (this->selected == nullptr || this->selected->state != ContentInfo::ALREADY_HERE) return; @@ -925,7 +925,7 @@ public: return ES_HANDLED; } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_NCL_FILTER) { this->filter_data.string_filter.SetFilterTerm(this->filter_editbox.text.buf); diff --git a/src/network/network_content_gui.h b/src/network/network_content_gui.h index 3973521661..6f96c91d7c 100644 --- a/src/network/network_content_gui.h +++ b/src/network/network_content_gui.h @@ -33,8 +33,8 @@ public: BaseNetworkContentDownloadStatusWindow(WindowDesc *desc); void Close([[maybe_unused]] int data = 0) override; - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; - void DrawWidget(const Rect &r, int widget) const override; + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; + void DrawWidget(const Rect &r, WidgetID widget) const override; void OnDownloadProgress(const ContentInfo *ci, int bytes) override; }; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 82aa644bc2..6726a60de8 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -93,21 +93,21 @@ class NWidgetServerListHeader : public NWidgetContainer { public: NWidgetServerListHeader() : NWidgetContainer(NWID_HORIZONTAL) { - NWidgetLeaf *leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME_TOOLTIP); + auto leaf = std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME_TOOLTIP); leaf->SetResize(1, 0); leaf->SetFill(1, 0); - this->Add(leaf); + this->Add(std::move(leaf)); - this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CLIENTS, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION_TOOLTIP)); - this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_MAPSIZE, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION_TOOLTIP)); - this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_DATE, STR_NETWORK_SERVER_LIST_DATE_CAPTION, STR_NETWORK_SERVER_LIST_DATE_CAPTION_TOOLTIP)); - this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_YEARS, STR_NETWORK_SERVER_LIST_YEARS_CAPTION, STR_NETWORK_SERVER_LIST_YEARS_CAPTION_TOOLTIP)); + this->Add(std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CLIENTS, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION_TOOLTIP)); + this->Add(std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_MAPSIZE, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION_TOOLTIP)); + this->Add(std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_DATE, STR_NETWORK_SERVER_LIST_DATE_CAPTION, STR_NETWORK_SERVER_LIST_DATE_CAPTION_TOOLTIP)); + this->Add(std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_YEARS, STR_NETWORK_SERVER_LIST_YEARS_CAPTION, STR_NETWORK_SERVER_LIST_YEARS_CAPTION_TOOLTIP)); - leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP); + leaf = std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP); leaf->SetMinimalSize(14 + GetSpriteSize(SPR_LOCK, nullptr, ZOOM_LVL_OUT_4X).width + GetSpriteSize(SPR_BLOT, nullptr, ZOOM_LVL_OUT_4X).width, 12); leaf->SetFill(0, 1); - this->Add(leaf); + this->Add(std::move(leaf)); } void SetupSmallestSize(Window *w) override @@ -119,18 +119,18 @@ public: this->resize_y = 0; // We never resize in this direction /* First initialise some variables... */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->SetupSmallestSize(w); this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.Vertical()); } /* ... then in a second pass make sure the 'current' sizes are set. Won't change for most widgets. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->current_x = child_wid->smallest_x; child_wid->current_y = this->smallest_y; } - this->smallest_x = this->head->smallest_x + this->tail->smallest_x; // First and last are always shown, rest not + this->smallest_x = this->children.front()->smallest_x + this->children.back()->smallest_x; // First and last are always shown, rest not } void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override @@ -142,27 +142,38 @@ public: this->current_x = given_width; this->current_y = given_height; - given_width -= this->tail->smallest_x; + given_width -= this->children.back()->smallest_x; /* The first and last widget are always visible, determine which other should be visible */ - for (NWidgetBase *child_wid = this->head->next; child_wid->next != nullptr; child_wid = child_wid->next) { - if (given_width > ScaleGUITrad(MINIMUM_NAME_WIDTH_BEFORE_NEW_HEADER) + child_wid->smallest_x && child_wid->prev->current_x != 0) { - given_width -= child_wid->smallest_x; - child_wid->current_x = child_wid->smallest_x; /* Make visible. */ - } else { - child_wid->current_x = 0; /* Make invisible. */ + if (this->children.size() > 2) { + auto first = std::next(std::begin(this->children)); + auto last = std::prev(std::end(this->children)); + for (auto it = first; it != last; ++it) { + auto &child_wid = *it; + if (given_width > ScaleGUITrad(MINIMUM_NAME_WIDTH_BEFORE_NEW_HEADER) + child_wid->smallest_x && (*std::prev(it))->current_x != 0) { + given_width -= child_wid->smallest_x; + child_wid->current_x = child_wid->smallest_x; /* Make visible. */ + } else { + child_wid->current_x = 0; /* Make invisible. */ + } } } /* All remaining space goes to the first (name) widget */ - this->head->current_x = given_width; + this->children.front()->current_x = given_width; /* Now assign the widgets to their rightful place */ uint position = 0; // Place to put next child relative to origin of the container. - for (NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid != nullptr; child_wid = rtl ? child_wid->prev : child_wid->next) { + auto assign_position = [&](const std::unique_ptr &child_wid) { if (child_wid->current_x != 0) { child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl); position += child_wid->current_x; } + }; + + if (rtl) { + std::for_each(std::rbegin(this->children), std::rend(this->children), assign_position); + } else { + std::for_each(std::begin(this->children), std::end(this->children), assign_position); } } }; @@ -470,7 +481,7 @@ public: this->flag_offset = this->blot_offset + ScaleGUITrad(2) + GetSpriteSize(SPR_BLOT).width; } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_NG_MATRIX: @@ -516,7 +527,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NG_MATRIX: { @@ -674,7 +685,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_NG_CANCEL: // Cancel button @@ -808,7 +819,7 @@ public: return state; } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { switch (wid) { case WID_NG_FILTER: { @@ -865,10 +876,9 @@ GUIGameServerList::FilterFunction * const NetworkGameWindow::filter_funcs[] = { &NGameSearchFilter }; -static NWidgetBase *MakeResizableHeader(int *biggest_index) +static std::unique_ptr MakeResizableHeader() { - *biggest_index = std::max(*biggest_index, WID_NG_INFO); - return new NWidgetServerListHeader(); + return std::make_unique(); } static const NWidgetPart _nested_network_game_widgets[] = { @@ -974,7 +984,7 @@ void ShowNetworkGameWindow() } struct NetworkStartServerWindow : public Window { - byte widget_id; ///< The widget that has the pop-up input menu + WidgetID widget_id; ///< The widget that has the pop-up input menu QueryString name_editbox; ///< Server name editbox. NetworkStartServerWindow(WindowDesc *desc) : Window(desc), name_editbox(NETWORK_NAME_LENGTH) @@ -987,7 +997,7 @@ struct NetworkStartServerWindow : public Window { this->SetFocusedWidget(WID_NSS_GAMENAME); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_NSS_CONNTYPE_BTN: @@ -1004,7 +1014,7 @@ struct NetworkStartServerWindow : public Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_NSS_CONNTYPE_BTN: @@ -1015,7 +1025,7 @@ struct NetworkStartServerWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NSS_SETPWD: @@ -1024,7 +1034,7 @@ struct NetworkStartServerWindow : public Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_NSS_CANCEL: // Cancel button @@ -1102,7 +1112,7 @@ struct NetworkStartServerWindow : public Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_NSS_CONNTYPE_BTN: @@ -1667,7 +1677,7 @@ public: this->SetWidgetDisabledState(WID_CL_SERVER_NAME_EDIT, !_network_server); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_CL_SERVER_VISIBILITY: @@ -1695,7 +1705,7 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_CL_MATRIX); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CL_SERVER_NAME: @@ -1730,7 +1740,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_CL_SERVER_NAME_EDIT: @@ -1764,7 +1774,7 @@ public: } } - bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { switch (widget) { case WID_CL_MATRIX: { @@ -1803,7 +1813,7 @@ public: return false; } - void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override + void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override { /* If you close the dropdown outside the list, don't take any action. */ if (widget == WID_CL_MATRIX) return; @@ -1811,7 +1821,7 @@ public: Window::OnDropdownClose(pt, widget, index, instant_close); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_CL_SERVER_VISIBILITY: @@ -2021,7 +2031,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_CL_MATRIX: { @@ -2057,7 +2067,7 @@ public: } } - void OnMouseOver([[maybe_unused]] Point pt, int widget) override + void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override { if (widget != WID_CL_MATRIX) { if (this->hover_index != -1) { @@ -2093,7 +2103,7 @@ struct NetworkJoinStatusWindow : Window { this->InitNested(WN_NETWORK_STATUS_WINDOW_JOIN); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NJS_PROGRESS_BAR: { @@ -2144,7 +2154,7 @@ struct NetworkJoinStatusWindow : Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_NJS_PROGRESS_BAR: @@ -2170,7 +2180,7 @@ struct NetworkJoinStatusWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget == WID_NJS_CANCELOK) { // Disconnect button NetworkDisconnect(); @@ -2259,14 +2269,14 @@ struct NetworkCompanyPasswordWindow : public Window { this->ReInit(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_NCP_WARNING) { *size = this->warning_size; } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_NCP_WARNING) return; @@ -2283,7 +2293,7 @@ struct NetworkCompanyPasswordWindow : public Window { NetworkChangeCompanyPassword(_local_company, this->password_editbox.text.buf); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_NCP_OK: @@ -2365,14 +2375,14 @@ struct NetworkAskRelayWindow : public Window { this->Window::Close(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_NAR_TEXT) { *size = GetStringBoundingBox(STR_NETWORK_ASK_RELAY_TEXT); } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_NAR_TEXT) { DrawStringMultiLine(r, STR_NETWORK_ASK_RELAY_TEXT, TC_FROMSTRING, SA_CENTER); @@ -2387,7 +2397,7 @@ struct NetworkAskRelayWindow : public Window { this->SetDirty(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_NAR_TEXT: @@ -2397,7 +2407,7 @@ struct NetworkAskRelayWindow : public Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_NAR_NO: @@ -2468,14 +2478,14 @@ struct NetworkAskSurveyWindow : public Window { this->InitNested(0); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_NAS_TEXT) { *size = GetStringBoundingBox(STR_NETWORK_ASK_SURVEY_TEXT); } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_NAS_TEXT) { DrawStringMultiLine(r, STR_NETWORK_ASK_SURVEY_TEXT, TC_BLACK, SA_CENTER); @@ -2490,7 +2500,7 @@ struct NetworkAskSurveyWindow : public Window { this->SetDirty(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_NAS_PREVIEW: diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index b3e23b0bae..4d0d097692 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -433,14 +433,14 @@ struct NewGRFInspectWindow : Window { this->OnInvalidateData(0, true); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_NGRFI_CAPTION) return; GetFeatureHelper(this->window_number)->SetStringParameters(this->GetFeatureIndex()); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_NGRFI_VEH_CHAIN: { @@ -486,7 +486,7 @@ struct NewGRFInspectWindow : Window { ::DrawString(r.Shrink(WidgetDimensions::scaled.frametext).Shrink(0, offset * this->resize.step_height, 0, 0), buf, TC_BLACK); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NGRFI_VEH_CHAIN: { @@ -877,7 +877,7 @@ struct NewGRFInspectWindow : Window { this->SelectTagArrayItem(this->marked_groups, group); } - void OnClick(Point pt, int widget, int click_count) override + void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_NGRFI_PARENT: { @@ -1059,7 +1059,7 @@ struct NewGRFInspectWindow : Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget == WID_NGRFI_MAIN_OPTIONS) { GetFeatureHelper(this->window_number)->OnOptionsDropdownSelect(this->GetFeatureIndex(), index); @@ -1146,7 +1146,7 @@ struct NewGRFInspectWindow : Window { this->redraw_scrollbar = false; } - virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override + virtual bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { if (widget == WID_NGRFI_MAINPANEL && this->sprite_dump) { _temp_special_strings[0] = GetString(this->click_to_mark_mode ? STR_NEWGRF_INSPECT_SPRITE_DUMP_PANEL_TOOLTIP_MARK : STR_NEWGRF_INSPECT_SPRITE_DUMP_PANEL_TOOLTIP_HIGHLIGHT); @@ -1418,7 +1418,7 @@ struct SpriteAlignerWindow : Window { this->InvalidateData(0, true); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { const Sprite *spr = GetSprite(this->current_sprite, SpriteType::Normal, ZoomMask(ZOOM_LVL_GUI)); switch (widget) { @@ -1452,7 +1452,7 @@ struct SpriteAlignerWindow : Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_SA_SPRITE: @@ -1470,7 +1470,7 @@ struct SpriteAlignerWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SA_SPRITE: { @@ -1522,7 +1522,7 @@ struct SpriteAlignerWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_SA_PREVIOUS: diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index ad0eb98e2b..4076fb3dce 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -221,7 +221,7 @@ struct NewGRFParametersWindow : public Window { return this->HasParameterInfo(nr) ? this->grf_config->param_info[nr].value() : GetDummyParameterInfo(nr); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_NP_NUMPAR_DEC: @@ -264,7 +264,7 @@ struct NewGRFParametersWindow : public Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_NP_NUMPAR: @@ -273,7 +273,7 @@ struct NewGRFParametersWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_NP_DESCRIPTION) { if (!this->HasParameterInfo(this->clicked_row)) return; @@ -342,7 +342,7 @@ struct NewGRFParametersWindow : public Window { this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_NP_NUMPAR_DEC: @@ -464,7 +464,7 @@ struct NewGRFParametersWindow : public Window { this->SetDirty(); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_NP_SETTING_DROPDOWN) return; assert(this->clicked_dropdown); @@ -473,7 +473,7 @@ struct NewGRFParametersWindow : public Window { this->SetDirty(); } - void OnDropdownClose(Point, int widget, int, bool) override + void OnDropdownClose(Point, WidgetID widget, int, bool) override { if (widget != WID_NP_SETTING_DROPDOWN) return; /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether @@ -577,7 +577,7 @@ struct NewGRFTextfileWindow : public TextfileWindow { this->LoadTextfile(textfile, NEWGRF_DIR); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, STR_CONTENT_TYPE_NEWGRF); @@ -756,7 +756,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_NS_FILE_LIST: @@ -814,7 +814,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->vscroll2->SetCapacityFromWidget(this, WID_NS_AVAIL_LIST); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_NS_PRESET_LIST: @@ -863,7 +863,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { return pal; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NS_FILE_LIST: { @@ -955,7 +955,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget >= WID_NS_NEWGRF_TEXTFILE && widget < WID_NS_NEWGRF_TEXTFILE + TFT_CONTENT_END) { if (this->active_sel == nullptr && this->avail_sel == nullptr) return; @@ -1197,7 +1197,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_NS_PRESET_LIST) return; if (!this->editable) return; @@ -1383,7 +1383,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { return ES_HANDLED; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (!this->editable) return; @@ -1395,7 +1395,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } } - void OnDragDrop(Point pt, int widget) override + void OnDragDrop(Point pt, WidgetID widget) override { if (!this->editable) return; @@ -1443,7 +1443,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } } - void OnMouseDrag(Point pt, int widget) override + void OnMouseDrag(Point pt, WidgetID widget) override { if (!this->editable) return; @@ -1622,27 +1622,22 @@ NewGRFWindow::GUIGRFConfigList::FilterFunction * const NewGRFWindow::filter_func * - two column mode, put the #acs and the #avs underneath each other and the #inf next to it, or * - three column mode, put the #avs, #acs, and #inf each in its own column. */ -class NWidgetNewGRFDisplay : public NWidgetContainer { +class NWidgetNewGRFDisplay : public NWidgetBase { public: static const uint MAX_EXTRA_INFO_WIDTH; ///< Maximal additional width given to the panel. static const uint MIN_EXTRA_FOR_3_COLUMNS; ///< Minimal additional width needed before switching to 3 columns. - NWidgetBase *avs; ///< Widget with the available grfs list and buttons. - NWidgetBase *acs; ///< Widget with the active grfs list and buttons. - NWidgetBase *inf; ///< Info panel. + std::unique_ptr avs; ///< Widget with the available grfs list and buttons. + std::unique_ptr acs; ///< Widget with the active grfs list and buttons. + std::unique_ptr inf; ///< Info panel. bool editable; ///< Editable status of the parent NewGRF window (if \c false, drop all widgets that make the window editable). - NWidgetNewGRFDisplay(NWidgetBase *avs, NWidgetBase *acs, NWidgetBase *inf) : NWidgetContainer(NWID_HORIZONTAL) + NWidgetNewGRFDisplay(std::unique_ptr &&avs, std::unique_ptr &&acs, std::unique_ptr &&inf) : NWidgetBase(NWID_CUSTOM) + , avs(std::move(avs)) + , acs(std::move(acs)) + , inf(std::move(inf)) + , editable(true) // Temporary setting, 'real' value is set in SetupSmallestSize(). { - this->avs = avs; - this->acs = acs; - this->inf = inf; - - this->Add(this->avs); - this->Add(this->acs); - this->Add(this->inf); - - this->editable = true; // Temporary setting, 'real' value is set in SetupSmallestSize(). } void SetupSmallestSize(Window *w) override @@ -1807,6 +1802,13 @@ public: } } + void FillWidgetLookup(WidgetLookup &widget_lookup) override + { + this->avs->FillWidgetLookup(widget_lookup); + this->acs->FillWidgetLookup(widget_lookup); + this->inf->FillWidgetLookup(widget_lookup); + } + NWidgetCore *GetWidgetFromPos(int x, int y) override { if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr; @@ -1970,18 +1972,13 @@ static const NWidgetPart _nested_newgrf_infopanel_widgets[] = { }; /** Construct nested container widget for managing the lists and the info panel of the NewGRF GUI. */ -NWidgetBase* NewGRFDisplay(int *biggest_index) +std::unique_ptr NewGRFDisplay() { - NWidgetBase *avs = MakeNWidgets(std::begin(_nested_newgrf_availables_widgets), std::end(_nested_newgrf_availables_widgets), biggest_index, nullptr); - - int biggest2; - NWidgetBase *acs = MakeNWidgets(std::begin(_nested_newgrf_actives_widgets), std::end(_nested_newgrf_actives_widgets), &biggest2, nullptr); - *biggest_index = std::max(*biggest_index, biggest2); - - NWidgetBase *inf = MakeNWidgets(std::begin(_nested_newgrf_infopanel_widgets), std::end(_nested_newgrf_infopanel_widgets), &biggest2, nullptr); - *biggest_index = std::max(*biggest_index, biggest2); + std::unique_ptr avs = MakeNWidgets(std::begin(_nested_newgrf_availables_widgets), std::end(_nested_newgrf_availables_widgets), nullptr); + std::unique_ptr acs = MakeNWidgets(std::begin(_nested_newgrf_actives_widgets), std::end(_nested_newgrf_actives_widgets), nullptr); + std::unique_ptr inf = MakeNWidgets(std::begin(_nested_newgrf_infopanel_widgets), std::end(_nested_newgrf_infopanel_widgets), nullptr); - return new NWidgetNewGRFDisplay(avs, acs, inf); + return std::make_unique(std::move(avs), std::move(acs), std::move(inf)); } /* Widget definition of the manage newgrfs window */ @@ -2137,7 +2134,7 @@ struct SavePresetWindow : public Window { if (initial_text != nullptr) this->presetname_editbox.text.Assign(initial_text); } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_SVP_PRESET_LIST: { @@ -2154,7 +2151,7 @@ struct SavePresetWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SVP_PRESET_LIST: { @@ -2178,7 +2175,7 @@ struct SavePresetWindow : public Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_SVP_PRESET_LIST: { @@ -2252,7 +2249,7 @@ struct ScanProgressWindow : public Window { this->InitNested(1); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_SP_PROGRESS_BAR: { @@ -2275,7 +2272,7 @@ struct ScanProgressWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SP_PROGRESS_BAR: { diff --git a/src/news_gui.cpp b/src/news_gui.cpp index c1cdbbc483..38ed50db61 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -344,7 +344,7 @@ struct NewsWindow : Window { return pt; } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { StringID str = STR_NULL; switch (widget) { @@ -418,12 +418,12 @@ struct NewsWindow : Window { *size = maxdim(*size, d); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_N_DATE) SetDParam(0, this->ni->date); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_N_CAPTION: @@ -480,7 +480,7 @@ struct NewsWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_N_CLOSEBOX: @@ -592,7 +592,7 @@ private: return this->ni->params[1].data; } - StringID GetNewVehicleMessageString(int widget) const + StringID GetNewVehicleMessageString(WidgetID widget) const { assert(this->ni->reftype1 == NR_ENGINE); EngineID engine = this->ni->ref1; @@ -1135,7 +1135,7 @@ struct MessageHistoryWindow : Window { this->OnInvalidateData(0); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_MH_BACKGROUND) { this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; @@ -1157,7 +1157,7 @@ struct MessageHistoryWindow : Window { this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_MH_BACKGROUND || _total_news == 0) return; @@ -1196,7 +1196,7 @@ struct MessageHistoryWindow : Window { this->vscroll->SetCount(_total_news); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget == WID_MH_BACKGROUND) { NewsItem *ni = _latest_news; diff --git a/src/object_gui.cpp b/src/object_gui.cpp index b12ad8c85f..a86f996859 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -182,7 +182,7 @@ public: assert(ObjectClass::Get(_selected_object_class)->GetUISpecCount() > 0); // object GUI should be disabled elsewise } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_BO_OBJECT_NAME: { @@ -210,7 +210,7 @@ public: this->object_margin = ScaleGUITrad(4); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_BO_CLASS_LIST: { @@ -302,9 +302,9 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BO_CLASS_LIST: { Rect mr = r.Shrink(WidgetDimensions::scaled.matrix); uint pos = 0; @@ -331,7 +331,8 @@ public: * look nice in all layouts, we use the 4x4 layout (smallest previews) as starting point. For the bigger * previews in the layouts with less views we add space homogeneously on all sides, so the 4x4 preview-rectangle * is centered in the 2x1, 1x2 resp. 1x1 buttons. */ - uint matrix_height = this->GetWidget(WID_BO_OBJECT_MATRIX)->current_y; + const NWidgetMatrix *matrix = this->GetWidget(widget)->GetParentWidget(); + uint matrix_height = matrix->current_y; DrawPixelInfo tmp_dpi; /* Set up a clipping area for the preview. */ @@ -343,7 +344,7 @@ public: const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id]; DrawOrigTileSeqInGUI(ir.Width() / 2 - 1, (ir.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE); } else { - DrawNewObjectTileInGUI(ir.Width() / 2 - 1, (ir.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec, GB(widget, 16, 16)); + DrawNewObjectTileInGUI(ir.Width() / 2 - 1, (ir.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec, matrix->GetCurrentElement()); } } break; @@ -351,7 +352,7 @@ public: case WID_BO_SELECT_IMAGE: { ObjectClass *objclass = ObjectClass::Get(_selected_object_class); - int obj_index = objclass->GetIndexFromUI(GB(widget, 16, 16)); + int obj_index = objclass->GetIndexFromUI(this->GetWidget(widget)->GetParentWidget()->GetCurrentElement()); if (obj_index < 0) break; const ObjectSpec *spec = objclass->GetSpec(obj_index); if (spec == nullptr) break; @@ -531,9 +532,9 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_BO_CLASS_LIST); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BO_CLASS_LIST: { auto it = this->vscroll->GetScrolledItemFromWidget(this->object_classes, pt.y, this, widget); if (it == this->object_classes.end()) break; @@ -545,14 +546,14 @@ public: case WID_BO_SELECT_IMAGE: { ObjectClass *objclass = ObjectClass::Get(_selected_object_class); - int num_clicked = objclass->GetIndexFromUI(GB(widget, 16, 16)); + int num_clicked = objclass->GetIndexFromUI(this->GetWidget(widget)->GetParentWidget()->GetCurrentElement()); if (num_clicked >= 0 && objclass->GetSpec(num_clicked)->IsAvailable()) this->SelectOtherObject(num_clicked); break; } case WID_BO_OBJECT_SPRITE: if (_selected_object_index != -1) { - _selected_object_view = GB(widget, 16, 16); + _selected_object_view = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); this->SelectOtherObject(_selected_object_index); // Re-select the object for a different view. } break; @@ -616,7 +617,7 @@ public: return ES_HANDLED; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_BO_FILTER) { string_filter.SetFilterTerm(this->filter_editbox.text.buf); diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 4ee63a0240..a433ca0305 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -187,7 +187,7 @@ public: this->Window::Close(); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget == WID_CTO_HEADER) { (*size).height = std::max((*size).height, (uint) GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.framerect.Vertical()); @@ -203,7 +203,7 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { if (WID_CTO_CARGO_LABEL_FIRST <= widget && widget <= WID_CTO_CARGO_LABEL_LAST) { Rect ir = r.Shrink(WidgetDimensions::scaled.framerect); @@ -227,7 +227,7 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { if (!this->CheckOrderStillValid()) { this->Close(); @@ -245,7 +245,7 @@ public: } } - virtual void OnDropdownSelect(int widget, int action_type) override + virtual void OnDropdownSelect(WidgetID widget, int action_type) override { if (!this->CheckOrderStillValid()) { this->Close(); @@ -283,7 +283,7 @@ public: } } - virtual void SetStringParameters(int widget) const override + virtual void SetStringParameters(WidgetID widget) const override { if (!this->CheckOrderStillValid()) { return; @@ -330,14 +330,12 @@ public: /** * Make a list of panel for each available cargo type. * Each panel contains a label to display the cargo name. - * @param biggest_index Storage for collecting the biggest index used in the returned tree * @return A vertical container of cargo type orders rows. * @post \c *biggest_index contains the largest used index in the tree. */ -static NWidgetBase *MakeCargoTypeOrdersRows(int *biggest_index, bool right) +static std::unique_ptr MakeCargoTypeOrdersRows(bool right) { - - NWidgetVertical *ver = new NWidgetVertical; + std::unique_ptr ver = std::make_unique(); const bool dual_column = (_sorted_standard_cargo_specs.size() >= 32); if (right && !dual_column) return ver; @@ -346,34 +344,36 @@ static NWidgetBase *MakeCargoTypeOrdersRows(int *biggest_index, bool right) for (int i = (right ? 1 : 0); i < (int)_sorted_standard_cargo_specs.size(); i += increment) { /* Cargo row */ - NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_CTO_CARGO_ROW_FIRST + i); - ver->Add(panel); - NWidgetHorizontal *horiz = new NWidgetHorizontal; - panel->Add(horiz); + std::unique_ptr panel = std::make_unique(WWT_PANEL, COLOUR_GREY, WID_CTO_CARGO_ROW_FIRST + i); + std::unique_ptr horiz = std::make_unique(); + /* Cargo label */ - NWidgetBackground *label = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_CTO_CARGO_LABEL_FIRST + i); + std::unique_ptr label = std::make_unique(WWT_PANEL, COLOUR_GREY, WID_CTO_CARGO_LABEL_FIRST + i); label->SetFill(1, 0); label->SetResize(1, 0); - horiz->Add(label); + horiz->Add(std::move(label)); + /* Orders dropdown */ - NWidgetLeaf *dropdown = new NWidgetLeaf(WWT_DROPDOWN, COLOUR_GREY, WID_CTO_CARGO_DROPDOWN_FIRST + i, STR_NULL, STR_EMPTY); + std::unique_ptr dropdown = std::make_unique(WWT_DROPDOWN, COLOUR_GREY, WID_CTO_CARGO_DROPDOWN_FIRST + i, STR_NULL, STR_EMPTY); dropdown->SetFill(1, 0); dropdown->SetResize(1, 0); - horiz->Add(dropdown); + horiz->Add(std::move(dropdown)); + + panel->Add(std::move(horiz)); + ver->Add(std::move(panel)); } - *biggest_index = WID_CTO_CARGO_DROPDOWN_LAST; return ver; } -static NWidgetBase *MakeCargoTypeOrdersRowsLeft(int *biggest_index) +static std::unique_ptr MakeCargoTypeOrdersRowsLeft() { - return MakeCargoTypeOrdersRows(biggest_index, false); + return MakeCargoTypeOrdersRows(false); } -static NWidgetBase *MakeCargoTypeOrdersRowsRight(int *biggest_index) +static std::unique_ptr MakeCargoTypeOrdersRowsRight() { - return MakeCargoTypeOrdersRows(biggest_index, true); + return MakeCargoTypeOrdersRows(true); } /** Widgets definition of CargoTypeOrdersWindow. */ @@ -1907,7 +1907,7 @@ public: this->GeneralVehicleWindow::Close(); } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_O_OCCUPANCY_LIST: @@ -2382,7 +2382,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_O_ORDER_LIST: @@ -2517,7 +2517,7 @@ public: DrawString(left, right, r.top + offset + clicked, STR_ORDERS_TIMETABLE_VIEW, TC_FROMSTRING, SA_HOR_CENTER); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_O_COND_VALUE: { @@ -2682,7 +2682,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_O_ORDER_LIST: { @@ -3214,7 +3214,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_O_NON_STOP: @@ -3351,7 +3351,7 @@ public: } } - void OnDragDrop(Point pt, int widget) override + void OnDragDrop(Point pt, WidgetID widget) override { switch (widget) { case WID_O_ORDER_LIST: { @@ -3525,7 +3525,7 @@ public: } } - void OnMouseDrag(Point pt, int widget) override + void OnMouseDrag(Point pt, WidgetID widget) override { if (this->selected_order != -1 && widget == WID_O_ORDER_LIST) { /* An order is dragged.. */ @@ -3565,7 +3565,7 @@ public: } } - bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { switch (widget) { case WID_O_SHARED_ORDER_LIST: { diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 033dc7db89..00c6ff7322 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -37,7 +37,7 @@ static byte _keystate = KEYS_NONE; struct OskWindow : public Window { StringID caption; ///< the caption for this window. QueryString *qs; ///< text-input - int text_btn; ///< widget number of parent's text field + WidgetID text_btn; ///< widget number of parent's text field Textbuf *text; ///< pointer to parent's textbuffer (to update caret position) std::string orig_str; ///< Original string. bool shift; ///< Is the shift effectively pressed? @@ -88,12 +88,12 @@ struct OskWindow : public Window { this->SetWidgetLoweredState(WID_OSK_CAPS, HasBit(_keystate, KEYS_CAPS)); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_OSK_CAPTION) SetDParam(0, this->caption); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget < WID_OSK_LETTERS) return; @@ -101,7 +101,7 @@ struct OskWindow : public Window { DrawCharCentered(_keyboard[this->shift][widget], r, TC_BLACK); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { /* clicked a letter */ if (widget >= WID_OSK_LETTERS) { @@ -183,7 +183,7 @@ struct OskWindow : public Window { } } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_OSK_TEXT) { this->SetWidgetDirty(WID_OSK_TEXT); @@ -220,103 +220,100 @@ static const int KEY_PADDING = 6; // Vertical padding for remaining key rows * @param widtype Widget type of the key. Must be either \c NWID_SPACER for an invisible key, or a \c WWT_* widget. * @param widnum Widget number of the key. * @param widdata Data value of the key widget. - * @param biggest_index Collected biggest widget index so far. * @note Key width is measured in 1/2 keys to allow for 1/2 key shifting between rows. */ -static void AddKey(NWidgetHorizontal *hor, int pad_y, int num_half, WidgetType widtype, int widnum, uint16 widdata, int *biggest_index) +static void AddKey(std::unique_ptr &hor, int pad_y, int num_half, WidgetType widtype, WidgetID widnum, uint16_t widdata) { int key_width = HALF_KEY_WIDTH + (INTER_KEY_SPACE + HALF_KEY_WIDTH) * (num_half - 1); if (widtype == NWID_SPACER) { if (!hor->IsEmpty()) key_width += INTER_KEY_SPACE; - NWidgetSpacer *spc = new NWidgetSpacer(key_width, 0); + auto spc = std::make_unique(key_width, 0); spc->SetMinimalTextLines(1, pad_y, FS_NORMAL); - hor->Add(spc); + hor->Add(std::move(spc)); } else { if (!hor->IsEmpty()) { - NWidgetSpacer *spc = new NWidgetSpacer(INTER_KEY_SPACE, 0); + auto spc = std::make_unique(INTER_KEY_SPACE, 0); spc->SetMinimalTextLines(1, pad_y, FS_NORMAL); - hor->Add(spc); + hor->Add(std::move(spc)); } - NWidgetLeaf *leaf = new NWidgetLeaf(widtype, COLOUR_GREY, widnum, widdata, STR_NULL); + auto leaf = std::make_unique(widtype, COLOUR_GREY, widnum, widdata, STR_NULL); leaf->SetMinimalSize(key_width, 0); leaf->SetMinimalTextLines(1, pad_y, FS_NORMAL); - hor->Add(leaf); + hor->Add(std::move(leaf)); } - - *biggest_index = std::max(*biggest_index, widnum); } /** Construct the top row keys (cancel, ok, backspace). */ -static NWidgetBase *MakeTopKeys(int *biggest_index) +static std::unique_ptr MakeTopKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontal(); + auto hor = std::make_unique(); - AddKey(hor, TOP_KEY_PADDING, 6 * 2, WWT_TEXTBTN, WID_OSK_CANCEL, STR_BUTTON_CANCEL, biggest_index); - AddKey(hor, TOP_KEY_PADDING, 6 * 2, WWT_TEXTBTN, WID_OSK_OK, STR_BUTTON_OK, biggest_index); - AddKey(hor, TOP_KEY_PADDING, 2 * 2, WWT_PUSHIMGBTN, WID_OSK_BACKSPACE, SPR_OSK_BACKSPACE, biggest_index); + AddKey(hor, TOP_KEY_PADDING, 6 * 2, WWT_TEXTBTN, WID_OSK_CANCEL, STR_BUTTON_CANCEL); + AddKey(hor, TOP_KEY_PADDING, 6 * 2, WWT_TEXTBTN, WID_OSK_OK, STR_BUTTON_OK ); + AddKey(hor, TOP_KEY_PADDING, 2 * 2, WWT_PUSHIMGBTN, WID_OSK_BACKSPACE, SPR_OSK_BACKSPACE); return hor; } /** Construct the row containing the digit keys. */ -static NWidgetBase *MakeNumberKeys(int *biggest_index) +static std::unique_ptr MakeNumberKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); + std::unique_ptr hor = std::make_unique(); - for (int widnum = WID_OSK_NUMBERS_FIRST; widnum <= WID_OSK_NUMBERS_LAST; widnum++) { - AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index); + for (WidgetID widnum = WID_OSK_NUMBERS_FIRST; widnum <= WID_OSK_NUMBERS_LAST; widnum++) { + AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } return hor; } /** Construct the qwerty row keys. */ -static NWidgetBase *MakeQwertyKeys(int *biggest_index) +static std::unique_ptr MakeQwertyKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); + std::unique_ptr hor = std::make_unique(); - AddKey(hor, KEY_PADDING, 3, WWT_PUSHIMGBTN, WID_OSK_SPECIAL, SPR_OSK_SPECIAL, biggest_index); - for (int widnum = WID_OSK_QWERTY_FIRST; widnum <= WID_OSK_QWERTY_LAST; widnum++) { - AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index); + AddKey(hor, KEY_PADDING, 3, WWT_PUSHIMGBTN, WID_OSK_SPECIAL, SPR_OSK_SPECIAL); + for (WidgetID widnum = WID_OSK_QWERTY_FIRST; widnum <= WID_OSK_QWERTY_LAST; widnum++) { + AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } - AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0, biggest_index); + AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0); return hor; } /** Construct the asdfg row keys. */ -static NWidgetBase *MakeAsdfgKeys(int *biggest_index) +static std::unique_ptr MakeAsdfgKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); + std::unique_ptr hor = std::make_unique(); - AddKey(hor, KEY_PADDING, 4, WWT_IMGBTN, WID_OSK_CAPS, SPR_OSK_CAPS, biggest_index); - for (int widnum = WID_OSK_ASDFG_FIRST; widnum <= WID_OSK_ASDFG_LAST; widnum++) { - AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index); + AddKey(hor, KEY_PADDING, 4, WWT_IMGBTN, WID_OSK_CAPS, SPR_OSK_CAPS); + for (WidgetID widnum = WID_OSK_ASDFG_FIRST; widnum <= WID_OSK_ASDFG_LAST; widnum++) { + AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } return hor; } /** Construct the zxcvb row keys. */ -static NWidgetBase *MakeZxcvbKeys(int *biggest_index) +static std::unique_ptr MakeZxcvbKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); + std::unique_ptr hor = std::make_unique(); - AddKey(hor, KEY_PADDING, 3, WWT_IMGBTN, WID_OSK_SHIFT, SPR_OSK_SHIFT, biggest_index); - for (int widnum = WID_OSK_ZXCVB_FIRST; widnum <= WID_OSK_ZXCVB_LAST; widnum++) { - AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index); + AddKey(hor, KEY_PADDING, 3, WWT_IMGBTN, WID_OSK_SHIFT, SPR_OSK_SHIFT); + for (WidgetID widnum = WID_OSK_ZXCVB_FIRST; widnum <= WID_OSK_ZXCVB_LAST; widnum++) { + AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } - AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0, biggest_index); + AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0); return hor; } /** Construct the spacebar row keys. */ -static NWidgetBase *MakeSpacebarKeys(int *biggest_index) +static std::unique_ptr MakeSpacebarKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontal(); + auto hor = std::make_unique(); - AddKey(hor, KEY_PADDING, 8, NWID_SPACER, 0, 0, biggest_index); - AddKey(hor, KEY_PADDING, 13, WWT_PUSHTXTBTN, WID_OSK_SPACE, STR_EMPTY, biggest_index); - AddKey(hor, KEY_PADDING, 3, NWID_SPACER, 0, 0, biggest_index); - AddKey(hor, KEY_PADDING, 2, WWT_PUSHIMGBTN, WID_OSK_LEFT, SPR_OSK_LEFT, biggest_index); - AddKey(hor, KEY_PADDING, 2, WWT_PUSHIMGBTN, WID_OSK_RIGHT, SPR_OSK_RIGHT, biggest_index); + AddKey(hor, KEY_PADDING, 8, NWID_SPACER, 0, 0); + AddKey(hor, KEY_PADDING, 13, WWT_PUSHTXTBTN, WID_OSK_SPACE, STR_EMPTY); + AddKey(hor, KEY_PADDING, 3, NWID_SPACER, 0, 0); + AddKey(hor, KEY_PADDING, 2, WWT_PUSHIMGBTN, WID_OSK_LEFT, SPR_OSK_LEFT); + AddKey(hor, KEY_PADDING, 2, WWT_PUSHIMGBTN, WID_OSK_RIGHT, SPR_OSK_RIGHT); return hor; } @@ -393,7 +390,7 @@ void GetKeyboardLayout() * @param parent pointer to the Window where this keyboard originated from * @param button widget number of parent's textbox */ -void ShowOnScreenKeyboard(Window *parent, int button) +void ShowOnScreenKeyboard(Window *parent, WidgetID button) { CloseWindowById(WC_OSK, 0); @@ -408,7 +405,7 @@ void ShowOnScreenKeyboard(Window *parent, int button) * @param parent window that just updated its original text * @param button widget number of parent's textbox to update */ -void UpdateOSKOriginalText(const Window *parent, int button) +void UpdateOSKOriginalText(const Window *parent, WidgetID button) { OskWindow *osk = dynamic_cast(FindWindowById(WC_OSK, 0)); if (osk == nullptr || osk->parent != parent || osk->text_btn != button) return; @@ -424,7 +421,7 @@ void UpdateOSKOriginalText(const Window *parent, int button) * @param button Editbox of \a w to check for * @return true if the OSK is opened for \a button. */ -bool IsOSKOpenedFor(const Window *w, int button) +bool IsOSKOpenedFor(const Window *w, WidgetID button) { OskWindow *osk = dynamic_cast(FindWindowById(WC_OSK, 0)); return osk != nullptr && osk->parent == w && osk->text_btn == button; diff --git a/src/plans_gui.cpp b/src/plans_gui.cpp index 2afc715f98..eaebd32320 100644 --- a/src/plans_gui.cpp +++ b/src/plans_gui.cpp @@ -108,7 +108,7 @@ struct PlansWindow : Window { this->Window::Close(); } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_PLN_NEW: @@ -222,7 +222,7 @@ struct PlansWindow : Window { } } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_PLN_COLOUR: @@ -262,7 +262,7 @@ struct PlansWindow : Window { this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_PLN_LIST: { @@ -316,7 +316,7 @@ struct PlansWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_PLN_COLOUR: @@ -330,7 +330,7 @@ struct PlansWindow : Window { this->vscroll->SetCapacityFromWidget(this, WID_PLN_LIST, WidgetDimensions::scaled.framerect.Vertical()); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_PLN_LIST: diff --git a/src/programmable_signals_gui.cpp b/src/programmable_signals_gui.cpp index 0a9d9e50fb..93ca60d4a7 100644 --- a/src/programmable_signals_gui.cpp +++ b/src/programmable_signals_gui.cpp @@ -267,7 +267,7 @@ public: RebuildInstructionList(); } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case PROGRAM_WIDGET_INSTRUCTION_LIST: { @@ -537,7 +537,7 @@ public: } } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { SignalInstruction *ins = this->GetSelected(); if (!ins) return; @@ -603,7 +603,7 @@ public: } } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case PROGRAM_WIDGET_INSTRUCTION_LIST: @@ -624,7 +624,7 @@ public: this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != PROGRAM_WIDGET_INSTRUCTION_LIST) return; @@ -649,7 +649,7 @@ public: } - virtual void SetStringParameters(int widget) const override + virtual void SetStringParameters(WidgetID widget) const override { switch (widget) { case PROGRAM_WIDGET_COND_VALUE: { diff --git a/src/querystring_gui.h b/src/querystring_gui.h index 7bf1b36afc..111cea490a 100644 --- a/src/querystring_gui.h +++ b/src/querystring_gui.h @@ -42,17 +42,17 @@ struct QueryString { } public: - void DrawEditBox(const Window *w, int wid) const; - void ClickEditBox(Window *w, Point pt, int wid, int click_count, bool focus_changed); - void HandleEditBox(Window *w, int wid); + void DrawEditBox(const Window *w, WidgetID wid) const; + void ClickEditBox(Window *w, Point pt, WidgetID wid, int click_count, bool focus_changed); + void HandleEditBox(Window *w, WidgetID wid); - Point GetCaretPosition(const Window *w, int wid) const; - Rect GetBoundingRect(const Window *w, int wid, const char *from, const char *to) const; - ptrdiff_t GetCharAtPosition(const Window *w, int wid, const Point &pt) const; + Point GetCaretPosition(const Window *w, WidgetID wid) const; + Rect GetBoundingRect(const Window *w, WidgetID wid, const char *from, const char *to) const; + ptrdiff_t GetCharAtPosition(const Window *w, WidgetID wid, const Point &pt) const; }; -void ShowOnScreenKeyboard(Window *parent, int button); -void UpdateOSKOriginalText(const Window *parent, int button); -bool IsOSKOpenedFor(const Window *w, int button); +void ShowOnScreenKeyboard(Window *parent, WidgetID button); +void UpdateOSKOriginalText(const Window *parent, WidgetID button); +bool IsOSKOpenedFor(const Window *w, WidgetID button); #endif /* QUERYSTRING_GUI_H */ diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 251cf6421d..8857dd64aa 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -370,7 +370,7 @@ static bool RailToolbar_CtrlChanged(Window *w) if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return false; /* allow ctrl to switch remove mode only for these widgets */ - for (uint i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) { + for (WidgetID i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) { if ((i <= WID_RAT_POLYRAIL || i >= WID_RAT_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) { ToggleRailButton_Remove(w); return true; @@ -557,7 +557,7 @@ struct BuildRailToolbarWindow : Window { this->ReInit(); } - void UpdateRemoveWidgetStatus(int clicked_widget) + void UpdateRemoveWidgetStatus(WidgetID clicked_widget) { switch (clicked_widget) { case WID_RAT_REMOVE: @@ -588,7 +588,7 @@ struct BuildRailToolbarWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_RAT_CAPTION) { const RailTypeInfo *rti = GetRailTypeInfo(this->railtype); @@ -602,7 +602,7 @@ struct BuildRailToolbarWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_RAT_POLYRAIL) { Dimension d = GetSpriteSize(SPR_BLOT); @@ -611,7 +611,7 @@ struct BuildRailToolbarWindow : Window { } } - void OnClick(Point pt, int widget, int click_count) override + void OnClick(Point pt, WidgetID widget, int click_count) override { if (widget < WID_RAT_BUILD_NS) return; @@ -742,7 +742,7 @@ struct BuildRailToolbarWindow : Window { if (_ctrl_pressed) RailToolbar_CtrlChanged(this); } - virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override + virtual bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { if (widget == WID_RAT_CONVERT_RAIL) { SetDParam(0, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL); @@ -1344,7 +1344,7 @@ public: return ES_HANDLED; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_BRAS_FILTER_EDITBOX) { string_filter.SetFilterTerm(this->filter_editbox.text.buf); @@ -1403,7 +1403,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_BRAS_NEWST_LIST: { @@ -1459,11 +1459,11 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { DrawPixelInfo tmp_dpi; - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BRAS_PLATFORM_DIR_X: { /* Set up a clipping area for the '/' station preview */ Rect ir = r.Shrink(WidgetDimensions::scaled.bevel); @@ -1508,7 +1508,7 @@ public: } case WID_BRAS_IMAGE: { - uint16_t type = GB(widget, 16, 16); + uint16_t type = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); assert(type < _railstation.station_count); /* Check station availability callback */ const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(type); @@ -1538,7 +1538,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_BRAS_SHOW_NEWST_TYPE) { const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type); @@ -1546,9 +1546,9 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BRAS_PLATFORM_DIR_X: case WID_BRAS_PLATFORM_DIR_Y: this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X); @@ -1682,7 +1682,7 @@ public: } case WID_BRAS_IMAGE: { - uint16_t y = GB(widget, 16, 16); + uint16_t y = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); if (y >= _railstation.station_count) return; /* Check station availability callback */ @@ -1692,7 +1692,7 @@ public: _railstation.station_type = y; this->CheckSelectedSize(statspec); - this->GetWidget(WID_BRAS_MATRIX)->SetClicked(_railstation.station_type); + this->GetWidget(widget)->GetParentWidget()->SetClicked(_railstation.station_type); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); @@ -1868,7 +1868,7 @@ private: * @param widget_index index of this widget in the window * @param image the sprite to draw */ - void DrawSignalSprite(const Rect &r, int widget_index, PalSpriteID image) const + void DrawSignalSprite(const Rect &r, WidgetID widget_index, PalSpriteID image) const { Point offset; Dimension sprite_size = GetSpriteSize(image.sprite, &offset); @@ -1884,10 +1884,10 @@ private: void SetDisableStates() { - for (int widget = WID_BS_SEMAPHORE_NORM; widget <= WID_BS_SEMAPHORE_NO_ENTRY; widget++) { + for (WidgetID widget = WID_BS_SEMAPHORE_NORM; widget <= WID_BS_SEMAPHORE_NO_ENTRY; widget++) { this->SetWidgetDisabledState(widget, _cur_signal_style > 0 && !HasBit(_new_signal_styles[_cur_signal_style - 1].semaphore_mask, TypeForClick(widget - WID_BS_SEMAPHORE_NORM))); } - for (int widget = WID_BS_ELECTRIC_NORM; widget <= WID_BS_ELECTRIC_NO_ENTRY; widget++) { + for (WidgetID widget = WID_BS_ELECTRIC_NORM; widget <= WID_BS_ELECTRIC_NO_ENTRY; widget++) { this->SetWidgetDisabledState(widget, _cur_signal_style > 0 && !HasBit(_new_signal_styles[_cur_signal_style - 1].electric_mask, TypeForClick(widget - WID_BS_ELECTRIC_NORM))); } if (_cur_signal_style > 0) { @@ -2009,7 +2009,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) { /* Two digits for signals density. */ @@ -2022,7 +2022,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_BS_DRAG_SIGNALS_DENSITY_LABEL: @@ -2035,7 +2035,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_NO_ENTRY + 1)) { /* Extract signal from widget number. */ @@ -2089,7 +2089,7 @@ public: } } - void OnClick(Point pt, int widget, int click_count) override + void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_BS_SEMAPHORE_NORM: @@ -2184,7 +2184,7 @@ public: this->InvalidateData(); } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_BS_STYLE: @@ -2352,7 +2352,7 @@ struct BuildRailDepotWindow : public PickerWindowBase { this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return; @@ -2360,7 +2360,7 @@ struct BuildRailDepotWindow : public PickerWindowBase { size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return; @@ -2374,7 +2374,7 @@ struct BuildRailDepotWindow : public PickerWindowBase { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_BRAD_DEPOT_NE: @@ -2507,7 +2507,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { this->PickerWindowBase::Close(data); } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_BRW_WAYPOINT_MATRIX: @@ -2526,7 +2526,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_BRW_NAME) { if (!this->list.empty() && IsInsideBS(_cur_waypoint_type, 0, this->waypoints->GetSpecCount())) { @@ -2548,11 +2548,11 @@ struct BuildRailWaypointWindow : PickerWindowBase { this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BRW_WAYPOINT: { - uint16_t type = this->list.at(GB(widget, 16, 16)); + uint16_t type = this->list.at(this->GetWidget(widget)->GetParentWidget()->GetCurrentElement()); const StationSpec *statspec = this->waypoints->GetSpec(type); DrawPixelInfo tmp_dpi; @@ -2571,11 +2571,11 @@ struct BuildRailWaypointWindow : PickerWindowBase { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BRW_WAYPOINT: { - uint16_t sel = GB(widget, 16, 16); + uint16_t sel = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); assert(sel < this->list.size()); uint16_t type = this->list.at(sel); @@ -2584,7 +2584,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { if (!IsStationAvailable(statspec)) return; _cur_waypoint_type = type; - this->GetWidget(WID_BRW_WAYPOINT_MATRIX)->SetClicked(sel); + this->GetWidget(widget)->GetParentWidget()->SetClicked(sel); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; @@ -2613,7 +2613,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { this->list.ForceRebuild(); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_BRW_FILTER) { this->string_filter.SetFilterTerm(this->editbox.text.buf); @@ -2863,7 +2863,7 @@ void ShowBuildRailStationPickerAndSelect(StationType station_type, const Station } if (w == nullptr) return; - auto trigger_widget = [&](int widget) { + auto trigger_widget = [&](WidgetID widget) { if (!w->IsWidgetLowered(widget)) { w->OnHotkey(widget); } diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 4e836d2951..f428743118 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -344,7 +344,7 @@ static bool RoadToolbar_CtrlChanged(Window *w) if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false; /* allow ctrl to switch remove mode only for these widgets */ - for (uint i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) { + for (WidgetID i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) { if (w->IsWidgetLowered(i)) { ToggleRoadButton_Remove(w); return true; @@ -460,7 +460,7 @@ struct BuildRoadToolbarWindow : Window { this->ReInit(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_ROT_CAPTION) { if (this->rti->max_speed > 0) { @@ -528,7 +528,7 @@ struct BuildRoadToolbarWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { _remove_button_clicked = false; _one_way_button_clicked = false; @@ -1135,13 +1135,15 @@ struct BuildRoadDepotWindow : public PickerWindowBase { this->LowerWidget(_build_depot_direction + WID_BROD_DEPOT_NE); if (RoadTypeIsTram(_cur_roadtype)) { this->GetWidget(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION; - for (int i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) this->GetWidget(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP; + for (WidgetID i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) { + this->GetWidget(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP; + } } this->FinishInitNested(TRANSPORT_ROAD); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return; @@ -1149,7 +1151,7 @@ struct BuildRoadDepotWindow : public PickerWindowBase { size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return; @@ -1163,7 +1165,7 @@ struct BuildRoadDepotWindow : public PickerWindowBase { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_BROD_DEPOT_NW: @@ -1325,7 +1327,7 @@ public: const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype); this->GetWidget(WID_BROS_CAPTION)->widget_data = rti->strings.picker_title[rs]; - for (uint i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) { + for (WidgetID i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) { this->GetWidget(i)->tool_tip = rti->strings.picker_tooltip[rs]; } @@ -1455,7 +1457,7 @@ public: return ES_HANDLED; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_BROS_FILTER_EDITBOX) { string_filter.SetFilterTerm(this->filter_editbox.text.buf); @@ -1503,7 +1505,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_BROS_NEWST_LIST: { @@ -1571,9 +1573,9 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BROS_STATION_NE: case WID_BROS_STATION_SE: case WID_BROS_STATION_SW: @@ -1616,7 +1618,7 @@ public: } case WID_BROS_IMAGE: { - uint16_t type = GB(widget, 16, 16); + uint16_t type = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); assert(type < _roadstop_gui_settings.roadstop_count); const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(type); @@ -1655,7 +1657,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_BROS_SHOW_NEWST_TYPE) { const RoadStopSpec *roadstopspec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type); @@ -1663,9 +1665,9 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BROS_STATION_NE: case WID_BROS_STATION_SE: case WID_BROS_STATION_SW: @@ -1706,7 +1708,7 @@ public: } case WID_BROS_IMAGE: { - uint16_t y = GB(widget, 16, 16); + uint16_t y = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); if (y >= _roadstop_gui_settings.roadstop_count) return; const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(y); @@ -1717,7 +1719,7 @@ public: /* Check station availability callback */ _roadstop_gui_settings.roadstop_type = y; - this->GetWidget(WID_BROS_MATRIX)->SetClicked(_roadstop_gui_settings.roadstop_type); + this->GetWidget(widget)->GetParentWidget()->SetClicked(_roadstop_gui_settings.roadstop_type); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); @@ -2022,7 +2024,7 @@ struct BuildRoadWaypointWindow : PickerWindowBase { this->PickerWindowBase::Close(); } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_BROW_WAYPOINT_MATRIX: @@ -2041,7 +2043,7 @@ struct BuildRoadWaypointWindow : PickerWindowBase { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_BROW_NAME) { if (!this->list.empty() && IsInsideBS(_cur_waypoint_type, 0, this->waypoints->GetSpecCount())) { @@ -2063,11 +2065,11 @@ struct BuildRoadWaypointWindow : PickerWindowBase { this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BROW_WAYPOINT: { - uint16_t type = this->list.at(GB(widget, 16, 16)); + uint16_t type = this->list.at(this->GetWidget(widget)->GetParentWidget()->GetCurrentElement()); const RoadStopSpec *spec = this->waypoints->GetSpec(type); DrawPixelInfo tmp_dpi; if (FillDrawPixelInfo(&tmp_dpi, r)) { @@ -2087,11 +2089,11 @@ struct BuildRoadWaypointWindow : PickerWindowBase { } } - void OnClick(Point pt, int widget, int click_count) override + void OnClick(Point pt, WidgetID widget, int click_count) override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BROW_WAYPOINT: { - uint16_t sel = GB(widget, 16, 16); + uint16_t sel = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); assert(sel < this->list.size()); uint16_t type = this->list.at(sel); @@ -2128,7 +2130,7 @@ struct BuildRoadWaypointWindow : PickerWindowBase { this->list.ForceRebuild(); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_BROW_FILTER) { this->string_filter.SetFilterTerm(this->editbox.text.buf); @@ -2406,7 +2408,7 @@ void ShowBuildRoadStopPickerAndSelect(StationType station_type, const RoadStopSp BuildRoadToolbarWindow *w = GetRoadToolbarWindowForRoadStop(spec, rtt_preferred); if (w == nullptr) return; - auto trigger_widget = [&](int widget) { + auto trigger_widget = [&](WidgetID widget) { if (!w->IsWidgetLowered(widget)) { w->OnHotkey(widget); } diff --git a/src/schdispatch_gui.cpp b/src/schdispatch_gui.cpp index 56ca81cbcb..988385228a 100644 --- a/src/schdispatch_gui.cpp +++ b/src/schdispatch_gui.cpp @@ -249,7 +249,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { return this->vehicle->orders->GetDispatchScheduleByIndex(this->schedule_index); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_SCHDISPATCH_MATRIX: { @@ -347,7 +347,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { this->DrawWidgets(); } - virtual void SetStringParameters(int widget) const override + virtual void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SCHDISPATCH_CAPTION: @@ -374,7 +374,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { } } - virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override + virtual bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { switch (widget) { case WID_SCHDISPATCH_ADD: { @@ -440,7 +440,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { } } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { const Vehicle *v = this->vehicle; @@ -658,7 +658,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { return 1; } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { const Vehicle *v = this->vehicle; @@ -809,7 +809,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_SCHDISPATCH_MANAGEMENT: { @@ -1092,7 +1092,7 @@ struct ScheduledDispatchAddSlotsWindow : Window { return pt; } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { Dimension d = {0, 0}; switch (widget) { @@ -1130,7 +1130,7 @@ struct ScheduledDispatchAddSlotsWindow : Window { *size = d; } - virtual void SetStringParameters(int widget) const override + virtual void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SCHDISPATCH_ADD_SLOT_START_HOUR: SetDParam(0, start.ClockHour()); break; @@ -1142,7 +1142,7 @@ struct ScheduledDispatchAddSlotsWindow : Window { } } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { auto handle_hours_dropdown = [&](ClockFaceMinutes current) { DropDownList list; @@ -1189,7 +1189,7 @@ struct ScheduledDispatchAddSlotsWindow : Window { } } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_SCHDISPATCH_ADD_SLOT_START_HOUR: diff --git a/src/screenshot_gui.cpp b/src/screenshot_gui.cpp index 5c8e1cfc4f..c350c943b5 100644 --- a/src/screenshot_gui.cpp +++ b/src/screenshot_gui.cpp @@ -26,7 +26,7 @@ struct ScreenshotWindow : Window { this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { ScreenshotType st; switch (widget) { diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index 21534121cf..9695ab0fd2 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -24,6 +24,9 @@ * API removals: * \li AIError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore. * + * Other changes: + * \li AIVehicleList accepts an optional filter function + * * \b 13.0 * * API additions: diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index d6267c7aab..07b172440d 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -84,6 +84,9 @@ * API removals: * \li GSError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore. * + * Other changes: + * \li GSVehicleList accepts an optional filter function + * * \b 13.0 * * API additions: diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp index bbb940b7d7..62dc95c847 100644 --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -925,7 +925,7 @@ public: * @param number The windownumber that was clicked. * @param widget The widget in the window that was clicked. */ - ScriptEventWindowWidgetClick(ScriptWindow::WindowClass window, uint32 number, uint8 widget) : + ScriptEventWindowWidgetClick(ScriptWindow::WindowClass window, uint32_t number, WidgetID widget) : ScriptEvent(ET_WINDOW_WIDGET_CLICK), window(window), number(number), @@ -956,12 +956,12 @@ public: * Get the number of the widget that was clicked. * @return The number of the clicked widget. */ - uint8 GetWidgetNumber() { return this->widget; } + int GetWidgetNumber() { return this->widget; } private: ScriptWindow::WindowClass window; ///< Window of the click. - uint32 number; ///< Number of the click. - uint8 widget; ///< Widget of the click. + uint32_t number; ///< Number of the click. + WidgetID widget; ///< Widget of the click. }; /** diff --git a/src/script/api/script_vehiclelist.cpp b/src/script/api/script_vehiclelist.cpp index a00ec91c85..6c09f3f88b 100644 --- a/src/script/api/script_vehiclelist.cpp +++ b/src/script/api/script_vehiclelist.cpp @@ -18,12 +18,78 @@ #include "../../safeguards.h" -ScriptVehicleList::ScriptVehicleList() +ScriptVehicleList::ScriptVehicleList(HSQUIRRELVM vm) { EnforceDeityOrCompanyModeValid_Void(); + + int nparam = sq_gettop(vm) - 1; + if (nparam >= 1) { + /* Make sure the filter function is really a function, and not any + * other type. It's parameter 2 for us, but for the user it's the + * first parameter they give. */ + SQObjectType valuator_type = sq_gettype(vm, 2); + if (valuator_type != OT_CLOSURE && valuator_type != OT_NATIVECLOSURE) { + throw sq_throwerror(vm, "parameter 1 has an invalid type (expected function)"); + } + + /* Push the function to call */ + sq_push(vm, 2); + } + + /* Don't allow docommand from a Valuator, as we can't resume in + * mid C++-code. */ + bool backup_allow = ScriptObject::GetAllowDoCommand(); + ScriptObject::SetAllowDoCommand(false); + for (const Vehicle *v : Vehicle::Iterate()) { - if ((v->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity()) && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::Train::From(v)->IsFreeWagon()))) this->AddItem(v->index); + if (v->owner != ScriptObject::GetCompany() && !ScriptCompanyMode::IsDeity()) continue; + if (!v->IsPrimaryVehicle() && !(v->type == VEH_TRAIN && ::Train::From(v)->IsFreeWagon())) continue; + + if (nparam < 1) { + /* No filter, just add the item. */ + this->AddItem(v->index); + continue; + } + + /* Push the root table as instance object, this is what squirrel does for meta-functions. */ + sq_pushroottable(vm); + /* Push all arguments for the valuator function. */ + sq_pushinteger(vm, v->index); + for (int i = 0; i < nparam - 1; i++) { + sq_push(vm, i + 3); + } + + /* Call the function. Squirrel pops all parameters and pushes the return value. */ + if (SQ_FAILED(sq_call(vm, nparam + 1, SQTrue, SQTrue))) { + ScriptObject::SetAllowDoCommand(backup_allow); + throw sq_throwerror(vm, "failed to run filter"); + } + + /* Retrieve the return value */ + switch (sq_gettype(vm, -1)) { + case OT_BOOL: { + SQBool add; + sq_getbool(vm, -1, &add); + if (add) this->AddItem(v->index); + break; + } + + default: { + ScriptObject::SetAllowDoCommand(backup_allow); + throw sq_throwerror(vm, "return value of filter is not valid (not bool)"); + } + } + + /* Pop the return value. */ + sq_poptop(vm); } + + if (nparam >= 1) { + /* Pop the filter function */ + sq_poptop(vm); + } + + ScriptObject::SetAllowDoCommand(backup_allow); } ScriptVehicleList_Station::ScriptVehicleList_Station(StationID station_id) diff --git a/src/script/api/script_vehiclelist.hpp b/src/script/api/script_vehiclelist.hpp index 22de3e344c..942e50b7ce 100644 --- a/src/script/api/script_vehiclelist.hpp +++ b/src/script/api/script_vehiclelist.hpp @@ -20,7 +20,32 @@ */ class ScriptVehicleList : public ScriptList { public: +#ifdef DOXYGEN_API ScriptVehicleList(); + + /** + * Apply a filter when building the list. + * @param filter_function The function which will be doing the filtering. + * @param params The params to give to the filters (minus the first param, + * which is always the index-value). + * @note You can write your own filters and use them. Just remember that + * the first parameter should be the index-value, and it should return + * a bool. + * @note Example: + * ScriptVehicleList(ScriptVehicle.IsInDepot); + * function IsType(vehicle_id, type) + * { + * return ScriptVehicle.GetVehicleType(vehicle_id) == type; + * } + * ScriptVehicleList(IsType, ScriptVehicle.VT_ROAD); + */ + ScriptVehicleList(void *filter_function, int params, ...); +#else + /** + * The constructor wrapper from Squirrel. + */ + ScriptVehicleList(HSQUIRRELVM vm); +#endif }; /** diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 686dec818a..14ebb44f64 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -97,14 +97,14 @@ struct ScriptListWindow : public Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_SCRL_CAPTION) return; SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_LIST_CAPTION_GAMESCRIPT : STR_AI_LIST_CAPTION_AI); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_SCRL_LIST) return; @@ -115,7 +115,7 @@ struct ScriptListWindow : public Window { size->height = 5 * this->line_height; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SCRL_LIST: { @@ -192,7 +192,7 @@ struct ScriptListWindow : public Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_SCRL_LIST: { // Select one of the Scripts @@ -351,14 +351,14 @@ struct ScriptSettingsWindow : public Window { this->vscroll->SetCount(this->visible_settings.size()); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_SCRS_CAPTION) return; SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_SETTINGS_CAPTION_GAMESCRIPT : STR_AI_SETTINGS_CAPTION_AI); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_SCRS_BACKGROUND) return; @@ -369,7 +369,7 @@ struct ScriptSettingsWindow : public Window { size->height = 5 * this->line_height; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_SCRS_BACKGROUND) return; @@ -437,7 +437,7 @@ struct ScriptSettingsWindow : public Window { this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_SCRS_BACKGROUND: { @@ -540,14 +540,14 @@ struct ScriptSettingsWindow : public Window { SetValue(value); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_SCRS_SETTING_DROPDOWN) return; assert(this->clicked_dropdown); SetValue(index); } - void OnDropdownClose(Point, int widget, int, bool) override + void OnDropdownClose(Point, WidgetID widget, int, bool) override { if (widget != WID_SCRS_SETTING_DROPDOWN) return; /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether @@ -652,7 +652,7 @@ struct ScriptTextfileWindow : public TextfileWindow { this->OnInvalidateData(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, (slot == OWNER_DEITY) ? STR_CONTENT_TYPE_GAME_SCRIPT : STR_CONTENT_TYPE_AI); @@ -803,19 +803,14 @@ struct ScriptDebugWindow : public Window { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SCRD_VSCROLLBAR); this->hscroll = this->GetScrollbar(WID_SCRD_HSCROLLBAR); - this->show_break_box = _settings_client.gui.ai_developer_tools; - this->GetWidget(WID_SCRD_BREAK_STRING_WIDGETS)->SetDisplayedPlane(this->show_break_box ? 0 : SZSP_HORIZONTAL); this->FinishInitNested(number); - if (!this->show_break_box) this->filter.break_check_enabled = false; - this->last_vscroll_pos = 0; this->autoscroll = true; this->highlight_row = -1; this->querystrings[WID_SCRD_BREAK_STR_EDIT_BOX] = &this->break_editbox; - SetWidgetsDisabledState(!this->show_break_box, WID_SCRD_BREAK_STR_ON_OFF_BTN, WID_SCRD_BREAK_STR_EDIT_BOX, WID_SCRD_MATCH_CASE_BTN); this->hscroll->SetStepSize(10); // Speed up horizontal scrollbar /* Restore the break string value from static variable, and enable the filter. */ @@ -831,6 +826,11 @@ struct ScriptDebugWindow : public Window { void OnInit() override { + this->show_break_box = _settings_client.gui.ai_developer_tools; + this->GetWidget(WID_SCRD_BREAK_STRING_WIDGETS)->SetDisplayedPlane(this->show_break_box ? 0 : SZSP_HORIZONTAL); + if (!this->show_break_box) this->filter.break_check_enabled = false; + SetWidgetsDisabledState(!this->show_break_box, WID_SCRD_BREAK_STR_ON_OFF_BTN, WID_SCRD_BREAK_STR_EDIT_BOX, WID_SCRD_MATCH_CASE_BTN); + this->InvalidateData(-1); } @@ -839,7 +839,7 @@ struct ScriptDebugWindow : public Window { ScriptDebugWindow::initial_state = this->filter; } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_SCRD_LOG_PANEL) { resize->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; @@ -856,7 +856,7 @@ struct ScriptDebugWindow : public Window { this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_SCRD_NAME_TEXT) return; @@ -877,7 +877,7 @@ struct ScriptDebugWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SCRD_LOG_PANEL: @@ -898,7 +898,7 @@ struct ScriptDebugWindow : public Window { * @param widget Widget index to start. * @param start Widget index of first company button. */ - void DrawWidgetCompanyButton(const Rect &r, int widget, int start) const + void DrawWidgetCompanyButton(const Rect &r, WidgetID widget, int start) const { if (this->IsWidgetDisabled(widget)) return; CompanyID cid = (CompanyID)(widget - start); @@ -1052,7 +1052,7 @@ struct ScriptDebugWindow : public Window { this->last_vscroll_pos = this->vscroll->GetPosition(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { /* Also called for hotkeys, so check for disabledness */ if (this->IsWidgetDisabled(widget)) return; @@ -1128,7 +1128,7 @@ struct ScriptDebugWindow : public Window { } } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid != WID_SCRD_BREAK_STR_EDIT_BOX) return; @@ -1145,6 +1145,8 @@ struct ScriptDebugWindow : public Window { */ void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override { + if (this->show_break_box != _settings_client.gui.ai_developer_tools) this->ReInit(); + /* If the log message is related to the active company tab, check the break string. * This needs to be done in gameloop-scope, so the AI is suspended immediately. */ if (!gui_scope && data == this->filter.script_debug_company && @@ -1218,9 +1220,9 @@ struct ScriptDebugWindow : public Window { }; /** Make a number of rows with buttons for each company for the Script debug window. */ -NWidgetBase *MakeCompanyButtonRowsScriptDebug(int *biggest_index) +std::unique_ptr MakeCompanyButtonRowsScriptDebug() { - return MakeCompanyButtonRows(biggest_index, WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END, COLOUR_GREY, 8, STR_AI_DEBUG_SELECT_AI_TOOLTIP); + return MakeCompanyButtonRows(WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END, COLOUR_GREY, 8, STR_AI_DEBUG_SELECT_AI_TOOLTIP); } /** diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 0a173fefd2..402706c284 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -105,7 +105,7 @@ struct BaseSetTextfileWindow : public TextfileWindow { this->LoadTextfile(textfile, BASESET_DIR); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, content_type); @@ -179,7 +179,7 @@ struct GameOptionsWindow : Window { GameSettings *opt; bool reload; int gui_scale; - static inline int active_tab = WID_GO_TAB_GENERAL; + static inline WidgetID active_tab = WID_GO_TAB_GENERAL; enum class QueryTextItem { None, @@ -217,7 +217,7 @@ struct GameOptionsWindow : Window { * @param selected_index Currently selected item * @return the built dropdown list, or nullptr if the widget has no dropdown menu. */ - DropDownList BuildDropDownList(int widget, int *selected_index) const + DropDownList BuildDropDownList(WidgetID widget, int *selected_index) const { DropDownList list; switch (widget) { @@ -322,7 +322,7 @@ struct GameOptionsWindow : Window { return list; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_GO_CURRENCY_DROPDOWN: { @@ -369,7 +369,7 @@ struct GameOptionsWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_GO_BASE_GRF_DESCRIPTION: @@ -406,7 +406,7 @@ struct GameOptionsWindow : Window { } } - void SetTab(int widget) + void SetTab(WidgetID widget) { this->SetWidgetsLoweredState(false, WID_GO_TAB_GENERAL, WID_GO_TAB_GRAPHICS, WID_GO_TAB_SOUND); this->LowerWidget(widget); @@ -455,7 +455,7 @@ struct GameOptionsWindow : Window { if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_GO_TEXT_SFX_VOLUME: @@ -475,7 +475,7 @@ struct GameOptionsWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_CONTENT_END) { if (BaseGraphics::GetUsedSet() == nullptr) return; @@ -676,7 +676,7 @@ struct GameOptionsWindow : Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_GO_CURRENCY_DROPDOWN: // Currency @@ -2602,7 +2602,7 @@ struct GameSettingsWindow : Window { _circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED)); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_GS_OPTIONSPANEL: @@ -2670,7 +2670,7 @@ struct GameSettingsWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_GS_RESTRICT_DROPDOWN: @@ -2688,7 +2688,7 @@ struct GameSettingsWindow : Window { } } - DropDownList BuildDropDownList(int widget) const + DropDownList BuildDropDownList(WidgetID widget) const { DropDownList list; switch (widget) { @@ -2712,7 +2712,7 @@ struct GameSettingsWindow : Window { return list; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_GS_OPTIONSPANEL: { @@ -2783,7 +2783,7 @@ struct GameSettingsWindow : Window { this->last_clicked = pe; } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_GS_EXPAND_ALL: @@ -3034,7 +3034,7 @@ struct GameSettingsWindow : Window { this->SetDirty(); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_GS_RESTRICT_DROPDOWN: @@ -3071,7 +3071,7 @@ struct GameSettingsWindow : Window { } } - void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override + void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override { if (widget != WID_GS_SETTING_DROPDOWN) { /* Normally the default implementation of OnDropdownClose() takes care of @@ -3120,7 +3120,7 @@ struct GameSettingsWindow : Window { this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_GS_FILTER) { this->filter.string.SetFilterTerm(this->filter_editbox.text.buf); @@ -3283,7 +3283,7 @@ struct CustomCurrencyWindow : Window { this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == MAX_YEAR); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break; @@ -3301,7 +3301,7 @@ struct CustomCurrencyWindow : Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { /* Set the appropriate width for the up/down buttons. */ @@ -3328,7 +3328,7 @@ struct CustomCurrencyWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { int line = 0; int len = 0; diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index d8bfe3a53f..861427b43b 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -189,7 +189,7 @@ struct SignListWindow : Window, SignList { this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SIL_LIST: { @@ -223,12 +223,12 @@ struct SignListWindow : Window, SignList { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_SIL_CAPTION) SetDParam(0, this->vscroll->GetCount()); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_SIL_LIST: { @@ -260,7 +260,7 @@ struct SignListWindow : Window, SignList { this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.Vertical()); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_SIL_LIST: { @@ -296,7 +296,7 @@ struct SignListWindow : Window, SignList { return ES_HANDLED; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_SIL_FILTER_TEXT) this->SetFilterString(this->filter_editbox.text.buf); } @@ -475,7 +475,7 @@ struct SignWindow : Window, SignList { return next ? this->signs.front() : this->signs.back(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_QES_CAPTION: @@ -484,7 +484,7 @@ struct SignWindow : Window, SignList { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_QES_LOCATION: { diff --git a/src/sl/oldloader_sl.cpp b/src/sl/oldloader_sl.cpp index 3fda18ee47..664570d59b 100644 --- a/src/sl/oldloader_sl.cpp +++ b/src/sl/oldloader_sl.cpp @@ -396,6 +396,7 @@ static bool FixTTOEngines() } Date aging_date = std::min(_date + DAYS_TILL_ORIGINAL_BASE_YEAR.AsDelta(), ConvertYMDToDate(2050, 0, 1)); + YearMonthDay aging_ymd = ConvertDateToYMD(aging_date); for (EngineID i = 0; i < 256; i++) { int oi = ttd_to_tto[i]; @@ -404,7 +405,7 @@ static bool FixTTOEngines() if (oi == 255) { /* Default engine is used */ _date += DAYS_TILL_ORIGINAL_BASE_YEAR.AsDelta(); - StartupOneEngine(e, aging_date, 0, INT_MAX); + StartupOneEngine(e, aging_date, aging_ymd, 0, INT_MAX); CalcEngineReliability(e, false); e->intro_date -= DAYS_TILL_ORIGINAL_BASE_YEAR.AsDelta(); _date -= DAYS_TILL_ORIGINAL_BASE_YEAR.AsDelta(); diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 967c2f84e9..a87ff78411 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1114,7 +1114,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary() BuildLandLegend(); } -/* virtual */ void SmallMapWindow::SetStringParameters(int widget) const +/* virtual */ void SmallMapWindow::SetStringParameters(WidgetID widget) const { switch (widget) { case WID_SM_CAPTION: @@ -1192,7 +1192,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary() this->DrawWidgets(); } -/* virtual */ void SmallMapWindow::DrawWidget(const Rect &r, int widget) const +/* virtual */ void SmallMapWindow::DrawWidget(const Rect &r, WidgetID widget) const { switch (widget) { case WID_SM_MAP: { @@ -1392,7 +1392,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt) return (column * number_of_rows) + line; } -/* virtual */ void SmallMapWindow::OnMouseOver([[maybe_unused]] Point pt, int widget) +/* virtual */ void SmallMapWindow::OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) { IndustryType new_highlight = INVALID_INDUSTRYTYPE; if (widget == WID_SM_LEGEND && this->map_type == SMT_INDUSTRY) { @@ -1409,7 +1409,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt) } } -/* virtual */ void SmallMapWindow::OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) +/* virtual */ void SmallMapWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) { switch (widget) { case WID_SM_MAP: { // Map window @@ -1555,7 +1555,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt) this->SetDirty(); } -/* virtual */ bool SmallMapWindow::OnRightClick([[maybe_unused]] Point pt, int widget) +/* virtual */ bool SmallMapWindow::OnRightClick([[maybe_unused]] Point pt, WidgetID widget) { if (widget != WID_SM_MAP || _scrolling_viewport) return false; @@ -1747,8 +1747,9 @@ public: void SetupSmallestSize(Window *w) override { - NWidgetBase *display = this->head; - NWidgetBase *bar = display->next; + assert(this->children.size() == 2); + NWidgetBase *display = this->children.front().get(); + NWidgetBase *bar = this->children.back().get(); display->SetupSmallestSize(w); bar->SetupSmallestSize(w); @@ -1770,8 +1771,9 @@ public: this->current_x = given_width; this->current_y = given_height; - NWidgetBase *display = this->head; - NWidgetBase *bar = display->next; + assert(this->children.size() == 2); + NWidgetBase *display = this->children.front().get(); + NWidgetBase *bar = this->children.back().get(); if (sizing == ST_SMALLEST) { this->smallest_x = given_width; @@ -1837,12 +1839,12 @@ static const NWidgetPart _nested_smallmap_bar[] = { EndContainer(), }; -static NWidgetBase *SmallMapDisplay(int *biggest_index) +static std::unique_ptr SmallMapDisplay() { - NWidgetContainer *map_display = new NWidgetSmallmapDisplay; + std::unique_ptr map_display = std::make_unique(); - MakeNWidgets(std::begin(_nested_smallmap_display), std::end(_nested_smallmap_display), biggest_index, map_display); - MakeNWidgets(std::begin(_nested_smallmap_bar), std::end(_nested_smallmap_bar), biggest_index, map_display); + map_display = MakeNWidgets(std::begin(_nested_smallmap_display), std::end(_nested_smallmap_display), std::move(map_display)); + map_display = MakeNWidgets(std::begin(_nested_smallmap_bar), std::end(_nested_smallmap_bar), std::move(map_display)); return map_display; } diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index ff9e56cd3d..f43906ccbc 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -207,17 +207,17 @@ public: Point GetStationMiddle(const Station *st) const; void Close([[maybe_unused]] int data = 0) override; - void SetStringParameters(int widget) const override; + void SetStringParameters(WidgetID widget) const override; void OnInit() override; void OnPaint() override; - void DrawWidget(const Rect &r, int widget) const override; - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override; + void DrawWidget(const Rect &r, WidgetID widget) const override; + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override; void OnInvalidateData(int data = 0, bool gui_scope = true) override; - bool OnRightClick(Point pt, int widget) override; + bool OnRightClick(Point pt, WidgetID widget) override; void OnMouseWheel(int wheel) override; void OnRealtimeTick(uint delta_ms) override; void OnScroll(Point delta) override; - void OnMouseOver(Point pt, int widget) override; + void OnMouseOver(Point pt, WidgetID widget) override; void TakeScreenshot(); void ScreenshotCallbackHandler(void *buf, uint y, uint pitch, uint n); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 1aa9be8527..0fcbfac687 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -500,7 +500,7 @@ public: this->Window::Close(data); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_STL_SORTBY: { @@ -554,7 +554,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_STL_SORTBY: @@ -626,7 +626,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_STL_CAPTION) { SetDParam(0, this->window_number); @@ -634,7 +634,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_STL_LIST: { @@ -673,7 +673,7 @@ public: break; case WID_STL_FACILALL: - for (uint i = WID_STL_TRAIN; i <= WID_STL_SHIP; i++) { + for (WidgetID i = WID_STL_TRAIN; i <= WID_STL_SHIP; i++) { this->LowerWidget(i); } @@ -749,7 +749,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget == WID_STL_SORTDROPBTN) { if (this->stations.SortType() != index) { @@ -819,23 +819,21 @@ const StringID CompanyStationsWindow::sorter_names[] = { /** * Make a horizontal row of cargo buttons, starting at widget #WID_STL_CARGOSTART. - * @param biggest_index Pointer to store biggest used widget number of the buttons. * @return Horizontal row. */ -static NWidgetBase *CargoWidgets(int *biggest_index) +static std::unique_ptr CargoWidgets() { - NWidgetHorizontal *container = new NWidgetHorizontal(); + auto container = std::make_unique(); for (uint i = 0; i < _sorted_standard_cargo_specs.size(); i++) { - NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_STL_CARGOSTART + i); + auto panel = std::make_unique(WWT_PANEL, COLOUR_GREY, WID_STL_CARGOSTART + i); panel->SetMinimalSize(14, 0); panel->SetMinimalTextLines(1, 0, FS_NORMAL); panel->SetResize(0, 0); panel->SetFill(0, 1); panel->SetDataTip(0, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE); - container->Add(panel); + container->Add(std::move(panel)); } - *biggest_index = WID_STL_CARGOSTART + static_cast(_sorted_standard_cargo_specs.size()); return container; } @@ -1509,7 +1507,7 @@ struct StationViewWindow : public Window { data->Update(count); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_SV_WAITING: @@ -1546,7 +1544,7 @@ struct StationViewWindow : public Window { } } - bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { if (widget == WID_SV_RENAME) { SetDParam(0, STR_STATION_VIEW_RENAME_TOOLTIP); @@ -1643,7 +1641,7 @@ struct StationViewWindow : public Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_SV_CAPTION) { const Station *st = Station::Get(this->window_number); @@ -2101,7 +2099,7 @@ struct StationViewWindow : public Window { this->SetWidgetDirty(WID_SV_WAITING); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_SV_WAITING: @@ -2326,7 +2324,7 @@ struct StationViewWindow : public Window { this->SetDirty(); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget == WID_SV_SORT_BY) { this->SelectSortBy(index); @@ -2563,7 +2561,7 @@ struct SelectStationWindow : Window { this->Window::Close(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_JS_PANEL) return; @@ -2583,7 +2581,7 @@ struct SelectStationWindow : Window { *size = d; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_JS_PANEL) return; @@ -2604,7 +2602,7 @@ struct SelectStationWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget != WID_JS_PANEL) return; @@ -2651,7 +2649,7 @@ struct SelectStationWindow : Window { this->SetDirty(); } - void OnMouseOver([[maybe_unused]] Point pt, int widget) override + void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override { if (widget != WID_JS_PANEL) { SetViewportCatchmentSpecializedStation(nullptr, true); @@ -3050,7 +3048,7 @@ public: this->data[line_nr][0] = '\0'; } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget != 0) return; @@ -3070,7 +3068,7 @@ public: size->height -= WidgetDimensions::scaled.vsep_normal; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { GfxDrawLine(r.left, r.top, r.right, r.top, PC_BLACK); GfxDrawLine(r.left, r.bottom, r.right, r.bottom, PC_BLACK); diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 83d30c1ade..f9f24c88fe 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -88,7 +88,7 @@ struct StatusBarWindow : Window { Window::FindWindowPlacementAndResize(_toolbar_width, def_height); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { Dimension d; switch (widget) { @@ -114,7 +114,7 @@ struct StatusBarWindow : Window { *size = maxdim(d, *size); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { Rect tr = r.Shrink(WidgetDimensions::scaled.framerect, RectPadding::zero); tr.top = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)); @@ -198,7 +198,7 @@ struct StatusBarWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_S_MIDDLE: ShowLastNewsMessage(); break; diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 6547b6cdda..81185ef7f7 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -646,7 +646,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SB_SEL_PAGE: { @@ -680,7 +680,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_SB_PAGE_PANEL) return; @@ -754,7 +754,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return; @@ -804,7 +804,7 @@ public: this->vscroll->SetCount(this->GetContentHeight()); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_SB_SEL_PAGE: { @@ -845,7 +845,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_SB_SEL_PAGE) return; diff --git a/src/string.cpp b/src/string.cpp index f1b732a6ab..0ce47d1585 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -340,6 +340,8 @@ void StrMakeValidInPlace(char *str, StringValidationSettings settings) */ std::string StrMakeValid(std::string_view str, StringValidationSettings settings) { + if (str.empty()) return {}; + auto buf = str.data(); auto last = buf + str.size() - 1; diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index dc8ab5cf9d..4336ab3b62 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -36,7 +36,7 @@ struct SubsidyListWindow : Window { this->OnInvalidateData(0); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget != WID_SUL_PANEL) return; @@ -125,7 +125,7 @@ struct SubsidyListWindow : Window { return 3 + num_awarded + num_not_awarded; } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_SUL_PANEL) return; Dimension d = maxdim(GetStringBoundingBox(STR_SUBSIDIES_OFFERED_TITLE), GetStringBoundingBox(STR_SUBSIDIES_SUBSIDISED_TITLE)); @@ -138,7 +138,7 @@ struct SubsidyListWindow : Window { *size = maxdim(*size, d); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_SUL_PANEL) return; diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index e3363f201e..ee8051a08e 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -1647,7 +1647,7 @@ cat = SC_EXPERT var = gui.ai_developer_tools flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC def = false -post_cb = [](auto) { InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); } +post_cb = [](auto) { InvalidateWindowClassesData(WC_GAME_OPTIONS); InvalidateWindowClassesData(WC_SCRIPT_DEBUG); InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); } cat = SC_EXPERT startup = true diff --git a/src/tbtr_template_gui_create.cpp b/src/tbtr_template_gui_create.cpp index 75772e6c91..ba5ead9cf8 100644 --- a/src/tbtr_template_gui_create.cpp +++ b/src/tbtr_template_gui_create.cpp @@ -217,7 +217,7 @@ public: UpdateButtonState(); } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { switch(widget) { case TCW_NEW_TMPL_PANEL: { @@ -286,7 +286,7 @@ public: this->SetDirty(); } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { switch(widget) { case TCW_NEW_TMPL_PANEL: { @@ -391,7 +391,7 @@ public: } } - virtual bool OnRightClick(Point pt, int widget) override + virtual bool OnRightClick(Point pt, WidgetID widget) override { if (widget != TCW_NEW_TMPL_PANEL) return false; @@ -443,7 +443,7 @@ public: return true; } - virtual void OnDragDrop(Point pt, int widget) override + virtual void OnDragDrop(Point pt, WidgetID widget) override { switch (widget) { case TCW_NEW_TMPL_PANEL: { @@ -504,7 +504,7 @@ public: this->SetDirty(); } - virtual void OnMouseDrag(Point pt, int widget) override + virtual void OnMouseDrag(Point pt, WidgetID widget) override { if (this->sel == INVALID_VEHICLE) return; diff --git a/src/tbtr_template_gui_main.cpp b/src/tbtr_template_gui_main.cpp index 07063af19a..5590c6469b 100644 --- a/src/tbtr_template_gui_main.cpp +++ b/src/tbtr_template_gui_main.cpp @@ -260,7 +260,7 @@ public: this->Window::Close(); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case TRW_WIDGET_TOP_MATRIX: @@ -312,7 +312,7 @@ public: } } - virtual void SetStringParameters(int widget) const override + virtual void SetStringParameters(WidgetID widget) const override { switch (widget) { case TRW_CAPTION: @@ -321,7 +321,7 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case TRW_WIDGET_TOP_MATRIX: { @@ -404,7 +404,7 @@ public: this->DrawWidgets(); } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { if (this->editInProgress) return; @@ -495,7 +495,7 @@ public: ShowDropDownList(this, GetRailTypeDropDownList(true, true), this->sel_railtype, TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN); break; case TRW_WIDGET_TOP_MATRIX: { - uint16 newindex = (uint16)((pt.y - this->nested_array[TRW_WIDGET_TOP_MATRIX]->pos_y) / (GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical()) ) + this->vscroll[0]->GetPosition(); + uint16 newindex = (uint16)((pt.y - this->GetWidget(TRW_WIDGET_TOP_MATRIX)->pos_y) / (GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical()) ) + this->vscroll[0]->GetPosition(); if (newindex == this->selected_group_index || newindex >= this->groups.size()) { this->selected_group_index = -1; } else if (newindex < this->groups.size()) { @@ -505,7 +505,7 @@ public: break; } case TRW_WIDGET_BOTTOM_MATRIX: { - uint16 newindex = (uint16)((pt.y - this->nested_array[TRW_WIDGET_BOTTOM_MATRIX]->pos_y) / this->bottom_matrix_item_size) + this->vscroll[1]->GetPosition(); + uint16 newindex = (uint16)((pt.y - this->GetWidget(TRW_WIDGET_BOTTOM_MATRIX)->pos_y) / this->bottom_matrix_item_size) + this->vscroll[1]->GetPosition(); if (newindex == this->selected_template_index || newindex >= templates.size()) { this->selected_template_index = -1; } else if (newindex < templates.size()) { @@ -560,7 +560,7 @@ public: this->RaiseButtons(); } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { RailType temp = (RailType) index; if (temp == this->sel_railtype) return; // we didn't select a new one. No need to change anything diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 5b4be27da3..87d4065f10 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -221,7 +221,7 @@ struct TerraformToolbarWindow : Window { SetWidgetDisabledState(WID_TT_BUY_LAND, _settings_game.construction.purchase_land_permitted == 0); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget < WID_TT_BUTTONS_START) return; @@ -628,7 +628,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_ETT_DOTS) return; @@ -636,7 +636,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { size->height = std::max(size->height, ScaleGUITrad(31)); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_ETT_DOTS) return; @@ -653,7 +653,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { } while (--n); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget < WID_ETT_BUTTONS_START) return; @@ -731,9 +731,9 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { void OnTimeout() override { - for (uint i = WID_ETT_START; i < this->nested_array_size; i++) { - if (i == WID_ETT_BUTTONS_START) i = WID_ETT_BUTTONS_END; // skip the buttons - this->RaiseWidgetWhenLowered(i); + for (const auto &pair : this->widget_lookup) { + if (pair.first < WID_ETT_START || (pair.first >= WID_ETT_BUTTONS_START && pair.first < WID_ETT_BUTTONS_END)) continue; // skip the buttons + this->RaiseWidgetWhenLowered(pair.first); } } diff --git a/src/tests/test_window_desc.cpp b/src/tests/test_window_desc.cpp index 1d65b957fd..3e02822e34 100644 --- a/src/tests/test_window_desc.cpp +++ b/src/tests/test_window_desc.cpp @@ -92,11 +92,9 @@ TEST_CASE_METHOD(WindowDescTestsFixture, "WindowDesc - NWidgetPart validity") INFO(fmt::format("{}:{}", window_desc->file, window_desc->line)); - int biggest_index = -1; NWidgetStacked *shade_select = nullptr; - NWidgetBase *root = nullptr; + std::unique_ptr root = nullptr; - REQUIRE_NOTHROW(root = MakeWindowNWidgetTree(window_desc->nwid_begin, window_desc->nwid_end, &biggest_index, &shade_select)); + REQUIRE_NOTHROW(root = MakeWindowNWidgetTree(window_desc->nwid_begin, window_desc->nwid_end, &shade_select)); CHECK((root != nullptr)); - delete root; } diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index d5920b1858..6dc8b5a41e 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -88,9 +88,9 @@ TextfileWindow::TextfileWindow(TextfileType file_type) : Window(&_textfile_desc) this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_TF_VSCROLLBAR); this->hscroll = this->GetScrollbar(WID_TF_HSCROLLBAR); - this->FinishInitNested(file_type); this->GetWidget(WID_TF_CAPTION)->SetDataTip(STR_TEXTFILE_README_CAPTION + file_type, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS); this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(SZSP_HORIZONTAL); + this->FinishInitNested(file_type); this->DisableWidget(WID_TF_NAVBACK); this->DisableWidget(WID_TF_NAVFORWARD); @@ -128,7 +128,7 @@ uint TextfileWindow::GetContentHeight() return this->lines.back().bottom; } -/* virtual */ void TextfileWindow::UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) +/* virtual */ void TextfileWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) { switch (widget) { case WID_TF_BACKGROUND: @@ -495,7 +495,7 @@ void TextfileWindow::NavigateToFile(std::string newfile, size_t line) if (StrEndsWithIgnoreCase(this->filename, ".md")) this->AfterLoadMarkdown(); - this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0); + if (this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0)) this->ReInit(); } /** @@ -518,7 +518,7 @@ void TextfileWindow::AfterLoadMarkdown() } } -/* virtual */ void TextfileWindow::OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) +/* virtual */ void TextfileWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) { switch (widget) { case WID_TF_WRAPTEXT: @@ -550,7 +550,7 @@ void TextfileWindow::AfterLoadMarkdown() } } -/* virtual */ void TextfileWindow::DrawWidget(const Rect &r, int widget) const +/* virtual */ void TextfileWindow::DrawWidget(const Rect &r, WidgetID widget) const { if (widget != WID_TF_BACKGROUND) return; @@ -594,7 +594,7 @@ void TextfileWindow::AfterLoadMarkdown() this->SetupScrollbars(true); } -void TextfileWindow::OnDropdownSelect(int widget, int index) +void TextfileWindow::OnDropdownSelect(WidgetID widget, int index) { if (widget != WID_TF_JUMPLIST) return; @@ -763,8 +763,7 @@ static void Xunzip(byte **bufp, size_t *sizep) this->lines.clear(); this->jumplist.clear(); - this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(SZSP_HORIZONTAL); - this->ReInit(); + if (this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(SZSP_HORIZONTAL)) this->ReInit(); if (textfile == nullptr) return; diff --git a/src/textfile_gui.h b/src/textfile_gui.h index 6f85e9d650..181c3eb99a 100644 --- a/src/textfile_gui.h +++ b/src/textfile_gui.h @@ -32,12 +32,12 @@ struct TextfileWindow : public Window, MissingGlyphSearcher { TextfileWindow(TextfileType file_type); - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override; - void DrawWidget(const Rect &r, int widget) const override; + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override; + void DrawWidget(const Rect &r, WidgetID widget) const override; void OnResize() override; void OnInvalidateData(int data = 0, bool gui_scope = true) override; - void OnDropdownSelect(int widget, int index) override; + void OnDropdownSelect(WidgetID widget, int index) override; void Reset() override; FontSize DefaultSize() override; diff --git a/src/tilehighlight_func.h b/src/tilehighlight_func.h index bc9ce37c6f..e42167e568 100644 --- a/src/tilehighlight_func.h +++ b/src/tilehighlight_func.h @@ -17,7 +17,7 @@ void PlaceProc_DemolishArea(TileIndex tile); bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile); -bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode); +bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode); void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w); void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num); void ResetObjectToPlace(); diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 5fa3ba9b6f..96b8061a26 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -400,7 +400,7 @@ struct TimetableWindow : GeneralVehicleWindow { return (travelling && v->lateness_counter < 0); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_VT_ARRIVAL_DEPARTURE_PANEL: @@ -609,7 +609,7 @@ struct TimetableWindow : GeneralVehicleWindow { this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_VT_CAPTION: SetDParam(0, this->vehicle->index); break; @@ -617,7 +617,7 @@ struct TimetableWindow : GeneralVehicleWindow { } } - bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { switch (widget) { case WID_VT_CHANGE_TIME: { @@ -649,7 +649,7 @@ struct TimetableWindow : GeneralVehicleWindow { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { const Vehicle *v = this->vehicle; int selected = this->sel_index; @@ -871,7 +871,7 @@ struct TimetableWindow : GeneralVehicleWindow { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { const Vehicle *v = this->vehicle; @@ -1071,7 +1071,7 @@ struct TimetableWindow : GeneralVehicleWindow { this->SetDirty(); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_VT_EXTRA: diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 134e24f76d..431bf7e38e 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -120,7 +120,7 @@ DropDownListItem *MakeCompanyDropDownListItem(CompanyID cid) * @param list List of items * @param def Default item */ -static void PopupMainToolbarMenu(Window *w, int widget, DropDownList &&list, int def) +static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def) { ShowDropDownList(w, std::move(list), def, widget, 0, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); @@ -132,7 +132,7 @@ static void PopupMainToolbarMenu(Window *w, int widget, DropDownList &&list, int * @param widget Toolbar button * @param strings List of strings for each item in the menu */ -static void PopupMainToolbarMenu(Window *w, int widget, const std::initializer_list &strings) +static void PopupMainToolbarMenu(Window *w, WidgetID widget, const std::initializer_list &strings) { DropDownList list; int i = 0; @@ -158,7 +158,7 @@ static const int CTMN_SPECTATOR = -3; ///< Show a company window as spectator * @param widget The button widget id. * @param grey A bitbask of which items to mark as disabled. */ -static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0) +static void PopupMainCompanyToolbMenu(Window *w, WidgetID widget, int grey = 0) { DropDownList list; @@ -845,7 +845,7 @@ static CallBackFunction MenuClickShowAir(int index) static CallBackFunction ToolbarZoomInClick(Window *w) { if (DoZoomInOutWindow(ZOOM_IN, GetMainWindow())) { - w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_IN : (byte)WID_TN_ZOOM_IN); + w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_IN : (WidgetID)WID_TN_ZOOM_IN); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } return CBF_NONE; @@ -856,7 +856,7 @@ static CallBackFunction ToolbarZoomInClick(Window *w) static CallBackFunction ToolbarZoomOutClick(Window *w) { if (DoZoomInOutWindow(ZOOM_OUT, GetMainWindow())) { - w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_OUT : (byte)WID_TN_ZOOM_OUT); + w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_OUT : (WidgetID)WID_TN_ZOOM_OUT); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } return CBF_NONE; @@ -1005,7 +1005,7 @@ static CallBackFunction MenuClickForest(int index) static CallBackFunction ToolbarMusicClick(Window *w) { - PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_MUSIC_SOUND : (int)WID_TN_MUSIC_SOUND, {STR_TOOLBAR_SOUND_MUSIC}); + PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (WidgetID)WID_TE_MUSIC_SOUND : (WidgetID)WID_TN_MUSIC_SOUND, {STR_TOOLBAR_SOUND_MUSIC}); return CBF_NONE; } @@ -1167,7 +1167,7 @@ static CallBackFunction PlacePickerTool() static CallBackFunction ToolbarHelpClick(Window *w) { - int widget = (_game_mode == GM_EDITOR) ? (int)WID_TE_HELP : (int)WID_TN_HELP; + WidgetID widget = (_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_HELP : (WidgetID)WID_TN_HELP; DropDownList list; list.emplace_back(new DropDownListStringItem(STR_ABOUT_MENU_LAND_BLOCK_INFO, HME_LANDINFO, false)); @@ -1291,7 +1291,7 @@ static CallBackFunction ToolbarSwitchClick(Window *w) } w->ReInit(); - w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (uint)WID_TE_SWITCH_BAR : (uint)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER); + w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (WidgetID)WID_TE_SWITCH_BAR : (WidgetID)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1495,7 +1495,7 @@ public: uint nbuttons = 0; /* First initialise some variables... */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->SetupSmallestSize(w); this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.Vertical()); if (this->IsButton(child_wid->type)) { @@ -1507,7 +1507,7 @@ public: } /* ... then in a second pass make sure the 'current' heights are set. Won't change ever. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->current_y = this->smallest_y; if (!this->IsButton(child_wid->type)) { child_wid->current_x = child_wid->smallest_x; @@ -1527,14 +1527,15 @@ public: /* Figure out what are the visible buttons */ uint arrangable_count, button_count, spacer_count; - const byte *arrangement = GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count); - - /* Create us ourselves a quick lookup table */ - NWidgetBase *widgets[WID_TN_END]; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { - child_wid->current_x = 0; /* Hide widget, it will be revealed in the next step. */ - if (child_wid->type == NWID_SPACER) continue; - widgets[((NWidgetCore*)child_wid)->index] = child_wid; + const WidgetID *arrangement = GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count); + + /* Create us ourselves a quick lookup table from WidgetID to slot. */ + std::map lookup; + for (auto it = std::begin(this->children); it != std::end(this->children); ++it) { + NWidgetBase *nwid = it->get(); + nwid->current_x = 0; /* Hide widget, it will be revealed in the next step. */ + if (nwid->type == NWID_SPACER) continue; + lookup[dynamic_cast(nwid)->index] = std::distance(this->children.begin(), it); } /* Now assign the widgets to their rightful place */ @@ -1545,12 +1546,13 @@ public: uint button_i = 0; /* Index into the arrangement indices. The macro lastof cannot be used here! */ - const byte *cur_wid = rtl ? &arrangement[arrangable_count - 1] : arrangement; + const WidgetID *slotp = rtl ? &arrangement[arrangable_count - 1] : arrangement; for (uint i = 0; i < arrangable_count; i++) { - NWidgetBase *child_wid = widgets[*cur_wid]; - /* If we have to give space to the spacers, do that */ - if (spacer_space != 0) { - NWidgetBase *possible_spacer = rtl ? child_wid->next : child_wid->prev; + uint slot = lookup[*slotp]; + auto &child_wid = this->children[slot]; + /* If we have space to give to the spacers, do that. */ + if (spacer_space > 0 && slot > 0 && slot < this->children.size() - 1) { + const auto &possible_spacer = this->children[slot + (rtl ? 1 : -1)]; if (possible_spacer != nullptr && possible_spacer->type == NWID_SPACER) { uint add = spacer_space / (spacer_count - spacer_i); position += add; @@ -1571,9 +1573,9 @@ public: position += child_wid->current_x; if (rtl) { - cur_wid--; + slotp--; } else { - cur_wid++; + slotp++; } } } @@ -1596,12 +1598,12 @@ public: * @param spacer_count output of the number of spacers. * @return the button configuration. */ - virtual const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const = 0; + virtual const WidgetID *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const = 0; }; /** Container for the 'normal' main toolbar */ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { - const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override + const WidgetID *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override { static const uint SMALLEST_ARRANGEMENT = 14; static const uint BIGGEST_ARRANGEMENT = 20; @@ -1612,7 +1614,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { * pause button appearing on the right of the lower toolbar and weird resizing of the widgets even if there is * enough space. */ - static const byte arrange14[] = { + static const WidgetID arrange14[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_TRAINS, @@ -1643,7 +1645,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { WID_TN_HELP, WID_TN_SWITCH_BAR, }; - static const byte arrange15[] = { + static const WidgetID arrange15[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SMALL_MAP, @@ -1676,7 +1678,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { WID_TN_HELP, WID_TN_SWITCH_BAR, }; - static const byte arrange16[] = { + static const WidgetID arrange16[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1711,7 +1713,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; - static const byte arrange17[] = { + static const WidgetID arrange17[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1748,7 +1750,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; - static const byte arrange18[] = { + static const WidgetID arrange18[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1787,7 +1789,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; - static const byte arrange19[] = { + static const WidgetID arrange19[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1828,7 +1830,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; - static const byte arrange20[] = { + static const WidgetID arrange20[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1871,7 +1873,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; - static const byte arrange_all[] = { + static const WidgetID arrange_all[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1913,7 +1915,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { } /* Introduce the split toolbar */ - static const byte * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 }; + static const WidgetID * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 }; button_count = arrangable_count = full_buttons; spacer_count = this->spacers; @@ -1931,7 +1933,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer { /* Find the size of panel_widths */ uint i = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { if (child_wid->type == NWID_SPACER || this->IsButton(child_wid->type)) continue; assert(i < lengthof(this->panel_widths)); @@ -1940,9 +1942,9 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer { } } - const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override + const WidgetID *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override { - static const byte arrange_all[] = { + static const WidgetID arrange_all[] = { WID_TE_PAUSE, WID_TE_FAST_FORWARD, WID_TE_SETTINGS, @@ -1963,7 +1965,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer { WID_TE_MUSIC_SOUND, WID_TE_HELP, }; - static const byte arrange_nopanel[] = { + static const WidgetID arrange_nopanel[] = { WID_TE_PAUSE, WID_TE_FAST_FORWARD, WID_TE_SETTINGS, @@ -1983,7 +1985,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer { WID_TE_MUSIC_SOUND, WID_TE_HELP, }; - static const byte arrange_switch[] = { + static const WidgetID arrange_switch[] = { WID_TE_DATE_PANEL, WID_TE_SMALL_MAP, WID_TE_LAND_GENERATE, @@ -2121,12 +2123,12 @@ struct MainToolbarWindow : Window { this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { CallBackFunction cbf = _menu_clicked_procs[widget](index); if (cbf != CBF_NONE) _last_started_action = cbf; @@ -2238,7 +2240,7 @@ struct MainToolbarWindow : Window { { /* We do not want to automatically raise the pause, fast forward and * switchbar buttons; they have to stay down when pressed etc. */ - for (uint i = WID_TN_SETTINGS; i < WID_TN_SWITCH_BAR; i++) { + for (WidgetID i = WID_TN_SETTINGS; i < WID_TN_SWITCH_BAR; i++) { this->RaiseWidgetWhenLowered(i); } } @@ -2316,7 +2318,7 @@ static Hotkey maintoolbar_hotkeys[] = { }; HotkeyList MainToolbarWindow::hotkeys("maintoolbar", maintoolbar_hotkeys); -static NWidgetBase *MakeMainToolbar(int *biggest_index) +static std::unique_ptr MakeMainToolbar() { /** Sprites to use for the different toolbar buttons */ static const SpriteID toolbar_button_sprites[] = { @@ -2353,8 +2355,8 @@ static NWidgetBase *MakeMainToolbar(int *biggest_index) SPR_IMG_SWITCH_TOOLBAR, // WID_TN_SWITCH_BAR }; - NWidgetMainToolbarContainer *hor = new NWidgetMainToolbarContainer(); - for (uint i = 0; i < WID_TN_END; i++) { + auto hor = std::make_unique(); + for (WidgetID i = 0; i < WID_TN_END; i++) { switch (i) { case WID_TN_SMALL_MAP: case WID_TN_FINANCES: @@ -2362,15 +2364,14 @@ static NWidgetBase *MakeMainToolbar(int *biggest_index) case WID_TN_ZOOM_IN: case WID_TN_BUILDING_TOOLS_START: case WID_TN_MUSIC_SOUND: - hor->Add(new NWidgetSpacer(0, 0)); + hor->Add(std::make_unique(0, 0)); break; } - NWidgetLeaf *leaf = new NWidgetLeaf(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i); + auto leaf = std::make_unique(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i); leaf->SetMinimalSize(20, 20); - hor->Add(leaf); + hor->Add(std::move(leaf)); } - *biggest_index = std::max(*biggest_index, WID_TN_SWITCH_BAR); return hor; } @@ -2504,7 +2505,7 @@ struct ScenarioEditorToolbarWindow : Window { this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_TE_DATE: @@ -2513,7 +2514,7 @@ struct ScenarioEditorToolbarWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_TE_SPACER: { @@ -2529,7 +2530,7 @@ struct ScenarioEditorToolbarWindow : Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_TE_SPACER: @@ -2543,14 +2544,14 @@ struct ScenarioEditorToolbarWindow : Window { } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (_game_mode == GM_MENU) return; CallBackFunction cbf = _scen_toolbar_button_procs[widget](this); if (cbf != CBF_NONE) _last_started_action = cbf; } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { CallBackFunction cbf = _scen_toolbar_dropdown_procs[widget](index); if (cbf != CBF_NONE) _last_started_action = cbf; @@ -2734,9 +2735,9 @@ static const NWidgetPart _nested_toolb_scen_inner_widgets[] = { NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SWITCH_BAR), SetDataTip(SPR_IMG_SWITCH_TOOLBAR, STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR), }; -static NWidgetBase *MakeScenarioToolbar(int *biggest_index) +static std::unique_ptr MakeScenarioToolbar() { - return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), biggest_index, new NWidgetScenarioToolbarContainer()); + return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), std::make_unique()); } static const NWidgetPart _nested_toolb_scen_widgets[] = { diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 457d53c1a9..0816f242f0 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -206,7 +206,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TA_CAPTION) { SetDParam(0, this->window_number); @@ -239,7 +239,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_TA_ACTION_INFO: @@ -346,7 +346,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_TA_ACTION_INFO: { @@ -378,7 +378,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_TA_ZONE_BUTTON: { @@ -473,7 +473,7 @@ public: } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_TA_SETTING: { @@ -541,7 +541,7 @@ public: this->Window::Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TV_CAPTION) SetDParam(0, this->town->index); } @@ -556,7 +556,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_TV_INFO) return; @@ -649,7 +649,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_TV_CENTER_VIEW: // scroll to location @@ -684,7 +684,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_TV_INFO: @@ -976,7 +976,7 @@ public: this->townname_editbox.cancel_button = QueryString::ACTION_CLEAR; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_TD_WORLD_POPULATION: @@ -1001,7 +1001,7 @@ public: return t->larger_town ? STR_TOWN_DIRECTORY_CITY : STR_TOWN_DIRECTORY_TOWN; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_TD_SORT_ORDER: @@ -1048,7 +1048,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_TD_SORT_ORDER: { @@ -1102,7 +1102,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_TD_SORT_ORDER: // Click on sort order button @@ -1139,7 +1139,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_TD_SORT_CRITERIA) return; @@ -1167,7 +1167,7 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_TD_LIST); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_TD_FILTER) { this->string_filter.SetFilterTerm(this->townname_editbox.text.buf); @@ -1363,13 +1363,13 @@ public: if (_settings_game.economy.found_town != TF_CUSTOM_LAYOUT) town_layout = _settings_game.economy.town_layout; } - for (int i = WID_TF_SIZE_SMALL; i <= WID_TF_SIZE_RANDOM; i++) { + for (WidgetID i = WID_TF_SIZE_SMALL; i <= WID_TF_SIZE_RANDOM; i++) { this->SetWidgetLoweredState(i, i == WID_TF_SIZE_SMALL + this->town_size); } this->SetWidgetLoweredState(WID_TF_CITY, this->city); - for (int i = WID_TF_LAYOUT_ORIGINAL; i <= WID_TF_LAYOUT_RANDOM; i++) { + for (WidgetID i = WID_TF_LAYOUT_ORIGINAL; i <= WID_TF_LAYOUT_RANDOM; i++) { this->SetWidgetLoweredState(i, i == WID_TF_LAYOUT_ORIGINAL + this->town_layout); } @@ -1396,7 +1396,7 @@ public: if (success && !_shift_pressed) this->RandomTownName(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_TF_NEW_TOWN: @@ -1731,7 +1731,7 @@ public: } } - virtual void SetStringParameters(int widget) const override + virtual void SetStringParameters(WidgetID widget) const override { if (widget == WID_HP_CAPTION) { if (this->house_list.NumHouseSets() == 1) SetDParamStr(0, this->house_list.GetNameOfHouseSet(0)); @@ -1844,7 +1844,7 @@ public: } } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_HP_HOUSE_SETS: { @@ -1920,9 +1920,9 @@ public: } } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_HP_HOUSE_SETS: { int y = r.top + WidgetDimensions::scaled.matrix.top; for (uint i = 0; i < this->house_list.NumHouseSets(); i++) { @@ -1940,7 +1940,7 @@ public: break; case WID_HP_HOUSE_SELECT: { - HouseID house = this->house_list.GetHouseAtOffset(this->house_set, GB(widget, 16, 16)); + HouseID house = this->house_list.GetHouseAtOffset(this->house_set, this->GetWidget(widget)->GetParentWidget()->GetCurrentElement()); int lowered = (house == _cur_house) ? 1 : 0; DrawHouseImage(house, r.left + WidgetDimensions::scaled.matrix.left + lowered, r.top + WidgetDimensions::scaled.matrix.top + lowered, @@ -1955,9 +1955,9 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_HP_HOUSE_SETS: { uint index = (uint)(pt.y - this->GetWidget(widget)->pos_y) / this->line_height; if (index < this->house_list.NumHouseSets() && index != this->house_set) this->SelectOtherHouse(index, 0); @@ -1965,7 +1965,7 @@ public: } case WID_HP_HOUSE_SELECT: - this->SelectOtherHouse(this->house_set, GB(widget, 16, 16)); + this->SelectOtherHouse(this->house_set, this->GetWidget(widget)->GetParentWidget()->GetCurrentElement()); break; } } @@ -2076,7 +2076,7 @@ struct SelectTownWindow : Window { this->FinishInitNested(); } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget != WID_ST_PANEL) return; @@ -2094,7 +2094,7 @@ struct SelectTownWindow : Window { *size = d; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_ST_PANEL) return; @@ -2108,7 +2108,7 @@ struct SelectTownWindow : Window { } } - void OnClick(Point pt, int widget, int click_count) override + void OnClick(Point pt, WidgetID widget, int click_count) override { if (widget != WID_ST_PANEL) return; diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index 6a166b6d51..68eac1a91f 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -1809,7 +1809,7 @@ public: this->Window::Close(); } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case TR_WIDGET_INSTRUCTION_LIST: { @@ -2282,7 +2282,7 @@ public: TraceRestrictDoCommandP(tile, track, TRDCT_MODIFY_ITEM, this->selected_instruction - 1, item, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM); } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { TraceRestrictItem item = GetSelected(); if (item == 0 || index < 0 || this->selected_instruction < 1) { @@ -2384,7 +2384,7 @@ public: virtual void OnPlaceObject(Point pt, TileIndex tile) override { - int widget = this->current_placement_widget; + WidgetID widget = this->current_placement_widget; if (widget != TR_WIDGET_SHARE_ONTO) { this->ResetObjectToPlaceAction(); @@ -2431,7 +2431,7 @@ public: /** * Common OnPlaceObject handler for program management actions which involve clicking on a signal */ - void OnPlaceObjectSignal(Point pt, TileIndex source_tile, int widget, int error_message) + void OnPlaceObjectSignal(Point pt, TileIndex source_tile, WidgetID widget, int error_message) { if (!IsPlainRailTile(source_tile) && !IsRailTunnelBridgeTile(source_tile)) { ShowErrorMessage(error_message, STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, WL_INFO); @@ -2504,7 +2504,7 @@ public: /** * Common OnPlaceObject handler for instruction value modification actions which involve selecting an order target */ - void OnPlaceObjectDestination(Point pt, TileIndex tile, int widget, int error_message) + void OnPlaceObjectDestination(Point pt, TileIndex tile, WidgetID widget, int error_message) { TraceRestrictItem item = GetSelected(); if (GetTraceRestrictTypeProperties(item).value_type != TRVT_ORDER) return; @@ -2543,7 +2543,7 @@ public: /** * Common OnPlaceObject handler for instruction value modification actions which involve selecting a signal tile value */ - void OnPlaceObjectSignalTileValue(Point pt, TileIndex tile, int widget, int error_message) + void OnPlaceObjectSignalTileValue(Point pt, TileIndex tile, WidgetID widget, int error_message) { TraceRestrictItem item = GetSelected(); TraceRestrictValueType val_type = GetTraceRestrictTypeProperties(item).value_type; @@ -2576,7 +2576,7 @@ public: /** * Common OnPlaceObject handler for instruction value modification actions which involve selecting a tile value */ - void OnPlaceObjectTileValue(Point pt, TileIndex tile, int widget, int error_message) + void OnPlaceObjectTileValue(Point pt, TileIndex tile, WidgetID widget, int error_message) { TraceRestrictItem item = GetSelected(); TraceRestrictValueType val_type = GetTraceRestrictTypeProperties(item).value_type; @@ -2591,7 +2591,7 @@ public: this->ResetObjectToPlaceAction(); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case TR_WIDGET_INSTRUCTION_LIST: @@ -2616,7 +2616,7 @@ public: this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != TR_WIDGET_INSTRUCTION_LIST) return; @@ -2659,7 +2659,7 @@ public: } } - virtual void SetStringParameters(int widget) const override + virtual void SetStringParameters(WidgetID widget) const override { switch (widget) { case TR_WIDGET_VALUE_INT: { @@ -2725,7 +2725,7 @@ public: } } - bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { switch (widget) { case TR_WIDGET_SHARE: { @@ -2929,7 +2929,7 @@ private: void UpdatePlaceObjectPlanes() { - int widget = this->current_placement_widget; + WidgetID widget = this->current_placement_widget; if (!(widget == TR_WIDGET_COPY || widget == TR_WIDGET_COPY_APPEND)) { NWidgetStacked *copy_sel = this->GetWidget(TR_WIDGET_SEL_COPY); @@ -3451,7 +3451,7 @@ private: /** * Helper function to set or unset a SetObjectToPlaceWnd, for the given widget and cursor type */ - void SetObjectToPlaceAction(int widget, CursorID cursor) + void SetObjectToPlaceAction(WidgetID widget, CursorID cursor) { if (this->current_placement_widget != -1 && widget != this->current_placement_widget) { ResetObjectToPlace(); @@ -3880,7 +3880,7 @@ public: this->Window::Close(); } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_TRSL_LIST_SLOTS: { @@ -3952,7 +3952,7 @@ public: this->SetDirty(); } - virtual void SetStringParameters(int widget) const override + virtual void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_TRSL_FILTER_BY_CARGO: @@ -4000,7 +4000,7 @@ public: this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_TRSL_ALL_VEHICLES: @@ -4041,7 +4041,7 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_TRSL_SORT_BY_ORDER: // Flip sorting method ascending/descending @@ -4116,7 +4116,7 @@ public: } } - void OnDragDrop_Vehicle(Point pt, int widget) + void OnDragDrop_Vehicle(Point pt, WidgetID widget) { switch (widget) { case WID_TRSL_ALL_VEHICLES: // All vehicles @@ -4165,7 +4165,7 @@ public: } } - virtual void OnDragDrop(Point pt, int widget) override + virtual void OnDragDrop(Point pt, WidgetID widget) override { if (this->vehicle_sel != INVALID_VEHICLE) OnDragDrop_Vehicle(pt, widget); @@ -4192,7 +4192,7 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_TRSL_LIST_VEHICLE); } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_TRSL_SORT_BY_DROPDOWN: @@ -4226,7 +4226,7 @@ public: this->SetWidgetDirty(WID_TRSL_LIST_VEHICLE); } - virtual void OnMouseDrag(Point pt, int widget) override + virtual void OnMouseDrag(Point pt, WidgetID widget) override { if (this->vehicle_sel == INVALID_VEHICLE) return; @@ -4471,7 +4471,7 @@ public: this->owner = this->ctr_company; } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_TRCL_LIST_COUNTERS: { @@ -4534,7 +4534,7 @@ public: this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const override + virtual void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_TRCL_LIST_COUNTERS: { @@ -4564,7 +4564,7 @@ public: } } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_TRCL_LIST_COUNTERS: { // Matrix diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 02b5143695..7b3d5b9cfd 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -63,7 +63,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_TT_SIGNS: @@ -76,13 +76,13 @@ public: case WID_TT_CATENARY: case WID_TT_LOADING: case WIT_TT_TUNNELS: { - uint i = widget - WID_TT_BEGIN; + int i = widget - WID_TT_BEGIN; if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, r.left + WidgetDimensions::scaled.fullbevel.left, r.top + WidgetDimensions::scaled.fullbevel.top); break; } case WID_TT_BUTTONS: { const Rect fr = r.Shrink(WidgetDimensions::scaled.framerect); - for (uint i = WID_TT_BEGIN; i < WID_TT_END; i++) { + for (WidgetID i = WID_TT_BEGIN; i < WID_TT_END; i++) { if (i == WID_TT_LOADING || i == WIT_TT_TUNNELS) continue; // Do not draw button for invisible loading indicators. const Rect wr = this->GetWidget(i)->GetCurrentRect().Shrink(WidgetDimensions::scaled.fullbevel); @@ -94,7 +94,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { if (widget >= WID_TT_BEGIN && widget < WID_TT_END) { if (_ctrl_pressed) { @@ -144,7 +144,7 @@ public: void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override { if (!gui_scope) return; - for (uint i = WID_TT_BEGIN; i < WID_TT_END; i++) { + for (WidgetID i = WID_TT_BEGIN; i < WID_TT_END; i++) { this->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))); } } diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 0966ba8fc3..b8feda8a05 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -139,7 +139,7 @@ public: this->FinishInitNested(window_number); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget >= WID_BT_TYPE_BUTTON_FIRST) { /* Ensure tree type buttons are sized after the largest tree type */ @@ -149,7 +149,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget >= WID_BT_TYPE_BUTTON_FIRST) { const int index = widget - WID_BT_TYPE_BUTTON_FIRST; @@ -158,7 +158,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_BT_TYPE_RANDOM: // tree of random type. @@ -249,7 +249,7 @@ public: * get producing the correct result than dynamically building the widgets is. * @see NWidgetFunctionType */ -static NWidgetBase *MakeTreeTypeButtons(int *biggest_index) +static std::unique_ptr MakeTreeTypeButtons() { const byte type_base = _tree_base_by_landscape[_settings_game.game_creation.landscape]; const byte type_count = _tree_count_by_landscape[_settings_game.game_creation.landscape]; @@ -259,21 +259,20 @@ static NWidgetBase *MakeTreeTypeButtons(int *biggest_index) const int num_rows = CeilDiv(type_count, num_columns); byte cur_type = type_base; - NWidgetVertical *vstack = new NWidgetVertical(NC_EQUALSIZE); + auto vstack = std::make_unique(NC_EQUALSIZE); vstack->SetPIP(0, 1, 0); for (int row = 0; row < num_rows; row++) { - NWidgetHorizontal *hstack = new NWidgetHorizontal(NC_EQUALSIZE); + auto hstack = std::make_unique(NC_EQUALSIZE); hstack->SetPIP(0, 1, 0); - vstack->Add(hstack); for (int col = 0; col < num_columns; col++) { if (cur_type > type_base + type_count) break; - NWidgetBackground *button = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_BT_TYPE_BUTTON_FIRST + cur_type); + auto button = std::make_unique(WWT_PANEL, COLOUR_GREY, WID_BT_TYPE_BUTTON_FIRST + cur_type); button->SetDataTip(0x0, STR_PLANT_TREE_TOOLTIP); - hstack->Add(button); - *biggest_index = WID_BT_TYPE_BUTTON_FIRST + cur_type; + hstack->Add(std::move(button)); cur_type++; } + vstack->Add(std::move(hstack)); } return vstack; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 4b97c71359..8181efe4d9 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -965,7 +965,7 @@ struct RefitWindow : public Window { this->DrawWidgets(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_VR_MATRIX: @@ -1010,7 +1010,7 @@ struct RefitWindow : public Window { return name; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_VR_CAPTION) SetDParam(0, Vehicle::Get(this->window_number)->index); @@ -1071,7 +1071,7 @@ struct RefitWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { @@ -1267,7 +1267,7 @@ struct RefitWindow : public Window { } } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_VR_VEHICLE_DROPDOWN) return; @@ -1290,7 +1290,7 @@ struct RefitWindow : public Window { this->InvalidateData(2); } - void OnClick(Point pt, int widget, int click_count) override + void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image. @@ -1354,7 +1354,7 @@ struct RefitWindow : public Window { } } - void OnMouseDrag(Point pt, int widget) override + void OnMouseDrag(Point pt, WidgetID widget) override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image. @@ -1367,7 +1367,7 @@ struct RefitWindow : public Window { } } - void OnDragDrop(Point pt, int widget) override + void OnDragDrop(Point pt, WidgetID widget) override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image. @@ -2254,7 +2254,7 @@ public: this->RefreshRouteOverlay(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_VL_LIST: @@ -2306,7 +2306,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_VL_AVAILABLE_VEHICLES: @@ -2349,7 +2349,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_VL_SORT_ORDER: @@ -2402,7 +2402,7 @@ public: this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_VL_ORDER_VIEW: // Open the shared orders window @@ -2490,7 +2490,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_VL_GROUP_BY_PULLDOWN: @@ -2945,7 +2945,7 @@ struct VehicleDetailsWindow : Window { return HasBit(Train::From(v)->flags, VRF_SPEED_ADAPTATION_EXEMPT); } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_VD_TOP_DETAILS: { @@ -3083,12 +3083,12 @@ struct VehicleDetailsWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_VD_CAPTION) SetDParam(0, Vehicle::Get(this->window_number)->index); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { const Vehicle *v = Vehicle::Get(this->window_number); @@ -3298,7 +3298,7 @@ struct VehicleDetailsWindow : Window { this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_VD_INCREASE_SERVICING_INTERVAL: // increase int @@ -3336,7 +3336,7 @@ struct VehicleDetailsWindow : Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_VD_SERVICE_INTERVAL_DROPDOWN: { @@ -3681,7 +3681,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { const Vehicle *v = Vehicle::Get(this->window_number); switch (widget) { @@ -3729,7 +3729,7 @@ public: this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_VV_CAPTION) return; @@ -3737,7 +3737,7 @@ public: SetDParam(0, v->index); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_VV_START_STOP) return; @@ -3915,7 +3915,7 @@ public: DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, GetCharacterHeight(FS_NORMAL)), str, text_colour, SA_HOR_CENTER); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { const Vehicle *v = Vehicle::Get(this->window_number); @@ -4047,7 +4047,7 @@ public: DoCommandP(0, this->window_number, 0, CMD_RENAME_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type), nullptr, str); } - virtual void OnDropdownSelect(int widget, int index) override + virtual void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_VV_GOTO_DEPOT: { @@ -4089,7 +4089,7 @@ public: this->SetWidgetDirty(WID_VV_GOTO_DEPOT); } - virtual bool OnRightClick(Point pt, int widget) override + virtual bool OnRightClick(Point pt, WidgetID widget) override { if (widget == WID_VV_GOTO_DEPOT && _settings_client.gui.hover_delay_ms == 0) { const Vehicle *v = Vehicle::Get(this->window_number); @@ -4103,7 +4103,7 @@ public: return false; } - virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override + virtual bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { if (widget == WID_VV_GOTO_DEPOT) { const Vehicle *v = Vehicle::Get(this->window_number); @@ -4124,7 +4124,7 @@ public: return false; } - void OnMouseOver([[maybe_unused]] Point pt, int widget) override + void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override { bool start_stop = widget == WID_VV_START_STOP; if (start_stop != mouse_over_start_stop) { diff --git a/src/viewport.cpp b/src/viewport.cpp index b205c7b645..01518edc6c 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -908,7 +908,7 @@ Point GetTileZoomCenterWindow(bool in, Window * w) * @param widget_zoom_in widget index for window with zoom-in button * @param widget_zoom_out widget index for window with zoom-out button */ -void HandleZoomMessage(Window *w, const Viewport *vp, byte widget_zoom_in, byte widget_zoom_out) +void HandleZoomMessage(Window *w, const Viewport *vp, WidgetID widget_zoom_in, WidgetID widget_zoom_out) { w->SetWidgetDisabledState(widget_zoom_in, vp->zoom <= _settings_client.gui.zoom_min); w->SetWidgetDirty(widget_zoom_in); diff --git a/src/viewport_func.h b/src/viewport_func.h index fb93160f1a..688e4d63ff 100644 --- a/src/viewport_func.h +++ b/src/viewport_func.h @@ -57,7 +57,7 @@ void ZoomInOrOutToCursorWindow(bool in, Window * w); void ConstrainAllViewportsZoom(); Point GetTileZoomCenterWindow(bool in, Window * w); void FixTitleGameZoom(int zoom_adjust = 0); -void HandleZoomMessage(Window *w, const Viewport *vp, byte widget_zoom_in, byte widget_zoom_out); +void HandleZoomMessage(Window *w, const Viewport *vp, WidgetID widget_zoom_in, WidgetID widget_zoom_out); /** * Zoom a viewport as far as possible in the given direction. diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index defd0c6004..43a5869098 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -85,7 +85,7 @@ public: this->viewport->map_type = (ViewportMapType) _settings_client.gui.default_viewport_map_mode; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_EV_CAPTION: @@ -95,7 +95,7 @@ public: } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_EV_ZOOM_IN: DoZoomInOutWindow(ZOOM_IN, this); break; @@ -141,7 +141,7 @@ public: this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y; } - bool OnRightClick([[maybe_unused]] Point pt, int widget) override + bool OnRightClick([[maybe_unused]] Point pt, WidgetID widget) override { return widget == WID_EV_VIEWPORT; } @@ -157,7 +157,7 @@ public: } } - virtual void OnMouseOver(Point pt, int widget) override + virtual void OnMouseOver(Point pt, WidgetID widget) override { if (pt.x != -1 && IsViewportMouseHoverActive()) { /* Show tooltip with last month production or town name */ diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index 024e9fe9a8..d1c6b7ac53 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -113,7 +113,7 @@ public: this->Window::Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_W_CAPTION) SetDParam(0, this->wp->index); } @@ -127,7 +127,7 @@ public: this->DrawWidgets(); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_W_CENTER_VIEW: // scroll to location diff --git a/src/widget.cpp b/src/widget.cpp index 8a48abdbea..ae5054a9d9 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -402,7 +402,7 @@ void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y) * @param y The Window client y coordinate * @return A widget index, or -1 if no widget was found. */ -int GetWidgetFromPos(const Window *w, int x, int y) +WidgetID GetWidgetFromPos(const Window *w, int x, int y) { NWidgetCore *nw = w->nested_root->GetWidgetFromPos(x, y); return (nw != nullptr) ? nw->index : -1; @@ -877,9 +877,9 @@ void Window::DrawWidgets() const if (this->flags & WF_HIGHLIGHTED) { extern bool _window_highlight_colour; - for (uint i = 0; i < this->nested_array_size; i++) { - const NWidgetBase *widget = this->GetWidget(i); - if (widget == nullptr || !widget->IsHighlighted()) continue; + for (const auto &pair : this->widget_lookup) { + const NWidgetBase *widget = pair.second; + if (!widget->IsHighlighted()) continue; Rect outer = widget->GetCurrentRect(); Rect inner = outer.Shrink(WidgetDimensions::scaled.bevel).Expand(1); @@ -899,11 +899,11 @@ void Window::DrawWidgets() const * @param widget Sort button widget * @param state State of sort button */ -void Window::DrawSortButtonState(int widget, SortButtonState state) const +void Window::DrawSortButtonState(WidgetID widget, SortButtonState state) const { if (state == SBS_OFF) return; - assert(this->nested_array != nullptr); + assert(!this->widget_lookup.empty()); Rect r = this->GetWidget(widget)->GetCurrentRect(); /* Sort button uses the same sprites as vertical scrollbar */ @@ -1023,10 +1023,9 @@ NWidgetBase::NWidgetBase(WidgetType tp) : ZeroedMemoryAllocator() */ /** - * @fn void NWidgetBase::FillNestedArray(NWidgetBase **array, uint length) - * Fill the Window::nested_array array with pointers to nested widgets in the tree. - * @param array Base pointer of the array. - * @param length Length of the array. + * @fn void NWidgetBase::FillWidgetLookup(WidgetLookup &widget_lookup) + * Fill the Window::widget_lookup with pointers to nested widgets in the tree. + * @param widget_lookup The WidgetLookup. */ /** @@ -1208,15 +1207,15 @@ void NWidgetResizeBase::AssignSizePosition(SizingType sizing, int x, int y, uint * Initialization of a 'real' widget. * @param tp Type of the widget. * @param colour Colour of the widget. + * @param index Index of the widget. * @param fill_x Default horizontal filling. * @param fill_y Default vertical filling. * @param widget_data Data component of the widget. @see Widget::data * @param tool_tip Tool tip of the widget. @see Widget::tooltips */ -NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip) : NWidgetResizeBase(tp, fill_x, fill_y) +NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, WidgetID index, uint fill_x, uint fill_y, uint32_t widget_data, StringID tool_tip) : NWidgetResizeBase(tp, fill_x, fill_y), index(index) { this->colour = colour; - this->index = -1; this->widget_data = widget_data; this->tool_tip = tool_tip; this->scrollbar_index = -1; @@ -1225,16 +1224,6 @@ NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y this->align = SA_CENTER; } -/** - * Set index of the nested widget in the widget array. - * @param index Index to use. - */ -void NWidgetCore::SetIndex(int index) -{ - assert(index >= 0); - this->index = index; -} - /** * Set data and tool tip of the nested widget. * @param widget_data Data to use. @@ -1275,9 +1264,9 @@ void NWidgetCore::SetAlignment(StringAlignment align) this->align = align; } -void NWidgetCore::FillNestedArray(NWidgetBase **array, uint length) +void NWidgetCore::FillWidgetLookup(WidgetLookup &widget_lookup) { - if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; + if (this->index >= 0) widget_lookup[this->index] = this; } NWidgetCore *NWidgetCore::GetWidgetFromPos(int x, int y) @@ -1290,30 +1279,10 @@ void NWidgetCore::FillDirtyWidgets(std::vector &dirty_widgets) if (this->base_flags & WBF_DIRTY) dirty_widgets.push_back(this); } -/** - * Constructor container baseclass. - * @param tp Type of the container. - */ -NWidgetContainer::NWidgetContainer(WidgetType tp) : NWidgetBase(tp) -{ - this->head = nullptr; - this->tail = nullptr; -} - -NWidgetContainer::~NWidgetContainer() -{ - while (this->head != nullptr) { - NWidgetBase *wid = this->head->next; - delete this->head; - this->head = wid; - } - this->tail = nullptr; -} - NWidgetBase *NWidgetContainer::GetWidgetOfType(WidgetType tp) { if (this->type == tp) return this; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { NWidgetBase *nwid = child_wid->GetWidgetOfType(tp); if (nwid != nullptr) return nwid; } @@ -1322,7 +1291,7 @@ NWidgetBase *NWidgetContainer::GetWidgetOfType(WidgetType tp) void NWidgetContainer::AdjustPaddingForZoom() { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->AdjustPaddingForZoom(); } NWidgetBase::AdjustPaddingForZoom(); @@ -1332,33 +1301,23 @@ void NWidgetContainer::AdjustPaddingForZoom() * Append widget \a wid to container. * @param wid Widget to append. */ -void NWidgetContainer::Add(NWidgetBase *wid) +void NWidgetContainer::Add(std::unique_ptr &&wid) { - assert(wid->next == nullptr && wid->prev == nullptr); - - if (this->head == nullptr) { - this->head = wid; - this->tail = wid; - } else { - assert(this->tail != nullptr); - assert(this->tail->next == nullptr); - - this->tail->next = wid; - wid->prev = this->tail; - this->tail = wid; - } + assert(wid != nullptr); + wid->parent = this; + this->children.push_back(std::move(wid)); } -void NWidgetContainer::FillNestedArray(NWidgetBase **array, uint length) +void NWidgetContainer::FillWidgetLookup(WidgetLookup &widget_lookup) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { - child_wid->FillNestedArray(array, length); + for (const auto &child_wid : this->children) { + child_wid->FillWidgetLookup(widget_lookup); } } void NWidgetContainer::Draw(const Window *w) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->Draw(w); } @@ -1369,7 +1328,7 @@ NWidgetCore *NWidgetContainer::GetWidgetFromPos(int x, int y) { if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y); if (nwid != nullptr) return nwid; } @@ -1381,7 +1340,7 @@ void NWidgetContainer::FillDirtyWidgets(std::vector &dirty_widget if (this->base_flags & WBF_DIRTY) { dirty_widgets.push_back(this); } else { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->FillDirtyWidgets(dirty_widgets); } } @@ -1390,19 +1349,13 @@ void NWidgetContainer::FillDirtyWidgets(std::vector &dirty_widget /** * Widgets stacked on top of each other. */ -NWidgetStacked::NWidgetStacked() : NWidgetContainer(NWID_SELECTION) -{ - this->index = -1; -} - -void NWidgetStacked::SetIndex(int index) +NWidgetStacked::NWidgetStacked(WidgetID index) : NWidgetContainer(NWID_SELECTION), index(index) { - this->index = index; } void NWidgetStacked::AdjustPaddingForZoom() { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->AdjustPaddingForZoom(); } NWidgetContainer::AdjustPaddingForZoom(); @@ -1431,12 +1384,13 @@ void NWidgetStacked::SetupSmallestSize(Window *w) /* First sweep, recurse down and compute minimal size and filling. */ this->smallest_x = 0; this->smallest_y = 0; - this->fill_x = (this->head != nullptr) ? 1 : 0; - this->fill_y = (this->head != nullptr) ? 1 : 0; - this->resize_x = (this->head != nullptr) ? 1 : 0; - this->resize_y = (this->head != nullptr) ? 1 : 0; - int plane = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; plane++, child_wid = child_wid->next) { + this->fill_x = this->IsEmpty() ? 0 : 1; + this->fill_y = this->IsEmpty() ? 0 : 1; + this->resize_x = this->IsEmpty() ? 0 : 1; + this->resize_y = this->IsEmpty() ? 0 : 1; + int plane = -1; + for (const auto &child_wid : this->children) { + plane++; if (this->independent_planes && plane != this->shown_plane) continue; child_wid->SetupSmallestSize(w); @@ -1457,10 +1411,10 @@ void NWidgetStacked::AssignSizePosition(SizingType sizing, int x, int y, uint gi if (this->shown_plane >= SZSP_BEGIN) return; - int plane = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; plane++, child_wid = child_wid->next) { + int plane = -1; + for (const auto &child_wid : this->children) { + plane++; if (this->independent_planes && plane != this->shown_plane) continue; - uint hor_step = (sizing == ST_SMALLEST) ? 1 : child_wid->GetHorizontalStepSize(sizing); uint child_width = ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding.Horizontal(), hor_step); uint child_pos_x = (rtl ? child_wid->padding.right : child_wid->padding.left); @@ -1473,10 +1427,10 @@ void NWidgetStacked::AssignSizePosition(SizingType sizing, int x, int y, uint gi } } -void NWidgetStacked::FillNestedArray(NWidgetBase **array, uint length) +void NWidgetStacked::FillWidgetLookup(WidgetLookup &widget_lookup) { - if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; - NWidgetContainer::FillNestedArray(array, length); + if (this->index >= 0) widget_lookup[this->index] = this; + NWidgetContainer::FillWidgetLookup(widget_lookup); } void NWidgetStacked::Draw(const Window *w) @@ -1485,16 +1439,9 @@ void NWidgetStacked::Draw(const Window *w) this->base_flags &= ~WBF_DIRTY; if (this->shown_plane >= SZSP_BEGIN) return; - int plane = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; plane++, child_wid = child_wid->next) { - if (plane == this->shown_plane) { - child_wid->Draw(w); - DrawOutline(w, this); - return; - } - } - - NOT_REACHED(); + assert(static_cast(this->shown_plane) < this->children.size()); + this->children[shown_plane]->Draw(w); + DrawOutline(w, this); } NWidgetCore *NWidgetStacked::GetWidgetFromPos(int x, int y) @@ -1502,13 +1449,9 @@ NWidgetCore *NWidgetStacked::GetWidgetFromPos(int x, int y) if (this->shown_plane >= SZSP_BEGIN) return nullptr; if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr; - int plane = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; plane++, child_wid = child_wid->next) { - if (plane == this->shown_plane) { - return child_wid->GetWidgetFromPos(x, y); - } - } - return nullptr; + + if (static_cast(this->shown_plane) >= this->children.size()) return nullptr; + return this->children[shown_plane]->GetWidgetFromPos(x, y); } void NWidgetStacked::FillDirtyWidgets(std::vector &dirty_widgets) @@ -1516,8 +1459,9 @@ void NWidgetStacked::FillDirtyWidgets(std::vector &dirty_widgets) if (this->base_flags & WBF_DIRTY) { dirty_widgets.push_back(this); } else { - int plane = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; plane++, child_wid = child_wid->next) { + int plane = -1; + for (const auto &child_wid : this->children) { + plane++; if (plane == this->shown_plane) { child_wid->FillDirtyWidgets(dirty_widgets); return; @@ -1602,10 +1546,10 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w) 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. */ + /* 1a. Forward call, collect longest/widest child length. */ uint longest = 0; // Longest child found. uint max_vert_fill = 0; // Biggest vertical fill step. - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->SetupSmallestSize(w); longest = std::max(longest, child_wid->smallest_x); max_vert_fill = std::max(max_vert_fill, child_wid->GetVerticalStepSize(ST_SMALLEST)); @@ -1617,7 +1561,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w) [[maybe_unused]] uint max_smallest = this->smallest_y + 3 * max_vert_fill; // Upper limit to computing smallest height. uint cur_height = this->smallest_y; for (;;) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint step_size = child_wid->GetVerticalStepSize(ST_SMALLEST); uint child_height = child_wid->smallest_y + child_wid->padding.Vertical(); if (step_size > 1 && child_height < cur_height) { // Small step sizes or already fitting children are not interesting. @@ -1634,12 +1578,12 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w) } /* 2. For containers that must maintain equal width, extend child minimal size. */ if (this->flags & NC_EQUALSIZE) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { if (child_wid->fill_x == 1) child_wid->smallest_x = longest; } } /* 3. Compute smallest, fill, and resize values of the container. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { 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; @@ -1662,7 +1606,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint /* Compute additional width given to us. */ uint additional_length = given_width - (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) { + for (const auto &child_wid : this->children) { if (child_wid->smallest_x != 0 || child_wid->fill_x != 0) additional_length -= child_wid->smallest_x + child_wid->padding.Horizontal(); } @@ -1684,7 +1628,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint */ int num_changing_childs = 0; // Number of children that can change size. uint biggest_stepsize = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint hor_step = child_wid->GetHorizontalStepSize(sizing); if (hor_step > 0) { if (!(flags & NC_BIGFIRST)) num_changing_childs++; @@ -1699,7 +1643,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint /* First.5 loop: count how many children are of the biggest step size. */ if ((flags & NC_BIGFIRST) && biggest_stepsize > 0) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint hor_step = child_wid->GetHorizontalStepSize(sizing); if (hor_step == biggest_stepsize) { num_changing_childs++; @@ -1710,7 +1654,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint /* Second loop: Allocate the additional horizontal space over the resizing children, starting with the biggest resize steps. */ while (biggest_stepsize > 0) { uint next_biggest_stepsize = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint hor_step = child_wid->GetHorizontalStepSize(sizing); if (hor_step > biggest_stepsize) continue; // Already done if (hor_step == biggest_stepsize) { @@ -1727,7 +1671,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint if (num_changing_childs == 0 && (flags & NC_BIGFIRST) && biggest_stepsize > 0) { /* Second.5 loop: count how many children are of the updated biggest step size. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint hor_step = child_wid->GetHorizontalStepSize(sizing); if (hor_step == biggest_stepsize) { num_changing_childs++; @@ -1752,8 +1696,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint /* Third loop: Compute position and call the child. */ 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) { + for (const auto &child_wid : this->children) { uint child_width = child_wid->current_x; uint child_x = x + (rtl ? position - child_width - child_wid->padding.left : position + child_wid->padding.left); uint child_y = y + child_wid->padding.top; @@ -1763,8 +1706,6 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint 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; } } @@ -1794,10 +1735,10 @@ void NWidgetVertical::SetupSmallestSize(Window *w) 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. */ + /* 1a. Forward call, collect longest/widest child length. */ uint highest = 0; // Highest child found. uint max_hor_fill = 0; // Biggest horizontal fill step. - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->SetupSmallestSize(w); highest = std::max(highest, child_wid->smallest_y); max_hor_fill = std::max(max_hor_fill, child_wid->GetHorizontalStepSize(ST_SMALLEST)); @@ -1809,7 +1750,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w) [[maybe_unused]] uint max_smallest = this->smallest_x + 3 * max_hor_fill; // Upper limit to computing smallest height. uint cur_width = this->smallest_x; for (;;) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint step_size = child_wid->GetHorizontalStepSize(ST_SMALLEST); uint child_width = child_wid->smallest_x + child_wid->padding.Horizontal(); if (step_size > 1 && child_width < cur_width) { // Small step sizes or already fitting children are not interesting. @@ -1826,12 +1767,12 @@ void NWidgetVertical::SetupSmallestSize(Window *w) } /* 2. For containers that must maintain equal width, extend children minimal size. */ if (this->flags & NC_EQUALSIZE) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { if (child_wid->fill_y == 1) child_wid->smallest_y = highest; } } /* 3. Compute smallest, fill, and resize values of the container. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { 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; @@ -1854,7 +1795,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g /* Compute additional height given to us. */ uint additional_length = given_height - (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) { + for (const auto &child_wid : this->children) { if (child_wid->smallest_y != 0 || child_wid->fill_y != 0) additional_length -= child_wid->smallest_y + child_wid->padding.Vertical(); } @@ -1867,7 +1808,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g /* First loop: Find biggest stepsize, find number of children that want a piece of the pie, handle horizontal size for all children, handle vertical size for non-resizing child. */ int num_changing_childs = 0; // Number of children that can change size. uint biggest_stepsize = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint vert_step = child_wid->GetVerticalStepSize(sizing); if (vert_step > 0) { if (!(flags & NC_BIGFIRST)) num_changing_childs++; @@ -1882,7 +1823,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g /* First.5 loop: count how many children are of the biggest step size. */ if ((this->flags & NC_BIGFIRST) && biggest_stepsize > 0) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint vert_step = child_wid->GetVerticalStepSize(sizing); if (vert_step == biggest_stepsize) { num_changing_childs++; @@ -1893,7 +1834,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g /* Second loop: Allocate the additional vertical space over the resizing children, starting with the biggest resize steps. */ while (biggest_stepsize > 0) { uint next_biggest_stepsize = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint vert_step = child_wid->GetVerticalStepSize(sizing); if (vert_step > biggest_stepsize) continue; // Already done if (vert_step == biggest_stepsize) { @@ -1910,7 +1851,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g if (num_changing_childs == 0 && (flags & NC_BIGFIRST) && biggest_stepsize > 0) { /* Second.5 loop: count how many children are of the updated biggest step size. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint vert_step = child_wid->GetVerticalStepSize(sizing); if (vert_step == biggest_stepsize) { num_changing_childs++; @@ -1935,7 +1876,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g /* Third loop: Compute position and call the child. */ 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) { + for (const auto &child_wid : this->children) { uint child_x = x + (rtl ? child_wid->padding.right : child_wid->padding.left); uint child_height = child_wid->current_y; @@ -1963,7 +1904,7 @@ void NWidgetSpacer::SetupSmallestSize(Window *) this->smallest_y = this->min_y; } -void NWidgetSpacer::FillNestedArray(NWidgetBase **, uint) +void NWidgetSpacer::FillWidgetLookup(WidgetLookup &) { } @@ -1994,23 +1935,14 @@ void NWidgetSpacer::FillDirtyWidgets(std::vector &dirty_widgets) /* Spacer widget never need repainting. */ } -NWidgetMatrix::NWidgetMatrix() : NWidgetPIPContainer(NWID_MATRIX, NC_EQUALSIZE), index(-1), clicked(-1), count(-1) -{ -} - -void NWidgetMatrix::SetIndex(int index) -{ - this->index = index; -} - -void NWidgetMatrix::SetColour(Colours colour) +NWidgetMatrix::NWidgetMatrix(Colours colour, WidgetID index) : NWidgetPIPContainer(NWID_MATRIX, NC_EQUALSIZE), index(index), clicked(-1), count(-1) { this->colour = colour; } /** - * Sets the clicked widget in the matrix. - * @param clicked The clicked widget. + * Sets the clicked element in the matrix. + * @param clicked The clicked element. */ void NWidgetMatrix::SetClicked(int clicked) { @@ -2041,7 +1973,7 @@ void NWidgetMatrix::SetCount(int count) * Then multiply that by the height of a widget, and add the pre * and post spacing "offsets". */ count = CeilDiv(count, this->sb->IsVertical() ? this->widgets_x : this->widgets_y); - count *= (this->sb->IsVertical() ? this->head->smallest_y : this->head->smallest_x) + this->pip_inter; + count *= (this->sb->IsVertical() ? this->children.front()->smallest_y : this->children.front()->smallest_x) + this->pip_inter; if (count > 0) count -= this->pip_inter; // We counted an inter too much in the multiplication above count += this->pip_pre + this->pip_post; this->sb->SetCount(count); @@ -2058,21 +1990,25 @@ void NWidgetMatrix::SetScrollbar(Scrollbar *sb) this->sb = sb; } +/** + * Get current element. + * @returns index of current element. + */ +int NWidgetMatrix::GetCurrentElement() const +{ + return this->current_element; +} + void NWidgetMatrix::SetupSmallestSize(Window *w) { - assert(this->head != nullptr); - assert(this->head->next == nullptr); + assert(this->children.size() == 1); - /* Reset the widget number. */ - NWidgetCore *nw = dynamic_cast(this->head); - assert(nw != nullptr); - SB(nw->index, 16, 16, 0); - this->head->SetupSmallestSize(w); + this->children.front()->SetupSmallestSize(w); Dimension padding = { (uint)this->pip_pre + this->pip_post, (uint)this->pip_pre + this->pip_post}; - Dimension size = {this->head->smallest_x + padding.width, this->head->smallest_y + padding.height}; + Dimension size = {this->children.front()->smallest_x + padding.width, this->children.front()->smallest_y + padding.height}; Dimension fill = {0, 0}; - Dimension resize = {this->pip_inter + this->head->smallest_x, this->pip_inter + this->head->smallest_y}; + Dimension resize = {this->pip_inter + this->children.front()->smallest_x, this->pip_inter + this->children.front()->smallest_y}; if (this->index >= 0) w->UpdateWidgetSize(this->index, &size, padding, &fill, &resize); @@ -2094,8 +2030,8 @@ void NWidgetMatrix::AssignSizePosition(SizingType, int x, int y, uint given_widt this->current_y = given_height; /* Determine the size of the widgets, and the number of visible widgets on each of the axis. */ - this->widget_w = this->head->smallest_x + this->pip_inter; - this->widget_h = this->head->smallest_y + this->pip_inter; + this->widget_w = this->children.front()->smallest_x + this->pip_inter; + this->widget_h = this->children.front()->smallest_y + this->pip_inter; /* Account for the pip_inter is between widgets, so we need to account for that when * the division assumes pip_inter is used for all widgets. */ @@ -2108,10 +2044,10 @@ void NWidgetMatrix::AssignSizePosition(SizingType, int x, int y, uint given_widt this->SetCount(this->count); } -void NWidgetMatrix::FillNestedArray(NWidgetBase **array, uint length) +void NWidgetMatrix::FillWidgetLookup(WidgetLookup &widget_lookup) { - if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; - NWidgetContainer::FillNestedArray(array, length); + if (this->index >= 0) widget_lookup[this->index] = this; + NWidgetContainer::FillWidgetLookup(widget_lookup); } NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y) @@ -2131,18 +2067,16 @@ NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y) int widget_row = (y - base_offs_y - (int)this->pip_pre - this->pos_y) / this->widget_h; - int sub_wid = (widget_row + start_y) * this->widgets_x + start_x + widget_col; - if (sub_wid >= this->count) return nullptr; + this->current_element = (widget_row + start_y) * this->widgets_x + start_x + widget_col; + if (this->current_element >= this->count) return nullptr; - NWidgetCore *child = dynamic_cast(this->head); + NWidgetCore *child = dynamic_cast(this->children.front().get()); assert(child != nullptr); child->AssignSizePosition(ST_RESIZE, this->pos_x + (rtl ? this->pip_post - widget_col * this->widget_w : this->pip_pre + widget_col * this->widget_w) + base_offs_x, this->pos_y + this->pip_pre + widget_row * this->widget_h + base_offs_y, child->smallest_x, child->smallest_y, rtl); - SB(child->index, 16, 16, sub_wid); - return child->GetWidgetFromPos(x, y); } @@ -2170,7 +2104,7 @@ void NWidgetMatrix::FillDirtyWidgets(std::vector &dirty_widgets) AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi); /* Get the appropriate offsets so we can draw the right widgets. */ - NWidgetCore *child = dynamic_cast(this->head); + NWidgetCore *child = dynamic_cast(this->children.front().get()); assert(child != nullptr); int start_x, start_y, base_offs_x, base_offs_y; this->GetScrollOffsets(start_x, start_y, base_offs_x, base_offs_y); @@ -2191,12 +2125,11 @@ void NWidgetMatrix::FillDirtyWidgets(std::vector &dirty_widgets) if (offs_x >= (int)this->current_x) continue; /* Do we have this many widgets? */ - int sub_wid = y * this->widgets_x + x; - if (sub_wid >= this->count) break; + this->current_element = y * this->widgets_x + x; + if (this->current_element >= this->count) break; child->AssignSizePosition(ST_RESIZE, offs_x, offs_y, child->smallest_x, child->smallest_y, rtl); - child->SetLowered(this->clicked == sub_wid); - SB(child->index, 16, 16, sub_wid); + child->SetLowered(this->clicked == this->current_element); child->Draw(w); } } @@ -2238,24 +2171,19 @@ void NWidgetMatrix::GetScrollOffsets(int &start_x, int &start_y, int &base_offs_ * Constructor parent nested widgets. * @param tp Type of parent widget. * @param colour Colour of the parent widget. - * @param index Index in the widget array used by the window system. + * @param index Index of the widget. * @param child Child container widget (if supplied). If not supplied, a * vertical container will be inserted while adding the first * child widget. */ -NWidgetBackground::NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL) +NWidgetBackground::NWidgetBackground(WidgetType tp, Colours colour, WidgetID index, std::unique_ptr child) : NWidgetCore(tp, colour, index, 1, 1, 0x0, STR_NULL) { assert(tp == WWT_PANEL || tp == WWT_INSET || tp == WWT_FRAME); - if (index >= 0) this->SetIndex(index); - this->child = child; + this->child = std::move(child); + if (this->child != nullptr) this->child->parent = this; this->SetAlignment(SA_TOP | SA_LEFT); } -NWidgetBackground::~NWidgetBackground() -{ - if (this->child != nullptr) delete this->child; -} - /** * Add a child to the parent. * @param nwid Nested widget to add to the background widget. @@ -2263,12 +2191,13 @@ NWidgetBackground::~NWidgetBackground() * Unless a child container has been given in the constructor, a parent behaves as a vertical container. * You can add several children to it, and they are put underneath each other. */ -void NWidgetBackground::Add(NWidgetBase *nwid) +void NWidgetBackground::Add(std::unique_ptr &&nwid) { if (this->child == nullptr) { - this->child = new NWidgetVertical(); + this->child = std::make_unique(); } - this->child->Add(nwid); + nwid->parent = this->child.get(); + this->child->Add(std::move(nwid)); } /** @@ -2284,8 +2213,9 @@ void NWidgetBackground::Add(NWidgetBase *nwid) void NWidgetBackground::SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post) { if (this->child == nullptr) { - this->child = new NWidgetVertical(); + this->child = std::make_unique(); } + this->child->parent = this; this->child->SetPIP(pip_pre, pip_inter, pip_post); } @@ -2302,8 +2232,9 @@ void NWidgetBackground::SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post) 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 = std::make_unique(); } + this->child->parent = this; this->child->SetPIPRatio(pip_ratio_pre, pip_ratio_inter, pip_ratio_post); } @@ -2388,10 +2319,10 @@ void NWidgetBackground::AssignSizePosition(SizingType sizing, int x, int y, uint } } -void NWidgetBackground::FillNestedArray(NWidgetBase **array, uint length) +void NWidgetBackground::FillWidgetLookup(WidgetLookup &widget_lookup) { - if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; - if (this->child != nullptr) this->child->FillNestedArray(array, length); + if (this->index >= 0) widget_lookup[this->index] = this; + if (this->child != nullptr) this->child->FillWidgetLookup(widget_lookup); } void NWidgetBackground::Draw(const Window *w) @@ -2463,9 +2394,8 @@ NWidgetBase *NWidgetBackground::GetWidgetOfType(WidgetType tp) return nwid; } -NWidgetViewport::NWidgetViewport(int index) : NWidgetCore(NWID_VIEWPORT, INVALID_COLOUR, 1, 1, 0x0, STR_NULL) +NWidgetViewport::NWidgetViewport(WidgetID index) : NWidgetCore(NWID_VIEWPORT, INVALID_COLOUR, index, 1, 1, 0x0, STR_NULL) { - this->SetIndex(index); } void NWidgetViewport::SetupSmallestSize(Window *) @@ -2531,7 +2461,7 @@ void NWidgetViewport::UpdateViewportCoordinates(Window *w) * @param line_height Height of a single row. A negative value means using the vertical resize step of the widget. * @return Row number clicked at. If clicked at a wrong position, #INT_MAX is returned. */ -int Scrollbar::GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding, int line_height) const +int Scrollbar::GetScrolledRowFromWidget(int clickpos, const Window * const w, WidgetID widget, int padding, int line_height) const { uint pos = w->GetRowFromWidget(clickpos, widget, padding, line_height); if (pos != INT_MAX) pos += this->GetPosition(); @@ -2605,7 +2535,7 @@ EventState Scrollbar::UpdateListPositionOnKeyPress(int &list_position, uint16 ke * @param padding Padding to subtract from the size. * @note Updates the position if needed. */ -void Scrollbar::SetCapacityFromWidget(Window *w, int widget, int padding) +void Scrollbar::SetCapacityFromWidget(Window *w, WidgetID widget, int padding) { NWidgetBase *nwid = w->GetWidget(widget); if (this->IsVertical()) { @@ -2619,12 +2549,11 @@ void Scrollbar::SetCapacityFromWidget(Window *w, int widget, int padding) * Scrollbar widget. * @param tp Scrollbar type. (horizontal/vertical) * @param colour Colour of the scrollbar. - * @param index Index in the widget array used by the window system. + * @param index Index of the widget. */ -NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, int index) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL), Scrollbar(tp != NWID_HSCROLLBAR) +NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, WidgetID index) : NWidgetCore(tp, colour, index, 1, 1, 0x0, STR_NULL), Scrollbar(tp != NWID_HSCROLLBAR) { assert(tp == NWID_HSCROLLBAR || tp == NWID_VSCROLLBAR); - this->SetIndex(index); switch (this->type) { case NWID_HSCROLLBAR: @@ -2746,14 +2675,13 @@ Dimension NWidgetLeaf::dropdown_dimension = {0, 0}; * Nested leaf widget. * @param tp Type of leaf widget. * @param colour Colour of the leaf widget. - * @param index Index in the widget array used by the window system. + * @param index Index of the widget. * @param data Data of the widget. * @param tip Tooltip of the widget. */ -NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip) : NWidgetCore(tp, colour, 1, 1, data, tip) +NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, WidgetID index, uint32_t data, StringID tip) : NWidgetCore(tp, colour, index, 1, 1, data, tip) { assert(index >= 0 || tp == WWT_LABEL || tp == WWT_TEXT || tp == WWT_CAPTION || tp == WWT_RESIZEBOX || tp == WWT_SHADEBOX || tp == WWT_DEFSIZEBOX || tp == WWT_DEBUGBOX || tp == WWT_STICKYBOX || tp == WWT_CLOSEBOX); - if (index >= 0) this->SetIndex(index); this->min_x = 0; this->min_y = 0; this->SetResize(0, 0); @@ -3187,72 +3115,62 @@ bool NWidgetLeaf::ButtonHit(const Point &pt) * @param nwid_end Pointer to ending of nested widget parts. * @param dest Address of pointer to use for returning the composed widget. * @param fill_dest Fill the composed widget with child widgets. - * @param biggest_index Pointer to biggest nested widget index in the tree encountered so far. * @return Pointer to remaining nested widget parts. - * @pre \c biggest_index != nullptr. */ -static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetBase **dest, bool *fill_dest, int *biggest_index) +static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr &dest, bool *fill_dest) { - *dest = nullptr; + dest = nullptr; *fill_dest = false; while (nwid_begin < nwid_end) { switch (nwid_begin->type) { case NWID_SPACER: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetSpacer(0, 0); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(0, 0); break; case NWID_HORIZONTAL: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetHorizontal(nwid_begin->u.cont_flags); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.cont_flags); *fill_dest = true; break; case NWID_HORIZONTAL_LTR: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetHorizontalLTR(nwid_begin->u.cont_flags); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.cont_flags); *fill_dest = true; break; case WWT_PANEL: case WWT_INSET: case WWT_FRAME: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetBackground(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index); *fill_dest = true; break; case NWID_VERTICAL: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetVertical(nwid_begin->u.cont_flags); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.cont_flags); *fill_dest = true; break; case NWID_MATRIX: { - if (*dest != nullptr) return nwid_begin; - NWidgetMatrix *nwm = new NWidgetMatrix(); - *dest = nwm; + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.widget.colour, nwid_begin->u.widget.index); *fill_dest = true; - nwm->SetIndex(nwid_begin->u.widget.index); - nwm->SetColour(nwid_begin->u.widget.colour); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); break; } case WPT_FUNCTION: { - if (*dest != nullptr) return nwid_begin; - /* Ensure proper functioning even when the called code simply writes its largest index. */ - int biggest = -1; - *dest = nwid_begin->u.func_ptr(&biggest); - *biggest_index = std::max(*biggest_index, biggest); + if (dest != nullptr) return nwid_begin; + dest = nwid_begin->u.func_ptr(); *fill_dest = false; break; } case WPT_RESIZE: { - NWidgetResizeBase *nwrb = dynamic_cast(*dest); + NWidgetResizeBase *nwrb = dynamic_cast(dest.get()); if (nwrb != nullptr) { assert(nwid_begin->u.xy.x >= 0 && nwid_begin->u.xy.y >= 0); nwrb->SetResize(nwid_begin->u.xy.x, nwid_begin->u.xy.y); @@ -3261,7 +3179,7 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_MINSIZE: { - NWidgetResizeBase *nwrb = dynamic_cast(*dest); + NWidgetResizeBase *nwrb = dynamic_cast(dest.get()); if (nwrb != nullptr) { assert(nwid_begin->u.xy.x >= 0 && nwid_begin->u.xy.y >= 0); nwrb->SetMinimalSize(nwid_begin->u.xy.x, nwid_begin->u.xy.y); @@ -3270,7 +3188,7 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_MINTEXTLINES: { - NWidgetResizeBase *nwrb = dynamic_cast(*dest); + NWidgetResizeBase *nwrb = dynamic_cast(dest.get()); if (nwrb != nullptr) { assert(nwid_begin->u.text_lines.size >= FS_BEGIN && nwid_begin->u.text_lines.size < FS_END); nwrb->SetMinimalTextLines(nwid_begin->u.text_lines.lines, nwid_begin->u.text_lines.spacing, nwid_begin->u.text_lines.size); @@ -3279,7 +3197,7 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_TEXTSTYLE: { - NWidgetCore *nwc = dynamic_cast(*dest); + NWidgetCore *nwc = dynamic_cast(dest.get()); if (nwc != nullptr) { nwc->SetTextStyle(nwid_begin->u.text_style.colour, nwid_begin->u.text_style.size); } @@ -3287,7 +3205,7 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_ALIGNMENT: { - NWidgetCore *nwc = dynamic_cast(*dest); + NWidgetCore *nwc = dynamic_cast(dest.get()); if (nwc != nullptr) { nwc->SetAlignment(nwid_begin->u.align.align); } @@ -3295,13 +3213,13 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_FILL: { - NWidgetResizeBase *nwrb = dynamic_cast(*dest); + NWidgetResizeBase *nwrb = dynamic_cast(dest.get()); if (nwrb != nullptr) nwrb->SetFill(nwid_begin->u.xy.x, nwid_begin->u.xy.y); break; } case WPT_DATATIP: { - NWidgetCore *nwc = dynamic_cast(*dest); + NWidgetCore *nwc = dynamic_cast(dest.get()); if (nwc != nullptr) { nwc->widget_data = nwid_begin->u.data_tip.data; nwc->tool_tip = nwid_begin->u.data_tip.tooltip; @@ -3310,23 +3228,23 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_PADDING: - if (*dest != nullptr) (*dest)->SetPadding(nwid_begin->u.padding); + if (dest != nullptr) dest->SetPadding(nwid_begin->u.padding); break; case WPT_PIPSPACE: { - NWidgetPIPContainer *nwc = dynamic_cast(*dest); + NWidgetPIPContainer *nwc = dynamic_cast(dest.get()); if (nwc != nullptr) nwc->SetPIP(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post); - NWidgetBackground *nwb = dynamic_cast(*dest); + NWidgetBackground *nwb = dynamic_cast(dest.get()); if (nwb != nullptr) nwb->SetPIP(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post); break; } case WPT_PIPRATIO: { - NWidgetPIPContainer *nwc = dynamic_cast(*dest); + NWidgetPIPContainer *nwc = dynamic_cast(dest.get()); 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); + NWidgetBackground *nwb = dynamic_cast(dest.get()); if (nwb != nullptr) nwb->SetPIPRatio(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post); if (unlikely(nwc == nullptr && nwb == nullptr)) throw std::runtime_error("WPT_PIPRATIO requires NWidgetPIPContainer or NWidgetBackground"); @@ -3334,7 +3252,7 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_SCROLLBAR: { - NWidgetCore *nwc = dynamic_cast(*dest); + NWidgetCore *nwc = dynamic_cast(dest.get()); if (nwc != nullptr) { nwc->scrollbar_index = nwid_begin->u.widget.index; } @@ -3345,33 +3263,27 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg return nwid_begin; case NWID_VIEWPORT: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetViewport(nwid_begin->u.widget.index); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.widget.index); break; case NWID_HSCROLLBAR: case NWID_VSCROLLBAR: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetScrollbar(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index); break; case NWID_SELECTION: { - if (*dest != nullptr) return nwid_begin; - NWidgetStacked *nws = new NWidgetStacked(); - *dest = nws; + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.widget.index); *fill_dest = true; - nws->SetIndex(nwid_begin->u.widget.index); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); break; } default: - if (*dest != nullptr) return nwid_begin; + if (dest != nullptr) return nwid_begin; assert((nwid_begin->type & WWT_MASK) < WWT_LAST || (nwid_begin->type & WWT_MASK) == NWID_BUTTON_DROPDOWN); - *dest = new NWidgetLeaf(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index, 0x0, STR_NULL); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); + dest = std::make_unique(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index, 0x0, STR_NULL); break; } nwid_begin++; @@ -3396,37 +3308,34 @@ bool IsContainerWidgetType(WidgetType tp) * @param nwid_begin Pointer to beginning of nested widget parts. * @param nwid_end Pointer to ending of nested widget parts. * @param parent Pointer or container to use for storing the child widgets (*parent == nullptr or *parent == container or background widget). - * @param biggest_index Pointer to biggest nested widget index in the tree. * @return Pointer to remaining nested widget parts. - * @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used. */ -static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetBase **parent, int *biggest_index) +static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr &parent) { /* If *parent == nullptr, only the first widget is read and returned. Otherwise, *parent must point to either * a #NWidgetContainer or a #NWidgetBackground object, and parts are added as much as possible. */ - NWidgetContainer *nwid_cont = dynamic_cast(*parent); - NWidgetBackground *nwid_parent = dynamic_cast(*parent); - assert(*parent == nullptr || (nwid_cont != nullptr && nwid_parent == nullptr) || (nwid_cont == nullptr && nwid_parent != nullptr)); + NWidgetContainer *nwid_cont = dynamic_cast(parent.get()); + NWidgetBackground *nwid_parent = dynamic_cast(parent.get()); + assert(parent == nullptr || (nwid_cont != nullptr && nwid_parent == nullptr) || (nwid_cont == nullptr && nwid_parent != nullptr)); for (;;) { - NWidgetBase *sub_widget = nullptr; + std::unique_ptr sub_widget = nullptr; bool fill_sub = false; - nwid_begin = MakeNWidget(nwid_begin, nwid_end, &sub_widget, &fill_sub, biggest_index); + nwid_begin = MakeNWidget(nwid_begin, nwid_end, sub_widget, &fill_sub); /* Break out of loop when end reached */ if (sub_widget == nullptr) break; /* If sub-widget is a container, recursively fill that container. */ if (fill_sub && IsContainerWidgetType(sub_widget->type)) { - NWidgetBase *sub_ptr = sub_widget; - nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, &sub_ptr, biggest_index); + nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, sub_widget); } /* Add sub_widget to parent container if available, otherwise return the widget to the caller. */ - if (nwid_cont != nullptr) nwid_cont->Add(sub_widget); - if (nwid_parent != nullptr) nwid_parent->Add(sub_widget); + if (nwid_cont != nullptr) nwid_cont->Add(std::move(sub_widget)); + if (nwid_parent != nullptr) nwid_parent->Add(std::move(sub_widget)); if (nwid_cont == nullptr && nwid_parent == nullptr) { - *parent = sub_widget; + parent = std::move(sub_widget); return nwid_begin; } } @@ -3442,19 +3351,17 @@ static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NW * Construct a nested widget tree from an array of parts. * @param nwid_begin Pointer to beginning of nested widget parts. * @param nwid_end Pointer to ending of nested widget parts. - * @param biggest_index Pointer to biggest nested widget index collected in the tree. * @param container Container to add the nested widgets to. In case it is nullptr a vertical container is used. * @return Root of the nested widget tree, a vertical container containing the entire GUI. * @ingroup NestedWidgetParts - * @pre \c biggest_index != nullptr - * @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used. */ -NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetContainer *container) +std::unique_ptr MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr container) { - *biggest_index = -1; - if (container == nullptr) container = new NWidgetVertical(); - NWidgetBase *cont_ptr = container; - MakeWidgetTree(nwid_begin, nwid_end, &cont_ptr, biggest_index); + if (container == nullptr) container = std::make_unique(); + [[maybe_unused]] const NWidgetPart *nwid_part = MakeWidgetTree(nwid_begin, nwid_end, container); +#ifdef WITH_ASSERT + if (unlikely(nwid_part != nwid_end)) throw std::runtime_error("Did not consume all NWidgetParts"); +#endif return container; } @@ -3464,104 +3371,89 @@ NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart * container with a caption widget) and has a shade box widget. * @param nwid_begin Pointer to beginning of nested widget parts. * @param nwid_end Pointer to ending of nested widget parts. - * @param biggest_index Pointer to biggest nested widget index collected in the tree. * @param[out] shade_select Pointer to the inserted shade selection widget (\c nullptr if not unserted). * @return Root of the nested widget tree, a vertical container containing the entire GUI. * @ingroup NestedWidgetParts - * @pre \c biggest_index != nullptr - * @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used. */ -NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetStacked **shade_select) +std::unique_ptr MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetStacked **shade_select) { - *biggest_index = -1; + *shade_select = nullptr; /* Read the first widget recursively from the array. */ - NWidgetBase *nwid = nullptr; - nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, &nwid, biggest_index); + std::unique_ptr nwid = nullptr; + nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, nwid); assert(nwid != nullptr); - NWidgetContainer *root = new NWidgetVertical; - root->Add(nwid); - if (nwid_begin == nwid_end) { // There is no body at all. - *shade_select = nullptr; - return root; - } + NWidgetHorizontal *hor_cont = dynamic_cast(nwid.get()); + + auto root = std::make_unique(); + root->Add(std::move(nwid)); + if (nwid_begin == nwid_end) return root; // There is no body at all. - /* If the first widget looks like a titlebar, treat it as such. - * If it has a shading box, silently add a shade selection widget in the tree. */ - NWidgetHorizontal *hor_cont = dynamic_cast(nwid); - NWidgetContainer *body; if (hor_cont != nullptr && hor_cont->GetWidgetOfType(WWT_CAPTION) != nullptr && hor_cont->GetWidgetOfType(WWT_SHADEBOX) != nullptr) { - *shade_select = new NWidgetStacked; - root->Add(*shade_select); - body = new NWidgetVertical; - (*shade_select)->Add(body); - } else { - *shade_select = nullptr; - body = root; + /* If the first widget has a title bar and a shade box, silently add a shade selection widget in the tree. */ + auto shade_stack = std::make_unique(-1); + *shade_select = shade_stack.get(); + /* Load the remaining parts into the shade stack. */ + shade_stack->Add(MakeNWidgets(nwid_begin, nwid_end, std::make_unique())); + root->Add(std::move(shade_stack)); + return root; } - /* Load the remaining parts into 'body'. */ - int biggest2 = -1; - MakeNWidgets(nwid_begin, nwid_end, &biggest2, body); - - *biggest_index = std::max(*biggest_index, biggest2); - return root; + /* Load the remaining parts into 'root'. */ + return MakeNWidgets(nwid_begin, nwid_end, std::move(root)); } /** * Make a number of rows with button-like graphics, for enabling/disabling each company. - * @param biggest_index Storage for collecting the biggest index used in the returned tree. * @param widget_first The first widget index to use. * @param widget_last The last widget index to use. * @param colour The colour in which to draw the button. * @param max_length Maximal number of company buttons in one row. * @param button_tooltip The tooltip-string of every button. * @return Panel with rows of company buttons. - * @post \c *biggest_index contains the largest used index in the tree. */ -NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip) +std::unique_ptr MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip) { assert(max_length >= 1); - NWidgetVertical *vert = nullptr; // Storage for all rows. - NWidgetHorizontal *hor = nullptr; // Storage for buttons in one row. + std::unique_ptr vert = nullptr; // Storage for all rows. + std::unique_ptr hor = nullptr; // Storage for buttons in one row. int hor_length = 0; Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON, nullptr, ZOOM_LVL_OUT_4X); sprite_size.width += WidgetDimensions::unscaled.matrix.Horizontal(); sprite_size.height += WidgetDimensions::unscaled.matrix.Vertical() + 1; // 1 for the 'offset' of being pressed - for (int widnum = widget_first; widnum <= widget_last; widnum++) { + for (WidgetID widnum = widget_first; widnum <= widget_last; widnum++) { /* Ensure there is room in 'hor' for another button. */ if (hor_length == max_length) { - if (vert == nullptr) vert = new NWidgetVertical(); - vert->Add(hor); + if (vert == nullptr) vert = std::make_unique(); + vert->Add(std::move(hor)); hor = nullptr; hor_length = 0; } if (hor == nullptr) { - hor = new NWidgetHorizontal(); + hor = std::make_unique(); hor_length = 0; } - NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, button_colour, widnum); + auto panel = std::make_unique(WWT_PANEL, button_colour, widnum); panel->SetMinimalSize(sprite_size.width, sprite_size.height); panel->SetFill(1, 1); panel->SetResize(1, 0); panel->SetDataTip(0x0, button_tooltip); - hor->Add(panel); + hor->Add(std::move(panel)); hor_length++; } - *biggest_index = widget_last; if (vert == nullptr) return hor; // All buttons fit in a single row. if (hor_length > 0 && hor_length < max_length) { /* Last row is partial, add a spacer at the end to force all buttons to the left. */ - NWidgetSpacer *spc = new NWidgetSpacer(sprite_size.width, sprite_size.height); + auto spc = std::make_unique(sprite_size.width, sprite_size.height); spc->SetFill(1, 1); spc->SetResize(1, 0); - hor->Add(spc); + hor->Add(std::move(spc)); } - if (hor != nullptr) vert->Add(hor); + if (hor != nullptr) vert->Add(std::move(hor)); return vert; } diff --git a/src/widget_type.h b/src/widget_type.h index c92e969661..07db7b2709 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -17,6 +17,7 @@ #include "gfx_func.h" #include "gfx_type.h" #include "window_type.h" +#include "3rdparty/cpp-btree/btree_map.h" #include @@ -50,7 +51,7 @@ enum ResizeWidgetValues { */ enum WidgetType : uint8 { /* Window widget types. */ - WWT_EMPTY, ///< Empty widget, place holder to reserve space in widget array + WWT_EMPTY, ///< Empty widget, place holder to reserve space in widget tree. WWT_PANEL, ///< Simple depressed panel WWT_INSET, ///< Pressed (inset) panel, most commonly used as combo box _text_ area @@ -87,6 +88,7 @@ enum WidgetType : uint8 { NWID_BUTTON_DROPDOWN, ///< Button with a drop-down. NWID_HSCROLLBAR, ///< Horizontal scrollbar NWID_VSCROLLBAR, ///< Vertical scrollbar + NWID_CUSTOM, ///< General Custom widget. /* Nested widget part types. */ WPT_RESIZE, ///< Widget part for specifying resizing. @@ -133,6 +135,9 @@ enum SizingType { class NWidgetCore; class Scrollbar; +/** Lookup between widget IDs and NWidget objects. */ +using WidgetLookup = btree::btree_map; + /** * Baseclass for nested widgets. * @invariant After initialization, \f$current\_x = smallest\_x + n * resize\_x, for n \geq 0\f$. @@ -147,11 +152,39 @@ public: virtual void SetupSmallestSize(Window *w) = 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; + virtual void FillWidgetLookup(WidgetLookup &widget_lookup) = 0; virtual NWidgetCore *GetWidgetFromPos(int x, int y) = 0; virtual NWidgetBase *GetWidgetOfType(WidgetType tp); + /** + * Get parent widget of type NWID. + * @tparam NWID Type of the nested widget. + * @returns Parent widget, or nullptr if no widget of the specified type is found. + */ + template + NWID *GetParentWidget() + { + for (NWidgetBase *nwid_parent = this->parent; nwid_parent != nullptr; nwid_parent = nwid_parent->parent) { + if (NWID *nwid = dynamic_cast(nwid_parent); nwid != nullptr) return nwid; + } + return nullptr; + } + + /** + * Get parent widget of type NWID. + * @tparam NWID Type of the nested widget. + * @returns Parent widget, or nullptr if no widget of the specified type is found. + */ + template + const NWID *GetParentWidget() const + { + for (const NWidgetBase *nwid_parent = this->parent; nwid_parent != nullptr; nwid_parent = nwid_parent->parent) { + if (const NWID *nwid = dynamic_cast(nwid_parent); nwid != nullptr) return nwid; + } + return nullptr; + } + virtual bool IsHighlighted() const { return false; } virtual TextColour GetHighlightColour() const { return TC_INVALID; } virtual void SetHighlighted([[maybe_unused]] TextColour highlight_colour) {} @@ -217,12 +250,11 @@ public: int pos_x; ///< Horizontal position of top-left corner of the widget in the window. int pos_y; ///< Vertical position of top-left corner of the widget in the window. - NWidgetBase *next; ///< Pointer to next widget in container. Managed by parent container widget. - NWidgetBase *prev; ///< Pointer to previous widget in container. Managed by parent container widget. - RectPadding padding; ///< Padding added to the widget. Managed by parent container widget. (parent container may swap left and right for RTL) RectPadding uz_padding; ///< Unscaled padding, for resize calculation. + NWidgetBase *parent; ///< Parent widget of this widget, automatically filled in when added to container. + inline bool IsOutsideDrawArea() const { if ((int)(this->pos_x + this->current_x) <= _cur_dpi->left || (int)(this->pos_x) >= _cur_dpi->left + _cur_dpi->width) return true; @@ -342,10 +374,9 @@ DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay) */ class NWidgetCore : public NWidgetResizeBase { public: - NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip); + NWidgetCore(WidgetType tp, Colours colour, WidgetID index, uint fill_x, uint fill_y, uint32_t widget_data, StringID tool_tip); - void SetIndex(int index); - void SetDataTip(uint32 widget_data, StringID tool_tip); + void SetDataTip(uint32_t widget_data, StringID tool_tip); void SetToolTip(StringID tool_tip); void SetTextStyle(TextColour colour, FontSize size); void SetAlignment(StringAlignment align); @@ -355,7 +386,7 @@ public: inline void SetDisabled(bool disabled); inline bool IsDisabled() const; - void FillNestedArray(NWidgetBase **array, uint length) override; + void FillWidgetLookup(WidgetLookup &widget_lookup) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; bool IsHighlighted() const override; TextColour GetHighlightColour() const override; @@ -364,10 +395,10 @@ public: NWidgetDisplay disp_flags; ///< Flags that affect display and interaction with the widget. Colours colour; ///< Colour of this widget. - int index; ///< Index of the nested widget in the widget array of the window (\c -1 means 'not used'). - uint32 widget_data; ///< Data of the widget. @see Widget::data + const WidgetID index; ///< Index of the nested widget (\c -1 means 'not used'). + uint32_t widget_data; ///< Data of the widget. @see Widget::data StringID tool_tip; ///< Tooltip of the widget. @see Widget::tootips - int scrollbar_index; ///< Index of an attached scrollbar. + WidgetID scrollbar_index; ///< Index of an attached scrollbar. TextColour highlight_colour; ///< Colour of highlight. TextColour text_colour; ///< Colour of text within widget. FontSize text_size; ///< Size of text within widget. @@ -433,25 +464,23 @@ inline bool NWidgetCore::IsDisabled() const */ class NWidgetContainer : public NWidgetBase { public: - NWidgetContainer(WidgetType tp); - ~NWidgetContainer(); + NWidgetContainer(WidgetType tp) : NWidgetBase(tp) { } void AdjustPaddingForZoom() override; - void Add(NWidgetBase *wid); - void FillNestedArray(NWidgetBase **array, uint length) override; + void Add(std::unique_ptr &&wid); + void FillWidgetLookup(WidgetLookup &widget_lookup) override; void Draw(const Window *w) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; void FillDirtyWidgets(std::vector &dirty_widgets) override; /** Return whether the container is empty. */ - inline bool IsEmpty() { return head == nullptr; } + inline bool IsEmpty() { return this->children.empty(); } NWidgetBase *GetWidgetOfType(WidgetType tp) override; protected: - NWidgetBase *head; ///< Pointer to first widget in container. - NWidgetBase *tail; ///< Pointer to last widget in container. + std::vector> children; ///< Child widgets in contaier. }; /** Display planes with zero size for #NWidgetStacked. */ @@ -475,14 +504,12 @@ enum StackedZeroSizePlanes { */ class NWidgetStacked : public NWidgetContainer { public: - NWidgetStacked(); - - void SetIndex(int index); + NWidgetStacked(WidgetID index); void AdjustPaddingForZoom() override; void SetupSmallestSize(Window *w) 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 FillWidgetLookup(WidgetLookup &widget_lookup) override; void Draw(const Window *w) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; @@ -491,7 +518,7 @@ public: bool SetDisplayedPlane(int plane); int shown_plane; ///< Plane being displayed (for #NWID_SELECTION only). - int index; ///< If non-negative, index in the #Window::nested_array. + const WidgetID index; ///< If non-negative, index in the #Window::widget_lookup. bool independent_planes = false; ///< If true, treat planes as independent for layout purposes. }; @@ -576,26 +603,26 @@ public: */ class NWidgetMatrix : public NWidgetPIPContainer { public: - NWidgetMatrix(); + NWidgetMatrix(Colours colour, WidgetID index); - void SetIndex(int index); - void SetColour(Colours colour); void SetClicked(int clicked); void SetCount(int count); void SetScrollbar(Scrollbar *sb); + int GetCurrentElement() const; void SetupSmallestSize(Window *w) 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 FillWidgetLookup(WidgetLookup &widget_lookup) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; void FillDirtyWidgets(std::vector &dirty_widgets) override; void Draw(const Window *w) override; protected: - int index; ///< If non-negative, index in the #Window::nested_array. + const WidgetID index; ///< If non-negative, index in the #Window::widget_lookup. Colours colour; ///< Colour of this widget. - int clicked; ///< The currently clicked widget. - int count; ///< Amount of valid widgets. + int clicked; ///< The currently clicked element. + int count; ///< Amount of valid elements. + int current_element; ///< The element currently being processed. Scrollbar *sb; ///< The scrollbar we're associated with. private: int widget_w; ///< The width of the child widget including inter spacing. @@ -616,7 +643,7 @@ public: NWidgetSpacer(int width, int height); void SetupSmallestSize(Window *w) override; - void FillNestedArray(NWidgetBase **array, uint length) override; + void FillWidgetLookup(WidgetLookup &widget_lookup) override; void Draw(const Window *w) override; void SetDirty(Window *w) override; @@ -630,10 +657,9 @@ public: */ class NWidgetBackground : public NWidgetCore { public: - NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = nullptr); - ~NWidgetBackground(); + NWidgetBackground(WidgetType tp, Colours colour, WidgetID index, std::unique_ptr child = nullptr); - void Add(NWidgetBase *nwid); + void Add(std::unique_ptr &&nwid); 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); @@ -641,7 +667,7 @@ public: void SetupSmallestSize(Window *w) 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 FillWidgetLookup(WidgetLookup &widget_lookup) override; void Draw(const Window *w) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; @@ -649,7 +675,7 @@ public: void FillDirtyWidgets(std::vector &dirty_widgets) override; private: - NWidgetPIPContainer *child; ///< Child widget. + std::unique_ptr child; ///< Child widget. }; /** @@ -663,7 +689,7 @@ private: */ class NWidgetViewport : public NWidgetCore { public: - NWidgetViewport(int index); + NWidgetViewport(WidgetID index); void SetupSmallestSize(Window *w) override; void Draw(const Window *w) override; @@ -780,7 +806,7 @@ public: this->SetPosition(this->pos); } - void SetCapacityFromWidget(Window *w, int widget, int padding = 0); + void SetCapacityFromWidget(Window *w, WidgetID widget, int padding = 0); /** * Sets the position of the first visible element @@ -829,7 +855,7 @@ public: } } - int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0, int line_height = -1) const; + int GetScrolledRowFromWidget(int clickpos, const Window * const w, WidgetID widget, int padding = 0, int line_height = -1) const; /** * Return an iterator pointing to the element of a scrolled widget that a user clicked in. @@ -842,7 +868,7 @@ public: * @return Iterator to the element clicked at. If clicked at a wrong position, returns as interator to the end of the container. */ template - typename Tcontainer::iterator GetScrolledItemFromWidget(Tcontainer &container, int clickpos, const Window * const w, int widget, int padding = 0, int line_height = -1) const + typename Tcontainer::iterator GetScrolledItemFromWidget(Tcontainer &container, int clickpos, const Window * const w, WidgetID widget, int padding = 0, int line_height = -1) const { assert(this->GetCount() == container.size()); // Scrollbar and container size must match. int row = this->GetScrolledRowFromWidget(clickpos, w, widget, padding, line_height); @@ -863,7 +889,7 @@ public: */ class NWidgetScrollbar : public NWidgetCore, public Scrollbar { public: - NWidgetScrollbar(WidgetType tp, Colours colour, int index); + NWidgetScrollbar(WidgetType tp, Colours colour, WidgetID index); void SetupSmallestSize(Window *w) override; void Draw(const Window *w) override; @@ -883,7 +909,7 @@ private: */ class NWidgetLeaf : public NWidgetCore { public: - NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip); + NWidgetLeaf(WidgetType tp, Colours colour, WidgetID index, uint32_t data, StringID tip); void SetupSmallestSize(Window *w) override; void Draw(const Window *w) override; @@ -1002,7 +1028,7 @@ struct NWidgetPartDataTip { */ struct NWidgetPartWidget { Colours colour; ///< Widget colour. - int16 index; ///< Widget index in the widget array. + WidgetID index; ///< Index of the widget. }; /** @@ -1049,11 +1075,9 @@ struct NWidgetPartAlignment { /** * Pointer to function returning a nested widget. - * @param biggest_index Pointer to storage for collecting the biggest index used in the nested widget. * @return Nested widget (tree). - * @post \c *biggest_index must contain the value of the biggest index in the returned tree. */ -typedef NWidgetBase *NWidgetFunctionType(int *biggest_index); +typedef std::unique_ptr NWidgetFunctionType(); /** * Partial widget specification to allow NWidgets to be written nested. @@ -1315,7 +1339,7 @@ static inline NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, ui * @param index Widget index of the scrollbar. * @ingroup NestedWidgetParts */ -static inline NWidgetPart SetScrollbar(int index) +static inline NWidgetPart SetScrollbar(WidgetID index) { NWidgetPart part; @@ -1329,12 +1353,12 @@ static inline NWidgetPart SetScrollbar(int index) * Widget part function for starting a new 'real' widget. * @param tp Type of the new nested widget. * @param col Colour of the new widget. - * @param idx Index of the widget in the widget array. + * @param idx Index of the widget. * @note with #WWT_PANEL, #WWT_FRAME, #WWT_INSET, a new container is started. * Child widgets must have a index bigger than the parent index. * @ingroup NestedWidgetParts */ -static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx = -1) +static inline NWidgetPart NWidget(WidgetType tp, Colours col, int idx = -1) { NWidgetPart part; @@ -1377,10 +1401,10 @@ static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr) } 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); +std::unique_ptr MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr container); +std::unique_ptr MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetStacked **shade_select); -NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip); +std::unique_ptr MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip); void SetupWidgetDimensions(); diff --git a/src/widgets/ai_widget.h b/src/widgets/ai_widget.h index 964026ff79..23144e0103 100644 --- a/src/widgets/ai_widget.h +++ b/src/widgets/ai_widget.h @@ -13,7 +13,7 @@ #include "../textfile_type.h" /** Widgets of the #AIConfigWindow class. */ -enum AIConfigWidgets { +enum AIConfigWidgets : WidgetID { WID_AIC_BACKGROUND, ///< Window background. WID_AIC_DECREASE_NUMBER, ///< Decrease the number of AIs. WID_AIC_INCREASE_NUMBER, ///< Increase the number of AIs. diff --git a/src/widgets/airport_widget.h b/src/widgets/airport_widget.h index 514a44e88a..4e16f4596e 100644 --- a/src/widgets/airport_widget.h +++ b/src/widgets/airport_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_AIRPORT_WIDGET_H /** Widgets of the #BuildAirToolbarWindow class. */ -enum AirportToolbarWidgets { +enum AirportToolbarWidgets : WidgetID { WID_AT_AIRPORT, ///< Build airport button. WID_AT_DEMOLISH, ///< Demolish button. @@ -19,7 +19,7 @@ enum AirportToolbarWidgets { }; /** Widgets of the #BuildAirportWindow class. */ -enum AirportPickerWidgets { +enum AirportPickerWidgets : WidgetID { WID_AP_CLASS_DROPDOWN, ///< Dropdown of airport classes. WID_AP_AIRPORT_LIST, ///< List of airports. WID_AP_SCROLLBAR, ///< Scrollbar of the list. diff --git a/src/widgets/autoreplace_widget.h b/src/widgets/autoreplace_widget.h index ab0b14aad2..c5d8c158aa 100644 --- a/src/widgets/autoreplace_widget.h +++ b/src/widgets/autoreplace_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_AUTOREPLACE_WIDGET_H /** Widgets of the #ReplaceVehicleWindow class. */ -enum ReplaceVehicleWidgets { +enum ReplaceVehicleWidgets : WidgetID { WID_RV_CAPTION, ///< Caption of the window. /* Sort dropdown at the right. */ diff --git a/src/widgets/bootstrap_widget.h b/src/widgets/bootstrap_widget.h index 16a36cc5b4..073e382907 100644 --- a/src/widgets/bootstrap_widget.h +++ b/src/widgets/bootstrap_widget.h @@ -11,19 +11,19 @@ #define WIDGETS_BOOTSTRAP_WIDGET_H /** Widgets of the #BootstrapBackground class. */ -enum BootstrapBackgroundWidgets { +enum BootstrapBackgroundWidgets : WidgetID { WID_BB_BACKGROUND, ///< Background of the window. }; /** Widgets of the #BootstrapErrmsgWindow class. */ -enum BootstrapErrorMessageWidgets { +enum BootstrapErrorMessageWidgets : WidgetID { WID_BEM_CAPTION, ///< Caption of the window. WID_BEM_MESSAGE, ///< Error message. WID_BEM_QUIT, ///< Quit button. }; /** Widgets of the #BootstrapContentDownloadStatusWindow class. */ -enum BootstrapAskForDownloadWidgets { +enum BootstrapAskForDownloadWidgets : WidgetID { WID_BAFD_QUESTION, ///< The question whether to download. WID_BAFD_YES, ///< An affirmative answer to the question. WID_BAFD_NO, ///< An negative answer to the question. diff --git a/src/widgets/bridge_widget.h b/src/widgets/bridge_widget.h index d9b6adedda..0d8f46362f 100644 --- a/src/widgets/bridge_widget.h +++ b/src/widgets/bridge_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_BRIDGE_WIDGET_H /** Widgets of the #BuildBridgeWindow class. */ -enum BuildBridgeSelectionWidgets { +enum BuildBridgeSelectionWidgets : WidgetID { WID_BBS_CAPTION, ///< Caption of the window. WID_BBS_DROPDOWN_ORDER, ///< Direction of sort dropdown. WID_BBS_DROPDOWN_CRITERIA, ///< Criteria of sort dropdown. diff --git a/src/widgets/build_vehicle_widget.h b/src/widgets/build_vehicle_widget.h index 00a4dcd4f2..13af53a0cb 100644 --- a/src/widgets/build_vehicle_widget.h +++ b/src/widgets/build_vehicle_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_BUILD_VEHICLE_WIDGET_H /** Widgets of the #BuildVehicleWindow class. */ -enum BuildVehicleWidgets { +enum BuildVehicleWidgets : WidgetID { WID_BV_CAPTION, ///< Caption of window. WID_BV_SORT_ASCENDING_DESCENDING, ///< Sort direction. WID_BV_SORT_DROPDOWN, ///< Criteria of sorting dropdown. diff --git a/src/widgets/cheat_widget.h b/src/widgets/cheat_widget.h index b8ee75f52b..204358e6a5 100644 --- a/src/widgets/cheat_widget.h +++ b/src/widgets/cheat_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_CHEAT_WIDGET_H /** Widgets of the #CheatWindow class. */ -enum CheatWidgets { +enum CheatWidgets : WidgetID { WID_C_NOTE, ///< Note on top of panel for use of cheat. WID_C_PANEL, ///< Panel where all cheats are shown in. }; diff --git a/src/widgets/company_widget.h b/src/widgets/company_widget.h index c427d2dc5c..f2a1a10add 100644 --- a/src/widgets/company_widget.h +++ b/src/widgets/company_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_COMPANY_WIDGET_H /** Widgets of the #CompanyWindow class. */ -enum CompanyWidgets { +enum CompanyWidgets : WidgetID { WID_C_CAPTION, ///< Caption of the window. WID_C_FACE, ///< View of the face. @@ -59,7 +59,7 @@ enum CompanyWidgets { }; /** Widgets of the #CompanyFinancesWindow class. */ -enum CompanyFinancesWidgets { +enum CompanyFinancesWidgets : WidgetID { WID_CF_CAPTION, ///< Caption of the window. WID_CF_TOGGLE_SIZE, ///< Toggle windows size. WID_CF_SEL_PANEL, ///< Select panel or nothing. @@ -83,7 +83,7 @@ enum CompanyFinancesWidgets { /** Widgets of the #SelectCompanyLiveryWindow class. */ -enum SelectCompanyLiveryWidgets { +enum SelectCompanyLiveryWidgets : WidgetID { WID_SCL_CAPTION, ///< Caption of window. WID_SCL_CLASS_GENERAL, ///< Class general. WID_SCL_CLASS_RAIL, ///< Class rail. @@ -107,7 +107,7 @@ enum SelectCompanyLiveryWidgets { * Do not change the order of the widgets from WID_SCMF_HAS_MOUSTACHE_EARRING to WID_SCMF_GLASSES_R, * this order is needed for the WE_CLICK event of DrawFaceStringLabel(). */ -enum SelectCompanyManagerFaceWidgets { +enum SelectCompanyManagerFaceWidgets : WidgetID { WID_SCMF_CAPTION, ///< Caption of window. WID_SCMF_TOGGLE_LARGE_SMALL, ///< Toggle for large or small. WID_SCMF_SELECT_FACE, ///< Select face. @@ -175,7 +175,7 @@ enum SelectCompanyManagerFaceWidgets { }; /** Widgets of the #CompanyInfrastructureWindow class. */ -enum CompanyInfrastructureWidgets { +enum CompanyInfrastructureWidgets : WidgetID { WID_CI_CAPTION, ///< Caption of window. WID_CI_DESC, ///< Description. WID_CI_COUNT, ///< Count. @@ -183,7 +183,7 @@ enum CompanyInfrastructureWidgets { }; /** Widgets of the #BuyCompanyWindow class. */ -enum BuyCompanyWidgets { +enum BuyCompanyWidgets : WidgetID { WID_BC_CAPTION, ///< Caption of window. WID_BC_FACE, ///< Face button. WID_BC_QUESTION, ///< Question text. diff --git a/src/widgets/console_widget.h b/src/widgets/console_widget.h index 1bc1be1f67..8f90631824 100644 --- a/src/widgets/console_widget.h +++ b/src/widgets/console_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_CONSOLE_WIDGET_H /** Widgets of the #IConsoleWindow class. */ -enum ConsoleWidgets { +enum ConsoleWidgets : WidgetID { WID_C_BACKGROUND, ///< Background of the console. }; diff --git a/src/widgets/date_widget.h b/src/widgets/date_widget.h index 3b397dae47..45bc4e9966 100644 --- a/src/widgets/date_widget.h +++ b/src/widgets/date_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_DATE_WIDGET_H /** Widgets of the #SetDateWindow class. */ -enum SetDateWidgets { +enum SetDateWidgets : WidgetID { WID_SD_DAY, ///< Dropdown for the day. WID_SD_MONTH, ///< Dropdown for the month. WID_SD_YEAR, ///< Dropdown for the year. diff --git a/src/widgets/depot_widget.h b/src/widgets/depot_widget.h index c162cb8b7d..f94f1263d2 100644 --- a/src/widgets/depot_widget.h +++ b/src/widgets/depot_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_DEPOT_WIDGET_H /** Widgets of the #DepotWindow class. */ -enum DepotWidgets { +enum DepotWidgets : WidgetID { WID_D_CAPTION, ///< Caption of window. WID_D_SELL, ///< Sell button. WID_D_SHOW_SELL_CHAIN, ///< Show sell chain panel. diff --git a/src/widgets/dock_widget.h b/src/widgets/dock_widget.h index f0854ffc08..cd77c2e9af 100644 --- a/src/widgets/dock_widget.h +++ b/src/widgets/dock_widget.h @@ -11,14 +11,14 @@ #define WIDGETS_DOCK_WIDGET_H /** Widgets of the #BuildDocksDepotWindow class. */ -enum BuildDockDepotWidgets { +enum BuildDockDepotWidgets : WidgetID { WID_BDD_BACKGROUND, ///< Background of the window. WID_BDD_X, ///< X-direction button. WID_BDD_Y, ///< Y-direction button. }; /** Widgets of the #BuildDocksToolbarWindow class. */ -enum DockToolbarWidgets { +enum DockToolbarWidgets : WidgetID { WID_DT_CANAL, ///< Build canal button. WID_DT_LOCK, ///< Build lock button. WID_DT_DEMOLISH, ///< Demolish aka dynamite button. diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 7c449c9ebd..705085df3a 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -40,7 +40,7 @@ static WindowDesc _dropdown_desc(__FILE__, __LINE__, /** Drop-down menu window */ struct DropdownWindow : Window { WindowToken parent_wnd_token; ///< Parent window token. - int parent_button; ///< Parent widget number where the window is dropped from. + WidgetID parent_button; ///< Parent widget number where the window is dropped from. Rect wi_rect; ///< Rect of the button that opened the dropdown. const DropDownList list; ///< List with dropdown menu items. int selected_result; ///< Result value of the selected item in the list. @@ -65,7 +65,7 @@ struct DropdownWindow : Window { * @param instant_close Close the window when the mouse button is raised. * @param wi_colour Colour of the parent widget. */ - DropdownWindow(Window *parent, DropDownList &&list, int selected, int button, const Rect wi_rect, bool instant_close, Colours wi_colour, DropDownSyncFocus sync_parent_focus) + DropdownWindow(Window *parent, DropDownList &&list, int selected, WidgetID button, const Rect wi_rect, bool instant_close, Colours wi_colour, DropDownSyncFocus sync_parent_focus) : Window(&_dropdown_desc) , parent_button(button) , wi_rect(wi_rect) @@ -172,7 +172,7 @@ struct DropdownWindow : Window { if (this->position.y < button_rect.top && list_dim.height > widget_dim.height) this->vscroll->UpdatePosition(INT_MAX); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_DM_ITEMS) *size = this->items_dim; } @@ -213,7 +213,7 @@ struct DropdownWindow : Window { return false; } - virtual void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_DM_ITEMS) return; @@ -240,7 +240,7 @@ struct DropdownWindow : Window { } } - virtual void OnClick(Point pt, int widget, int click_count) override + virtual void OnClick(Point pt, WidgetID widget, int click_count) override { if (widget != WID_DM_ITEMS) return; int item; @@ -357,7 +357,7 @@ Dimension GetDropDownListDimension(const DropDownList &list) * @param instant_close Set to true if releasing mouse button should close the * list regardless of where the cursor is. */ -void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool instant_close, DropDownSyncFocus sync_parent_focus) +void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, bool instant_close, DropDownSyncFocus sync_parent_focus) { CloseWindowByClass(WC_DROPDOWN_MENU); new DropdownWindow(w, std::move(list), selected, button, wi_rect, instant_close, wi_colour, sync_parent_focus); @@ -374,7 +374,7 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button * @param instant_close Set to true if releasing mouse button should close the * list regardless of where the cursor is. */ -void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool instant_close, DropDownSyncFocus sync_parent_focus) +void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, DropDownSyncFocus sync_parent_focus) { /* Our parent's button widget is used to determine where to place the drop * down list window. */ @@ -411,7 +411,7 @@ void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, * @param hidden_mask Bitmask for hidden items (items with their bit set are not copied to the dropdown list). * @param width Minimum width of the dropdown menu. */ -void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width, DropDownSyncFocus sync_parent_focus) +void ShowDropDownMenu(Window *w, const StringID *strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width, DropDownSyncFocus sync_parent_focus) { DropDownList list; diff --git a/src/widgets/dropdown_func.h b/src/widgets/dropdown_func.h index 836548b544..85b2240dc1 100644 --- a/src/widgets/dropdown_func.h +++ b/src/widgets/dropdown_func.h @@ -14,7 +14,7 @@ #include "dropdown_type.h" /* Show drop down menu containing a fixed list of strings */ -void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width = 0, DropDownSyncFocus sync_parent_focus = DDSF_NONE); +void ShowDropDownMenu(Window *w, const StringID *strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width = 0, DropDownSyncFocus sync_parent_focus = DDSF_NONE); /* Hide drop down menu of a parent window */ int HideDropDownMenu(Window *pw); diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h index d4f36c281e..8de1790c15 100644 --- a/src/widgets/dropdown_type.h +++ b/src/widgets/dropdown_type.h @@ -219,9 +219,9 @@ using DropDownListCheckedItem = DropDownCheck>; */ typedef std::vector> DropDownList; -void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool instant_close = false, DropDownSyncFocus sync_parent_focus = DDSF_NONE); +void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, bool instant_close = false, DropDownSyncFocus sync_parent_focus = DDSF_NONE); -void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width = 0, bool instant_close = false, DropDownSyncFocus sync_parent_focus = DDSF_NONE); +void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width = 0, bool instant_close = false, DropDownSyncFocus sync_parent_focus = DDSF_NONE); Dimension GetDropDownListDimension(const DropDownList &list); diff --git a/src/widgets/dropdown_widget.h b/src/widgets/dropdown_widget.h index 21223179e9..b9a5f3e17a 100644 --- a/src/widgets/dropdown_widget.h +++ b/src/widgets/dropdown_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_DROPDOWN_WIDGET_H /** Widgets of the #DropdownWindow class. */ -enum DropdownMenuWidgets { +enum DropdownMenuWidgets : WidgetID { WID_DM_ITEMS, ///< Panel showing the dropdown items. WID_DM_SHOW_SCROLL, ///< Hide scrollbar if too few items. WID_DM_SCROLL, ///< Scrollbar. diff --git a/src/widgets/engine_widget.h b/src/widgets/engine_widget.h index 5d3468efc6..e66319ba05 100644 --- a/src/widgets/engine_widget.h +++ b/src/widgets/engine_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_ENGINE_WIDGET_H /** Widgets of the #EnginePreviewWindow class. */ -enum EnginePreviewWidgets { +enum EnginePreviewWidgets : WidgetID { WID_EP_QUESTION, ///< The container for the question. WID_EP_NO, ///< No button. WID_EP_YES, ///< Yes button. diff --git a/src/widgets/error_widget.h b/src/widgets/error_widget.h index 7a7fa4af38..40519644e7 100644 --- a/src/widgets/error_widget.h +++ b/src/widgets/error_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_ERROR_WIDGET_H /** Widgets of the #ErrmsgWindow class. */ -enum ErrorMessageWidgets { +enum ErrorMessageWidgets : WidgetID { WID_EM_CAPTION, ///< Caption of the window. WID_EM_FACE, ///< Error title. WID_EM_MESSAGE, ///< Error message. diff --git a/src/widgets/fios_widget.h b/src/widgets/fios_widget.h index 86995588ed..0d8e723848 100644 --- a/src/widgets/fios_widget.h +++ b/src/widgets/fios_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_FIOS_WIDGET_H /** Widgets of the #SaveLoadWindow class. */ -enum SaveLoadWidgets { +enum SaveLoadWidgets : WidgetID { WID_SL_CAPTION, ///< Caption of the window. WID_SL_SORT_BYNAME, ///< Sort by name button. WID_SL_SORT_BYDATE, ///< Sort by date button. diff --git a/src/widgets/framerate_widget.h b/src/widgets/framerate_widget.h index 49ee2f9528..0192b540c6 100644 --- a/src/widgets/framerate_widget.h +++ b/src/widgets/framerate_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_FRAMERATE_WIDGET_H /** Widgets of the #FramerateWindow class. */ -enum FramerateWindowWidgets { +enum FramerateWindowWidgets : WidgetID { WID_FRW_CAPTION, WID_FRW_RATE_GAMELOOP, WID_FRW_RATE_DRAWING, @@ -26,7 +26,7 @@ enum FramerateWindowWidgets { }; /** Widgets of the #FrametimeGraphWindow class. */ -enum FrametimeGraphWindowWidgets { +enum FrametimeGraphWindowWidgets : WidgetID { WID_FGW_CAPTION, WID_FGW_GRAPH, }; diff --git a/src/widgets/game_widget.h b/src/widgets/game_widget.h index 3a2d2d7082..5b105d9934 100644 --- a/src/widgets/game_widget.h +++ b/src/widgets/game_widget.h @@ -13,7 +13,7 @@ #include "../textfile_type.h" /** Widgets of the #GSConfigWindow class. */ -enum GSConfigWidgets { +enum GSConfigWidgets : WidgetID { WID_GSC_BACKGROUND, ///< Window background. WID_GSC_GSLIST, ///< List with current selected Game Script. WID_GSC_SETTINGS, ///< Panel to draw the Game Script settings on diff --git a/src/widgets/genworld_widget.h b/src/widgets/genworld_widget.h index 03bba336b5..fad02545c0 100644 --- a/src/widgets/genworld_widget.h +++ b/src/widgets/genworld_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_GENWORLD_WIDGET_H /** Widgets of the #GenerateLandscapeWindow class. */ -enum GenerateLandscapeWidgets { +enum GenerateLandscapeWidgets : WidgetID { WID_GL_TEMPERATE, ///< Button with icon "Temperate". WID_GL_ARCTIC, ///< Button with icon "Arctic". WID_GL_TROPICAL, ///< Button with icon "Tropical". @@ -77,7 +77,7 @@ enum GenerateLandscapeWidgets { }; /** Widgets of the #CreateScenarioWindow class. */ -enum CreateScenarioWidgets { +enum CreateScenarioWidgets : WidgetID { WID_CS_TEMPERATE, ///< Select temperate landscape style. WID_CS_ARCTIC, ///< Select arctic landscape style. WID_CS_TROPICAL, ///< Select tropical landscape style. @@ -95,7 +95,7 @@ enum CreateScenarioWidgets { }; /** Widgets of the #GenerateProgressWindow class. */ -enum GenerationProgressWidgets { +enum GenerationProgressWidgets : WidgetID { WID_GP_PROGRESS_BAR, ///< Progress bar. WID_GP_PROGRESS_TEXT, ///< Text with the progress bar. WID_GP_ABORT, ///< Abort button. diff --git a/src/widgets/goal_widget.h b/src/widgets/goal_widget.h index 303eaa69e9..c34749022a 100644 --- a/src/widgets/goal_widget.h +++ b/src/widgets/goal_widget.h @@ -12,7 +12,7 @@ #define WIDGETS_GOAL_WIDGET_H /** Widgets of the #GoalListWindow class. */ -enum GoalListWidgets { +enum GoalListWidgets : WidgetID { WID_GOAL_CAPTION, ///< Caption of the window. WID_GOAL_SELECT_BUTTONS, ///< Selection widget for the title bar button. WID_GOAL_GLOBAL_BUTTON, ///< Button to show global goals. @@ -22,7 +22,7 @@ enum GoalListWidgets { }; /** Widgets of the #GoalQuestionWindow class. */ -enum GoalQuestionWidgets { +enum GoalQuestionWidgets : WidgetID { WID_GQ_CAPTION, ///< Caption of the window. WID_GQ_QUESTION, ///< Question text. WID_GQ_BUTTONS, ///< Buttons selection (between 1, 2 or 3). diff --git a/src/widgets/graph_widget.h b/src/widgets/graph_widget.h index 86921f6e0a..81a9bded53 100644 --- a/src/widgets/graph_widget.h +++ b/src/widgets/graph_widget.h @@ -14,7 +14,7 @@ #include "../company_type.h" /** Widgets of the #GraphLegendWindow class. */ -enum GraphLegendWidgets { +enum GraphLegendWidgets : WidgetID { WID_GL_BACKGROUND, ///< Background of the window. WID_GL_FIRST_COMPANY, ///< First company in the legend. @@ -22,7 +22,7 @@ enum GraphLegendWidgets { }; /** Widgets of the #OperatingProfitGraphWindow class, #IncomeGraphWindow class, #DeliveredCargoGraphWindow class, and #CompanyValueGraphWindow class. */ -enum CompanyValueWidgets { +enum CompanyValueWidgets : WidgetID { WID_CV_KEY_BUTTON, ///< Key button. WID_CV_BACKGROUND, ///< Background of the window. WID_CV_GRAPH, ///< Graph itself. @@ -36,7 +36,7 @@ enum DeliveredCargoGraphWindowWidgets { }; /** Widget of the #PerformanceHistoryGraphWindow class. */ -enum PerformanceHistoryGraphWidgets { +enum PerformanceHistoryGraphWidgets : WidgetID { WID_PHG_KEY, ///< Key button. WID_PHG_DETAILED_PERFORMANCE, ///< Detailed performance. WID_PHG_BACKGROUND, ///< Background of the window. @@ -45,7 +45,7 @@ enum PerformanceHistoryGraphWidgets { }; /** Widget of the #PaymentRatesGraphWindow class. */ -enum CargoPaymentRatesWidgets { +enum CargoPaymentRatesWidgets : WidgetID { WID_CPR_BACKGROUND, ///< Background of the window. WID_CPR_HEADER, ///< Header. WID_CPR_GRAPH, ///< Graph itself. @@ -74,7 +74,7 @@ enum StationCargoWidgets { }; /** Widget of the #PerformanceRatingDetailWindow class. */ -enum PerformanceRatingDetailsWidgets { +enum PerformanceRatingDetailsWidgets : WidgetID { WID_PRD_SCORE_FIRST, ///< First entry in the score list. WID_PRD_SCORE_LAST = WID_PRD_SCORE_FIRST + (SCORE_END - SCORE_BEGIN) - 1, ///< Last entry in the score list. diff --git a/src/widgets/group_widget.h b/src/widgets/group_widget.h index 6b2338fb51..4d31828cea 100644 --- a/src/widgets/group_widget.h +++ b/src/widgets/group_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_GROUP_WIDGET_H /** Widgets of the #VehicleGroupWindow class. */ -enum GroupListWidgets { +enum GroupListWidgets : WidgetID { WID_GL_LIST_VEHICLE, ///< List of the vehicles, this must be first, see: DirtyVehicleListWindowForVehicle WID_GL_CAPTION, ///< Caption of the window. WID_GL_GROUP_BY_ORDER, ///< Group order. diff --git a/src/widgets/help_widget.h b/src/widgets/help_widget.h index 5b898fc01c..d6715d9632 100644 --- a/src/widgets/help_widget.h +++ b/src/widgets/help_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_HELP_WIDGET_H /** Widgets of the #HelpWindow class. */ -enum HelpWindowWidgets { +enum HelpWindowWidgets : WidgetID { WID_HW_README, WID_HW_CHANGELOG, WID_HW_KNOWN_BUGS, diff --git a/src/widgets/highscore_widget.h b/src/widgets/highscore_widget.h index 394b8c9bf7..3cf6fef968 100644 --- a/src/widgets/highscore_widget.h +++ b/src/widgets/highscore_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_HIGHSCORE_WIDGET_H /** Widgets of the #EndGameHighScoreBaseWindow class and #HighScoreWindow class. */ -enum HighscoreWidgets { +enum HighscoreWidgets : WidgetID { WID_H_BACKGROUND, ///< Background of the window. }; diff --git a/src/widgets/industry_widget.h b/src/widgets/industry_widget.h index ee74d90d54..da8de1c58f 100644 --- a/src/widgets/industry_widget.h +++ b/src/widgets/industry_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_INDUSTRY_WIDGET_H /** Widgets of the #BuildIndustryWindow class. */ -enum DynamicPlaceIndustriesWidgets { +enum DynamicPlaceIndustriesWidgets : WidgetID { WID_DPI_SCENARIO_EDITOR_PANE, ///< Pane containing SE-only widgets. WID_DPI_REMOVE_ALL_INDUSTRIES_WIDGET, ///< Remove all industries button. WID_DPI_CREATE_RANDOM_INDUSTRIES_WIDGET, ///< Create random industries button. @@ -23,7 +23,7 @@ enum DynamicPlaceIndustriesWidgets { }; /** Widgets of the #IndustryViewWindow class. */ -enum IndustryViewWidgets { +enum IndustryViewWidgets : WidgetID { WID_IV_CAPTION, ///< Caption of the window. WID_IV_VIEWPORT, ///< Viewport of the industry. WID_IV_INFO, ///< Info of the industry. @@ -32,7 +32,7 @@ enum IndustryViewWidgets { }; /** Widgets of the #IndustryDirectoryWindow class. */ -enum IndustryDirectoryWidgets { +enum IndustryDirectoryWidgets : WidgetID { WID_ID_DROPDOWN_ORDER, ///< Dropdown for the order of the sort. WID_ID_DROPDOWN_CRITERIA, ///< Dropdown for the criteria of the sort. WID_ID_FILTER_BY_ACC_CARGO, ///< Accepted cargo filter dropdown list. @@ -44,7 +44,7 @@ enum IndustryDirectoryWidgets { }; /** Widgets of the #IndustryCargoesWindow class */ -enum IndustryCargoesWidgets { +enum IndustryCargoesWidgets : WidgetID { WID_IC_CAPTION, ///< Caption of the window. WID_IC_NOTIFY, ///< Row of buttons at the bottom. WID_IC_PANEL, ///< Panel that shows the chain. diff --git a/src/widgets/intro_widget.h b/src/widgets/intro_widget.h index 6e5e70eea9..dcefc172be 100644 --- a/src/widgets/intro_widget.h +++ b/src/widgets/intro_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_INTRO_WIDGET_H /** Widgets of the #SelectGameWindow class. */ -enum SelectGameIntroWidgets { +enum SelectGameIntroWidgets : WidgetID { WID_SGI_GENERATE_GAME, ///< Generate game button. WID_SGI_LOAD_GAME, ///< Load game button. WID_SGI_PLAY_SCENARIO, ///< Play scenario button. diff --git a/src/widgets/league_widget.h b/src/widgets/league_widget.h index 381d379a7e..d6f7c13717 100644 --- a/src/widgets/league_widget.h +++ b/src/widgets/league_widget.h @@ -11,12 +11,12 @@ #define WIDGETS_LEAGUE_WIDGET_H /** Widget of the #PerformanceLeagueWindow class. */ -enum PerformanceLeagueWidgets { +enum PerformanceLeagueWidgets : WidgetID { WID_PLT_BACKGROUND, ///< Background of the window. }; /** Widget of the #ScriptLeagueWindow class. */ -enum ScriptLeagueWidgets { +enum ScriptLeagueWidgets : WidgetID { WID_SLT_CAPTION, ///< Caption of the window. WID_SLT_BACKGROUND, ///< Background of the window. }; diff --git a/src/widgets/link_graph_legend_widget.h b/src/widgets/link_graph_legend_widget.h index a0ff68ab07..a8b2357d72 100644 --- a/src/widgets/link_graph_legend_widget.h +++ b/src/widgets/link_graph_legend_widget.h @@ -14,7 +14,7 @@ /** Widgets of the WC_LINKGRAPH_LEGEND. */ -enum LinkGraphLegendWidgets { +enum LinkGraphLegendWidgets : WidgetID { WID_LGL_CAPTION, ///< Caption widget. WID_LGL_SATURATION, ///< Saturation legend. WID_LGL_SATURATION_FIRST, diff --git a/src/widgets/main_widget.h b/src/widgets/main_widget.h index 51627da5c0..8c12f42620 100644 --- a/src/widgets/main_widget.h +++ b/src/widgets/main_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_MAIN_WIDGET_H /** Widgets of the #MainWindow class. */ -enum MainWidgets { +enum MainWidgets : WidgetID { WID_M_VIEWPORT, ///< Main window viewport. }; diff --git a/src/widgets/misc_widget.h b/src/widgets/misc_widget.h index 95e717e197..f7acd8439f 100644 --- a/src/widgets/misc_widget.h +++ b/src/widgets/misc_widget.h @@ -11,18 +11,18 @@ #define WIDGETS_MISC_WIDGET_H /** Widgets of the #LandInfoWindow class. */ -enum LandInfoWidgets { +enum LandInfoWidgets : WidgetID { WID_LI_LOCATION, ///< Scroll to location. WID_LI_BACKGROUND, ///< Background of the window. }; /** Widgets of the #TooltipsWindow class. */ -enum ToolTipsWidgets { +enum ToolTipsWidgets : WidgetID { WID_TT_BACKGROUND, ///< Background of the window. }; /** Widgets of the #AboutWindow class. */ -enum AboutWidgets { +enum AboutWidgets : WidgetID { WID_A_SCROLLING_TEXT, ///< The actually scrolling text. WID_A_WEBSITE, ///< URL of OpenTTD website. WID_A_WEBSITE1, ///< URL of patchpack thread. @@ -31,7 +31,7 @@ enum AboutWidgets { }; /** Widgets of the #QueryStringWindow class. */ -enum QueryStringWidgets { +enum QueryStringWidgets : WidgetID { WID_QS_CAPTION, ///< Caption of the window. WID_QS_TEXT, ///< Text of the query. WID_QS_WARNING, ///< Warning label about password security @@ -41,7 +41,7 @@ enum QueryStringWidgets { }; /** Widgets of the #QueryWindow class. */ -enum QueryWidgets { +enum QueryWidgets : WidgetID { WID_Q_CAPTION, ///< Caption of the window. WID_Q_TEXT, ///< Text of the query. WID_Q_NO, ///< Yes button. @@ -49,7 +49,7 @@ enum QueryWidgets { }; /** Widgets of the #TextfileWindow class. */ -enum TextfileWidgets { +enum TextfileWidgets : WidgetID { WID_TF_CAPTION, ///< The caption of the window. WID_TF_NAVBACK, ///< Navigate back button. WID_TF_NAVFORWARD, ///< Navigate forward button. diff --git a/src/widgets/music_widget.h b/src/widgets/music_widget.h index dc2e685325..bbb0a3e4d0 100644 --- a/src/widgets/music_widget.h +++ b/src/widgets/music_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_MUSIC_WIDGET_H /** Widgets of the #MusicTrackSelectionWindow class. */ -enum MusicTrackSelectionWidgets { +enum MusicTrackSelectionWidgets : WidgetID { WID_MTS_CAPTION, ///< Window caption. WID_MTS_LIST_LEFT, ///< Left button. WID_MTS_PLAYLIST, ///< Playlist. @@ -27,7 +27,7 @@ enum MusicTrackSelectionWidgets { }; /** Widgets of the #MusicWindow class. */ -enum MusicWidgets { +enum MusicWidgets : WidgetID { WID_M_PREV, ///< Previous button. WID_M_NEXT, ///< Next button. WID_M_STOP, ///< Stop button. diff --git a/src/widgets/network_chat_widget.h b/src/widgets/network_chat_widget.h index ccfb467f71..26a3a1e436 100644 --- a/src/widgets/network_chat_widget.h +++ b/src/widgets/network_chat_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_NETWORK_CHAT_WIDGET_H /** Widgets of the #NetworkChatWindow class. */ -enum NetWorkChatWidgets { +enum NetWorkChatWidgets : WidgetID { WID_NC_CLOSE, ///< Close button. WID_NC_BACKGROUND, ///< Background of the window. WID_NC_DESTINATION, ///< Destination. diff --git a/src/widgets/network_content_widget.h b/src/widgets/network_content_widget.h index c8092aefa8..38158272ba 100644 --- a/src/widgets/network_content_widget.h +++ b/src/widgets/network_content_widget.h @@ -13,14 +13,14 @@ #include "../textfile_type.h" /** Widgets of the #NetworkContentDownloadStatusWindow class. */ -enum NetworkContentDownloadStatusWidgets { +enum NetworkContentDownloadStatusWidgets : WidgetID { WID_NCDS_PROGRESS_BAR, ///< Simple progress bar. WID_NCDS_PROGRESS_TEXT, ///< Text explaining what is happening. WID_NCDS_CANCELOK, ///< (Optional) Cancel/OK button. }; /** Widgets of the #NetworkContentListWindow class. */ -enum NetworkContentListWidgets { +enum NetworkContentListWidgets : WidgetID { WID_NCL_BACKGROUND, ///< Resize button. WID_NCL_FILTER_CAPT, ///< Caption for the filter editbox. diff --git a/src/widgets/network_widget.h b/src/widgets/network_widget.h index 087436a516..276874f92e 100644 --- a/src/widgets/network_widget.h +++ b/src/widgets/network_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_NETWORK_WIDGET_H /** Widgets of the #NetworkGameWindow class. */ -enum NetworkGameWidgets { +enum NetworkGameWidgets : WidgetID { WID_NG_MAIN, ///< Main panel. WID_NG_CLIENT_LABEL, ///< Label in front of client name edit box. @@ -49,7 +49,7 @@ enum NetworkGameWidgets { }; /** Widgets of the #NetworkStartServerWindow class. */ -enum NetworkStartServerWidgets { +enum NetworkStartServerWidgets : WidgetID { WID_NSS_BACKGROUND, ///< Background of the window. WID_NSS_GAMENAME_LABEL, ///< Label for the game name. WID_NSS_GAMENAME, ///< Background for editbox to set game name. @@ -74,7 +74,7 @@ enum NetworkStartServerWidgets { }; /** Widgets of the #NetworkClientListWindow class. */ -enum ClientListWidgets { +enum ClientListWidgets : WidgetID { WID_CL_PANEL, ///< Panel of the window. WID_CL_SERVER_SELECTOR, ///< Selector to hide the server frame. WID_CL_SERVER_NAME, ///< Server name. @@ -91,14 +91,14 @@ enum ClientListWidgets { }; /** Widgets of the #NetworkJoinStatusWindow class. */ -enum NetworkJoinStatusWidgets { +enum NetworkJoinStatusWidgets : WidgetID { WID_NJS_PROGRESS_BAR, ///< Simple progress bar. WID_NJS_PROGRESS_TEXT, ///< Text explaining what is happening. WID_NJS_CANCELOK, ///< Cancel / OK button. }; /** Widgets of the #NetworkCompanyPasswordWindow class. */ -enum NetworkCompanyPasswordWidgets { +enum NetworkCompanyPasswordWidgets : WidgetID { WID_NCP_BACKGROUND, ///< Background of the window. WID_NCP_LABEL, ///< Label in front of the password field. WID_NCP_PASSWORD, ///< Input field for the password. @@ -109,7 +109,7 @@ enum NetworkCompanyPasswordWidgets { }; /** Widgets of the #NetworkAskRelayWindow class. */ -enum NetworkAskRelayWidgets { +enum NetworkAskRelayWidgets : WidgetID { WID_NAR_CAPTION, ///< Caption of the window. WID_NAR_TEXT, ///< Text in the window. WID_NAR_NO, ///< "No" button. @@ -118,7 +118,7 @@ enum NetworkAskRelayWidgets { }; /** Widgets of the #NetworkAskSurveyWindow class. */ -enum NetworkAskSurveyWidgets { +enum NetworkAskSurveyWidgets : WidgetID { WID_NAS_CAPTION, ///< Caption of the window. WID_NAS_TEXT, ///< Text in the window. WID_NAS_PREVIEW, ///< "Preview" button. diff --git a/src/widgets/newgrf_debug_widget.h b/src/widgets/newgrf_debug_widget.h index ea68a2f838..6d19691f44 100644 --- a/src/widgets/newgrf_debug_widget.h +++ b/src/widgets/newgrf_debug_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_NEWGRF_DEBUG_WIDGET_H /** Widgets of the #NewGRFInspectWindow class. */ -enum NewGRFInspectWidgets { +enum NewGRFInspectWidgets : WidgetID { WID_NGRFI_CAPTION, ///< The caption bar of course. WID_NGRFI_PARENT, ///< Inspect the parent. WID_NGRFI_VEH_PREV, ///< Go to previous vehicle in chain. @@ -32,7 +32,7 @@ enum NewGRFInspectWidgets { }; /** Widgets of the #SpriteAlignerWindow class. */ -enum SpriteAlignerWidgets { +enum SpriteAlignerWidgets : WidgetID { WID_SA_CAPTION, ///< Caption of the window. WID_SA_PREVIOUS, ///< Skip to the previous sprite. WID_SA_GOTO, ///< Go to a given sprite. diff --git a/src/widgets/newgrf_widget.h b/src/widgets/newgrf_widget.h index da4e4d584d..d4bab8e200 100644 --- a/src/widgets/newgrf_widget.h +++ b/src/widgets/newgrf_widget.h @@ -14,7 +14,7 @@ #include "../textfile_type.h" /** Widgets of the #NewGRFParametersWindow class. */ -enum NewGRFParametersWidgets { +enum NewGRFParametersWidgets : WidgetID { 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. @@ -32,7 +32,7 @@ enum NewGRFParametersWidgets { }; /** Widgets of the #NewGRFWindow class. */ -enum NewGRFStateWidgets { +enum NewGRFStateWidgets : WidgetID { WID_NS_PRESET_LIST, ///< Active NewGRF preset. WID_NS_PRESET_SAVE, ///< Save list of active NewGRFs as presets. WID_NS_PRESET_DELETE, ///< Delete active preset. @@ -63,7 +63,7 @@ enum NewGRFStateWidgets { }; /** Widgets of the #SavePresetWindow class. */ -enum SavePresetWidgets { +enum SavePresetWidgets : WidgetID { WID_SVP_PRESET_LIST, ///< List with available preset names. WID_SVP_SCROLLBAR, ///< Scrollbar for the list available preset names. WID_SVP_EDITBOX, ///< Edit box for changing the preset name. @@ -72,7 +72,7 @@ enum SavePresetWidgets { }; /** Widgets of the #ScanProgressWindow class. */ -enum ScanProgressWidgets { +enum ScanProgressWidgets : WidgetID { WID_SP_PROGRESS_BAR, ///< Simple progress bar. WID_SP_PROGRESS_TEXT, ///< Text explaining what is happening. }; diff --git a/src/widgets/news_widget.h b/src/widgets/news_widget.h index e5b8934439..68d59fa133 100644 --- a/src/widgets/news_widget.h +++ b/src/widgets/news_widget.h @@ -13,7 +13,7 @@ #include "../news_type.h" /** Widgets of the #NewsWindow class. */ -enum NewsWidgets { +enum NewsWidgets : WidgetID { WID_N_PANEL, ///< Panel of the window. WID_N_TITLE, ///< Title of the company news. WID_N_HEADLINE, ///< The news headline. @@ -35,7 +35,7 @@ enum NewsWidgets { }; /** Widgets of the #MessageHistoryWindow class. */ -enum MessageHistoryWidgets { +enum MessageHistoryWidgets : WidgetID { WID_MH_STICKYBOX, ///< Stickybox. WID_MH_BACKGROUND, ///< Background of the window. WID_MH_SCROLLBAR, ///< Scrollbar for the list. diff --git a/src/widgets/object_widget.h b/src/widgets/object_widget.h index 9afb783c56..9adf13dde7 100644 --- a/src/widgets/object_widget.h +++ b/src/widgets/object_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_OBJECT_WIDGET_H /** Widgets of the #BuildObjectWindow class. */ -enum BuildObjectWidgets { +enum BuildObjectWidgets : WidgetID { WID_BO_FILTER, ///< The filter text box for the object list. WID_BO_CLASS_LIST, ///< The list with classes. WID_BO_SCROLLBAR, ///< The scrollbar associated with the list. diff --git a/src/widgets/order_widget.h b/src/widgets/order_widget.h index bdaace516c..a0775c31c5 100644 --- a/src/widgets/order_widget.h +++ b/src/widgets/order_widget.h @@ -13,7 +13,7 @@ #include "../cargo_type.h" /** Widgets of the #OrdersWindow class. */ -enum OrderWidgets { +enum OrderWidgets : WidgetID { WID_O_CAPTION, ///< Caption of the window. WID_O_TIMETABLE_VIEW, ///< Toggle timetable view. WID_O_ORDER_LIST, ///< Order list panel. diff --git a/src/widgets/osk_widget.h b/src/widgets/osk_widget.h index ccda502fff..ae84037b53 100644 --- a/src/widgets/osk_widget.h +++ b/src/widgets/osk_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_OSK_WIDGET_H /** Widgets of the #OskWindow class. */ -enum OnScreenKeyboardWidgets { +enum OnScreenKeyboardWidgets : WidgetID { WID_OSK_CAPTION, ///< Caption of window. WID_OSK_TEXT, ///< Edit box. WID_OSK_CANCEL, ///< Cancel key. diff --git a/src/widgets/plans_widget.h b/src/widgets/plans_widget.h index 1fb8a02edc..0e3a07faf5 100644 --- a/src/widgets/plans_widget.h +++ b/src/widgets/plans_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_PLANS_WIDGET_H /** Widgets of the #PlansWindow class. */ -enum PlansWidgets { +enum PlansWidgets : WidgetID { WID_PLN_CAPTION, ///< Caption of the window. WID_PLN_LIST, WID_PLN_SCROLLBAR, diff --git a/src/widgets/rail_widget.h b/src/widgets/rail_widget.h index fc5ba35a1b..9289121587 100644 --- a/src/widgets/rail_widget.h +++ b/src/widgets/rail_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_RAIL_WIDGET_H /** Widgets of the #BuildRailToolbarWindow class. */ -enum RailToolbarWidgets { +enum RailToolbarWidgets : WidgetID { /* Name starts with RA instead of R, because of collision with RoadToolbarWidgets */ WID_RAT_CAPTION, ///< Caption of the window. WID_RAT_BUILD_NS, ///< Build rail along the game view Y axis. @@ -35,7 +35,7 @@ enum RailToolbarWidgets { }; /** Widgets of the #BuildRailStationWindow class. */ -enum BuildRailStationWidgets { +enum BuildRailStationWidgets : WidgetID { /* Name starts with BRA instead of BR, because of collision with BuildRoadStationWidgets */ WID_BRAS_PLATFORM_DIR_X, ///< Button to select '/' view. WID_BRAS_PLATFORM_DIR_Y, ///< Button to select '\' view. @@ -81,7 +81,7 @@ enum BuildRailStationWidgets { }; /** Widgets of the #BuildSignalWindow class. */ -enum BuildSignalWidgets { +enum BuildSignalWidgets : WidgetID { WID_BS_CAPTION, ///< Caption for the Signal Selection window. WID_BS_TOGGLE_SIZE, ///< Toggle showing advanced signal types. WID_BS_SEMAPHORE_NORM, ///< Build a semaphore normal block signal @@ -125,7 +125,7 @@ enum BuildSignalWidgets { }; /** Widgets of the #BuildRailDepotWindow class. */ -enum BuildRailDepotWidgets { +enum BuildRailDepotWidgets : WidgetID { /* Name starts with BRA instead of BR, because of collision with BuildRoadDepotWidgets */ WID_BRAD_DEPOT_NE, ///< Build a depot with the entrance in the north east. WID_BRAD_DEPOT_SE, ///< Build a depot with the entrance in the south east. @@ -134,7 +134,7 @@ enum BuildRailDepotWidgets { }; /** Widgets of the #BuildRailWaypointWindow class. */ -enum BuildRailWaypointWidgets { +enum BuildRailWaypointWidgets : WidgetID { WID_BRW_FILTER, ///< Text filter. WID_BRW_WAYPOINT_MATRIX, ///< Matrix with waypoints. WID_BRW_WAYPOINT, ///< A single waypoint. diff --git a/src/widgets/road_widget.h b/src/widgets/road_widget.h index 96e9b06699..c86e8de6a1 100644 --- a/src/widgets/road_widget.h +++ b/src/widgets/road_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_ROAD_WIDGET_H /** Widgets of the #BuildRoadToolbarWindow class. */ -enum RoadToolbarWidgets { +enum RoadToolbarWidgets : WidgetID { /* Name starts with RO instead of R, because of collision with RailToolbarWidgets */ WID_ROT_CAPTION, ///< Caption of the window WID_ROT_ROAD_X, ///< Build road in x-direction. @@ -32,7 +32,7 @@ enum RoadToolbarWidgets { }; /** Widgets of the #BuildRoadDepotWindow class. */ -enum BuildRoadDepotWidgets { +enum BuildRoadDepotWidgets : WidgetID { /* Name starts with BRO instead of BR, because of collision with BuildRailDepotWidgets */ WID_BROD_CAPTION, ///< Caption of the window. WID_BROD_DEPOT_NE, ///< Depot with NE entry. @@ -42,7 +42,7 @@ enum BuildRoadDepotWidgets { }; /** Widgets of the #BuildRoadStationWindow class. */ -enum BuildRoadStationWidgets { +enum BuildRoadStationWidgets : WidgetID { /* Name starts with BRO instead of BR, because of collision with BuildRailStationWidgets */ WID_BROS_CAPTION, ///< Caption of the window. WID_BROS_STATION_NE, ///< Terminal station with NE entry. @@ -71,7 +71,7 @@ enum BuildRoadStationWidgets { }; /** Widgets of the #BuildRoadWaypointWindow class. */ -enum BuildRoadWaypointWidgets { +enum BuildRoadWaypointWidgets : WidgetID { WID_BROW_FILTER, ///< Text filter. WID_BROW_WAYPOINT_MATRIX, ///< Matrix with waypoints. WID_BROW_WAYPOINT, ///< A single waypoint. diff --git a/src/widgets/screenshot_widget.h b/src/widgets/screenshot_widget.h index 62c380a28d..cdf7526f43 100644 --- a/src/widgets/screenshot_widget.h +++ b/src/widgets/screenshot_widget.h @@ -12,7 +12,7 @@ /** Widgets of the #ScreenshotWindow class. */ -enum ScreenshotWindowWidgets { +enum ScreenshotWindowWidgets : WidgetID { WID_SC_TAKE, ///< Button for taking a normal screenshot WID_SC_TAKE_ZOOMIN, ///< Button for taking a zoomed in screenshot WID_SC_TAKE_DEFAULTZOOM, ///< Button for taking a screenshot at normal zoom diff --git a/src/widgets/script_widget.h b/src/widgets/script_widget.h index d4ba17e452..253e1673ed 100644 --- a/src/widgets/script_widget.h +++ b/src/widgets/script_widget.h @@ -13,7 +13,7 @@ #include "../company_type.h" /** Widgets of the #ScriptListWindow class. */ -enum ScriptListWidgets { +enum ScriptListWidgets : WidgetID { WID_SCRL_CAPTION, ///< Caption of the window. WID_SCRL_LIST, ///< The matrix with all available Scripts. WID_SCRL_SCROLLBAR, ///< Scrollbar next to the Script list. @@ -23,7 +23,7 @@ enum ScriptListWidgets { }; /** Widgets of the #ScriptSettingsWindow class. */ -enum ScriptSettingsWidgets { +enum ScriptSettingsWidgets : WidgetID { WID_SCRS_CAPTION, ///< Caption of the window. WID_SCRS_BACKGROUND, ///< Panel to draw the settings on. WID_SCRS_SCROLLBAR, ///< Scrollbar to scroll through all settings. @@ -34,7 +34,7 @@ enum ScriptSettingsWidgets { }; /** Widgets of the #ScriptDebugWindow class. */ -enum ScriptDebugWidgets { +enum ScriptDebugWidgets : WidgetID { WID_SCRD_VIEW, ///< The row of company buttons. WID_SCRD_NAME_TEXT, ///< Name of the current selected. WID_SCRD_SETTINGS, ///< Settings button. diff --git a/src/widgets/settings_widget.h b/src/widgets/settings_widget.h index 06b94bb049..6bc7072c33 100644 --- a/src/widgets/settings_widget.h +++ b/src/widgets/settings_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_SETTINGS_WIDGET_H /** Widgets of the #GameOptionsWindow class. */ -enum GameOptionsWidgets { +enum GameOptionsWidgets : WidgetID { WID_GO_TAB_GENERAL, ///< General tab. WID_GO_TAB_GRAPHICS, ///< Graphics tab. WID_GO_TAB_SOUND, ///< Sound tab. @@ -55,7 +55,7 @@ enum GameOptionsWidgets { }; /** Widgets of the #GameSettingsWindow class. */ -enum GameSettingsWidgets { +enum GameSettingsWidgets : WidgetID { WID_GS_FILTER, ///< Text filter. WID_GS_OPTIONSPANEL, ///< Panel widget containing the option lists. WID_GS_SCROLLBAR, ///< Scrollbar. @@ -72,7 +72,7 @@ enum GameSettingsWidgets { }; /** Widgets of the #CustomCurrencyWindow class. */ -enum CustomCurrencyWidgets { +enum CustomCurrencyWidgets : WidgetID { WID_CC_RATE_DOWN, ///< Down button. WID_CC_RATE_UP, ///< Up button. WID_CC_RATE, ///< Rate of currency. diff --git a/src/widgets/sign_widget.h b/src/widgets/sign_widget.h index 1a05dd349b..0ab5fe060d 100644 --- a/src/widgets/sign_widget.h +++ b/src/widgets/sign_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_SIGN_WIDGET_H /** Widgets of the #SignListWindow class. */ -enum SignListWidgets { +enum SignListWidgets : WidgetID { /* Name starts with SI instead of S, because of collision with SaveLoadWidgets */ WID_SIL_CAPTION, ///< Caption of the window. WID_SIL_LIST, ///< List of signs. @@ -22,7 +22,7 @@ enum SignListWidgets { }; /** Widgets of the #SignWindow class. */ -enum QueryEditSignWidgets { +enum QueryEditSignWidgets : WidgetID { WID_QES_CAPTION, ///< Caption of the window. WID_QES_LOCATION, ///< Scroll to sign location. WID_QES_TEXT, ///< Text of the query. diff --git a/src/widgets/smallmap_widget.h b/src/widgets/smallmap_widget.h index 1ad9513296..5a999a2069 100644 --- a/src/widgets/smallmap_widget.h +++ b/src/widgets/smallmap_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_SMALLMAP_WIDGET_H /** Widgets of the #SmallMapWindow class. */ -enum SmallMapWidgets { +enum SmallMapWidgets : WidgetID { WID_SM_CAPTION, ///< Caption of the window. WID_SM_MAP_BORDER, ///< Border around the smallmap. WID_SM_MAP, ///< Panel containing the smallmap. diff --git a/src/widgets/station_widget.h b/src/widgets/station_widget.h index ed36fe5b0c..6cf8ecdf2b 100644 --- a/src/widgets/station_widget.h +++ b/src/widgets/station_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_STATION_WIDGET_H /** Widgets of the #StationViewWindow class. */ -enum StationViewWidgets { +enum StationViewWidgets : WidgetID { WID_SV_CAPTION, ///< Caption of the window. WID_SV_GROUP, ///< label for "group by" WID_SV_GROUP_BY, ///< 'Group by' button @@ -34,7 +34,7 @@ enum StationViewWidgets { }; /** Widgets of the #CompanyStationsWindow class. */ -enum StationListWidgets { +enum StationListWidgets : WidgetID { /* Name starts with ST instead of S, because of collision with SaveLoadWidgets */ WID_STL_CAPTION, ///< Caption of the window. WID_STL_LIST, ///< The main panel, list of stations. @@ -58,7 +58,7 @@ enum StationListWidgets { }; /** Widgets of the #SelectStationWindow class. */ -enum JoinStationWidgets { +enum JoinStationWidgets : WidgetID { WID_JS_CAPTION, // Caption of the window. WID_JS_PANEL, // Main panel. WID_JS_SCROLLBAR, // Scrollbar of the panel. diff --git a/src/widgets/statusbar_widget.h b/src/widgets/statusbar_widget.h index bb8149e461..dae3efb5b9 100644 --- a/src/widgets/statusbar_widget.h +++ b/src/widgets/statusbar_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_STATUSBAR_WIDGET_H /** Widgets of the #StatusBarWindow class. */ -enum StatusbarWidgets { +enum StatusbarWidgets : WidgetID { WID_S_LEFT, ///< Left part of the statusbar; date is shown there. WID_S_MIDDLE, ///< Middle part; current news or company name or *** SAVING *** or *** PAUSED ***. WID_S_RIGHT, ///< Right part; bank balance. diff --git a/src/widgets/story_widget.h b/src/widgets/story_widget.h index 3492aed419..ce3ffd5dff 100644 --- a/src/widgets/story_widget.h +++ b/src/widgets/story_widget.h @@ -12,7 +12,7 @@ #define WIDGETS_STORY_WIDGET_H /** Widgets of the #GoalListWindow class. */ -enum StoryBookWidgets { +enum StoryBookWidgets : WidgetID { WID_SB_CAPTION, ///< Caption of the window. WID_SB_SEL_PAGE, ///< Page selector. WID_SB_PAGE_PANEL,///< Page body. diff --git a/src/widgets/subsidy_widget.h b/src/widgets/subsidy_widget.h index b3edd897c5..a2dfe8d1e8 100644 --- a/src/widgets/subsidy_widget.h +++ b/src/widgets/subsidy_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_SUBSIDY_WIDGET_H /** Widgets of the #SubsidyListWindow class. */ -enum SubsidyListWidgets { +enum SubsidyListWidgets : WidgetID { /* Name starts with SU instead of S, because of collision with SaveLoadWidgets. */ WID_SUL_PANEL, ///< Main panel of window. WID_SUL_SCROLLBAR, ///< Scrollbar of panel. diff --git a/src/widgets/terraform_widget.h b/src/widgets/terraform_widget.h index c04cdd567c..52cfcac30d 100644 --- a/src/widgets/terraform_widget.h +++ b/src/widgets/terraform_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TERRAFORM_WIDGET_H /** Widgets of the #TerraformToolbarWindow class. */ -enum TerraformToolbarWidgets { +enum TerraformToolbarWidgets : WidgetID { WID_TT_SHOW_PLACE_OBJECT, ///< Should the place object button be shown? WID_TT_BUTTONS_START, ///< Start of pushable buttons. WID_TT_LOWER_LAND = WID_TT_BUTTONS_START, ///< Lower land button. @@ -28,7 +28,7 @@ enum TerraformToolbarWidgets { }; /** Widgets of the #ScenarioEditorLandscapeGenerationWindow class. */ -enum EditorTerraformToolbarWidgets { +enum EditorTerraformToolbarWidgets : WidgetID { WID_ETT_SHOW_PLACE_DESERT, ///< Should the place desert button be shown? WID_ETT_SHOW_PUBLIC_ROADS, ///< Should the public roads button be shown? WID_ETT_START, ///< Used for iterations. diff --git a/src/widgets/timetable_widget.h b/src/widgets/timetable_widget.h index 8dcecaa080..739c788309 100644 --- a/src/widgets/timetable_widget.h +++ b/src/widgets/timetable_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TIMETABLE_WIDGET_H /** Widgets of the #TimetableWindow class. */ -enum VehicleTimetableWidgets { +enum VehicleTimetableWidgets : WidgetID { WID_VT_CAPTION, ///< Caption of the window. WID_VT_ORDER_VIEW, ///< Order view. WID_VT_TIMETABLE_PANEL, ///< Timetable panel. diff --git a/src/widgets/toolbar_widget.h b/src/widgets/toolbar_widget.h index d68de49700..36b53516af 100644 --- a/src/widgets/toolbar_widget.h +++ b/src/widgets/toolbar_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TOOLBAR_WIDGET_H /** Widgets of the #MainToolbarWindow class. */ -enum ToolbarNormalWidgets { +enum ToolbarNormalWidgets : WidgetID { WID_TN_PAUSE, ///< Pause the game. WID_TN_FAST_FORWARD, ///< Fast forward the game. WID_TN_SETTINGS, ///< Settings menu. @@ -49,7 +49,7 @@ enum ToolbarNormalWidgets { }; /** Widgets of the #ScenarioEditorToolbarWindow class. */ -enum ToolbarEditorWidgets { +enum ToolbarEditorWidgets : WidgetID { WID_TE_PAUSE, ///< Pause the game. WID_TE_FAST_FORWARD, ///< Fast forward the game. WID_TE_SETTINGS, ///< Settings menu. diff --git a/src/widgets/town_widget.h b/src/widgets/town_widget.h index 85901f4587..d20af2f118 100644 --- a/src/widgets/town_widget.h +++ b/src/widgets/town_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TOWN_WIDGET_H /** Widgets of the #TownDirectoryWindow class. */ -enum TownDirectoryWidgets { +enum TownDirectoryWidgets : WidgetID { WID_TD_SORT_ORDER, ///< Direction of sort dropdown. WID_TD_SORT_CRITERIA, ///< Criteria of sort dropdown. WID_TD_FILTER, ///< Filter of name. @@ -21,7 +21,7 @@ enum TownDirectoryWidgets { }; /** Widgets of the #TownAuthorityWindow class. */ -enum TownAuthorityWidgets { +enum TownAuthorityWidgets : WidgetID { WID_TA_CAPTION, ///< Caption of window. WID_TA_ZONE_BUTTON, ///< Turn on/off showing local authority zone. WID_TA_RATING_INFO, ///< Overview with ratings for each company. @@ -34,7 +34,7 @@ enum TownAuthorityWidgets { }; /** Widgets of the #TownViewWindow class. */ -enum TownViewWidgets { +enum TownViewWidgets : WidgetID { WID_TV_CAPTION, ///< Caption of window. WID_TV_VIEWPORT, ///< View of the center of the town. WID_TV_INFO, ///< General information about the town. @@ -47,7 +47,7 @@ enum TownViewWidgets { }; /** Widgets of the #FoundTownWindow class. */ -enum TownFoundingWidgets { +enum TownFoundingWidgets : WidgetID { WID_TF_NEW_TOWN, ///< Create a new town. WID_TF_RANDOM_TOWN, ///< Randomly place a town. WID_TF_MANY_RANDOM_TOWNS, ///< Randomly place many towns. @@ -67,7 +67,7 @@ enum TownFoundingWidgets { }; /** Widgets of the #HousePickerWindow class. */ -enum HousePickerWidgets { +enum HousePickerWidgets : WidgetID { WID_HP_CAPTION, WID_HP_MAIN_PANEL_SEL, ///< Selection widget to show/hide the main panel. WID_HP_HOUSE_SETS_SEL, ///< Selection widget to show/hide the list of house sets. @@ -88,7 +88,7 @@ enum HousePickerWidgets { }; /** Widgets of the #SelectTownWindow class. */ -enum SelectTownWidgets { +enum SelectTownWidgets : WidgetID { WID_ST_CAPTION, ///< Caption of the window. WID_ST_PANEL, ///< Main panel. WID_ST_SCROLLBAR, ///< Scrollbar of the panel. diff --git a/src/widgets/transparency_widget.h b/src/widgets/transparency_widget.h index 79a0f4bb12..a7885e24c8 100644 --- a/src/widgets/transparency_widget.h +++ b/src/widgets/transparency_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TRANSPARENCY_WIDGET_H /** Widgets of the #TransparenciesWindow class. */ -enum TransparencyToolbarWidgets { +enum TransparencyToolbarWidgets : WidgetID { /* Button row. */ WID_TT_BEGIN, ///< First toggle button. WID_TT_SIGNS = WID_TT_BEGIN, ///< Signs background transparency toggle button. diff --git a/src/widgets/tree_widget.h b/src/widgets/tree_widget.h index b046ea7f98..9cdc5a855c 100644 --- a/src/widgets/tree_widget.h +++ b/src/widgets/tree_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TREE_WIDGET_H /** Widgets of the #BuildTreesWindow class. */ -enum BuildTreesWidgets { +enum BuildTreesWidgets : WidgetID { WID_BT_TYPE_RANDOM, ///< Button to build random type of tree. WID_BT_SE_PANE, ///< Selection pane to show/hide scenario editor tools. WID_BT_MODE_NORMAL, ///< Select normal/rectangle planting mode. diff --git a/src/widgets/vehicle_widget.h b/src/widgets/vehicle_widget.h index fe337b6fbd..5b45ed190c 100644 --- a/src/widgets/vehicle_widget.h +++ b/src/widgets/vehicle_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_VEHICLE_WIDGET_H /** Widgets of the #VehicleViewWindow class. */ -enum VehicleViewWidgets { +enum VehicleViewWidgets : WidgetID { WID_VV_CAPTION, ///< Caption of window. WID_VV_VIEWPORT, ///< Viewport widget. WID_VV_START_STOP, ///< Start or stop this vehicle, and show information about the current state. @@ -31,7 +31,7 @@ enum VehicleViewWidgets { }; /** Widgets of the #RefitWindow class. */ -enum VehicleRefitWidgets { +enum VehicleRefitWidgets : WidgetID { WID_VR_CAPTION, ///< Caption of window. WID_VR_VEHICLE_PANEL_DISPLAY, ///< Display with a representation of the vehicle to refit. WID_VR_SHOW_HSCROLLBAR, ///< Selection widget for the horizontal scrollbar. @@ -45,7 +45,7 @@ enum VehicleRefitWidgets { }; /** Widgets of the #VehicleDetailsWindow class. */ -enum VehicleDetailsWidgets { +enum VehicleDetailsWidgets : WidgetID { WID_VD_CAPTION, ///< Caption of window. WID_VD_TOP_DETAILS, ///< Panel with generic details. WID_VD_INCREASE_SERVICING_INTERVAL, ///< Increase the servicing interval. @@ -62,7 +62,7 @@ enum VehicleDetailsWidgets { }; /** Widgets of the #VehicleListWindow class. */ -enum VehicleListWidgets { +enum VehicleListWidgets : WidgetID { WID_VL_LIST, ///< List of the vehicles, this must be first, see: DirtyVehicleListWindowForVehicle WID_VL_CAPTION, ///< Caption of window (for non shared orders windows). WID_VL_CAPTION_SHARED_ORDERS, ///< Caption of window (for shared orders windows). diff --git a/src/widgets/viewport_widget.h b/src/widgets/viewport_widget.h index 81a6983e89..b83d3c55e3 100644 --- a/src/widgets/viewport_widget.h +++ b/src/widgets/viewport_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_VIEWPORT_WIDGET_H /** Widgets of the #ExtraViewportWindow class. */ -enum ExtraViewportWidgets { +enum ExtraViewportWidgets : WidgetID { WID_EV_CAPTION, ///< Caption of window. WID_EV_VIEWPORT, ///< The viewport. WID_EV_ZOOM_IN, ///< Zoom in. diff --git a/src/widgets/waypoint_widget.h b/src/widgets/waypoint_widget.h index c276523a12..1d077c0013 100644 --- a/src/widgets/waypoint_widget.h +++ b/src/widgets/waypoint_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_WAYPOINT_WIDGET_H /** Widgets of the #WaypointWindow class. */ -enum WaypointWidgets { +enum WaypointWidgets : WidgetID { WID_W_CAPTION, ///< Caption of window. WID_W_VIEWPORT, ///< The viewport on this waypoint. WID_W_CENTER_VIEW, ///< Center the main view on this waypoint. diff --git a/src/window.cpp b/src/window.cpp index c6378656d4..a405f944f6 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -216,7 +216,7 @@ void Window::ApplyDefaults() * @return Row number clicked at. If clicked at a wrong position, #INT_MAX is returned. * @note The widget does not know where a list printed at the widget ends, so below a list is not a wrong position. */ -int Window::GetRowFromWidget(int clickpos, int widget, int padding, int line_height) const +int Window::GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height) const { const NWidgetBase *wid = this->GetWidget(widget); if (line_height < 0) line_height = wid->resize_y; @@ -229,10 +229,8 @@ int Window::GetRowFromWidget(int clickpos, int widget, int padding, int line_hei */ void Window::DisableAllWidgetHighlight() { - for (uint i = 0; i < this->nested_array_size; i++) { - NWidgetBase *nwid = this->GetWidget(i); - if (nwid == nullptr) continue; - + for (auto &pair : this->widget_lookup) { + NWidgetBase *nwid = pair.second; if (nwid->IsHighlighted()) { nwid->SetHighlighted(TC_INVALID); nwid->SetDirty(this); @@ -247,10 +245,8 @@ void Window::DisableAllWidgetHighlight() * @param widget_index index of this widget in the window * @param highlighted_colour Colour of highlight, or TC_INVALID to disable. */ -void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour) +void Window::SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_colour) { - dbg_assert(widget_index < this->nested_array_size); - NWidgetBase *nwid = this->GetWidget(widget_index); if (nwid == nullptr) return; @@ -263,10 +259,9 @@ void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour } else { /* If we disable a highlight, check all widgets if anyone still has a highlight */ bool valid = false; - for (uint i = 0; i < this->nested_array_size; i++) { - NWidgetBase *child_nwid = this->GetWidget(i); - if (child_nwid == nullptr) continue; - if (!child_nwid->IsHighlighted()) continue; + for (const auto &pair : this->widget_lookup) { + nwid = pair.second; + if (!nwid->IsHighlighted()) continue; valid = true; } @@ -280,10 +275,8 @@ void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour * @param widget_index index of this widget in the window * @return status of the widget ie: highlighted = true, not highlighted = false */ -bool Window::IsWidgetHighlighted(byte widget_index) const +bool Window::IsWidgetHighlighted(WidgetID widget_index) const { - dbg_assert(widget_index < this->nested_array_size); - const NWidgetBase *nwid = this->GetWidget(widget_index); if (nwid == nullptr) return false; @@ -297,7 +290,7 @@ bool Window::IsWidgetHighlighted(byte widget_index) const * @param index the element in the dropdown that is selected. * @param instant_close whether the dropdown was configured to close on mouse up. */ -void Window::OnDropdownClose(Point pt, int widget, int index, bool instant_close) +void Window::OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) { if (widget < 0) return; @@ -324,7 +317,7 @@ void Window::OnDropdownClose(Point pt, int widget, int index, bool instant_close * @param widnum Scrollbar widget index * @return Scrollbar to the widget */ -const Scrollbar *Window::GetScrollbar(uint widnum) const +const Scrollbar *Window::GetScrollbar(WidgetID widnum) const { return this->GetWidget(widnum); } @@ -334,7 +327,7 @@ const Scrollbar *Window::GetScrollbar(uint widnum) const * @param widnum Scrollbar widget index * @return Scrollbar to the widget */ -Scrollbar *Window::GetScrollbar(uint widnum) +Scrollbar *Window::GetScrollbar(WidgetID widnum) { return this->GetWidget(widnum); } @@ -344,7 +337,7 @@ Scrollbar *Window::GetScrollbar(uint widnum) * @param widnum Editbox widget index * @return QueryString or nullptr. */ -const QueryString *Window::GetQueryString(uint widnum) const +const QueryString *Window::GetQueryString(WidgetID widnum) const { auto query = this->querystrings.find(widnum); return query != this->querystrings.end() ? query->second : nullptr; @@ -355,7 +348,7 @@ const QueryString *Window::GetQueryString(uint widnum) const * @param widnum Editbox widget index * @return QueryString or nullptr. */ -QueryString *Window::GetQueryString(uint widnum) +QueryString *Window::GetQueryString(WidgetID widnum) { auto query = this->querystrings.find(widnum); return query != this->querystrings.end() ? query->second : nullptr; @@ -508,20 +501,21 @@ void Window::UnfocusFocusedWidget() * @param widget_index Index of the widget in the window to set the focus to. * @return Focus has changed. */ -bool Window::SetFocusedWidget(int widget_index) +bool Window::SetFocusedWidget(WidgetID widget_index) { - /* Do nothing if widget_index is already focused, or if it wasn't a valid widget. */ - if ((uint)widget_index >= this->nested_array_size) return false; + NWidgetCore *widget = this->GetWidget(widget_index); + dbg_assert(widget != nullptr); /* Setting focus to a non-existing widget is a bad idea. */ - dbg_assert(this->nested_array[widget_index] != nullptr); // Setting focus to a non-existing widget is a bad idea. if (this->nested_focus != nullptr) { - if (this->GetWidget(widget_index) == this->nested_focus) return false; + /* Do nothing if widget_index is already focused. */ + if (widget == this->nested_focus) return false; /* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */ this->nested_focus->SetDirty(this); if (this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus(); } - this->nested_focus = this->GetWidget(widget_index); + + this->nested_focus = widget; if (_focused_window == this && this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxGainedFocus(); return true; } @@ -548,21 +542,23 @@ void Window::OnFocusLost(bool closing, Window *newly_focused_window) */ void Window::RaiseButtons(bool autoraise) { - for (uint i = 0; i < this->nested_array_size; i++) { - if (this->nested_array[i] == nullptr) continue; - WidgetType type = this->nested_array[i]->type; + for (auto &pair : this->widget_lookup) { + WidgetType type = pair.second->type; + NWidgetCore *wid = dynamic_cast(pair.second); if (((type & ~WWB_PUSHBUTTON) < WWT_LAST || type == NWID_PUSHBUTTON_DROPDOWN) && - (!autoraise || (type & WWB_PUSHBUTTON) || type == WWT_EDITBOX) && this->IsWidgetLowered(i)) { - this->RaiseWidget(i); - this->SetWidgetDirty(i); + (!autoraise || (type & WWB_PUSHBUTTON) || type == WWT_EDITBOX) && wid->IsLowered()) { + wid->SetLowered(false); + wid->SetDirty(this); } } /* Special widgets without widget index */ - NWidgetCore *wid = this->nested_root != nullptr ? (NWidgetCore*)this->nested_root->GetWidgetOfType(WWT_DEFSIZEBOX) : nullptr; - if (wid != nullptr) { - wid->SetLowered(false); - wid->SetDirty(this); + { + NWidgetCore *wid = this->nested_root != nullptr ? dynamic_cast(this->nested_root->GetWidgetOfType(WWT_DEFSIZEBOX)) : nullptr; + if (wid != nullptr) { + wid->SetLowered(false); + wid->SetDirty(this); + } } } @@ -570,12 +566,13 @@ void Window::RaiseButtons(bool autoraise) * Invalidate a widget, i.e. mark it as being changed and in need of redraw. * @param widget_index the widget to redraw. */ -void Window::SetWidgetDirty(byte widget_index) +void Window::SetWidgetDirty(WidgetID widget_index) { /* Sometimes this function is called before the window is even fully initialized */ - if (this->nested_array == nullptr) return; + auto it = this->widget_lookup.find(widget_index); + if (it == std::end(this->widget_lookup)) return; - this->nested_array[widget_index]->SetDirty(this); + it->second->SetDirty(this); } /** @@ -608,7 +605,7 @@ EventState Window::OnHotkey(int hotkey) * unclicked in a few ticks. * @param widget the widget to "click" */ -void Window::HandleButtonClick(byte widget) +void Window::HandleButtonClick(WidgetID widget) { this->LowerWidget(widget); this->SetTimeout(); @@ -644,12 +641,12 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) /* don't allow any interaction if the button has been disabled */ if (nw->IsDisabled()) return; - int widget_index = nw->index; ///< Index of the widget + WidgetID widget_index = nw->index; ///< Index of the widget /* Clicked on a widget that is not disabled. * So unless the clicked widget is the caption bar, change focus to this widget. * Exception: In the OSK we always want the editbox to stay focused. */ - if (widget_type != WWT_CAPTION && w->window_class != WC_OSK) { + if (widget_index >= 0 && widget_type != WWT_CAPTION && w->window_class != WC_OSK) { /* focused_widget_changed is 'now' only true if the window this widget * is in gained focus. In that case it must remain true, also if the * local widget focus did not change. As such it's the logical-or of @@ -1107,9 +1104,6 @@ Window::~Window() assert(this->window_class == WC_INVALID); if (this->viewport != nullptr) DeleteWindowViewport(this); - - free(this->nested_array); // Contents is released through deletion of #nested_root. - delete this->nested_root; } /** @@ -1495,7 +1489,7 @@ void Window::ChangeWindowClass(WindowClass cls) * @param window_number Number being assigned to the new window * @return Window pointer of the newly created window * @pre If nested widgets are used (\a widget is \c nullptr), #nested_root and #nested_array_size must be initialized. - * In addition, #nested_array is either \c nullptr, or already initialized. + * In addition, #widget_lookup is either \c nullptr, or already initialized. */ void Window::InitializeData(WindowNumber window_number) { @@ -1855,19 +1849,15 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int /** * Perform the first part of the initialization of a nested widget tree. - * Construct a nested widget tree in #nested_root, and optionally fill the #nested_array array to provide quick access to the uninitialized widgets. + * Construct a nested widget tree in #nested_root, and optionally fill the #widget_lookup array to provide quick access to the uninitialized widgets. * This is mainly useful for setting very basic properties. - * @param fill_nested Fill the #nested_array (enabling is expensive!). + * @param fill_nested Fill the #widget_lookup (enabling is expensive!). * @note Filling the nested array requires an additional traversal through the nested widget tree, and is best performed by #FinishInitNested rather than here. */ void Window::CreateNestedTree() { - int biggest_index = -1; - this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_begin, this->window_desc->nwid_end, &biggest_index, &this->shade_select); - this->nested_array_size = (uint)(biggest_index + 1); - - this->nested_array = CallocT(this->nested_array_size); - this->nested_root->FillNestedArray(this->nested_array, this->nested_array_size); + this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_begin, this->window_desc->nwid_end, &this->shade_select); + this->nested_root->FillWidgetLookup(this->widget_lookup); } /** @@ -1985,9 +1975,9 @@ static void DecreaseWindowCounters() if (_scroller_click_timeout == 0) { /* Unclick scrollbar buttons if they are pressed. */ - for (uint i = 0; i < w->nested_array_size; i++) { - NWidgetBase *nwid = w->nested_array[i]; - if (nwid != nullptr && (nwid->type == NWID_HSCROLLBAR || nwid->type == NWID_VSCROLLBAR)) { + for (auto &pair : w->widget_lookup) { + NWidgetBase *nwid = pair.second; + if (nwid->type == NWID_HSCROLLBAR || nwid->type == NWID_VSCROLLBAR) { NWidgetScrollbar *sb = static_cast(nwid); if (sb->disp_flags & (ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN)) { sb->disp_flags &= ~(ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN); @@ -2636,7 +2626,7 @@ static bool MaybeBringWindowToFront(Window *w) * @return #ES_HANDLED if the key press has been handled and no other * window should receive the event. */ -EventState Window::HandleEditBoxKey(int wid, WChar key, uint16 keycode) +EventState Window::HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode) { QueryString *query = this->GetQueryString(wid); if (query == nullptr) return ES_NOT_HANDLED; @@ -2709,7 +2699,7 @@ EventState Window::HandleEditBoxKey(int wid, WChar key, uint16 keycode) * @param wid Editbox widget. * @return if the Editbox was successfully cleared */ -bool Window::ClearEditBox(int wid) +bool Window::ClearEditBox(WidgetID wid) { QueryString *query = this->GetQueryString(wid); if (query == nullptr) return false; @@ -2840,7 +2830,7 @@ void HandleShiftChanged() * @param wid Edit box widget. * @param str Text string to insert. */ -/* virtual */ void Window::InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) +/* virtual */ void Window::InsertTextString(WidgetID wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) { QueryString *query = this->GetQueryString(wid); if (query == nullptr) return; @@ -3360,7 +3350,7 @@ void SetWindowDirty(WindowClass cls, WindowNumber number) * @param number Window number in that class * @param widget_index Index number of the widget that needs repainting */ -void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index) +void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index) { if (cls < WC_END && !_present_window_types[cls]) return; @@ -3420,8 +3410,8 @@ void Window::ProcessHighlightedInvalidations() { if ((this->flags & WF_HIGHLIGHTED) == 0) return; - for (uint i = 0; i < this->nested_array_size; i++) { - if (this->IsWidgetHighlighted(i)) this->SetWidgetDirty(i); + for (const auto &pair : this->widget_lookup) { + if (pair.second->IsHighlighted()) pair.second->SetDirty(this); } } diff --git a/src/window_func.h b/src/window_func.h index 6eefe44382..2ecadf9d1c 100644 --- a/src/window_func.h +++ b/src/window_func.h @@ -54,7 +54,7 @@ void ShowVitalWindows(); */ void ReInitAllWindows(bool zoom_changed); -void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index); +void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index); void SetWindowDirty(WindowClass cls, WindowNumber number); void SetWindowClassesDirty(WindowClass cls); diff --git a/src/window_gui.h b/src/window_gui.h index 99a1402647..7dcf00b998 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -302,27 +302,26 @@ public: ViewportData *viewport; ///< Pointer to viewport data, if present. NWidgetViewport *viewport_widget; ///< Pointer to viewport widget, if present. NWidgetCore *nested_focus; ///< Currently focused nested widget, or \c nullptr if no nested widget has focus. - btree::btree_map querystrings; ///< QueryString associated to WWT_EDITBOX widgets. - NWidgetBase *nested_root; ///< Root of the nested tree. - NWidgetBase **nested_array; ///< Array of pointers into the tree. Do not access directly, use #Window::GetWidget() instead. - uint nested_array_size; ///< Size of the nested array. + btree::btree_map querystrings; ///< QueryString associated to WWT_EDITBOX widgets. + std::unique_ptr nested_root; ///< Root of the nested tree. + WidgetLookup widget_lookup; ///< Indexed access to the nested widget tree. Do not access directly, use #Window::GetWidget() instead. NWidgetStacked *shade_select; ///< Selection widget (#NWID_SELECTION) to use for shading the window. If \c nullptr, window cannot shade. Dimension unshaded_size; ///< Last known unshaded size (only valid while shaded). - int mouse_capture_widget; ///< Widgetindex of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture. + WidgetID mouse_capture_widget; ///< ID of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture. Window *parent; ///< Parent window. template - inline const NWID *GetWidget(uint widnum) const; + inline const NWID *GetWidget(WidgetID widnum) const; template - inline NWID *GetWidget(uint widnum); + inline NWID *GetWidget(WidgetID widnum); - const Scrollbar *GetScrollbar(uint widnum) const; - Scrollbar *GetScrollbar(uint widnum); + const Scrollbar *GetScrollbar(WidgetID widnum) const; + Scrollbar *GetScrollbar(WidgetID widnum); - const QueryString *GetQueryString(uint widnum) const; - QueryString *GetQueryString(uint widnum); + const QueryString *GetQueryString(WidgetID widnum) const; + QueryString *GetQueryString(WidgetID widnum); void UpdateQueryStringSize(); virtual const struct Textbuf *GetFocusedTextbuf() const; @@ -357,8 +356,8 @@ public: } void DisableAllWidgetHighlight(); - void SetWidgetHighlight(byte widget_index, TextColour highlighted_colour); - bool IsWidgetHighlighted(byte widget_index) const; + void SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_colour); + bool IsWidgetHighlighted(WidgetID widget_index) const; /** * Sets the enabled/disabled status of a widget. @@ -367,17 +366,17 @@ public: * @param widget_index index of this widget in the window * @param disab_stat status to use ie: disabled = true, enabled = false */ - inline void SetWidgetDisabledState(byte widget_index, bool disab_stat) + inline void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat) { - assert(widget_index < this->nested_array_size); - if (this->nested_array[widget_index] != nullptr) this->GetWidget(widget_index)->SetDisabled(disab_stat); + NWidgetCore *nwid = this->GetWidget(widget_index); + if (nwid != nullptr) nwid->SetDisabled(disab_stat); } /** * Sets a widget to disabled. * @param widget_index index of this widget in the window */ - inline void DisableWidget(byte widget_index) + inline void DisableWidget(WidgetID widget_index) { SetWidgetDisabledState(widget_index, true); } @@ -386,7 +385,7 @@ public: * Sets a widget to Enabled. * @param widget_index index of this widget in the window */ - inline void EnableWidget(byte widget_index) + inline void EnableWidget(WidgetID widget_index) { SetWidgetDisabledState(widget_index, false); } @@ -396,9 +395,8 @@ public: * @param widget_index index of this widget in the window * @return status of the widget ie: disabled = true, enabled = false */ - inline bool IsWidgetDisabled(byte widget_index) const + inline bool IsWidgetDisabled(WidgetID widget_index) const { - assert(widget_index < this->nested_array_size); return this->GetWidget(widget_index)->IsDisabled(); } @@ -407,7 +405,7 @@ public: * @param widget_index : index of the widget in the window to check * @return true if given widget is the focused window in this window */ - inline bool IsWidgetFocused(byte widget_index) const + inline bool IsWidgetFocused(WidgetID widget_index) const { return this->nested_focus != nullptr && this->nested_focus->index == widget_index; } @@ -418,7 +416,7 @@ public: * @param widget_index : index of the widget in the window to check * @return true if given widget is the focused window in this window and this window has focus */ - inline bool IsWidgetGloballyFocused(byte widget_index) const + inline bool IsWidgetGloballyFocused(WidgetID widget_index) const { return _focused_window == this && IsWidgetFocused(widget_index); } @@ -428,9 +426,8 @@ public: * @param widget_index index of this widget in the window * @param lowered_stat status to use ie: lowered = true, raised = false */ - inline void SetWidgetLoweredState(byte widget_index, bool lowered_stat) + inline void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat) { - assert(widget_index < this->nested_array_size); this->GetWidget(widget_index)->SetLowered(lowered_stat); } @@ -438,9 +435,8 @@ public: * Invert the lowered/raised status of a widget. * @param widget_index index of this widget in the window */ - inline void ToggleWidgetLoweredState(byte widget_index) + inline void ToggleWidgetLoweredState(WidgetID widget_index) { - assert(widget_index < this->nested_array_size); bool lowered_state = this->GetWidget(widget_index)->IsLowered(); this->GetWidget(widget_index)->SetLowered(!lowered_state); } @@ -449,7 +445,7 @@ public: * Marks a widget as lowered. * @param widget_index index of this widget in the window */ - inline void LowerWidget(byte widget_index) + inline void LowerWidget(WidgetID widget_index) { SetWidgetLoweredState(widget_index, true); } @@ -458,7 +454,7 @@ public: * Marks a widget as raised. * @param widget_index index of this widget in the window */ - inline void RaiseWidget(byte widget_index) + inline void RaiseWidget(WidgetID widget_index) { SetWidgetLoweredState(widget_index, false); } @@ -467,7 +463,7 @@ public: * Marks a widget as raised and dirty (redraw), when it is marked as lowered. * @param widget_index index of this widget in the window */ - inline void RaiseWidgetWhenLowered(byte widget_index) + inline void RaiseWidgetWhenLowered(WidgetID widget_index) { if (this->IsWidgetLowered(widget_index)) { this->RaiseWidget(widget_index); @@ -480,21 +476,20 @@ public: * @param widget_index index of this widget in the window * @return status of the widget ie: lowered = true, raised= false */ - inline bool IsWidgetLowered(byte widget_index) const + inline bool IsWidgetLowered(WidgetID widget_index) const { - assert(widget_index < this->nested_array_size); return this->GetWidget(widget_index)->IsLowered(); } void UnfocusFocusedWidget(); - bool SetFocusedWidget(int widget_index); + bool SetFocusedWidget(WidgetID widget_index); - EventState HandleEditBoxKey(int wid, WChar key, uint16 keycode); - bool ClearEditBox(int wid); - virtual void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end); + EventState HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode); + bool ClearEditBox(WidgetID wid); + virtual void InsertTextString(WidgetID wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end); - void HandleButtonClick(byte widget); - int GetRowFromWidget(int clickpos, int widget, int padding, int line_height = -1) const; + void HandleButtonClick(WidgetID widget); + int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height = -1) const; void RaiseButtons(bool autoraise = false); @@ -532,11 +527,11 @@ public: (this->RaiseWidgetWhenLowered(widgets), ...); } - void SetWidgetDirty(byte widget_index); + void SetWidgetDirty(WidgetID widget_index); void DrawWidgets() const; void DrawViewport(uint8 display_flags) const; - void DrawSortButtonState(int widget, SortButtonState state) const; + void DrawSortButtonState(WidgetID widget, SortButtonState state) const; static int SortButtonWidth(); void CloseChildWindows(WindowClass wc = WC_INVALID) const; @@ -561,7 +556,7 @@ public: /** * Notification that the nested widget tree gets initialized. The event can be used to perform general computations. - * @note #nested_root and/or #nested_array (normally accessed via #GetWidget()) may not exist during this call. + * @note #nested_root and/or #widget_lookup (normally accessed via #GetWidget()) may not exist during this call. */ virtual void OnInit() { } @@ -591,7 +586,7 @@ public: * @param widget Number of the widget to draw. * @note This method may not change any state, it may only use drawing functions. */ - virtual void DrawWidget([[maybe_unused]] const Rect &r, [[maybe_unused]] int widget) const {} + virtual void DrawWidget([[maybe_unused]] const Rect &r, [[maybe_unused]] WidgetID widget) const {} /** * Update size and resize step of a widget in the window. @@ -605,7 +600,7 @@ public: * @param fill Fill step of the widget. * @param resize Resize step of the widget. */ - virtual void UpdateWidgetSize([[maybe_unused]] int widget, [[maybe_unused]] Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) {} + virtual void UpdateWidgetSize([[maybe_unused]] WidgetID widget, [[maybe_unused]] Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) {} /** * Initialize string parameters for a widget. @@ -613,7 +608,7 @@ public: * and while re-initializing the window. Only for widgets that render text initializing is requested. * @param widget Widget number. */ - virtual void SetStringParameters([[maybe_unused]] int widget) const {} + virtual void SetStringParameters([[maybe_unused]] WidgetID widget) const {} virtual void OnFocus(Window *previously_focused_window); @@ -653,7 +648,7 @@ public: * @param widget the clicked widget. * @param click_count Number of fast consecutive clicks at same position */ - virtual void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] int widget, [[maybe_unused]] int click_count) {} + virtual void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] int click_count) {} /** * A click with the right mouse button has been made on the window. @@ -662,14 +657,14 @@ public: * @return true if the click was actually handled, i.e. do not show a * tooltip if tooltip-on-right-click is enabled. */ - virtual bool OnRightClick([[maybe_unused]] Point pt, [[maybe_unused]] int widget) { return false; } + virtual bool OnRightClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) { return false; } /** * The mouse is hovering over a widget in the window, perform an action for it. * @param pt The point where the mouse is hovering. * @param widget The widget where the mouse is hovering. */ - virtual void OnHover([[maybe_unused]] Point pt, [[maybe_unused]] int widget) {} + virtual void OnHover([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {} /** * Event to display a custom tooltip. @@ -677,21 +672,21 @@ public: * @param widget The widget where the mouse is located. * @return True if the event is handled, false if it is ignored. */ - virtual bool OnTooltip([[maybe_unused]] Point pt, [[maybe_unused]] int widget, [[maybe_unused]] TooltipCloseCondition close_cond) { return false; } + virtual bool OnTooltip([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] TooltipCloseCondition close_cond) { return false; } /** * An 'object' is being dragged at the provided position, highlight the target if possible. * @param pt The point inside the window that the mouse hovers over. * @param widget The widget the mouse hovers over. */ - virtual void OnMouseDrag([[maybe_unused]] Point pt, [[maybe_unused]] int widget) {} + virtual void OnMouseDrag([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {} /** * A dragged 'object' has been released. * @param pt the point inside the window where the release took place. * @param widget the widget where the release took place. */ - virtual void OnDragDrop([[maybe_unused]] Point pt, [[maybe_unused]] int widget) {} + virtual void OnDragDrop([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {} /** * Handle the request for (viewport) scrolling. @@ -705,7 +700,7 @@ public: * @param pt the point inside the window that the mouse hovers over. * @param widget the widget the mouse hovers over. */ - virtual void OnMouseOver([[maybe_unused]] Point pt, [[maybe_unused]] int widget) {} + virtual void OnMouseOver([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {} /** * The mouse wheel has been turned. @@ -753,15 +748,15 @@ public: * @param widget the widget (button) that the dropdown is associated with. * @param index the element in the dropdown that is selected. */ - virtual void OnDropdownSelect([[maybe_unused]] int widget, [[maybe_unused]] int index) {} + virtual void OnDropdownSelect([[maybe_unused]] WidgetID widget, [[maybe_unused]] int index) {} - virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close); + virtual void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close); /** * The text in an editbox has been edited. * @param widget The widget of the editbox. */ - virtual void OnEditboxChanged([[maybe_unused]] int widget) {} + virtual void OnEditboxChanged([[maybe_unused]] WidgetID widget) {} /** * The query window opened from this window has closed. @@ -977,20 +972,22 @@ inline bool AllEqual(It begin, It end, Pred pred) * @return The requested widget if it is instantiated, \c nullptr otherwise. */ template -inline NWID *Window::GetWidget(uint widnum) +inline NWID *Window::GetWidget(WidgetID widnum) { - if (widnum >= this->nested_array_size || this->nested_array[widnum] == nullptr) return nullptr; - NWID *nwid = dynamic_cast(this->nested_array[widnum]); + auto it = this->widget_lookup.find(widnum); + if (it == std::end(this->widget_lookup)) return nullptr; + NWID *nwid = dynamic_cast(it->second); assert(nwid != nullptr); return nwid; } /** Specialized case of #Window::GetWidget for the nested widget base class. */ template <> -inline const NWidgetBase *Window::GetWidget(uint widnum) const +inline const NWidgetBase *Window::GetWidget(WidgetID widnum) const { - if (widnum >= this->nested_array_size) return nullptr; - return this->nested_array[widnum]; + auto it = this->widget_lookup.find(widnum); + if (it == std::end(this->widget_lookup)) return nullptr; + return it->second; } /** @@ -1000,7 +997,7 @@ inline const NWidgetBase *Window::GetWidget(uint widnum) const * @return The requested widget if it is instantiated, \c nullptr otherwise. */ template -inline const NWID *Window::GetWidget(uint widnum) const +inline const NWID *Window::GetWidget(WidgetID widnum) const { return const_cast(this)->GetWidget(widnum); } @@ -1044,7 +1041,7 @@ void RelocateAllWindows(int neww, int newh); void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount = 0); /* widget.cpp */ -int GetWidgetFromPos(const Window *w, int x, int y); +WidgetID GetWidgetFromPos(const Window *w, int x, int y); extern Point _cursorpos_drag_start; diff --git a/src/window_type.h b/src/window_type.h index 1f23a5d171..427ca11263 100644 --- a/src/window_type.h +++ b/src/window_type.h @@ -12,6 +12,13 @@ #include "core/strong_typedef_type.hpp" +/** + * Widget ID. + * Even though the ID is signed, actual IDs must be non-negative. + * Negative IDs are used for special cases, like denoting 'no widget'. + */ +using WidgetID = int; + /** %Window numbers. */ enum WindowNumberEnum { WN_GAME_OPTIONS_AI = 0, ///< AI settings. diff --git a/src/zoning_gui.cpp b/src/zoning_gui.cpp index 9363994106..6111c27fb3 100644 --- a/src/zoning_gui.cpp +++ b/src/zoning_gui.cpp @@ -88,7 +88,7 @@ struct ZoningWindow : public Window { this->DrawWidgets(); } - void OnClick(Point pt, int widget, int click_count) override + void OnClick(Point pt, WidgetID widget, int click_count) override { switch (widget) { case ZTW_OUTER_DROPDOWN: @@ -101,7 +101,7 @@ struct ZoningWindow : public Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch(widget) { case ZTW_OUTER_DROPDOWN: @@ -115,7 +115,7 @@ struct ZoningWindow : public Window { this->InvalidateData(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case ZTW_OUTER_DROPDOWN: @@ -128,7 +128,7 @@ struct ZoningWindow : public Window { } } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { const StringID *strs = nullptr; switch (widget) { diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000000..30492e1fe1 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,53 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", + "dependencies": [ + { + "name": "curl", + "platform": "linux", + "features": [ + "http2" + ] + }, + { + "name": "dbus", + "platform": "linux", + "default-features": false + }, + { + "name": "fontconfig", + "platform": "linux" + }, + { + "name": "freetype", + "platform": "linux" + }, + { + "name": "harfbuzz", + "platform": "linux" + }, + { + "name": "icu", + "platform": "linux" + }, + { + "name": "liblzma" + }, + { + "name": "libpng" + }, + { + "name": "lzo" + }, + { + "name": "sdl2", + "platform": "linux" + }, + { + "name": "zlib" + }, + { + "name": "zstd" + } + ], + "builtin-baseline": "94cf042e6b7713913a3b3150f3ca3d0f4550f7c4" +}