mirror of
https://github.com/louis-e/arnis.git
synced 2025-12-31 02:08:04 -05:00
Compare commits
211 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
449fcc18bd | ||
|
|
c69e124eb5 | ||
|
|
7956826c07 | ||
|
|
acbe9adedf | ||
|
|
4ec8f65e6f | ||
|
|
fd2d4b272b | ||
|
|
daf07bd743 | ||
|
|
163ab0407d | ||
|
|
0361e7d63d | ||
|
|
bc422460ff | ||
|
|
53f0097884 | ||
|
|
bbfb63886d | ||
|
|
928f487a29 | ||
|
|
ff7a09061e | ||
|
|
911ec00ddb | ||
|
|
54137f2117 | ||
|
|
50d38a1dd4 | ||
|
|
e5ab62eb18 | ||
|
|
1a8a3114f4 | ||
|
|
a52ba2bd39 | ||
|
|
8195f0bc6e | ||
|
|
4df4a3de32 | ||
|
|
e65a1ee37e | ||
|
|
66e47e190a | ||
|
|
8755fd3285 | ||
|
|
982ef56b29 | ||
|
|
28070d3c51 | ||
|
|
d9a0a4aa86 | ||
|
|
1f0f6676ed | ||
|
|
ff44fe4eda | ||
|
|
42976b0113 | ||
|
|
55b170fb7d | ||
|
|
852bbf2236 | ||
|
|
cc6080c0c3 | ||
|
|
5672ca3f1e | ||
|
|
fc29544835 | ||
|
|
bf6ac1f61a | ||
|
|
8c17a5b0bb | ||
|
|
bc6ffa3bf9 | ||
|
|
dec0317790 | ||
|
|
091acd5849 | ||
|
|
056203fb21 | ||
|
|
415c9d33fe | ||
|
|
1820112093 | ||
|
|
c573a02fd6 | ||
|
|
4c6b9833eb | ||
|
|
8cb8d76357 | ||
|
|
fc105b84e0 | ||
|
|
f873a7ab69 | ||
|
|
61a67240a6 | ||
|
|
c0753ab23e | ||
|
|
9461d1f46e | ||
|
|
3036237fdf | ||
|
|
95e71b8da5 | ||
|
|
255786bc93 | ||
|
|
3c552fe5ed | ||
|
|
49ff415316 | ||
|
|
71315c60ea | ||
|
|
18b1ea0e0b | ||
|
|
c6a8da0b40 | ||
|
|
308498550b | ||
|
|
f7e917edc7 | ||
|
|
8221da46e0 | ||
|
|
3645b7edd7 | ||
|
|
606779f681 | ||
|
|
dce5f472f0 | ||
|
|
f4bf8c1d3c | ||
|
|
686ac2c181 | ||
|
|
b334ed9841 | ||
|
|
96dc9ced30 | ||
|
|
03d86f4552 | ||
|
|
6e3406f117 | ||
|
|
7e929d5ef3 | ||
|
|
49a5ed8157 | ||
|
|
f60170ef59 | ||
|
|
b34bf4f646 | ||
|
|
efc14821cf | ||
|
|
ba9c7df5ff | ||
|
|
3eb29a0c21 | ||
|
|
17ead3c2fc | ||
|
|
f661f174bd | ||
|
|
7792930277 | ||
|
|
18d3e45d2c | ||
|
|
c2b9f87688 | ||
|
|
0850bca4de | ||
|
|
ef25c669c1 | ||
|
|
df09afe868 | ||
|
|
e9a2329e38 | ||
|
|
9cb919eeae | ||
|
|
e2c9b07e91 | ||
|
|
3efb8460c1 | ||
|
|
0efa681bb9 | ||
|
|
a92c5bb01f | ||
|
|
408e182be2 | ||
|
|
ea3cf80472 | ||
|
|
28ecbb58e7 | ||
|
|
7b7ff6b534 | ||
|
|
5e6eb0969b | ||
|
|
9d6c528438 | ||
|
|
920725d21f | ||
|
|
3689bfbf6d | ||
|
|
8ed864210f | ||
|
|
a0d242716d | ||
|
|
a604e546a7 | ||
|
|
3e88da384a | ||
|
|
3c5f5eff24 | ||
|
|
c750b90719 | ||
|
|
553dce3c3b | ||
|
|
24d7a7e3eb | ||
|
|
b34a9c851c | ||
|
|
1274781223 | ||
|
|
ab21b88c90 | ||
|
|
9470bbf87f | ||
|
|
c4e27b6059 | ||
|
|
c26cb933dc | ||
|
|
83be3c7c64 | ||
|
|
999dd8db51 | ||
|
|
9570d0533c | ||
|
|
103fe83efc | ||
|
|
155f66dfb1 | ||
|
|
9ea8e8860a | ||
|
|
cc5e691531 | ||
|
|
9b33ed17ce | ||
|
|
bac263311a | ||
|
|
486541b14a | ||
|
|
7cfb78b0e1 | ||
|
|
dbd96cfdac | ||
|
|
e4ed404f5e | ||
|
|
b6838fdbb1 | ||
|
|
ac9bfab3e6 | ||
|
|
dc57d092f8 | ||
|
|
357dded61a | ||
|
|
edba29bf2b | ||
|
|
410bd7b926 | ||
|
|
14d93526d4 | ||
|
|
273e02d626 | ||
|
|
88e7cc35a9 | ||
|
|
37cd210104 | ||
|
|
ed22a6cd99 | ||
|
|
ecaaea5da1 | ||
|
|
43e8cce970 | ||
|
|
f05ed0c3dc | ||
|
|
9be60f7805 | ||
|
|
366a651925 | ||
|
|
6c593694d0 | ||
|
|
09d3b891bb | ||
|
|
a841178d46 | ||
|
|
aea28d185d | ||
|
|
3af10a2a6b | ||
|
|
6e8160cf73 | ||
|
|
1c0a3b3035 | ||
|
|
b4a9852ecc | ||
|
|
05cd857c5f | ||
|
|
dba0e4512a | ||
|
|
23e55e0c27 | ||
|
|
5d2cdee14f | ||
|
|
8d91d98a20 | ||
|
|
a2d61702f1 | ||
|
|
893f8c3802 | ||
|
|
ac8c5bf466 | ||
|
|
e4c6208b22 | ||
|
|
f5144d7ba4 | ||
|
|
f50e10891b | ||
|
|
66819a577b | ||
|
|
85f3e55f04 | ||
|
|
8c270b71bb | ||
|
|
49ead6c42e | ||
|
|
1baa0d9d40 | ||
|
|
028ef4bd50 | ||
|
|
596231f50b | ||
|
|
f8fc8e4020 | ||
|
|
9417f0e67b | ||
|
|
5e70a9c7e3 | ||
|
|
df65d2393e | ||
|
|
7c4eee955c | ||
|
|
8ca2cf9ab9 | ||
|
|
97e70bfef0 | ||
|
|
b52f5fb552 | ||
|
|
bad6c6df57 | ||
|
|
8999fc9a26 | ||
|
|
40d28e0d93 | ||
|
|
8e2ad72dc8 | ||
|
|
49b08a84af | ||
|
|
2beee07f98 | ||
|
|
a21c92849e | ||
|
|
2844c812e0 | ||
|
|
aeeb1912d3 | ||
|
|
08d7f7dbbe | ||
|
|
73f87162c9 | ||
|
|
ccf7784848 | ||
|
|
704249b5cc | ||
|
|
6d0c03862c | ||
|
|
bd2a852105 | ||
|
|
c0778c265f | ||
|
|
a513f0e230 | ||
|
|
c2c9f2e556 | ||
|
|
712127228d | ||
|
|
3ee1b80ea2 | ||
|
|
b1c0f39a65 | ||
|
|
23233a5f11 | ||
|
|
424e2751a6 | ||
|
|
458f709931 | ||
|
|
9ad0b5d5ee | ||
|
|
47231f5121 | ||
|
|
4f749d3e98 | ||
|
|
7fb4670c87 | ||
|
|
451c346f3d | ||
|
|
2c996637d4 | ||
|
|
c9c0cb2f2c | ||
|
|
18de6ec808 | ||
|
|
9f521489ab |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -20,4 +20,4 @@ Please tell us what version of Arnis and Minecraft you used.
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here. If you used any more custom settings, please provide them here too.
|
||||
Add any other context about the problem here. If you used any more custom settings, please provide them here too. If you experienced any issue with the application itself like a crash, please provide the log file which can be found at C:\Users\USERNAME\AppData\Local\com.louisdev.arnis\logs
|
||||
|
||||
18
.github/workflows/ci-build.yml
vendored
18
.github/workflows/ci-build.yml
vendored
@@ -8,25 +8,37 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, macos-latest]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: ${{ matrix.os == 'windows-latest' && 'x86_64-pc-windows-msvc' || 'x86_64-unknown-linux-gnu' || 'x86_64-apple-darwin' }}
|
||||
targets: ${{ matrix.os == 'windows-latest' && 'x86_64-pc-windows-msvc' || 'x86_64-unknown-linux-gnu' || 'x86_64-apple-darwin' }}
|
||||
components: clippy
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y software-properties-common
|
||||
sudo add-apt-repository universe
|
||||
echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
sudo apt update
|
||||
sudo apt install -y libgtk-3-dev build-essential pkg-config libglib2.0-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev
|
||||
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
|
||||
|
||||
- name: Check formatting
|
||||
run: cargo fmt -- --check
|
||||
|
||||
|
||||
92
.github/workflows/prerelease.yml.disabled
vendored
Normal file
92
.github/workflows/prerelease.yml.disabled
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
name: [DISABLED] Pre-release Dev Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
binary_name: arnis.exe
|
||||
asset_name: arnis-windows-x64.exe
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
binary_name: arnis
|
||||
asset_name: arnis-linux-x64
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y software-properties-common
|
||||
sudo add-apt-repository universe
|
||||
echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
sudo apt update
|
||||
sudo apt install -y libgtk-3-dev build-essential pkg-config libglib2.0-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev
|
||||
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
|
||||
|
||||
- name: Install dependencies
|
||||
run: cargo fetch --locked
|
||||
|
||||
- name: Build
|
||||
run: cargo build --frozen --release
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.os }}-build
|
||||
path: target/release/${{ matrix.binary_name }}
|
||||
|
||||
prerelease:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Download Windows build artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: windows-latest-build
|
||||
path: ./builds/windows
|
||||
|
||||
- name: Download Linux build artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ubuntu-latest-build
|
||||
path: ./builds/linux
|
||||
|
||||
- name: Make Linux binary executable
|
||||
run: chmod +x ./builds/linux/arnis
|
||||
|
||||
- name: Create Pre-release on GitHub
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: "dev-build-${{ github.run_number }}"
|
||||
name: "Experimental Development Build #${{ github.run_number }}"
|
||||
body: "Automated pre-release built from the main branch for testing purposes. This build may contain experimental features. For the latest official version, please download the latest stable release."
|
||||
draft: false
|
||||
prerelease: true
|
||||
makeLatest: false
|
||||
files: |
|
||||
builds/windows/arnis.exe
|
||||
builds/linux/arnis
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
107
.github/workflows/release.yml
vendored
107
.github/workflows/release.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Build and Release Rust Project
|
||||
name: Build and Release Arnis
|
||||
|
||||
on:
|
||||
release:
|
||||
@@ -6,17 +6,44 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
binary_name: arnis.exe
|
||||
asset_name: arnis-windows.exe
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
binary_name: arnis
|
||||
asset_name: arnis-linux
|
||||
- os: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
binary_name: arnis
|
||||
asset_name: arnis-mac
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Rust for Windows
|
||||
uses: actions-rs/toolchain@v1
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: x86_64-pc-windows-msvc
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y software-properties-common
|
||||
sudo add-apt-repository universe
|
||||
echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
sudo apt update
|
||||
sudo apt install -y libgtk-3-dev build-essential pkg-config libglib2.0-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev
|
||||
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
|
||||
|
||||
- name: Install dependencies
|
||||
run: cargo fetch
|
||||
@@ -24,29 +51,79 @@ jobs:
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
|
||||
- name: Upload artifact (Windows)
|
||||
uses: actions/upload-artifact@v3
|
||||
- name: Rename binary for release
|
||||
run: mv target/release/${{ matrix.binary_name }} target/release/${{ matrix.asset_name }}
|
||||
|
||||
- name: Install Windows SDK
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: |
|
||||
choco install windows-sdk-10.1 -y
|
||||
$env:Path += ";C:\Program Files (x86)\Windows Kits\10\bin\x64"
|
||||
shell: powershell
|
||||
|
||||
- name: Locate signtool.exe
|
||||
if: matrix.os == 'windows-latest'
|
||||
id: locate_signtool
|
||||
run: |
|
||||
$env:ProgramFilesX86 = [System.Environment]::GetFolderPath('ProgramFilesX86')
|
||||
$signtoolPath = Get-ChildItem -Path "$env:ProgramFilesX86\Windows Kits\10\bin" -Recurse -Filter signtool.exe | Where-Object { $_.FullName -match '\\x64\\' } | Select-Object -First 1 -ExpandProperty FullName
|
||||
if (-not $signtoolPath) { throw "signtool.exe not found." }
|
||||
echo "signtool=$signtoolPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
shell: powershell
|
||||
|
||||
- name: Self-sign Windows executable
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: |
|
||||
$password = ConvertTo-SecureString -String $env:WINDOWS_CERT_PASSWORD -Force -AsPlainText
|
||||
$cert = New-SelfSignedCertificate -Type CodeSigningCert -Subject 'CN=Arnis' -CertStoreLocation Cert:\CurrentUser\My -NotAfter (Get-Date).AddYears(5)
|
||||
Export-PfxCertificate -Cert $cert -FilePath arnis-cert.pfx -Password $password
|
||||
& $env:signtool sign /f arnis-cert.pfx /p $env:WINDOWS_CERT_PASSWORD /t http://timestamp.digicert.com target/release/${{ matrix.asset_name }}
|
||||
env:
|
||||
WINDOWS_CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }}
|
||||
shell: powershell
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-latest-build
|
||||
path: target/release/arnis.exe
|
||||
name: ${{ matrix.os }}-build
|
||||
path: target/release/${{ matrix.asset_name }}
|
||||
|
||||
release:
|
||||
runs-on: windows-latest
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Download Windows build artifact
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-latest-build
|
||||
path: ./builds/windows
|
||||
|
||||
- name: Download Linux build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ubuntu-latest-build
|
||||
path: ./builds/linux
|
||||
|
||||
- name: Download macOS build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: macos-latest-build
|
||||
path: ./builds/macos
|
||||
|
||||
- name: Make Linux and macOS binaries executable
|
||||
run: |
|
||||
chmod +x ./builds/linux/arnis-linux
|
||||
chmod +x ./builds/macos/arnis-mac
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: |
|
||||
builds/windows/arnis.exe
|
||||
builds/windows/arnis-windows.exe
|
||||
builds/linux/arnis-linux
|
||||
builds/macos/arnis-mac
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -27,6 +27,7 @@ Thumbs.db
|
||||
# Generated files
|
||||
/export.json
|
||||
/parsed_osm_data.txt
|
||||
/elevation_debug.png
|
||||
/gen/
|
||||
/build/
|
||||
*.rmeta
|
||||
|
||||
1017
Cargo.lock
generated
1017
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
27
Cargo.toml
27
Cargo.toml
@@ -1,18 +1,22 @@
|
||||
[package]
|
||||
name = "arnis"
|
||||
version = "2.1.2"
|
||||
version = "2.2.1"
|
||||
edition = "2021"
|
||||
description = "Arnis - Generate real life cities in Minecraft"
|
||||
homepage = "https://github.com/louis-e/arnis"
|
||||
repository = "https://github.com/louis-e/arnis"
|
||||
license = "GPL-3.0"
|
||||
license = "Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
lto = "thin"
|
||||
|
||||
[features]
|
||||
default = ["gui"]
|
||||
gui = ["dep:tauri", "dep:tauri-plugin-log", "dep:tauri-plugin-shell"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
tauri-build = "2"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.1", features = ["derive"] }
|
||||
@@ -24,17 +28,22 @@ flate2 = "1.0"
|
||||
fnv = "1.0.7"
|
||||
fs2 = "0.4"
|
||||
geo = "0.29.3"
|
||||
image = "0.24"
|
||||
indicatif = "0.17.8"
|
||||
itertools = "0.14.0"
|
||||
nalgebra = "0.33.0"
|
||||
log = "0.4.22"
|
||||
once_cell = "1.19.0"
|
||||
rand = "0.8.5"
|
||||
rayon = "1.10.0"
|
||||
reqwest = { version = "0.12.7", features = ["blocking", "json"] }
|
||||
rfd = { version = "0.15.1", default-features = false, features = ["tokio"] }
|
||||
rfd = "0.15.1"
|
||||
semver = "1.0.23"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri-plugin-dialog = "2.0.0"
|
||||
tauri-plugin-shell = "2"
|
||||
tauri = { version = "2", optional = true }
|
||||
tauri-plugin-log = { version = "2.2.0", optional = true }
|
||||
tauri-plugin-shell = { version = "2", optional = true }
|
||||
tokio = { version = "1.42.0", features = ["full"] }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows = { version = "0.59.0", features = ["Win32_System_Console"] }
|
||||
|
||||
875
LICENSE
875
LICENSE
@@ -1,674 +1,201 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
50
README.md
50
README.md
@@ -1,11 +1,13 @@
|
||||
<p align="center">
|
||||
<img width="456" height="125" src="https://github.com/louis-e/arnis/blob/main/gitassets/logo.png?raw=true">
|
||||
<img width="456" height="125" src="https://github.com/louis-e/arnis/blob/main/gui-src/images/logo.png?raw=true">
|
||||
</p>
|
||||
|
||||
# Arnis [](https://github.com/louis-e/arnis/actions) [<img alt="GitHub Release" src="https://img.shields.io/github/v/release/louis-e/arnis" />](https://github.com/louis-e/arnis/releases) [<img alt="GitHub Downloads (all assets, all releases" src="https://img.shields.io/github/downloads/louis-e/arnis/total" />](https://github.com/louis-e/arnis/releases)
|
||||
|
||||
This open source project written in Rust generates any chosen location from the real world in Minecraft Java Edition with a high level of detail.
|
||||
|
||||
###### ⚠️ This Github page is the official project website. Do not download Arnis from any other website.
|
||||
|
||||
## :desktop_computer: Example
|
||||

|
||||
|
||||
@@ -20,9 +22,10 @@ Download the [latest release](https://github.com/louis-e/arnis/releases/) or [co
|
||||
Choose your area in Arnis using the rectangle tool and select your Minecraft world - then simply click on 'Start Generation'!
|
||||
The world will always be generated starting from the Minecraft coordinates 0 0 0 (/tp 0 0 0). This is the top left of your selected area.
|
||||
|
||||
If you choose to select an own world, make sure to generate a new flat world in advance in Minecraft.
|
||||
To generate your world with terrain, make sure to enable the corresponding feature in the generation settings.
|
||||
|
||||
Minecraft version 1.16.5 and below is currently not supported, but we are working on it! For the best results, use Minecraft version 1.21.4.
|
||||
If you choose to select an own world, be aware that Arnis will overwrite certain areas.
|
||||
|
||||
## :floppy_disk: How it works
|
||||

|
||||
@@ -41,7 +44,7 @@ The raw data obtained from the API *[(see FAQ)](#question-faq)* includes each el
|
||||
- *Wasn't this written in Python before?*<br>
|
||||
Yes! Arnis was initially developed in Python, which benefited from Python's open-source friendliness and ease of readability. This is why we strive for clear, well-documented code in the Rust port of this project to find the right balance. I decided to port the project to Rust to learn more about the language and push the algorithm's performance further. We were nearing the limits of optimization in Python, and Rust's capabilities allow for even better performance and efficiency. The old Python implementation is still available in the python-legacy branch.
|
||||
- *Where does the data come from?*<br>
|
||||
The geographic data is sourced from OpenStreetMap (OSM)[^1], a free, collaborative mapping project that serves as an open-source alternative to commercial mapping services. The data is accessed via the Overpass API, which queries OSM's database.
|
||||
The geographic data is sourced from OpenStreetMap (OSM)[^1], a free, collaborative mapping project that serves as an open-source alternative to commercial mapping services. The data is accessed via the Overpass API, which queries OSM's database. Other services like Google Maps do not provide data like this, which makes OSM perfect for this project.
|
||||
- *How does the Minecraft world generation work?*<br>
|
||||
The script uses the [fastnbt](https://github.com/owengage/fastnbt) cargo package to interact with Minecraft's world format. This library allows Arnis to manipulate Minecraft region files, enabling the generation of real-world locations. The section 'Processing Pipeline' goes a bit further into the details and steps of the generation process itself.
|
||||
- *Where does the name come from?*<br>
|
||||
@@ -54,28 +57,36 @@ If you're on Windows, please install the [Evergreen Bootstrapper from Microsoft]
|
||||
Please use Minecraft version 1.21.4 for the best results. Minecraft version 1.16.5 and below is currently not supported, but we are working on it!
|
||||
- *The generation did finish, but there's nothing in the world!*<br>
|
||||
Make sure to teleport to the generation starting point (/tp 0 0 0). If there is still nothing, you might need to travel a bit further into the positive X and positive Z direction.
|
||||
- *What features are in the world generation settings?*<br>
|
||||
**Terrain:** Make sure to enable this feature to generate your world with elevation data included.<br>
|
||||
**Winter Mode:** This setting changes the generation style to a snowy theme and adds snow layers to the ground.<br>
|
||||
**Scale Factor:** The scale factor determines the size of the generated world.<br>
|
||||
**Custom BBOX Input:** This setting allows you to manually input the bounding box coordinates for the area you want to generate.<br>
|
||||
**Floodfill-Timeout (Sec):** This setting determines the maximum time the floodfill algorithm is allowed to run before being terminated. Increasing this value may improve the generation of large water areas but may also increase processing time.<br>
|
||||
**Ground Height:** This setting determines the base height of the generated world and can be adjusted to create different terrain types.
|
||||
|
||||
## :memo: ToDo and Known Bugs
|
||||
Feel free to choose an item from the To-Do or Known Bugs list, or bring your own idea to the table. Bug reports shall be raised as a Github issue. Contributions are highly welcome and appreciated!
|
||||
- [ ] Fix compilation for Linux
|
||||
- [ ] Rotate maps (https://github.com/louis-e/arnis/issues/97)
|
||||
- [ ] Fix coastal cities generation duration time (water_areas.rs)
|
||||
- [ ] Add street names as signs
|
||||
- [ ] Add support for older Minecraft versions (<=1.16.5) (https://github.com/louis-e/arnis/issues/124, https://github.com/louis-e/arnis/issues/137)
|
||||
- [ ] Mapping real coordinates to Minecraft coordinates (https://github.com/louis-e/arnis/issues/29)
|
||||
- [ ] Add interior to buildings
|
||||
- [ ] Implement house roof types
|
||||
- [ ] Evaluate and implement elevation (https://github.com/louis-e/arnis/issues/66)
|
||||
- [ ] Add support for inner attribute in multipolygons and multipolygon elements other than buildings
|
||||
- [ ] Fix Github Action Workflow for releasing Linux & MacOS Binary
|
||||
- [ ] Evaluate and implement faster region saving
|
||||
- [ ] Refactor bridges implementation
|
||||
- [ ] Refactor railway implementation
|
||||
- [ ] Better code documentation
|
||||
- [ ] Refactor fountain structure implementation
|
||||
- [ ] Luanti Support (https://github.com/louis-e/arnis/issues/120)
|
||||
- [ ] Minecraft Bedrock Edition Support (https://github.com/louis-e/arnis/issues/148)
|
||||
- [x] Evaluate and implement elevation (https://github.com/louis-e/arnis/issues/66)
|
||||
- [x] Refactor railway implementation
|
||||
- [x] Evaluate and implement faster region saving
|
||||
- [x] Support multipolygons (https://github.com/louis-e/arnis/issues/112, https://github.com/louis-e/arnis/issues/114)
|
||||
- [x] Memory optimization
|
||||
- [x] Fix Github Action Workflow for releasing MacOS Binary
|
||||
- [x] Design and implement a GUI
|
||||
- [x] Automatic new world creation instead of using an existing world
|
||||
- [x] Fix faulty empty chunks ([https://github.com/owengage/fastnbt/issues/120](https://github.com/owengage/fastnbt/issues/120)) (workaround found)
|
||||
@@ -92,7 +103,7 @@ Feel free to choose an item from the To-Do or Known Bugs list, or bring your own
|
||||
#### How to contribute
|
||||
This project is open source and welcomes contributions from everyone! Whether you're interested in fixing bugs, improving performance, adding new features, or enhancing documentation, your input is valuable. Simply fork the repository, make your changes, and submit a pull request. We encourage discussions and suggestions to ensure the project remains modular, optimized, and easy to use for the community. You can use the parameter --debug to get a more detailed output of the processed values, which can be helpful for debugging and development. Contributions of all levels are appreciated, and your efforts help improve this tool for everyone.
|
||||
|
||||
Build and run it using: ```cargo run --release -- --path="C:/YOUR_PATH/.minecraft/saves/worldname" --bbox="min_lng,min_lat,max_lng,max_lat"```<br>
|
||||
Build and run it using: ```cargo run --release --no-default-features -- --path="C:/YOUR_PATH/.minecraft/saves/worldname" --bbox="min_lng,min_lat,max_lng,max_lat"```<br>
|
||||
For the GUI: ```cargo run --release```<br>
|
||||
|
||||
After your pull request was merged, I will take care of regularly creating update releases which will include your changes.
|
||||
@@ -108,14 +119,27 @@ After your pull request was merged, I will take care of regularly creating updat
|
||||
</a>
|
||||
|
||||
## :copyright: License Information
|
||||
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).[^3]
|
||||
|
||||
Copyright (c) 2022-2025 Louis Erbkamm (louis-e)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.[^3]
|
||||
|
||||
Download Arnis only from the official source (https://github.com/louis-e/arnis/). Every other website providing a download and claiming to be affiliated with the project is unofficial and may be malicious.
|
||||
|
||||
The logo was made by @nxfx21.
|
||||
|
||||
|
||||
[^1]: https://en.wikipedia.org/wiki/OpenStreetMap
|
||||
|
||||
[^2]: https://en.wikipedia.org/wiki/Arnis,_Germany
|
||||
|
||||
[^3]:
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
For the full license text, see the LICENSE file.
|
||||
[^3]: https://github.com/louis-e/arnis/blob/main/LICENSE
|
||||
|
||||
@@ -21,6 +21,13 @@
|
||||
openssl.dev
|
||||
pkg-config
|
||||
fenixPkgs.toolchain
|
||||
wayland
|
||||
glib
|
||||
gdk-pixbuf
|
||||
pango
|
||||
gtk3
|
||||
libsoup_3.dev
|
||||
webkitgtk_4_1.dev
|
||||
];
|
||||
};
|
||||
});
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB |
63
gui-src/css/styles.css
vendored
63
gui-src/css/styles.css
vendored
@@ -186,6 +186,7 @@ button:hover {
|
||||
button {
|
||||
color: #ffffff;
|
||||
background-color: #0f0f0f98;
|
||||
border-style: inherit;
|
||||
}
|
||||
button:active {
|
||||
background-color: #0f0f0f69;
|
||||
@@ -202,39 +203,6 @@ button:hover {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tooltip .tooltiptext {
|
||||
visibility: hidden;
|
||||
width: 90%;
|
||||
background-color: #808080;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 5px 0;
|
||||
border-radius: 6px;
|
||||
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
bottom: -100%;
|
||||
left: 5%;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.tooltip .tooltiptext::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: -10px;
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
border-width: 5px;
|
||||
border-style: solid;
|
||||
border-color: transparent transparent #808080 transparent;
|
||||
}
|
||||
|
||||
.tooltip:hover .tooltiptext {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.controls-box button {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -275,6 +243,14 @@ button:hover {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
#terrain-toggle {
|
||||
accent-color: #fecc44;
|
||||
}
|
||||
|
||||
.terrain-toggle-container, .scale-slider-container {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
#winter-toggle {
|
||||
accent-color: #fecc44;
|
||||
}
|
||||
@@ -356,3 +332,24 @@ button:hover {
|
||||
content: "⚙️";
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
/* Logo Animation */
|
||||
#arnis-logo {
|
||||
width: 35%;
|
||||
height: auto;
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
animation: zoomInLogo 1s ease-out forwards;
|
||||
}
|
||||
|
||||
/* Keyframe Animation */
|
||||
@keyframes zoomInLogo {
|
||||
0% {
|
||||
transform: scale(0);
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
BIN
gui-src/images/logo.png
vendored
BIN
gui-src/images/logo.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 231 KiB |
64
gui-src/index.html
vendored
64
gui-src/index.html
vendored
@@ -7,21 +7,22 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Arnis</title>
|
||||
<script type="module" src="./js/main.js" defer></script>
|
||||
<script type="module" src="./js/license.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="container">
|
||||
<div class="row">
|
||||
<a href="https://github.com/louis-e/arnis" target="_blank">
|
||||
<img src="./images/logo.png" class="logo arnis" alt="Arnis Logo" />
|
||||
<img src="./images/logo.png" id="arnis-logo" class="logo arnis" alt="Arnis Logo" style="width: 35%; height: auto;" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="flex-container">
|
||||
<!-- Left Box: Map and BBox Input -->
|
||||
<section class="section map-box" style="margin-bottom: 0; padding-bottom: 0;">
|
||||
<h2>Select Location</h2>
|
||||
<span id="bbox-text" style="font-size: 1.0em; display: block; margin-top: -8px; margin-bottom: 3px;">
|
||||
<h2 data-localize="select_location">Select Location</h2>
|
||||
<span id="bbox-text" style="font-size: 1.0em; display: block; margin-top: -8px; margin-bottom: 3px;" data-localize="zoom_in_and_choose">
|
||||
Zoom in and choose your area using the rectangle tool
|
||||
</span>
|
||||
<iframe src="maps.html" width="100%" height="300" class="map-container" title="Map Picker"></iframe>
|
||||
@@ -33,24 +34,21 @@
|
||||
<!-- Right Box: Directory Selection, Start Button, and Progress Bar -->
|
||||
<section class="section controls-box">
|
||||
<div class="controls-content">
|
||||
<h2>Select World</h2>
|
||||
<h2 data-localize="select_world">Select World</h2>
|
||||
|
||||
<!-- Updated Tooltip Structure -->
|
||||
<div class="tooltip" style="width: 100%;">
|
||||
<button type="button" onclick="openWorldPicker()" style="padding: 10px; line-height: 1.2; width: 100%;">
|
||||
Choose World
|
||||
<span id="choose_world">Choose World</span>
|
||||
<br>
|
||||
<span id="selected-world" style="font-size: 0.8em; color: #fecc44; display: block; margin-top: 4px;">
|
||||
<span id="selected-world" style="font-size: 0.8em; color: #fecc44; display: block; margin-top: 4px;" data-localize="no_world_selected">
|
||||
No world selected
|
||||
</span>
|
||||
</button>
|
||||
<span class="tooltiptext" style="font-size: 0.8em; line-height: 1.2;">
|
||||
Please select a Minecraft world that can be overwritten, as the generation process will replace existing structures in the chosen world!
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="button-container">
|
||||
<button type="button" id="start-button" class="start-button" onclick="startGeneration()">Start Generation</button>
|
||||
<button type="button" id="start-button" class="start-button" onclick="startGeneration()" data-localize="start_generation">Start Generation</button>
|
||||
<button type="button" class="settings-button" onclick="openSettings()">
|
||||
<i class="gear-icon"></i>
|
||||
</button>
|
||||
@@ -58,7 +56,7 @@
|
||||
<br><br>
|
||||
|
||||
<div class="progress-section">
|
||||
<h2>Progress</h2>
|
||||
<h2 data-localize="progress">Progress</h2>
|
||||
<div class="progress-bar-container">
|
||||
<div class="progress-bar" id="progress-bar"></div>
|
||||
</div>
|
||||
@@ -75,10 +73,10 @@
|
||||
<div id="world-modal" class="modal" style="display: none;">
|
||||
<div class="modal-content">
|
||||
<span class="close-button" onclick="closeWorldPicker()">×</span>
|
||||
<h2>Choose World</h2>
|
||||
<h2 data-localize="choose_world_modal_title">Choose World</h2>
|
||||
|
||||
<button type="button" id="select-world-button" class="select-world-button" onclick="selectWorld(false)">Select existing world</button>
|
||||
<button type="button" id="generate-world-button" class="generate-world-button" onclick="selectWorld(true)">Generate new world</button>
|
||||
<button type="button" id="select-world-button" class="select-world-button" onclick="selectWorld(false)" data-localize="select_existing_world">Select existing world</button>
|
||||
<button type="button" id="generate-world-button" class="generate-world-button" onclick="selectWorld(true)" data-localize="generate_new_world">Generate new world</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -86,45 +84,65 @@
|
||||
<div id="settings-modal" class="modal" style="display: none;">
|
||||
<div class="modal-content">
|
||||
<span class="close-button" onclick="closeSettings()">×</span>
|
||||
<h2>Customization Settings</h2>
|
||||
<h2 data-localize="customization_settings">Customization Settings</h2>
|
||||
|
||||
<!-- Terrain Toggle Button -->
|
||||
<div class="terrain-toggle-container">
|
||||
<label for="terrain-toggle" data-localize="terrain">Terrain:</label>
|
||||
<input type="checkbox" id="terrain-toggle" name="terrain-toggle">
|
||||
</div>
|
||||
|
||||
<!-- Winter Mode Toggle Button -->
|
||||
<div class="winter-toggle-container">
|
||||
<label for="winter-toggle">Winter Mode:</label>
|
||||
<label for="winter-toggle" data-localize="winter_mode">Winter Mode:</label>
|
||||
<input type="checkbox" id="winter-toggle" name="winter-toggle">
|
||||
</div>
|
||||
|
||||
<!-- World Scale Slider -->
|
||||
<div class="scale-slider-container">
|
||||
<label for="scale-value-slider">World Scale:</label>
|
||||
<label for="scale-value-slider" data-localize="world_scale">World Scale:</label>
|
||||
<input type="range" id="scale-value-slider" name="scale-value-slider" min="0.30" max="2.5" step="0.1" value="1">
|
||||
<span id="slider-value">1.00</span>
|
||||
</div>
|
||||
|
||||
<!-- Bounding Box Input -->
|
||||
<div class="bbox-input-container">
|
||||
<label for="bbox-coords">Custom Bounding Box:</label>
|
||||
<input type="text" id="bbox-coords" name="bbox-coords" maxlength="55" style="width: 280px;" autocomplete="one-time-code" placeholder="Format: lat,lng,lat,lng">
|
||||
<label for="bbox-coords" data-localize="custom_bounding_box">Custom Bounding Box:</label>
|
||||
<input type="text" id="bbox-coords" name="bbox-coords" maxlength="55" style="width: 280px;" placeholder="Format: lat,lng,lat,lng">
|
||||
</div>
|
||||
|
||||
<!-- Floodfill Timeout Input -->
|
||||
<div class="timeout-input-container">
|
||||
<label for="floodfill-timeout">Floodfill Timeout (sec):</label>
|
||||
<label for="floodfill-timeout" data-localize="floodfill_timeout">Floodfill Timeout (sec):</label>
|
||||
<input type="number" id="floodfill-timeout" name="floodfill-timeout" min="0" step="1" value="20" style="width: 100px;" placeholder="Seconds">
|
||||
</div><br>
|
||||
|
||||
<!-- Ground Level Input -->
|
||||
<div class="ground-level-input-container">
|
||||
<label for="ground-level">Ground Level:</label>
|
||||
<label for="ground-level" data-localize="ground_level">Ground Level:</label>
|
||||
<input type="number" id="ground-level" name="ground-level" min="-64" max="290" value="-62" style="width: 100px;" placeholder="Ground Level">
|
||||
</div>
|
||||
|
||||
<!-- License and Credits Button -->
|
||||
<button type="button" id="license-button" class="license-button" onclick="openLicense()" data-localize="license_and_credits">License and Credits</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- License Modal -->
|
||||
<div id="license-modal" class="modal" style="display: none;">
|
||||
<div class="modal-content">
|
||||
<span class="close-button" onclick="closeLicense()">×</span>
|
||||
<h2 data-localize="license_and_credits">License and Credits</h2>
|
||||
<div id="license-content" style="overflow-y: auto; max-height: 300px; font-size: 0.85em; line-height: 1.3; padding: 10px; border: 1px solid #ccc; border-radius: 4px;">
|
||||
Loading...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="footer">
|
||||
<a href="https://github.com/louis-e/arnis" target="_blank" class="footer-link">
|
||||
© <span id="current-year"></span> Arnis v<span id="version-placeholder">x.x.x</span> by louis-e
|
||||
<a href="https://github.com/louis-e/arnis" target="_blank" class="footer-link" data-localize="footer_text">
|
||||
© {year} Arnis v{version} by louis-e
|
||||
</a>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
85
gui-src/js/bbox.js
vendored
85
gui-src/js/bbox.js
vendored
@@ -322,7 +322,7 @@ function addLayer(layer, name, title, zIndex, on) {
|
||||
}
|
||||
link.innerHTML = name;
|
||||
link.title = title;
|
||||
link.onclick = function(e) {
|
||||
link.onclick = function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
@@ -456,13 +456,19 @@ $(document).ready(function () {
|
||||
** on top of your DOM
|
||||
**
|
||||
*/
|
||||
$('input[type="textarea"]').on('click', function (evt) { this.select() });
|
||||
|
||||
// Have to init the projection input box as it is used to format the initial values
|
||||
// init the projection input box as it is used to format the initial values
|
||||
$('input[type="textarea"]').on('click', function (evt) { this.select() });
|
||||
$("#projection").val(currentproj);
|
||||
|
||||
L.mapbox.accessToken = 'pk.eyJ1IjoiY3Vnb3MiLCJhIjoiY2p4Nm43MzA3MDFmZDQwcGxsMjB4Z3hnNiJ9.SQbnMASwdqZe6G4n6OMvVw';
|
||||
map = L.mapbox.map('map').setView([50.114768, 8.687322], 4).addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));
|
||||
// Initialize map with OpenStreetMap tiles
|
||||
map = L.map('map').setView([50.114768, 8.687322], 4);
|
||||
|
||||
// Add OpenStreetMap tile layer (free to use with attribution)
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© Map data from <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
|
||||
maxZoom: 19
|
||||
}).addTo(map);
|
||||
|
||||
rsidebar = L.control.sidebar('rsidebar', {
|
||||
position: 'right',
|
||||
@@ -498,14 +504,25 @@ $(document).ready(function () {
|
||||
|
||||
// Initialize the FeatureGroup to store editable layers
|
||||
drawnItems = new L.FeatureGroup();
|
||||
map.addLayer(drawnItems);
|
||||
|
||||
// Initialize the draw control and pass it the FeatureGroup of editable layers
|
||||
map.addLayer(drawnItems); // Initialize the draw control and pass it the FeatureGroup of editable layers
|
||||
drawControl = new L.Control.Draw({
|
||||
edit: {
|
||||
featureGroup: drawnItems
|
||||
},
|
||||
draw: {
|
||||
rectangle: {
|
||||
shapeOptions: {
|
||||
color: '#fe57a1',
|
||||
opacity: 0.6,
|
||||
weight: 3,
|
||||
fillColor: '#fe57a1',
|
||||
fillOpacity: 0.1,
|
||||
dashArray: '10, 10',
|
||||
lineCap: 'round',
|
||||
lineJoin: 'round'
|
||||
},
|
||||
repeatMode: false
|
||||
},
|
||||
polyline: false,
|
||||
polygon: false,
|
||||
circle: false,
|
||||
@@ -513,7 +530,6 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
map.addControl(drawControl);
|
||||
|
||||
/*
|
||||
**
|
||||
** create bounds layer
|
||||
@@ -523,17 +539,22 @@ $(document).ready(function () {
|
||||
**
|
||||
*/
|
||||
startBounds = new L.LatLngBounds([0.0, 0.0], [0.0, 0.0]);
|
||||
var bounds = new L.Rectangle(startBounds,
|
||||
{
|
||||
fill: false,
|
||||
opacity: 1.0,
|
||||
color: '#000'
|
||||
}
|
||||
);
|
||||
var bounds = new L.Rectangle(startBounds, {
|
||||
color: '#3778d4',
|
||||
opacity: 1.0,
|
||||
weight: 3,
|
||||
fill: '#3778d4',
|
||||
lineCap: 'round',
|
||||
lineJoin: 'round'
|
||||
});
|
||||
|
||||
bounds.on('bounds-set', function (e) {
|
||||
// move it to the end of the parent
|
||||
var parent = e.target._renderer._container.parentElement;
|
||||
$(parent).append(e.target._renderer._container);
|
||||
// move it to the end of the parent if renderer exists
|
||||
if (e.target._renderer && e.target._renderer._container) {
|
||||
var parent = e.target._renderer._container.parentElement;
|
||||
$(parent).append(e.target._renderer._container);
|
||||
}
|
||||
|
||||
// Set the hash
|
||||
var southwest = this.getBounds().getSouthWest();
|
||||
var northeast = this.getBounds().getNorthEast();
|
||||
@@ -543,8 +564,21 @@ $(document).ready(function () {
|
||||
var ymax = northeast.lat.toFixed(6);
|
||||
location.hash = ymin + ',' + xmin + ',' + ymax + ',' + xmax;
|
||||
});
|
||||
map.addLayer(bounds)
|
||||
map.addLayer(bounds);
|
||||
|
||||
map.on('draw:created', function (e) {
|
||||
// Check if it's a rectangle and set proper styles before adding it to the layer
|
||||
if (e.layerType === 'rectangle') {
|
||||
e.layer.setStyle({
|
||||
color: '#3778d4',
|
||||
opacity: 1.0,
|
||||
weight: 3,
|
||||
fill: '#3778d4',
|
||||
lineCap: 'round',
|
||||
lineJoin: 'round'
|
||||
});
|
||||
}
|
||||
|
||||
drawnItems.addLayer(e.layer);
|
||||
bounds.setBounds(drawnItems.getBounds())
|
||||
$('#boxbounds').text(formatBounds(bounds.getBounds(), '4326'));
|
||||
@@ -629,7 +663,14 @@ $(document).ready(function () {
|
||||
var splitBounds = initialBBox.split(',');
|
||||
startBounds = new L.LatLngBounds([splitBounds[0], splitBounds[1]],
|
||||
[splitBounds[2], splitBounds[3]]);
|
||||
var lyr = new L.Rectangle(startBounds);
|
||||
var lyr = new L.Rectangle(startBounds, {
|
||||
color: '#3778d4',
|
||||
opacity: 1.0,
|
||||
weight: 3,
|
||||
fill: '#3778d4',
|
||||
lineCap: 'round',
|
||||
lineJoin: 'round'
|
||||
});
|
||||
var evt = {
|
||||
layer: lyr,
|
||||
layerType: "polygon",
|
||||
@@ -654,4 +695,4 @@ $(document).ready(function () {
|
||||
function notifyBboxUpdate() {
|
||||
const bboxText = document.getElementById('boxbounds').textContent;
|
||||
window.parent.postMessage({ bboxText: bboxText }, '*');
|
||||
}
|
||||
}
|
||||
81
gui-src/js/license.js
vendored
Normal file
81
gui-src/js/license.js
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
export const licenseText = `
|
||||
<p><b>Contributors:</b></p>
|
||||
louis-e (Louis Erbkamm)<br>
|
||||
scd31<br>
|
||||
amir16yp<br>
|
||||
vfosnar<br>
|
||||
TheComputerGuy96<br>
|
||||
zer0-dev<br>
|
||||
RedAuburn<br>
|
||||
daniil2327<br>
|
||||
benjamin051000<br>
|
||||
|
||||
<p>For a full list of contributors, please refer to the <a href="https://github.com/louis-e/arnis" style="color: inherit;" target="_blank">Github page</a>. Logo made by nxfx21. Map data from <a href="https://www.openstreetmap.org/copyright" style="color: inherit;" target="_blank">OpenStreetMap</a>.</p>
|
||||
|
||||
<p style="color: #ff7070;"><b>Download Arnis only from the official source:</b> <a href="https://github.com/louis-e/arnis" style="color: inherit;" target="_blank">https://github.com/louis-e/arnis/</a>. Every other website providing a download and claiming to be affiliated with the project is unofficial and may be malicious.</p>
|
||||
|
||||
<p><b>License:</b></p>
|
||||
<pre style="white-space: pre-wrap; font-family: inherit;">
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized bythe copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and allother entities that control, are controlled by, or are under commoncontrol with that entity. For the purposes of this definition,"control" means (i) the power, direct or indirect, to cause thedirection or management of such entity, whether by contract orotherwise, or (ii) ownership of fifty percent (50%) or more of theoutstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entityexercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,including but not limited to software source code, documentationsource, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanicaltransformation or translation of a Source form, including butnot limited to compiled object code, generated documentation,and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source orObject form, made available under the License, as indicated by acopyright notice that is included in or attached to the work(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Objectform, that is based on (or derived from) the Work and for which theeditorial revisions, annotations, elaborations, or other modificationsrepresent, as a whole, an original work of authorship. For the purposesof this License, Derivative Works shall not include works that remainseparable from, or merely link (or bind by name) to the interfaces of,the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, includingthe original version of the Work and any modifications or additionsto that Work or Derivative Works thereof, that is intentionallysubmitted to Licensor for inclusion in the Work by the copyright owneror by an individual or Legal Entity authorized to submit on behalf ofthe copyright owner. For the purposes of this definition, "submitted"means any form of electronic, verbal, or written communication sentto the Licensor or its representatives, including but not limited tocommunication on electronic mailing lists, source code control systems,and issue tracking systems that are managed by, or on behalf of, theLicensor for the purpose of discussing and improving the Work, butexcluding communication that is conspicuously marked or otherwisedesignated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entityon behalf of whom a Contribution has been received by Licensor andsubsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions ofthis License, each Contributor hereby grants to You a perpetual,worldwide, non-exclusive, no-charge, royalty-free, irrevocablecopyright license to reproduce, prepare Derivative Works of,publicly display, publicly perform, sublicense, and distribute theWork and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions ofthis License, each Contributor hereby grants to You a perpetual,worldwide, non-exclusive, no-charge, royalty-free, irrevocable(except as stated in this section) patent license to make, have made,use, offer to sell, sell, import, and otherwise transfer the Work,where such license applies only to those patent claims licensableby such Contributor that are necessarily infringed by theirContribution(s) alone or by combination of their Contribution(s)with the Work to which such Contribution(s) was submitted. If Youinstitute patent litigation against any entity (including across-claim or counterclaim in a lawsuit) alleging that the Workor a Contribution incorporated within the Work constitutes director contributory patent infringement, then any patent licensesgranted to You under this License for that Work shall terminateas of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of theWork or Derivative Works thereof in any medium, with or withoutmodifications, and in Source or Object form, provided that Youmeet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications andmay provide additional or different license terms and conditionsfor use, reproduction, or distribution of Your modifications, orfor any such Derivative Works as a whole, provided Your use,reproduction, and distribution of the Work otherwise complies withthe conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,any Contribution intentionally submitted for inclusion in the Workby You to the Licensor shall be under the terms and conditions ofthis License, without any additional terms or conditions.Notwithstanding the above, nothing herein shall supersede or modifythe terms of any separate license agreement you may have executedwith Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the tradenames, trademarks, service marks, or product names of the Licensor,except as required for reasonable and customary use in describing theorigin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law oragreed to in writing, Licensor provides the Work (and eachContributor provides its Contributions) on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied, including, without limitation, any warranties or conditionsof TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR APARTICULAR PURPOSE. You are solely responsible for determining theappropriateness of using or redistributing the Work and assume anyrisks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,whether in tort (including negligence), contract, or otherwise,unless required by applicable law (such as deliberate and grosslynegligent acts) or agreed to in writing, shall any Contributor beliable to You for damages, including any direct, indirect, special,incidental, or consequential damages of any character arising as aresult of this License or out of the use or inability to use theWork (including but not limited to damages for loss of goodwill,work stoppage, computer failure or malfunction, or any and allother commercial damages or losses), even if such Contributorhas been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributingthe Work or Derivative Works thereof, You may choose to offer,and charge a fee for, acceptance of support, warranty, indemnity,or other liability obligations and/or rights consistent with thisLicense. However, in accepting such obligations, You may act onlyon Your own behalf and on Your sole responsibility, not on behalfof any other Contributor, and only if You agree to indemnify,defend, and hold each Contributor harmless for any liabilityincurred by, or claims asserted against, such Contributor by reasonof your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright ${new Date().getFullYear()} Louis Erbkamm
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions andlimitations under the License.
|
||||
</pre>
|
||||
`;
|
||||
244
gui-src/js/main.js
vendored
244
gui-src/js/main.js
vendored
@@ -1,9 +1,18 @@
|
||||
const { invoke } = window.__TAURI__.core;
|
||||
import { licenseText } from './license.js';
|
||||
|
||||
let invoke;
|
||||
if (window.__TAURI__) {
|
||||
invoke = window.__TAURI__.core.invoke;
|
||||
} else {
|
||||
function dummyFunc() {}
|
||||
window.__TAURI__ = { event: { listen: dummyFunc } };
|
||||
invoke = dummyFunc;
|
||||
}
|
||||
|
||||
const DEFAULT_LOCALE_PATH = `./locales/en.json`;
|
||||
|
||||
// Initialize elements and start the demo progress
|
||||
window.addEventListener("DOMContentLoaded", async () => {
|
||||
initFooter();
|
||||
await checkForUpdates();
|
||||
registerMessageEvent();
|
||||
window.selectWorld = selectWorld;
|
||||
window.startGeneration = startGeneration;
|
||||
@@ -11,20 +20,123 @@ window.addEventListener("DOMContentLoaded", async () => {
|
||||
initSettings();
|
||||
initWorldPicker();
|
||||
handleBboxInput();
|
||||
const localization = await getLocalization();
|
||||
await applyLocalization(localization);
|
||||
initFooter();
|
||||
await checkForUpdates();
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks if a JSON response is invalid or falls back to HTML
|
||||
* @param {Response} response - The fetch response object
|
||||
* @returns {boolean} True if the response is invalid JSON
|
||||
*/
|
||||
function invalidJSON(response) {
|
||||
// Workaround for Tauri always falling back to index.html for asset loading
|
||||
return !response.ok || response.headers.get("Content-Type") === "text/html";
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and returns localization data based on user's language
|
||||
* Falls back to English if requested language is not available
|
||||
* @returns {Promise<Object>} The localization JSON object
|
||||
*/
|
||||
async function getLocalization() {
|
||||
const lang = navigator.language;
|
||||
let response = await fetch(`./locales/${lang}.json`);
|
||||
|
||||
// Try with only first part of language code
|
||||
if (invalidJSON(response)) {
|
||||
response = await fetch(`./locales/${lang.split('-')[0]}.json`);
|
||||
|
||||
// Fallback to default English localization
|
||||
if (invalidJSON(response)) {
|
||||
response = await fetch(DEFAULT_LOCALE_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
const localization = await response.json();
|
||||
return localization;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an HTML element with localized text
|
||||
* @param {Object} json - Localization data
|
||||
* @param {Object} elementObject - Object containing element or selector
|
||||
* @param {string} localizedStringKey - Key for the localized string
|
||||
*/
|
||||
async function localizeElement(json, elementObject, localizedStringKey) {
|
||||
const element =
|
||||
(!elementObject.element || elementObject.element === "")
|
||||
? document.querySelector(elementObject.selector) : elementObject.element;
|
||||
const attribute = localizedStringKey.startsWith("placeholder_") ? "placeholder" : "textContent";
|
||||
|
||||
if (element) {
|
||||
if (localizedStringKey in json) {
|
||||
element[attribute] = json[localizedStringKey];
|
||||
} else {
|
||||
// Fallback to default (English) string
|
||||
const response = await fetch(DEFAULT_LOCALE_PATH);
|
||||
const defaultJson = await response.json();
|
||||
element[attribute] = defaultJson[localizedStringKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function applyLocalization(localization) {
|
||||
const localizationElements = {
|
||||
"h2[data-localize='select_location']": "select_location",
|
||||
"#bbox-text": "zoom_in_and_choose",
|
||||
"h2[data-localize='select_world']": "select_world",
|
||||
"span[id='choose_world']": "choose_world",
|
||||
"#selected-world": "no_world_selected",
|
||||
"#start-button": "start_generation",
|
||||
"h2[data-localize='progress']": "progress",
|
||||
"h2[data-localize='choose_world_modal_title']": "choose_world_modal_title",
|
||||
"button[data-localize='select_existing_world']": "select_existing_world",
|
||||
"button[data-localize='generate_new_world']": "generate_new_world",
|
||||
"h2[data-localize='customization_settings']": "customization_settings",
|
||||
"label[data-localize='winter_mode']": "winter_mode",
|
||||
"label[data-localize='world_scale']": "world_scale",
|
||||
"label[data-localize='custom_bounding_box']": "custom_bounding_box",
|
||||
"label[data-localize='floodfill_timeout']": "floodfill_timeout",
|
||||
"label[data-localize='ground_level']": "ground_level",
|
||||
".footer-link": "footer_text",
|
||||
"button[data-localize='license_and_credits']": "license_and_credits",
|
||||
"h2[data-localize='license_and_credits']": "license_and_credits",
|
||||
|
||||
// Placeholder strings
|
||||
"input[id='bbox-coords']": "placeholder_bbox",
|
||||
"input[id='floodfill-timeout']": "placeholder_floodfill",
|
||||
"input[id='ground-level']": "placeholder_ground"
|
||||
};
|
||||
|
||||
for (const selector in localizationElements) {
|
||||
localizeElement(localization, { selector: selector }, localizationElements[selector]);
|
||||
}
|
||||
|
||||
// Update error messages
|
||||
window.localization = localization;
|
||||
}
|
||||
|
||||
// Function to initialize the footer with the current year and version
|
||||
async function initFooter() {
|
||||
const currentYear = new Date().getFullYear();
|
||||
document.getElementById("current-year").textContent = currentYear;
|
||||
let version = "x.x.x";
|
||||
|
||||
try {
|
||||
const version = await invoke('gui_get_version');
|
||||
const footerLink = document.querySelector(".footer-link");
|
||||
footerLink.textContent = `© ${currentYear} Arnis v${version} by louis-e`;
|
||||
version = await invoke('gui_get_version');
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch version:", error);
|
||||
}
|
||||
|
||||
const footerElement = document.querySelector(".footer-link");
|
||||
if (footerElement) {
|
||||
footerElement.textContent =
|
||||
footerElement.textContent
|
||||
.replace("{year}", currentYear)
|
||||
.replace("{version}", version);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to check for updates and display a notification if available
|
||||
@@ -42,7 +154,7 @@ async function checkForUpdates() {
|
||||
updateMessage.style.display = "block";
|
||||
updateMessage.style.textDecoration = "none";
|
||||
|
||||
updateMessage.textContent = "There's a new version available! Click here to download it.";
|
||||
localizeElement(window.localization, { element: updateMessage }, "new_version_available");
|
||||
footer.style.marginTop = "15px";
|
||||
footer.appendChild(updateMessage);
|
||||
}
|
||||
@@ -118,6 +230,29 @@ function initSettings() {
|
||||
slider.addEventListener("input", () => {
|
||||
sliderValue.textContent = parseFloat(slider.value).toFixed(2);
|
||||
});
|
||||
|
||||
|
||||
/// License and Credits
|
||||
function openLicense() {
|
||||
const licenseModal = document.getElementById("license-modal");
|
||||
const licenseContent = document.getElementById("license-content");
|
||||
|
||||
// Render the license text as HTML
|
||||
licenseContent.innerHTML = licenseText;
|
||||
|
||||
// Show the modal
|
||||
licenseModal.style.display = "flex";
|
||||
licenseModal.style.justifyContent = "center";
|
||||
licenseModal.style.alignItems = "center";
|
||||
}
|
||||
|
||||
function closeLicense() {
|
||||
const licenseModal = document.getElementById("license-modal");
|
||||
licenseModal.style.display = "none";
|
||||
}
|
||||
|
||||
window.openLicense = openLicense;
|
||||
window.closeLicense = closeLicense;
|
||||
}
|
||||
|
||||
function initWorldPicker() {
|
||||
@@ -140,7 +275,11 @@ function initWorldPicker() {
|
||||
window.closeWorldPicker = closeWorldPicker;
|
||||
}
|
||||
|
||||
// Function to validate and handle bbox input
|
||||
/**
|
||||
* Validates and processes bounding box coordinates input
|
||||
* Supports both comma and space-separated formats
|
||||
* Updates the map display when valid coordinates are entered
|
||||
*/
|
||||
function handleBboxInput() {
|
||||
const inputBox = document.getElementById("bbox-coords");
|
||||
const bboxInfo = document.getElementById("bbox-info");
|
||||
@@ -178,25 +317,38 @@ function handleBboxInput() {
|
||||
const bboxText = `${lat1} ${lng1} ${lat2} ${lng2}`;
|
||||
window.dispatchEvent(new MessageEvent('message', { data: { bboxText } }));
|
||||
|
||||
// Show custom bbox on the map
|
||||
let map_container = document.querySelector('.map-container');
|
||||
map_container.setAttribute('src', `maps.html#${lat1},${lng1},${lat2},${lng2}`);
|
||||
map_container.contentWindow.location.reload();
|
||||
|
||||
// Update the info text
|
||||
bboxInfo.textContent = "Custom selection confirmed!";
|
||||
localizeElement(window.localization, { element: bboxInfo }, "custom_selection_confirmed");
|
||||
bboxInfo.style.color = "#7bd864";
|
||||
} else {
|
||||
// Valid numbers but invalid order or range
|
||||
bboxInfo.textContent = "Error: Coordinates are out of range or incorrectly ordered (Lat before Lng required).";
|
||||
localizeElement(window.localization, { element: bboxInfo }, "error_coordinates_out_of_range");
|
||||
bboxInfo.style.color = "#fecc44";
|
||||
selectedBBox = "";
|
||||
}
|
||||
} else {
|
||||
// Input doesn't match the required format
|
||||
bboxInfo.textContent = "Invalid format. Please use 'lat,lng,lat,lng' or 'lat lng lat lng'.";
|
||||
localizeElement(window.localization, { element: bboxInfo }, "invalid_format");
|
||||
bboxInfo.style.color = "#fecc44";
|
||||
selectedBBox = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to calculate the bounding box "size" in square meters based on latitude and longitude
|
||||
/**
|
||||
* Calculates the approximate area of a bounding box in square meters
|
||||
* Uses the Haversine formula for geodesic calculations
|
||||
* @param {number} lng1 - First longitude coordinate
|
||||
* @param {number} lat1 - First latitude coordinate
|
||||
* @param {number} lng2 - Second longitude coordinate
|
||||
* @param {number} lat2 - Second latitude coordinate
|
||||
* @returns {number} Area in square meters
|
||||
*/
|
||||
function calculateBBoxSize(lng1, lat1, lng2, lat2) {
|
||||
// Approximate distance calculation using Haversine formula or geodesic formula
|
||||
const toRad = (angle) => (angle * Math.PI) / 180;
|
||||
@@ -217,13 +369,17 @@ function calculateBBoxSize(lng1, lat1, lng2, lat2) {
|
||||
return Math.abs(width * height);
|
||||
}
|
||||
|
||||
// Function to normalize longitude to the range [-180, 180]
|
||||
/**
|
||||
* Normalizes a longitude value to the range [-180, 180]
|
||||
* @param {number} lon - Longitude value to normalize
|
||||
* @returns {number} Normalized longitude value
|
||||
*/
|
||||
function normalizeLongitude(lon) {
|
||||
return ((lon + 180) % 360 + 360) % 360 - 180;
|
||||
}
|
||||
|
||||
const threshold1 = 12332660.00;
|
||||
const threshold2 = 36084700.00;
|
||||
const threshold1 = 30000000.00;
|
||||
const threshold2 = 45000000.00;
|
||||
let selectedBBox = "";
|
||||
|
||||
// Function to handle incoming bbox data
|
||||
@@ -248,13 +404,13 @@ function displayBboxInfoText(bboxText) {
|
||||
const selectedSize = calculateBBoxSize(lng1, lat1, lng2, lat2);
|
||||
|
||||
if (selectedSize > threshold2) {
|
||||
bboxInfo.textContent = "This area is very large and could exceed typical computing limits.";
|
||||
localizeElement(window.localization, { element: bboxInfo }, "area_too_large");
|
||||
bboxInfo.style.color = "#fa7878";
|
||||
} else if (selectedSize > threshold1) {
|
||||
bboxInfo.textContent = "The area is quite extensive and may take significant time and resources.";
|
||||
localizeElement(window.localization, { element: bboxInfo }, "area_extensive");
|
||||
bboxInfo.style.color = "#fecc44";
|
||||
} else {
|
||||
bboxInfo.textContent = "Selection confirmed!";
|
||||
localizeElement(window.localization, { element: bboxInfo }, "selection_confirmed");
|
||||
bboxInfo.style.color = "#7bd864";
|
||||
}
|
||||
}
|
||||
@@ -270,16 +426,38 @@ async function selectWorld(generate_new_world) {
|
||||
document.getElementById('selected-world').style.color = "#fecc44";
|
||||
}
|
||||
} catch (error) {
|
||||
worldPath = error;
|
||||
console.error(error);
|
||||
document.getElementById('selected-world').textContent = error;
|
||||
document.getElementById('selected-world').style.color = "#fa7878";
|
||||
handleWorldSelectionError(error);
|
||||
}
|
||||
|
||||
closeWorldPicker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles world selection errors and displays appropriate messages
|
||||
* @param {number} errorCode - Error code from the backend
|
||||
*/
|
||||
function handleWorldSelectionError(errorCode) {
|
||||
const errorKeys = {
|
||||
1: "minecraft_directory_not_found",
|
||||
2: "world_in_use",
|
||||
3: "failed_to_create_world",
|
||||
4: "no_world_selected_error"
|
||||
};
|
||||
|
||||
const errorKey = errorKeys[errorCode] || "unknown_error";
|
||||
const selectedWorld = document.getElementById('selected-world');
|
||||
localizeElement(window.localization, { element: selectedWorld }, errorKey);
|
||||
selectedWorld.style.color = "#fa7878";
|
||||
worldPath = "";
|
||||
console.error(errorCode);
|
||||
}
|
||||
|
||||
let generationButtonEnabled = true;
|
||||
/**
|
||||
* Initiates the world generation process
|
||||
* Validates required inputs and sends generation parameters to the backend
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function startGeneration() {
|
||||
try {
|
||||
if (generationButtonEnabled === false) {
|
||||
@@ -287,23 +465,20 @@ async function startGeneration() {
|
||||
}
|
||||
|
||||
if (!selectedBBox || selectedBBox == "0.000000 0.000000 0.000000 0.000000") {
|
||||
document.getElementById('bbox-info').textContent = "Select a location first!";
|
||||
document.getElementById('bbox-info').style.color = "#fa7878";
|
||||
const bboxInfo = document.getElementById('bbox-info');
|
||||
localizeElement(window.localization, { element: bboxInfo }, "select_location_first");
|
||||
bboxInfo.style.color = "#fa7878";
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
worldPath === "No world selected" ||
|
||||
worldPath == "Invalid Minecraft world" ||
|
||||
worldPath == "The selected world is currently in use" ||
|
||||
worldPath == "Minecraft directory not found" ||
|
||||
worldPath === ""
|
||||
) {
|
||||
document.getElementById('selected-world').textContent = "Select a Minecraft world first!";
|
||||
document.getElementById('selected-world').style.color = "#fa7878";
|
||||
if (!worldPath || worldPath === "") {
|
||||
const selectedWorld = document.getElementById('selected-world');
|
||||
localizeElement(window.localization, { element: selectedWorld }, "select_minecraft_world_first");
|
||||
selectedWorld.style.color = "#fa7878";
|
||||
return;
|
||||
}
|
||||
|
||||
var terrain = document.getElementById("terrain-toggle").checked;
|
||||
var winter_mode = document.getElementById("winter-toggle").checked;
|
||||
var scale = parseFloat(document.getElementById("scale-value-slider").value);
|
||||
var floodfill_timeout = parseInt(document.getElementById("floodfill-timeout").value, 10);
|
||||
@@ -321,6 +496,7 @@ async function startGeneration() {
|
||||
groundLevel: ground_level,
|
||||
winterMode: winter_mode,
|
||||
floodfillTimeout: floodfill_timeout,
|
||||
terrainEnabled: terrain
|
||||
});
|
||||
|
||||
console.log("Generation process started.");
|
||||
|
||||
66
gui-src/js/maps/mapbox.v3.2.0.js
vendored
66
gui-src/js/maps/mapbox.v3.2.0.js
vendored
File diff suppressed because one or more lines are too long
38
gui-src/locales/de.json
vendored
Normal file
38
gui-src/locales/de.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "Standort auswählen",
|
||||
"zoom_in_and_choose": "Zoome hinein und wähle dein Gebiet aus",
|
||||
"select_world": "Welt auswählen",
|
||||
"choose_world": "Welt wählen",
|
||||
"no_world_selected": "Keine Welt ausgewählt",
|
||||
"start_generation": "Generierung starten",
|
||||
"progress": "Fortschritt",
|
||||
"custom_selection_confirmed": "Benutzerdefinierte Auswahl bestätigt!",
|
||||
"error_coordinates_out_of_range": "Fehler: Koordinaten sind außerhalb des Bereichs oder falsch geordnet (Lat vor Lng erforderlich).",
|
||||
"invalid_format": "Ungültiges Format. Bitte verwende 'lat,lng,lat,lng' oder 'lat lng lat lng'.",
|
||||
"generation_process_started": "Generierungsprozess gestartet.",
|
||||
"winter_mode": "Wintermodus:",
|
||||
"world_scale": "Weltmaßstab:",
|
||||
"custom_bounding_box": "Benutzerdefinierte BBOX:",
|
||||
"floodfill_timeout": "Floodfill-Timeout (Sek):",
|
||||
"ground_level": "Bodenhöhe:",
|
||||
"choose_world_modal_title": "Welt wählen",
|
||||
"select_existing_world": "Vorhandene Welt auswählen",
|
||||
"generate_new_world": "Neue Welt generieren",
|
||||
"customization_settings": "Anpassungseinstellungen",
|
||||
"footer_text": "© {year} Arnis v{version} von louis-e",
|
||||
"new_version_available": "Eine neue Version ist verfügbar! Klicke hier, um sie herunterzuladen.",
|
||||
"minecraft_directory_not_found": "Minecraft Verzeichnis nicht gefunden",
|
||||
"world_in_use": "Die ausgewählte Welt ist gerade in Benutzung",
|
||||
"failed_to_create_world": "Neue Welt konnte nicht erstellt werden",
|
||||
"no_world_selected_error": "Keine Welt ausgewählt",
|
||||
"select_minecraft_world_first": "Wähle zuerst eine Minecraft Welt aus!",
|
||||
"select_location_first": "Wähle zuerst einen Standort aus!",
|
||||
"area_too_large": "Dieses Gebiet ist sehr groß und könnte das Berechnungslimit überschreiten.",
|
||||
"area_extensive": "Diese Gebietsgröße könnte längere Zeit für die Generierung benötigen.",
|
||||
"selection_confirmed": "Auswahl bestätigt!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Sekunden",
|
||||
"placeholder_ground": "Bodenhöhe"
|
||||
}
|
||||
38
gui-src/locales/en-US.json
vendored
Normal file
38
gui-src/locales/en-US.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "Select Location",
|
||||
"zoom_in_and_choose": "Zoom in and choose your area using the rectangle tool",
|
||||
"select_world": "Select World",
|
||||
"choose_world": "Choose World",
|
||||
"no_world_selected": "No world selected",
|
||||
"start_generation": "Start Generation",
|
||||
"progress": "Progress",
|
||||
"custom_selection_confirmed": "Custom selection confirmed!",
|
||||
"error_coordinates_out_of_range": "Error: Coordinates are out of range or incorrectly ordered (Lat before Lng required).",
|
||||
"invalid_format": "Invalid format. Please use 'lat,lng,lat,lng' or 'lat lng lat lng'.",
|
||||
"generation_process_started": "Generation process started.",
|
||||
"winter_mode": "Winter Mode:",
|
||||
"world_scale": "World Scale:",
|
||||
"custom_bounding_box": "Custom Bounding Box:",
|
||||
"floodfill_timeout": "Floodfill Timeout (sec):",
|
||||
"ground_level": "Ground Level:",
|
||||
"choose_world_modal_title": "Choose World",
|
||||
"select_existing_world": "Select existing world",
|
||||
"generate_new_world": "Generate new world",
|
||||
"customization_settings": "Customization Settings",
|
||||
"footer_text": "© {year} Arnis v{version} by louis-e",
|
||||
"new_version_available": "There's a new version available! Click here to download it.",
|
||||
"minecraft_directory_not_found": "Minecraft directory not found",
|
||||
"world_in_use": "The selected world is currently in use",
|
||||
"failed_to_create_world": "Failed to create new world",
|
||||
"no_world_selected_error": "No world selected",
|
||||
"select_minecraft_world_first": "Select a Minecraft world first!",
|
||||
"select_location_first": "Select a location first!",
|
||||
"area_too_large": "This area is very large and could exceed typical computing limits.",
|
||||
"area_extensive": "The area is quite extensive and may take significant time and resources.",
|
||||
"selection_confirmed": "Selection confirmed!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level"
|
||||
}
|
||||
1
gui-src/locales/en.json
vendored
Symbolic link
1
gui-src/locales/en.json
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
en-US.json
|
||||
38
gui-src/locales/es.json
vendored
Normal file
38
gui-src/locales/es.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "Seleccionar ubicación",
|
||||
"zoom_in_and_choose": "Acércate y elige tu área usando la herramienta de rectángulo",
|
||||
"select_world": "Seleccionar mundo",
|
||||
"choose_world": "Elegir mundo",
|
||||
"no_world_selected": "Ningún mundo seleccionado",
|
||||
"start_generation": "Iniciar generación",
|
||||
"progress": "Progreso",
|
||||
"custom_selection_confirmed": "¡Selección personalizada confirmada!",
|
||||
"error_coordinates_out_of_range": "Error: Las coordenadas están fuera de rango o están ordenadas incorrectamente (Lat antes de Lng requerido).",
|
||||
"invalid_format": "Formato inválido. Por favor, use 'lat,lng,lat,lng' o 'lat lng lat lng'.",
|
||||
"generation_process_started": "Proceso de generación iniciado.",
|
||||
"winter_mode": "Modo invierno:",
|
||||
"world_scale": "Escala del mundo:",
|
||||
"custom_bounding_box": "Caja delimitadora personalizada:",
|
||||
"floodfill_timeout": "Tiempo de espera de relleno (seg):",
|
||||
"ground_level": "Nivel del suelo:",
|
||||
"choose_world_modal_title": "Elegir mundo",
|
||||
"select_existing_world": "Seleccionar mundo existente",
|
||||
"generate_new_world": "Generar nuevo mundo",
|
||||
"customization_settings": "Configuración de personalización",
|
||||
"footer_text": "© {year} Arnis v{version} por louis-e",
|
||||
"new_version_available": "¡Hay una nueva versión disponible! Haga clic aquí para descargarla.",
|
||||
"minecraft_directory_not_found": "Directorio de Minecraft no encontrado",
|
||||
"world_in_use": "El mundo seleccionado está en uso",
|
||||
"failed_to_create_world": "No se pudo crear un nuevo mundo",
|
||||
"no_world_selected_error": "Ningún mundo seleccionado",
|
||||
"select_minecraft_world_first": "¡Seleccione un mundo de Minecraft primero!",
|
||||
"select_location_first": "¡Seleccione una ubicación primero!",
|
||||
"area_too_large": "Esta área es muy grande y podría exceder los límites típicos de computación.",
|
||||
"area_extensive": "El área es bastante extensa y puede requerir mucho tiempo y recursos.",
|
||||
"selection_confirmed": "¡Selección confirmada!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level"
|
||||
}
|
||||
38
gui-src/locales/fi.json
vendored
Normal file
38
gui-src/locales/fi.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "Valitse paikka",
|
||||
"zoom_in_and_choose": "Zoomaa ja valitse paikka käyttämällä suorakulmatyökalua.",
|
||||
"select_world": "Valitse maailma",
|
||||
"choose_world": "Valitse maailma",
|
||||
"no_world_selected": "Maailmaa ei valittu",
|
||||
"start_generation": "Aloita generointi",
|
||||
"progress": "Edistys",
|
||||
"custom_selection_confirmed": "Mukautettu valinta vahvistettu!",
|
||||
"error_coordinates_out_of_range": "Virhe: Koordinaatit ovat kantaman ulkopuolella tai vääriin aseteltu (Lat ennen Lng vaadittu).",
|
||||
"invalid_format": "Väärä formaatti. Käytä 'lat,lng,lat,lng' tai 'lat lng lat lng'.",
|
||||
"generation_process_started": "Luontiprosessi aloitettu.",
|
||||
"winter_mode": "Talvitila:",
|
||||
"world_scale": "Maailmanskaalaus:",
|
||||
"custom_bounding_box": "Mukautettu rajoituslaatikko:",
|
||||
"floodfill_timeout": "Täytön aikakatkaisu (sec):",
|
||||
"ground_level": "Maataso:",
|
||||
"choose_world_modal_title": "Valitse maailma",
|
||||
"select_existing_world": "Valitse olemassa oleva maailma",
|
||||
"generate_new_world": "Luo uusi maailma",
|
||||
"customization_settings": "Kustomisaatio-asetukset",
|
||||
"footer_text": "© {year} Arnis v{version} tekijänä louis-e",
|
||||
"new_version_available": "Uusi versio on saatavilla! Paina tästä ladataksesi sen.",
|
||||
"minecraft_directory_not_found": "Minecraft-hakemistoa ei löytynyt",
|
||||
"world_in_use": "Valittu maailma käytössä.",
|
||||
"failed_to_create_world": "Uuden maailman luonti epäonnistui",
|
||||
"no_world_selected_error": "Maailmaa ei valittu",
|
||||
"select_minecraft_world_first": "Valitse Minecraft-maailma ensin!",
|
||||
"select_location_first": "Valitse paikka ensin!",
|
||||
"area_too_large": "Tämä alue on todella iso ja voi ylittää tyypilliset laskentarajat.",
|
||||
"area_extensive": "Alue on aika laaja ja voi viedä pitkän ajan ja resursseja.",
|
||||
"selection_confirmed": "Valinta vahvistettu!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level"
|
||||
}
|
||||
38
gui-src/locales/ko.json
vendored
Normal file
38
gui-src/locales/ko.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "장소 선택",
|
||||
"zoom_in_and_choose": "줌 인하고 직사각형 도구를 사용하여 영역을 선택하세요.",
|
||||
"select_world": "세계 선택",
|
||||
"choose_world": "세계 선택",
|
||||
"no_world_selected": "선택된 세계 없음",
|
||||
"start_generation": "생성 시작",
|
||||
"progress": "진행",
|
||||
"custom_selection_confirmed": "사용자 지정 선택이 확인되었습니다!",
|
||||
"error_coordinates_out_of_range": "오류: 좌표가 범위를 벗어나거나 잘못된 순서입니다 (Lat이 Lng보다 먼저 필요합니다).",
|
||||
"invalid_format": "잘못된 형식입니다. 'lat,lng,lat,lng' 또는 'lat lng lat lng' 형식을 사용하세요.",
|
||||
"generation_process_started": "생성 프로세스가 시작되었습니다.",
|
||||
"winter_mode": "겨울 모드:",
|
||||
"world_scale": "세계 규모:",
|
||||
"custom_bounding_box": "사용자 지정 경계 상자:",
|
||||
"floodfill_timeout": "채우기 시간 초과 (초):",
|
||||
"ground_level": "지면 레벨:",
|
||||
"choose_world_modal_title": "세계 선택",
|
||||
"select_existing_world": "이미 존재하는 세계 선택",
|
||||
"generate_new_world": "새 세계 생성",
|
||||
"customization_settings": "사용자 지정 설정",
|
||||
"footer_text": "© {year} Arnis v{version} by louis-e",
|
||||
"new_version_available": "새로운 버전이 있습니다! 여기를 클릭하여 다운로드하세요.",
|
||||
"minecraft_directory_not_found": "마인크래프트 디렉토리가 발견되지 않았습니다",
|
||||
"world_in_use": "선택한 세계가 현재 사용 중입니다",
|
||||
"failed_to_create_world": "새 세계 생성에 실패했습니다",
|
||||
"no_world_selected_error": "선택된 세계 없음 오류",
|
||||
"select_minecraft_world_first": "먼저 마인크래프트 세계를 선택하세요!",
|
||||
"select_location_first": "먼저 위치를 선택하세요!",
|
||||
"area_too_large": "이 지역은 매우 크고, 일반적인 계산 한계를 초과할 수 있습니다.",
|
||||
"area_extensive": "이 지역은 꽤 광범위하여 значитель한 시간과 자원이 필요할 수 있습니다.",
|
||||
"selection_confirmed": "선택이 확인되었습니다!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level"
|
||||
}
|
||||
38
gui-src/locales/lt.json
vendored
Normal file
38
gui-src/locales/lt.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "Vietos pasirinkimas",
|
||||
"zoom_in_and_choose": "Pasididinkite žemėlapį ir pasirinkite plotą su kvadrato įrankiu",
|
||||
"select_world": "Pasaulio pasirinkimas",
|
||||
"choose_world": "Pasirinkti pasaulį",
|
||||
"no_world_selected": "Pasaulis nepasirinktas",
|
||||
"start_generation": "Pradėti generaciją",
|
||||
"progress": "Progresas",
|
||||
"custom_selection_confirmed": "Rėmo pasirinkimas patvirtintas!",
|
||||
"error_coordinates_out_of_range": "Klaida: Koordinatės yra už ribų arba neteisingai išdėstytos (plat turi būti prieš ilg).",
|
||||
"invalid_format": "Neteisingas formatas. Prašome naudoti 'plat,ilg,plat,ilg' arba 'plat ilg plat ilg'.",
|
||||
"generation_process_started": "Generacijos procesas pradėtas.",
|
||||
"winter_mode": "Žiemos režimas:",
|
||||
"world_scale": "Pasaulio mastelis:",
|
||||
"custom_bounding_box": "Pasirinktinis ribos rėmas:",
|
||||
"floodfill_timeout": "Užpildymo laiko limitas (sek.):",
|
||||
"ground_level": "Žemės lygis:",
|
||||
"choose_world_modal_title": "Pasaulio pasirinkimas",
|
||||
"select_existing_world": "Pasirinkti esamą pasaulį",
|
||||
"generate_new_world": "Sugeneruoti naują pasaulį",
|
||||
"customization_settings": "Generacijos nustatymai",
|
||||
"footer_text": "© {year} „Arnis“ v{version} sukurta louis-e",
|
||||
"new_version_available": "Surasta nauja versija! Spauskite čia kad ją atsisiųstumėte.",
|
||||
"minecraft_directory_not_found": "Nerastas „Minecraft“ aplankas",
|
||||
"world_in_use": "Pasirinktas pasaulis dabar užimtas",
|
||||
"failed_to_create_world": "Klaida sukuriant naują pasaulį",
|
||||
"no_world_selected_error": "Nėra pasirinktas pasaulis",
|
||||
"select_minecraft_world_first": "Pirma pasirinkite „Minecraft“ pasaulį!",
|
||||
"select_location_first": "Pirma pasirinkite vietą!",
|
||||
"area_too_large": "Šis plotas yra labai didelis ir gali viršyti tipinius resursų limitus.",
|
||||
"area_extensive": "Šis plotas yra pakankamai didelis kuriam reikėtų daug laiko ir resursų.",
|
||||
"selection_confirmed": "Pasirinkimas patvirtintas!",
|
||||
"unknown_error": "Nežinoma klaida",
|
||||
"license_and_credits": "Licencija ir padėkos",
|
||||
"placeholder_bbox": "Formatas: plat,lyg,plat,lyg",
|
||||
"placeholder_floodfill": "Sekundės",
|
||||
"placeholder_ground": "Žemės lygis"
|
||||
}
|
||||
38
gui-src/locales/pl.json
vendored
Normal file
38
gui-src/locales/pl.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "Wybierz lokalizację",
|
||||
"zoom_in_and_choose": "Przybliż i zaznacz obszar za pomocą prostokąta",
|
||||
"select_world": "Wybierz świat",
|
||||
"choose_world": "Wybierz świat",
|
||||
"no_world_selected": "Nie wybrano świata",
|
||||
"start_generation": "Rozpocznij generowanie",
|
||||
"progress": "Postęp",
|
||||
"custom_selection_confirmed": "Niestandardowy wybór potwierdzony!",
|
||||
"error_coordinates_out_of_range": "Błąd: Współrzędne są poza zakresem lub w złej kolejności (wymagana szerokość przed długością).",
|
||||
"invalid_format": "Nieprawidłowy format. Użyj 'szer.,dł.,szer.,dł.' lub 'szer. dł. szer. dł.'.",
|
||||
"generation_process_started": "Proces generowania rozpoczęty.",
|
||||
"winter_mode": "Tryb Zimowy:",
|
||||
"world_scale": "Skala świata:",
|
||||
"custom_bounding_box": "Niestandardowy obszar:",
|
||||
"floodfill_timeout": "Limit czasu wypełniania (sek):",
|
||||
"ground_level": "Wysokość obszaru:",
|
||||
"choose_world_modal_title": "Wybierz świat",
|
||||
"select_existing_world": "Wybierz istniejący świat",
|
||||
"generate_new_world": "Generuj nowy świat",
|
||||
"customization_settings": "Ustawienia personalizacji",
|
||||
"footer_text": "© {year} Arnis v{version} autorstwa louis-e",
|
||||
"new_version_available": "Dostępna jest nowa wersja! Kliknij tutaj, aby ją pobrać.",
|
||||
"minecraft_directory_not_found": "Nie znaleziono katalogu Minecrafta",
|
||||
"world_in_use": "Wybrany świat jest obecnie używany",
|
||||
"failed_to_create_world": "Nie udało się utworzyć świata",
|
||||
"no_world_selected_error": "Nie wybrano świata",
|
||||
"select_minecraft_world_first": "Najpierw wybierz świat Minecrafta!",
|
||||
"select_location_first": "Najpierw wybierz lokalizację!",
|
||||
"area_too_large": "Ten obszar jest bardzo duży i może przekroczyć limity obliczeniowe.",
|
||||
"area_extensive": "Ten obszar jest rozległy i może pochłonąć dużo czasu oraz zasobów.",
|
||||
"selection_confirmed": "Wybór potwierdzony!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level"
|
||||
}
|
||||
38
gui-src/locales/ru.json
vendored
Normal file
38
gui-src/locales/ru.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "Выбрать местоположение",
|
||||
"zoom_in_and_choose": "Приблизьте и выберите область",
|
||||
"select_world": "Выбрать мир",
|
||||
"choose_world": "Выбрать мир",
|
||||
"no_world_selected": "Мир не выбран",
|
||||
"start_generation": "Начать генерацию",
|
||||
"progress": "Прогресс",
|
||||
"custom_selection_confirmed": "Пользовательский выбор подтвержден!",
|
||||
"error_coordinates_out_of_range": "Ошибка: Координаты находятся вне зоны действия или указаны в неправильном порядке (сначала широта, затем долгота)",
|
||||
"invalid_format": "Неверный формат. Используйте 'широта,долгота,широта,долгота' или 'широта долгота широта долгота'",
|
||||
"generation_process_started": "Процесс генерации начат",
|
||||
"winter_mode": "Зимний режим:",
|
||||
"world_scale": "Масштаб мира:",
|
||||
"custom_bounding_box": "Пользовательская ограничивающая рамка:",
|
||||
"floodfill_timeout": "Тайм-аут заливки (сек):",
|
||||
"ground_level": "Уровень земли:",
|
||||
"choose_world_modal_title": "Выбрать мир",
|
||||
"select_existing_world": "Выбрать существующий мир",
|
||||
"generate_new_world": "Создать новый мир",
|
||||
"customization_settings": "Настройки персонализации",
|
||||
"footer_text": "© {year} Arnis v{version} от louis-e",
|
||||
"new_version_available": "Доступна новая версия! Нажмите здесь, чтобы скачать",
|
||||
"minecraft_directory_not_found": "Каталог Minecraft не найден",
|
||||
"world_in_use": "Выбранный мир уже используется",
|
||||
"failed_to_create_world": "Не удалось создать новый мир",
|
||||
"no_world_selected_error": "Мир не выбран",
|
||||
"select_minecraft_world_first": "Сначала выберите мир Minecraft!",
|
||||
"select_location_first": "Сначала выберите местоположение!",
|
||||
"area_too_large": "Эта область слишком велика и может превысить типичные вычислительные ограничения",
|
||||
"area_extensive": "Область довольно обширна и может потребовать значительного времени и ресурсов",
|
||||
"selection_confirmed": "Выбор подтвержден!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level"
|
||||
}
|
||||
38
gui-src/locales/sv.json
vendored
Normal file
38
gui-src/locales/sv.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "Välj plats",
|
||||
"zoom_in_and_choose": "Zooma in och välj ditt område med rektangulärt verktyg",
|
||||
"select_world": "Välj värld",
|
||||
"choose_world": "Välj värld",
|
||||
"no_world_selected": "Ingen värld vald",
|
||||
"start_generation": "Starta generering",
|
||||
"progress": "Framsteg",
|
||||
"custom_selection_confirmed": "Anpassad markering bekräftad!",
|
||||
"error_coordinates_out_of_range": "Fel: Koordinater är utanför området eller felaktigt ordnade (Lat före Lng krävs).",
|
||||
"invalid_format": "Ogiltigt format. Använd 'lat,lng,lat,lng' eller 'lat lng lat lng'.",
|
||||
"generation_process_started": "Genereringsprocessen startad.",
|
||||
"winter_mode": "Vinterläge:",
|
||||
"world_scale": "Världsskala:",
|
||||
"custom_bounding_box": "Anpassad begränsningsram:",
|
||||
"floodfill_timeout": "Floodfill-tidsgräns (sek):",
|
||||
"ground_level": "Marknivå:",
|
||||
"choose_world_modal_title": "Välj värld",
|
||||
"select_existing_world": "Välj existerande värld",
|
||||
"generate_new_world": "Generera ny värld",
|
||||
"customization_settings": "Anpassningsinställningar",
|
||||
"footer_text": "© {year} Arnis v{version} by louis-e",
|
||||
"new_version_available": "Det finns en ny version tillgänglig! Klicka här för att ladda ner den.",
|
||||
"minecraft_directory_not_found": "Minecraft-katalogen hittades inte",
|
||||
"world_in_use": "Den valda världen används just nu",
|
||||
"failed_to_create_world": "Misslyckades att skapa ny värld",
|
||||
"no_world_selected_error": "Ingen värld vald fel",
|
||||
"select_minecraft_world_first": "Välj Minecraft-värld först!",
|
||||
"select_location_first": "Välj plats först!",
|
||||
"area_too_large": "Detta område är mycket stort och kan överskrida vanliga beräkningsgränser.",
|
||||
"area_extensive": "Området är ganska extensivt och kan ta betydande tid och resurser.",
|
||||
"selection_confirmed": "Val bekräftat!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level"
|
||||
}
|
||||
38
gui-src/locales/ua.json
vendored
Normal file
38
gui-src/locales/ua.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "Обрати локацію",
|
||||
"zoom_in_and_choose": "Збільште масштаб і оберіть область за допомогою прямокутника",
|
||||
"select_world": "Обрати світ",
|
||||
"choose_world": "Обрати світ",
|
||||
"no_world_selected": "Світ не обрано",
|
||||
"start_generation": "Почати генерацію",
|
||||
"progress": "Прогрес",
|
||||
"custom_selection_confirmed": "Користувацький вибір підтверджено!",
|
||||
"error_coordinates_out_of_range": "Помилка: Координати поза діапазоном або неправильно впорядковані (потрібно широта перед довгота)",
|
||||
"invalid_format": "Неправильний формат. Будь ласка, використовуйте 'широта,довгота,широта,довгота' або 'широта довгота широта довгота'",
|
||||
"generation_process_started": "Процес генерації розпочато",
|
||||
"winter_mode": "Зимовий режим:",
|
||||
"world_scale": "Масштаб світу:",
|
||||
"custom_bounding_box": "Користувацька обмежувальна рамка:",
|
||||
"floodfill_timeout": "Тайм-аут заливки (сек):",
|
||||
"ground_level": "Рівень землі:",
|
||||
"choose_world_modal_title": "Обрати світ",
|
||||
"select_existing_world": "Обрати наявний світ",
|
||||
"generate_new_world": "Створити новий світ",
|
||||
"customization_settings": "Налаштування параметрів",
|
||||
"footer_text": "© {year} Arnis v{version} від louis-e",
|
||||
"new_version_available": "Доступна нова версія! Натисніть тут, щоб завантажити її",
|
||||
"minecraft_directory_not_found": "Каталог Minecraft не знайдено",
|
||||
"world_in_use": "Вибраний світ зараз використовується",
|
||||
"failed_to_create_world": "Не вдалося створити новий світ",
|
||||
"no_world_selected_error": "Світ не обрано",
|
||||
"select_minecraft_world_first": "Спочатку виберіть світ Minecraft!",
|
||||
"select_location_first": "Спочатку виберіть місцезнаходження!",
|
||||
"area_too_large": "Ця область дуже велика і може перевищити типові обчислювальні межі",
|
||||
"area_extensive": "Область досить велика і може вимагати значного часу та ресурсів",
|
||||
"selection_confirmed": "Вибір підтверджено!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level"
|
||||
}
|
||||
38
gui-src/locales/zh-CN.json
vendored
Normal file
38
gui-src/locales/zh-CN.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"select_location": "选择位置",
|
||||
"zoom_in_and_choose": "放大并使用矩形工具选择您的区域",
|
||||
"select_world": "选择世界",
|
||||
"choose_world": "选择世界",
|
||||
"no_world_selected": "未选择世界",
|
||||
"start_generation": "开始生成",
|
||||
"progress": "进度",
|
||||
"custom_selection_confirmed": "自定义选择已确认!",
|
||||
"error_coordinates_out_of_range": "错误:坐标超出范围或顺序不正确(需要先纬度后经度)。",
|
||||
"invalid_format": "格式无效。请使用 'lat,lng,lat,lng' 或 'lat lng lat lng'。",
|
||||
"generation_process_started": "生成过程已开始。",
|
||||
"winter_mode": "冬季模式:",
|
||||
"world_scale": "世界比例:",
|
||||
"custom_bounding_box": "自定义边界框:",
|
||||
"floodfill_timeout": "填充超时(秒):",
|
||||
"ground_level": "地面高度:",
|
||||
"choose_world_modal_title": "选择世界",
|
||||
"select_existing_world": "选择现有世界",
|
||||
"generate_new_world": "生成新世界",
|
||||
"customization_settings": "自定义设置",
|
||||
"footer_text": "© {year} Arnis v{version} 由 louis-e 提供",
|
||||
"new_version_available": "有新版本可用!点击这里下载。",
|
||||
"minecraft_directory_not_found": "未找到 Minecraft 目录",
|
||||
"world_in_use": "所选世界正在使用中",
|
||||
"failed_to_create_world": "无法创建新世界",
|
||||
"no_world_selected_error": "未选择世界",
|
||||
"select_minecraft_world_first": "请先选择一个 Minecraft 世界!",
|
||||
"select_location_first": "请先选择一个位置!",
|
||||
"area_too_large": "该区域非常大,可能会超出典型的计算限制。",
|
||||
"area_extensive": "该区域相当广泛,可能需要大量时间和资源。",
|
||||
"selection_confirmed": "选择已确认!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level"
|
||||
}
|
||||
2
gui-src/maps.html
vendored
2
gui-src/maps.html
vendored
@@ -7,13 +7,11 @@
|
||||
<link rel="stylesheet" href="css/maps/leaflet.css" />
|
||||
<link rel="stylesheet" href="css/maps/leaflet.draw.css" />
|
||||
<link rel="stylesheet" href="css/maps/leaflet.sidebar.css" />
|
||||
<link rel="stylesheet" href="css/maps/mapbox.v3.2.0.css" />
|
||||
<link rel="stylesheet" href="css/bbox.css" />
|
||||
|
||||
<script src="js/libs/jquery-1.9.1.min.js"></script>
|
||||
<script src="js/libs/jquery-ui-1.10.3.custom.js"></script>
|
||||
<script src="js/maps/leaflet.js"></script>
|
||||
<script src="js/maps/mapbox.v3.2.0.js"></script>
|
||||
<script src="js/maps/leaflet.draw.js"></script>
|
||||
<script src="js/maps/leaflet.sidebar.js"></script>
|
||||
<script src="js/maps/wkt.parser.js"></script>
|
||||
|
||||
@@ -41,6 +41,10 @@ pub struct Args {
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub winter: bool,
|
||||
|
||||
/// Enable terrain (optional)
|
||||
#[arg(long, default_value_t = false, action = clap::ArgAction::SetFalse)]
|
||||
pub terrain: bool,
|
||||
|
||||
/// Enable debug mode (optional)
|
||||
#[arg(long, default_value_t = false, action = clap::ArgAction::SetTrue)]
|
||||
pub debug: bool,
|
||||
|
||||
@@ -141,6 +141,9 @@ impl Block {
|
||||
111 => "snow_block",
|
||||
112 => "snow",
|
||||
113 => "oak_sign",
|
||||
114 => "andesite_wall",
|
||||
115 => "stone_brick_wall",
|
||||
116..=125 => "rail",
|
||||
_ => panic!("Invalid id"),
|
||||
}
|
||||
}
|
||||
@@ -187,6 +190,80 @@ impl Block {
|
||||
map
|
||||
})),
|
||||
|
||||
116 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String("north_south".to_string()),
|
||||
);
|
||||
map
|
||||
})),
|
||||
|
||||
117 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("shape".to_string(), Value::String("east_west".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
118 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String("ascending_east".to_string()),
|
||||
);
|
||||
map
|
||||
})),
|
||||
|
||||
119 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String("ascending_west".to_string()),
|
||||
);
|
||||
map
|
||||
})),
|
||||
|
||||
120 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String("ascending_north".to_string()),
|
||||
);
|
||||
map
|
||||
})),
|
||||
|
||||
121 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String("ascending_south".to_string()),
|
||||
);
|
||||
map
|
||||
})),
|
||||
|
||||
122 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("shape".to_string(), Value::String("north_east".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
123 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("shape".to_string(), Value::String("north_west".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
124 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("shape".to_string(), Value::String("south_east".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
125 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("shape".to_string(), Value::String("south_west".to_string()));
|
||||
map
|
||||
})),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -301,6 +378,8 @@ pub const YELLOW_TERRACOTTA: Block = Block::new(104);
|
||||
pub const SNOW_BLOCK: Block = Block::new(111);
|
||||
pub const SNOW_LAYER: Block = Block::new(112);
|
||||
pub const SIGN: Block = Block::new(113);
|
||||
pub const ANDESITE_WALL: Block = Block::new(114);
|
||||
pub const STONE_BRICK_WALL: Block = Block::new(115);
|
||||
|
||||
pub const CARROTS: Block = Block::new(105);
|
||||
pub const DARK_OAK_DOOR_LOWER: Block = Block::new(106);
|
||||
@@ -310,6 +389,17 @@ pub const WHEAT: Block = Block::new(109);
|
||||
|
||||
pub const BEDROCK: Block = Block::new(110);
|
||||
|
||||
pub const RAIL_NORTH_SOUTH: Block = Block::new(116);
|
||||
pub const RAIL_EAST_WEST: Block = Block::new(117);
|
||||
pub const RAIL_ASCENDING_EAST: Block = Block::new(118);
|
||||
pub const RAIL_ASCENDING_WEST: Block = Block::new(119);
|
||||
pub const RAIL_ASCENDING_NORTH: Block = Block::new(120);
|
||||
pub const RAIL_ASCENDING_SOUTH: Block = Block::new(121);
|
||||
pub const RAIL_NORTH_EAST: Block = Block::new(122);
|
||||
pub const RAIL_NORTH_WEST: Block = Block::new(123);
|
||||
pub const RAIL_SOUTH_EAST: Block = Block::new(124);
|
||||
pub const RAIL_SOUTH_WEST: Block = Block::new(125);
|
||||
|
||||
// Variations for building corners
|
||||
pub fn building_corner_variations() -> Vec<Block> {
|
||||
vec![
|
||||
|
||||
@@ -8,26 +8,32 @@ pub fn bresenham_line(
|
||||
y2: i32,
|
||||
z2: i32,
|
||||
) -> Vec<(i32, i32, i32)> {
|
||||
let mut points: Vec<(i32, i32, i32)> = Vec::new();
|
||||
// Calculate max possible points needed
|
||||
let dx = if x2 > x1 { x2 - x1 } else { x1 - x2 };
|
||||
let dy = if y2 > y1 { y2 - y1 } else { y1 - y2 };
|
||||
let dz = if z2 > z1 { z2 - z1 } else { z1 - z2 };
|
||||
|
||||
let dx: i32 = (x2 - x1).abs();
|
||||
let dy: i32 = (y2 - y1).abs();
|
||||
let dz: i32 = (z2 - z1).abs();
|
||||
// Pre-allocate vector with exact size needed
|
||||
let capacity = dx.max(dy).max(dz) + 1;
|
||||
let mut points = Vec::with_capacity(capacity as usize);
|
||||
points.reserve_exact(capacity as usize);
|
||||
|
||||
let xs: i32 = if x1 < x2 { 1 } else { -1 };
|
||||
let ys: i32 = if y1 < y2 { 1 } else { -1 };
|
||||
let zs: i32 = if z1 < z2 { 1 } else { -1 };
|
||||
let xs = if x1 < x2 { 1 } else { -1 };
|
||||
let ys = if y1 < y2 { 1 } else { -1 };
|
||||
let zs = if z1 < z2 { 1 } else { -1 };
|
||||
|
||||
let mut x: i32 = x1;
|
||||
let mut y: i32 = y1;
|
||||
let mut z: i32 = z1;
|
||||
let mut x = x1;
|
||||
let mut y = y1;
|
||||
let mut z = z1;
|
||||
|
||||
// Determine dominant axis once, outside the loop
|
||||
if dx >= dy && dx >= dz {
|
||||
let mut p1: i32 = 2 * dy - dx;
|
||||
let mut p2: i32 = 2 * dz - dx;
|
||||
let mut p1 = 2 * dy - dx;
|
||||
let mut p2 = 2 * dz - dx;
|
||||
|
||||
while x != x2 {
|
||||
points.push((x, y, z));
|
||||
|
||||
if p1 >= 0 {
|
||||
y += ys;
|
||||
p1 -= 2 * dx;
|
||||
@@ -41,11 +47,12 @@ pub fn bresenham_line(
|
||||
x += xs;
|
||||
}
|
||||
} else if dy >= dx && dy >= dz {
|
||||
let mut p1: i32 = 2 * dx - dy;
|
||||
let mut p2: i32 = 2 * dz - dy;
|
||||
let mut p1 = 2 * dx - dy;
|
||||
let mut p2 = 2 * dz - dy;
|
||||
|
||||
while y != y2 {
|
||||
points.push((x, y, z));
|
||||
|
||||
if p1 >= 0 {
|
||||
x += xs;
|
||||
p1 -= 2 * dy;
|
||||
@@ -59,11 +66,12 @@ pub fn bresenham_line(
|
||||
y += ys;
|
||||
}
|
||||
} else {
|
||||
let mut p1: i32 = 2 * dy - dz;
|
||||
let mut p2: i32 = 2 * dx - dz;
|
||||
let mut p1 = 2 * dy - dz;
|
||||
let mut p2 = 2 * dx - dz;
|
||||
|
||||
while z != z2 {
|
||||
points.push((x, y, z));
|
||||
|
||||
if p1 >= 0 {
|
||||
y += ys;
|
||||
p1 -= 2 * dz;
|
||||
|
||||
12
src/cartesian.rs
Normal file
12
src/cartesian.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct XZPoint {
|
||||
pub x: i32,
|
||||
pub z: i32,
|
||||
}
|
||||
|
||||
impl XZPoint {
|
||||
#[inline]
|
||||
pub fn new(x: i32, z: i32) -> Self {
|
||||
Self { x, z }
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,32 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::{DIRT, GRASS_BLOCK, SNOW_BLOCK};
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::element_processing::*;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedElement;
|
||||
use crate::progress::emit_gui_progress_update;
|
||||
use crate::world_editor::WorldEditor;
|
||||
use colored::Colorize;
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
|
||||
const MIN_Y: i32 = -64;
|
||||
|
||||
pub fn generate_world(
|
||||
elements: Vec<ProcessedElement>,
|
||||
args: &Args,
|
||||
scale_factor_x: f64,
|
||||
scale_factor_z: f64,
|
||||
) -> Result<(), String> {
|
||||
println!("{} Processing data...", "[3/5]".bold());
|
||||
emit_gui_progress_update(10.0, "Processing data...");
|
||||
|
||||
let ground_level: i32 = args.ground_level;
|
||||
let region_dir: String = format!("{}/region", args.path);
|
||||
let mut editor: WorldEditor =
|
||||
WorldEditor::new(®ion_dir, scale_factor_x, scale_factor_z, args);
|
||||
let mut editor: WorldEditor = WorldEditor::new(®ion_dir, scale_factor_x, scale_factor_z);
|
||||
|
||||
editor.set_sign(
|
||||
"↑".to_string(),
|
||||
"Generated World".to_string(),
|
||||
"This direction".to_string(),
|
||||
"".to_string(),
|
||||
9,
|
||||
-61,
|
||||
9,
|
||||
6,
|
||||
);
|
||||
println!("{} Processing data...", "[3/5]".bold());
|
||||
if args.terrain {
|
||||
emit_gui_progress_update(10.0, "Fetching elevation...");
|
||||
}
|
||||
let ground: Ground = Ground::new(args);
|
||||
|
||||
emit_gui_progress_update(11.0, "Processing terrain...");
|
||||
|
||||
// Process data
|
||||
let elements_count: usize = elements.len();
|
||||
@@ -40,9 +36,10 @@ pub fn generate_world(
|
||||
.unwrap()
|
||||
.progress_chars("█▓░"));
|
||||
|
||||
let progress_increment_prcs: f64 = 50.0 / elements_count as f64;
|
||||
let mut current_progress_prcs: f64 = 10.0;
|
||||
let progress_increment_prcs: f64 = 49.0 / elements_count as f64;
|
||||
let mut current_progress_prcs: f64 = 11.0;
|
||||
let mut last_emitted_progress: f64 = current_progress_prcs;
|
||||
|
||||
for element in &elements {
|
||||
process_pb.inc(1);
|
||||
current_progress_prcs += progress_increment_prcs;
|
||||
@@ -64,56 +61,56 @@ pub fn generate_world(
|
||||
match element {
|
||||
ProcessedElement::Way(way) => {
|
||||
if way.tags.contains_key("building") || way.tags.contains_key("building:part") {
|
||||
buildings::generate_buildings(&mut editor, way, ground_level, args);
|
||||
buildings::generate_buildings(&mut editor, way, &ground, args, None);
|
||||
} else if way.tags.contains_key("highway") {
|
||||
highways::generate_highways(&mut editor, element, ground_level, args);
|
||||
highways::generate_highways(&mut editor, element, &ground, args);
|
||||
} else if way.tags.contains_key("landuse") {
|
||||
landuse::generate_landuse(&mut editor, way, ground_level, args);
|
||||
landuse::generate_landuse(&mut editor, way, &ground, args);
|
||||
} else if way.tags.contains_key("natural") {
|
||||
natural::generate_natural(&mut editor, element, ground_level, args);
|
||||
natural::generate_natural(&mut editor, element, &ground, args);
|
||||
} else if way.tags.contains_key("amenity") {
|
||||
amenities::generate_amenities(&mut editor, element, ground_level, args);
|
||||
amenities::generate_amenities(&mut editor, element, &ground, args);
|
||||
} else if way.tags.contains_key("leisure") {
|
||||
leisure::generate_leisure(&mut editor, way, ground_level, args);
|
||||
leisure::generate_leisure(&mut editor, way, &ground, args);
|
||||
} else if way.tags.contains_key("barrier") {
|
||||
barriers::generate_barriers(&mut editor, element, ground_level);
|
||||
barriers::generate_barriers(&mut editor, element, &ground);
|
||||
} else if way.tags.contains_key("waterway") {
|
||||
waterways::generate_waterways(&mut editor, way, ground_level);
|
||||
waterways::generate_waterways(&mut editor, way, &ground);
|
||||
} else if way.tags.contains_key("bridge") {
|
||||
bridges::generate_bridges(&mut editor, way, ground_level);
|
||||
//bridges::generate_bridges(&mut editor, way, ground_level); // TODO FIX
|
||||
} else if way.tags.contains_key("railway") {
|
||||
railways::generate_railways(&mut editor, way, ground_level);
|
||||
railways::generate_railways(&mut editor, way, &ground);
|
||||
} else if way.tags.contains_key("aeroway") || way.tags.contains_key("area:aeroway")
|
||||
{
|
||||
highways::generate_aeroway(&mut editor, way, &ground);
|
||||
} else if way.tags.get("service") == Some(&"siding".to_string()) {
|
||||
highways::generate_siding(&mut editor, way, ground_level);
|
||||
highways::generate_siding(&mut editor, way, &ground);
|
||||
}
|
||||
}
|
||||
ProcessedElement::Node(node) => {
|
||||
if node.tags.contains_key("door") || node.tags.contains_key("entrance") {
|
||||
doors::generate_doors(&mut editor, node, ground_level);
|
||||
doors::generate_doors(&mut editor, node, &ground);
|
||||
} else if node.tags.contains_key("natural")
|
||||
&& node.tags.get("natural") == Some(&"tree".to_string())
|
||||
{
|
||||
natural::generate_natural(&mut editor, element, ground_level, args);
|
||||
natural::generate_natural(&mut editor, element, &ground, args);
|
||||
} else if node.tags.contains_key("amenity") {
|
||||
amenities::generate_amenities(&mut editor, element, ground_level, args);
|
||||
amenities::generate_amenities(&mut editor, element, &ground, args);
|
||||
} else if node.tags.contains_key("barrier") {
|
||||
barriers::generate_barriers(&mut editor, element, ground_level);
|
||||
barriers::generate_barriers(&mut editor, element, &ground);
|
||||
} else if node.tags.contains_key("highway") {
|
||||
highways::generate_highways(&mut editor, element, ground_level, args);
|
||||
highways::generate_highways(&mut editor, element, &ground, args);
|
||||
} else if node.tags.contains_key("tourism") {
|
||||
tourisms::generate_tourisms(&mut editor, node, ground_level);
|
||||
tourisms::generate_tourisms(&mut editor, node, &ground);
|
||||
}
|
||||
}
|
||||
ProcessedElement::Relation(rel) => {
|
||||
if rel.tags.contains_key("building") || rel.tags.contains_key("building:part") {
|
||||
buildings::generate_building_from_relation(
|
||||
&mut editor,
|
||||
rel,
|
||||
ground_level,
|
||||
args,
|
||||
);
|
||||
buildings::generate_building_from_relation(&mut editor, rel, &ground, args);
|
||||
} else if rel.tags.contains_key("water") {
|
||||
water_areas::generate_water_areas(&mut editor, rel, ground_level);
|
||||
water_areas::generate_water_areas(&mut editor, rel, &ground);
|
||||
} else if rel.tags.get("leisure") == Some(&"park".to_string()) {
|
||||
leisure::generate_leisure_from_relation(&mut editor, rel, &ground, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,8 +125,8 @@ pub fn generate_world(
|
||||
|
||||
let mut block_counter: u64 = 0;
|
||||
|
||||
println!("{} Generating ground layer...", "[4/5]".bold());
|
||||
emit_gui_progress_update(60.0, "Generating ground layer...");
|
||||
println!("{} Generating ground...", "[4/5]".bold());
|
||||
emit_gui_progress_update(60.0, "Generating ground...");
|
||||
|
||||
let ground_pb: ProgressBar = ProgressBar::new(total_blocks);
|
||||
ground_pb.set_style(
|
||||
@@ -146,24 +143,86 @@ pub fn generate_world(
|
||||
|
||||
let groundlayer_block = if args.winter { SNOW_BLOCK } else { GRASS_BLOCK };
|
||||
|
||||
for x in 0..=(scale_factor_x as i32) {
|
||||
for z in 0..=(scale_factor_z as i32) {
|
||||
editor.set_block(groundlayer_block, x, ground_level, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level - 1, z, None, None);
|
||||
|
||||
block_counter += 1;
|
||||
if block_counter % batch_size == 0 {
|
||||
ground_pb.inc(batch_size);
|
||||
// Differentiate between terrain and non-terrain generation
|
||||
if ground.elevation_enabled {
|
||||
// Pre-calculate ground levels for all points
|
||||
let mut ground_levels: Vec<Vec<i32>> = Vec::with_capacity(scale_factor_x as usize + 1);
|
||||
for x in 0..=(scale_factor_x as i32) {
|
||||
let mut row = Vec::with_capacity(scale_factor_z as usize + 1);
|
||||
for z in 0..=(scale_factor_z as i32) {
|
||||
row.push(ground.level(XZPoint::new(x, z)));
|
||||
}
|
||||
ground_levels.push(row);
|
||||
}
|
||||
|
||||
gui_progress_grnd += progress_increment_grnd;
|
||||
if (gui_progress_grnd - last_emitted_progress).abs() > 0.25 {
|
||||
emit_gui_progress_update(gui_progress_grnd, "");
|
||||
last_emitted_progress = gui_progress_grnd;
|
||||
// Process blocks in larger batches
|
||||
for x in 0..=(scale_factor_x as i32) {
|
||||
for z in 0..=(scale_factor_z as i32) {
|
||||
let ground_level = ground_levels[x as usize][z as usize];
|
||||
|
||||
// Find the highest block in this column
|
||||
let max_y = (MIN_Y..ground_level)
|
||||
.find(|y: &i32| editor.block_at(x, *y, z))
|
||||
.unwrap_or(ground_level)
|
||||
.min(ground_level);
|
||||
|
||||
// Set blocks in a single batch
|
||||
editor.set_block(groundlayer_block, x, max_y, z, None, None);
|
||||
editor.set_block(DIRT, x, max_y - 1, z, None, None);
|
||||
editor.set_block(DIRT, x, max_y - 2, z, None, None);
|
||||
|
||||
block_counter += 1;
|
||||
if block_counter % batch_size == 0 {
|
||||
ground_pb.inc(batch_size);
|
||||
}
|
||||
|
||||
gui_progress_grnd += progress_increment_grnd;
|
||||
if (gui_progress_grnd - last_emitted_progress).abs() > 0.25 {
|
||||
emit_gui_progress_update(gui_progress_grnd, "");
|
||||
last_emitted_progress = gui_progress_grnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set blocks at spawn location
|
||||
for x in 0..=20 {
|
||||
for z in 0..=20 {
|
||||
editor.set_block(groundlayer_block, x, -62, z, None, None);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for x in 0..=(scale_factor_x as i32) {
|
||||
for z in 0..=(scale_factor_z as i32) {
|
||||
let ground_level = ground.level(XZPoint::new(x, z));
|
||||
editor.set_block(groundlayer_block, x, ground_level, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level - 1, z, None, None);
|
||||
|
||||
block_counter += 1;
|
||||
if block_counter % batch_size == 0 {
|
||||
ground_pb.inc(batch_size);
|
||||
}
|
||||
|
||||
gui_progress_grnd += progress_increment_grnd;
|
||||
if (gui_progress_grnd - last_emitted_progress).abs() > 0.25 {
|
||||
emit_gui_progress_update(gui_progress_grnd, "");
|
||||
last_emitted_progress = gui_progress_grnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set sign for player orientation
|
||||
/*editor.set_sign(
|
||||
"↑".to_string(),
|
||||
"Generated World".to_string(),
|
||||
"This direction".to_string(),
|
||||
"".to_string(),
|
||||
9,
|
||||
-61,
|
||||
9,
|
||||
6,
|
||||
);*/
|
||||
|
||||
ground_pb.inc(block_counter % batch_size);
|
||||
ground_pb.finish();
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedElement;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_amenities(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedElement,
|
||||
ground_level: i32,
|
||||
ground: &Ground,
|
||||
args: &Args,
|
||||
) {
|
||||
// Skip if 'layer' or 'level' is negative in the tags
|
||||
@@ -25,21 +27,23 @@ pub fn generate_amenities(
|
||||
}
|
||||
|
||||
if let Some(amenity_type) = element.tags().get("amenity") {
|
||||
let first_node: Option<(i32, i32)> = element
|
||||
let first_node: Option<XZPoint> = element
|
||||
.nodes()
|
||||
.map(|n: &crate::osm_parser::ProcessedNode| (n.x, n.z))
|
||||
.map(|n: &crate::osm_parser::ProcessedNode| XZPoint::new(n.x, n.z))
|
||||
.next();
|
||||
match amenity_type.as_str() {
|
||||
"waste_disposal" | "waste_basket" => {
|
||||
// Place a cauldron for waste disposal or waste basket
|
||||
if let Some((x, z)) = first_node {
|
||||
editor.set_block(CAULDRON, x, ground_level + 1, z, None, None);
|
||||
if let Some(pt) = first_node {
|
||||
editor.set_block(CAULDRON, pt.x, ground.level(pt) + 1, pt.z, None, None);
|
||||
}
|
||||
}
|
||||
"vending_machine" | "atm" => {
|
||||
if let Some((x, z)) = first_node {
|
||||
editor.set_block(IRON_BLOCK, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(IRON_BLOCK, x, ground_level + 2, z, None, None);
|
||||
if let Some(pt) = first_node {
|
||||
let y = ground.level(pt);
|
||||
|
||||
editor.set_block(IRON_BLOCK, pt.x, y + 1, pt.z, None, None);
|
||||
editor.set_block(IRON_BLOCK, pt.x, y + 2, pt.z, None, None);
|
||||
}
|
||||
}
|
||||
"bicycle_parking" => {
|
||||
@@ -53,9 +57,18 @@ pub fn generate_amenities(
|
||||
let floor_area: Vec<(i32, i32)> =
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
let pts: Vec<_> = floor_area.iter().map(|c| XZPoint::new(c.0, c.1)).collect();
|
||||
|
||||
if pts.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
let y_min = ground.min_level(pts.iter().cloned()).unwrap();
|
||||
let roof_y = ground.max_level(pts.iter().cloned()).unwrap() + 5;
|
||||
|
||||
// Fill the floor area
|
||||
for (x, z) in floor_area.iter() {
|
||||
editor.set_block(ground_block, *x, ground_level, *z, None, None);
|
||||
editor.set_block(ground_block, *x, y_min, *z, None, None);
|
||||
}
|
||||
|
||||
// Place fences and roof slabs at each corner node directly
|
||||
@@ -63,37 +76,79 @@ pub fn generate_amenities(
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
|
||||
for y in 1..=4 {
|
||||
editor.set_block(ground_block, x, ground_level, z, None, None);
|
||||
editor.set_block(OAK_FENCE, x, ground_level + y, z, None, None);
|
||||
let pt = XZPoint::new(x, z);
|
||||
|
||||
let y = ground.level(pt);
|
||||
editor.set_block(ground_block, x, y, z, None, None);
|
||||
|
||||
for cur_y in (y_min + 1)..roof_y {
|
||||
editor.set_block(OAK_FENCE, x, cur_y, z, None, None);
|
||||
}
|
||||
editor.set_block(roof_block, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(roof_block, x, roof_y, z, None, None);
|
||||
}
|
||||
|
||||
// Flood fill the roof area
|
||||
let roof_height: i32 = ground_level + 5;
|
||||
for (x, z) in floor_area.iter() {
|
||||
editor.set_block(roof_block, *x, roof_height, *z, None, None);
|
||||
editor.set_block(roof_block, *x, roof_y, *z, None, None);
|
||||
}
|
||||
}
|
||||
"bench" => {
|
||||
// Place a bench
|
||||
if let Some((x, z)) = first_node {
|
||||
editor.set_block(SMOOTH_STONE, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(OAK_LOG, x + 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(OAK_LOG, x - 1, ground_level + 1, z, None, None);
|
||||
if let Some(pt) = first_node {
|
||||
let y = ground.level(pt) + 1;
|
||||
|
||||
editor.set_block(SMOOTH_STONE, pt.x, y, pt.z, None, None);
|
||||
editor.set_block(OAK_LOG, pt.x + 1, y, pt.z, None, None);
|
||||
editor.set_block(OAK_LOG, pt.x - 1, y, pt.z, None, None);
|
||||
}
|
||||
}
|
||||
"vending" => {
|
||||
// Place vending machine blocks
|
||||
if let Some((x, z)) = first_node {
|
||||
editor.set_block(IRON_BLOCK, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(IRON_BLOCK, x, ground_level + 2, z, None, None);
|
||||
if let Some(pt) = first_node {
|
||||
let y = ground.level(pt);
|
||||
|
||||
editor.set_block(IRON_BLOCK, pt.x, y + 1, pt.z, None, None);
|
||||
editor.set_block(IRON_BLOCK, pt.x, y + 2, pt.z, None, None);
|
||||
}
|
||||
}
|
||||
"shelter" => {
|
||||
let roof_block: Block = STONE_BRICK_SLAB;
|
||||
|
||||
let polygon_coords: Vec<(i32, i32)> = element
|
||||
.nodes()
|
||||
.map(|n: &crate::osm_parser::ProcessedNode| (n.x, n.z))
|
||||
.collect();
|
||||
let roof_area: Vec<(i32, i32)> =
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
// Place fences and roof slabs at each corner node directly
|
||||
for node in element.nodes() {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
|
||||
let Some(y) = ground.min_level(element.nodes().map(|n| n.xz())) else {
|
||||
return;
|
||||
};
|
||||
|
||||
for fence_height in 1..=4 {
|
||||
editor.set_block(OAK_FENCE, x, y + fence_height, z, None, None);
|
||||
}
|
||||
editor.set_block(roof_block, x, y + 5, z, None, None);
|
||||
}
|
||||
|
||||
// Flood fill the roof area
|
||||
let Some(y) = ground.min_level(element.nodes().map(|n| n.xz())) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let roof_height: i32 = y + 5;
|
||||
for (x, z) in roof_area.iter() {
|
||||
editor.set_block(roof_block, *x, roof_height, *z, None, None);
|
||||
}
|
||||
}
|
||||
"parking" | "fountain" => {
|
||||
// Process parking or fountain areas
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let mut previous_node: Option<XZPoint> = None;
|
||||
let mut corner_addup: (i32, i32, i32) = (0, 0, 0);
|
||||
let mut current_amenity: Vec<(i32, i32)> = vec![];
|
||||
|
||||
@@ -102,23 +157,18 @@ pub fn generate_amenities(
|
||||
"parking" => GRAY_CONCRETE,
|
||||
_ => GRAY_CONCRETE,
|
||||
};
|
||||
|
||||
for node in element.nodes() {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
let pt: XZPoint = node.xz();
|
||||
let y = ground.level(pt);
|
||||
|
||||
if let Some(prev) = previous_node {
|
||||
// Create borders for fountain or parking area
|
||||
let prev_y = ground.level(prev);
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level, prev.1, x, ground_level, z);
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
editor.set_block(
|
||||
block_type,
|
||||
bx,
|
||||
ground_level,
|
||||
bz,
|
||||
Some(&[BLACK_CONCRETE]),
|
||||
None,
|
||||
);
|
||||
bresenham_line(prev.x, prev_y, prev.z, pt.x, y, pt.z);
|
||||
for (bx, by, bz) in bresenham_points {
|
||||
editor.set_block(block_type, bx, by, bz, Some(&[BLACK_CONCRETE]), None);
|
||||
|
||||
// Decorative border around fountains
|
||||
if amenity_type == "fountain" {
|
||||
@@ -128,7 +178,7 @@ pub fn generate_amenities(
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
bx + dx,
|
||||
ground_level,
|
||||
by,
|
||||
bz + dz,
|
||||
None,
|
||||
None,
|
||||
@@ -144,7 +194,7 @@ pub fn generate_amenities(
|
||||
corner_addup.2 += 1;
|
||||
}
|
||||
}
|
||||
previous_node = Some((x, z));
|
||||
previous_node = Some(pt);
|
||||
}
|
||||
|
||||
// Flood-fill the interior area for parking or fountains
|
||||
@@ -154,10 +204,12 @@ pub fn generate_amenities(
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
for (x, z) in flood_area {
|
||||
let pt = XZPoint::new(x, z);
|
||||
let y = ground.level(pt);
|
||||
editor.set_block(
|
||||
block_type,
|
||||
x,
|
||||
ground_level,
|
||||
y,
|
||||
z,
|
||||
Some(&[BLACK_CONCRETE, GRAY_CONCRETE]),
|
||||
None,
|
||||
@@ -168,7 +220,7 @@ pub fn generate_amenities(
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
x,
|
||||
ground_level,
|
||||
y,
|
||||
z,
|
||||
Some(&[BLACK_CONCRETE, GRAY_CONCRETE]),
|
||||
None,
|
||||
|
||||
@@ -1,63 +1,117 @@
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedElement;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_barriers(editor: &mut WorldEditor, element: &ProcessedElement, ground_level: i32) {
|
||||
if let Some(barrier_type) = element.tags().get("barrier") {
|
||||
if barrier_type == "bollard" {
|
||||
pub fn generate_barriers(editor: &mut WorldEditor, element: &ProcessedElement, ground: &Ground) {
|
||||
// Default values
|
||||
let mut barrier_material: Block = COBBLESTONE_WALL;
|
||||
let mut barrier_height: i32 = 2;
|
||||
|
||||
match element.tags().get("barrier").map(|s| s.as_str()) {
|
||||
Some("bollard") => {
|
||||
if let ProcessedElement::Node(node) = element {
|
||||
editor.set_block(
|
||||
COBBLESTONE_WALL,
|
||||
node.x,
|
||||
ground_level + 1,
|
||||
ground.level(node.xz()) + 1,
|
||||
node.z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
// Place bollard
|
||||
}
|
||||
} else if let ProcessedElement::Way(way) = element {
|
||||
// Determine wall height
|
||||
let wall_height: i32 = element
|
||||
.tags()
|
||||
.get("height")
|
||||
.and_then(|height: &String| height.parse::<f32>().ok())
|
||||
.map(|height: f32| f32::min(3.0, height).round() as i32)
|
||||
.unwrap_or(2); // Default height is 2 if not specified or invalid
|
||||
return;
|
||||
}
|
||||
Some("kerb") => {
|
||||
// Ignore kerbs
|
||||
return;
|
||||
}
|
||||
Some("hedge") => {
|
||||
barrier_material = OAK_LEAVES;
|
||||
barrier_height = 2;
|
||||
}
|
||||
Some("fence") => {
|
||||
// Handle fence sub-types
|
||||
match element.tags().get("fence_type").map(|s| s.as_str()) {
|
||||
Some("railing" | "bars" | "krest") => {
|
||||
barrier_material = STONE_BRICK_WALL;
|
||||
barrier_height = 1;
|
||||
}
|
||||
Some("chain_link" | "metal" | "wire" | "barbed_wire" | "corrugated_metal") => {
|
||||
barrier_material = STONE_BRICK_WALL;
|
||||
barrier_height = 2;
|
||||
}
|
||||
Some("slatted" | "paling") => {
|
||||
barrier_material = OAK_FENCE;
|
||||
barrier_height = 1;
|
||||
}
|
||||
Some("wood" | "split_rail" | "panel" | "pole") => {
|
||||
barrier_material = OAK_FENCE;
|
||||
barrier_height = 2;
|
||||
}
|
||||
Some("concrete") => {
|
||||
barrier_material = ANDESITE_WALL;
|
||||
barrier_height = 2;
|
||||
}
|
||||
Some("glass") => {
|
||||
barrier_material = GLASS;
|
||||
barrier_height = 1;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
// Tagged material takes priority over inferred
|
||||
if let Some(barrier_mat) = element.tags().get("material") {
|
||||
if barrier_mat == "brick" {
|
||||
barrier_material = BRICK;
|
||||
}
|
||||
}
|
||||
|
||||
// Process nodes to create the barrier wall
|
||||
for i in 1..way.nodes.len() {
|
||||
let prev: &crate::osm_parser::ProcessedNode = &way.nodes[i - 1];
|
||||
let x1: i32 = prev.x;
|
||||
let z1: i32 = prev.z;
|
||||
if let ProcessedElement::Way(way) = element {
|
||||
// Determine wall height
|
||||
let wall_height: i32 = element
|
||||
.tags()
|
||||
.get("height")
|
||||
.and_then(|height: &String| height.parse::<f32>().ok())
|
||||
.map(|height: f32| f32::min(3.0, height).round() as i32)
|
||||
.unwrap_or(barrier_height);
|
||||
|
||||
let cur: &crate::osm_parser::ProcessedNode = &way.nodes[i];
|
||||
let x2: i32 = cur.x;
|
||||
let z2: i32 = cur.z;
|
||||
// Process nodes to create the barrier wall
|
||||
for i in 1..way.nodes.len() {
|
||||
let prev: &crate::osm_parser::ProcessedNode = &way.nodes[i - 1];
|
||||
let x1: i32 = prev.x;
|
||||
let z1: i32 = prev.z;
|
||||
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(x1, ground_level, z1, x2, ground_level, z2);
|
||||
let cur: &crate::osm_parser::ProcessedNode = &way.nodes[i];
|
||||
let x2: i32 = cur.x;
|
||||
let z2: i32 = cur.z;
|
||||
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
// Build the barrier wall to the specified height
|
||||
for y in (ground_level + 1)..=(ground_level + wall_height) {
|
||||
editor.set_block(COBBLESTONE_WALL, bx, y, bz, None, None);
|
||||
// Barrier wall
|
||||
}
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> = bresenham_line(x1, 0, z1, x2, 0, z2);
|
||||
|
||||
// Add an optional top to the barrier if the height is more than 1
|
||||
if wall_height > 1 {
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
bx,
|
||||
ground_level + wall_height + 1,
|
||||
bz,
|
||||
None,
|
||||
None,
|
||||
); // Top of the barrier
|
||||
}
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
// Build the barrier wall to the specified height
|
||||
let ground_level = ground.level(XZPoint::new(bx, bz));
|
||||
for y in (ground_level + 1)..=(ground_level + wall_height) {
|
||||
editor.set_block(barrier_material, bx, y, bz, None, None);
|
||||
// Barrier wall
|
||||
}
|
||||
|
||||
// Add an optional top to the barrier if the height is more than 1
|
||||
if wall_height > 1 {
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
bx,
|
||||
ground_level + wall_height + 1,
|
||||
bz,
|
||||
None,
|
||||
None,
|
||||
); // Top of the barrier
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +1,41 @@
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
//use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedWay;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
// TODO FIX
|
||||
#[allow(dead_code)]
|
||||
pub fn generate_bridges(editor: &mut WorldEditor, element: &ProcessedWay, ground_level: i32) {
|
||||
if let Some(_bridge_type) = element.tags.get("bridge") {
|
||||
let bridge_height: i32 = element
|
||||
.tags
|
||||
.get("layer")
|
||||
.and_then(|layer: &String| layer.parse::<i32>().ok())
|
||||
.unwrap_or(1); // Default height if not specified
|
||||
|
||||
// Calculate the total length of the bridge
|
||||
let total_steps: usize = element
|
||||
.nodes
|
||||
.windows(2)
|
||||
.map(|nodes: &[crate::osm_parser::ProcessedNode]| {
|
||||
let x1: i32 = nodes[0].x;
|
||||
let z1: i32 = nodes[0].z;
|
||||
let x2: i32 = nodes[1].x;
|
||||
let z2: i32 = nodes[1].z;
|
||||
|
||||
bresenham_line(x1, ground_level, z1, x2, ground_level, z2).len()
|
||||
})
|
||||
.sum();
|
||||
|
||||
let half_steps: usize = total_steps / 2; // Calculate midpoint for descending after rising
|
||||
let mut current_step: usize = 0;
|
||||
let bridge_height = 3; // Fixed height
|
||||
|
||||
for i in 1..element.nodes.len() {
|
||||
let prev: &crate::osm_parser::ProcessedNode = &element.nodes[i - 1];
|
||||
let x1: i32 = prev.x;
|
||||
let z1: i32 = prev.z;
|
||||
let prev = &element.nodes[i - 1];
|
||||
let cur = &element.nodes[i];
|
||||
let points = bresenham_line(prev.x, ground_level, prev.z, cur.x, ground_level, cur.z);
|
||||
|
||||
let cur: &crate::osm_parser::ProcessedNode = &element.nodes[i];
|
||||
let x2: i32 = cur.x;
|
||||
let z2: i32 = cur.z;
|
||||
let total_length = points.len();
|
||||
let ramp_length = 6; // Length of ramp at each end
|
||||
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(x1, ground_level, z1, x2, ground_level, z2);
|
||||
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
// Calculate the current height of the bridge
|
||||
let current_height: i32 = if current_step <= half_steps {
|
||||
ground_level + bridge_height + current_step as i32 / 5 // Rise for the first half
|
||||
for (idx, (x, _, z)) in points.iter().enumerate() {
|
||||
let height = if idx < ramp_length {
|
||||
// Start ramp (rising)
|
||||
(idx * bridge_height) / ramp_length
|
||||
} else if idx >= total_length - ramp_length {
|
||||
// End ramp (descending)
|
||||
((total_length - idx) * bridge_height) / ramp_length
|
||||
} else {
|
||||
ground_level + bridge_height + (half_steps as i32 / 5)
|
||||
- ((current_step - half_steps) as i32 / 5) // Descend for the second half
|
||||
// Middle section (constant height)
|
||||
bridge_height
|
||||
};
|
||||
|
||||
// Set bridge blocks
|
||||
editor.set_block(LIGHT_GRAY_CONCRETE, bx, current_height, bz, None, None);
|
||||
for (offset_x, offset_z) in &[(-1, -1), (1, -1), (1, 1), (-1, 1)] {
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
bx + offset_x,
|
||||
current_height,
|
||||
bz + offset_z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
let bridge_y = ground_level + height as i32;
|
||||
|
||||
current_step += 1;
|
||||
// Place bridge blocks
|
||||
for dx in -2..=2 {
|
||||
editor.set_block(LIGHT_GRAY_CONCRETE, *x + dx, bridge_y, *z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::colors::{color_text_to_rgb_tuple, rgb_distance, RGBTuple};
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::{ProcessedMemberRole, ProcessedRelation, ProcessedWay};
|
||||
use crate::world_editor::WorldEditor;
|
||||
use rand::Rng;
|
||||
@@ -12,9 +14,24 @@ use std::time::Duration;
|
||||
pub fn generate_buildings(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedWay,
|
||||
ground_level: i32,
|
||||
ground: &Ground,
|
||||
args: &Args,
|
||||
relation_levels: Option<i32>,
|
||||
) {
|
||||
let Some(base_y) = ground.min_level(element.nodes.iter().map(|n| n.xz())) else {
|
||||
return;
|
||||
};
|
||||
|
||||
// Get min_level first so we can use it both for start_level and building height calculations
|
||||
let min_level = if let Some(min_level_str) = element.tags.get("building:min_level") {
|
||||
min_level_str.parse::<i32>().unwrap_or(0)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
// Calculate starting level using base_y and min_level
|
||||
let start_level = base_y + (min_level * 4);
|
||||
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let mut corner_addup: (i32, i32, i32) = (0, 0, 0);
|
||||
let mut current_building: Vec<(i32, i32)> = vec![];
|
||||
@@ -45,12 +62,29 @@ pub fn generate_buildings(
|
||||
})
|
||||
})
|
||||
.flatten()
|
||||
.unwrap_or_else(|| building_floor_variations()[variation_index_floor]);
|
||||
.unwrap_or_else(|| {
|
||||
if let Some(building_type) = element
|
||||
.tags
|
||||
.get("building")
|
||||
.or_else(|| element.tags.get("building:part"))
|
||||
{
|
||||
//Random roof color only for single houses
|
||||
match building_type.as_str() {
|
||||
"yes" | "house" | "detached" | "static_caravan" | "semidetached_house"
|
||||
| "bungalow" | "manor" | "villa" => {
|
||||
return building_floor_variations()[variation_index_floor];
|
||||
}
|
||||
_ => return LIGHT_GRAY_CONCRETE,
|
||||
}
|
||||
}
|
||||
LIGHT_GRAY_CONCRETE
|
||||
});
|
||||
let window_block: Block = WHITE_STAINED_GLASS;
|
||||
|
||||
// Set to store processed flood fill points
|
||||
let mut processed_points: HashSet<(i32, i32)> = HashSet::new();
|
||||
let mut building_height: i32 = 6; // Default building height
|
||||
let scale_factor = args.scale;
|
||||
let mut building_height: i32 = ((6.0 * scale_factor) as i32).max(3); // Default building height with scale and minimum
|
||||
|
||||
// Skip if 'layer' or 'level' is negative in the tags
|
||||
if let Some(layer) = element.tags.get("layer") {
|
||||
@@ -68,18 +102,27 @@ pub fn generate_buildings(
|
||||
// Determine building height from tags
|
||||
if let Some(levels_str) = element.tags.get("building:levels") {
|
||||
if let Ok(levels) = levels_str.parse::<i32>() {
|
||||
if levels >= 1 && (levels * 4 + 2) > building_height {
|
||||
building_height = levels * 4 + 2;
|
||||
let lev = levels - min_level;
|
||||
|
||||
if lev >= 1 {
|
||||
building_height = ((lev * 4 + 2) as f64 * scale_factor) as i32;
|
||||
building_height = building_height.max(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(height_str) = element.tags.get("height") {
|
||||
if let Ok(height) = height_str.trim_end_matches("m").trim().parse::<f64>() {
|
||||
building_height = height.round() as i32;
|
||||
building_height = (height * scale_factor) as i32;
|
||||
building_height = building_height.max(3);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(levels) = relation_levels {
|
||||
building_height = ((levels * 4 + 2) as f64 * scale_factor) as i32;
|
||||
building_height = building_height.max(3);
|
||||
}
|
||||
|
||||
if let Some(amenity_type) = element.tags.get("amenity") {
|
||||
if amenity_type == "shelter" {
|
||||
let roof_block: Block = STONE_BRICK_SLAB;
|
||||
@@ -97,14 +140,22 @@ pub fn generate_buildings(
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
|
||||
for y in 1..=4 {
|
||||
editor.set_block(OAK_FENCE, x, ground_level + y, z, None, None);
|
||||
let Some(y) = ground.min_level(element.nodes.iter().map(|n| n.xz())) else {
|
||||
return;
|
||||
};
|
||||
|
||||
for shelter_y in 1..=4 {
|
||||
editor.set_block(OAK_FENCE, x, shelter_y + y, z, None, None);
|
||||
}
|
||||
editor.set_block(roof_block, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(roof_block, x, y + 5, z, None, None);
|
||||
}
|
||||
|
||||
// Flood fill the roof area
|
||||
let roof_height: i32 = ground_level + 5;
|
||||
let Some(y) = ground.min_level(element.nodes.iter().map(|n| n.xz())) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let roof_height: i32 = y + 5;
|
||||
for (x, z) in roof_area.iter() {
|
||||
editor.set_block(roof_block, *x, roof_height, *z, None, None);
|
||||
}
|
||||
@@ -115,9 +166,9 @@ pub fn generate_buildings(
|
||||
|
||||
if let Some(building_type) = element.tags.get("building") {
|
||||
if building_type == "garage" {
|
||||
building_height = 2;
|
||||
building_height = ((2.0 * scale_factor) as i32).max(3);
|
||||
} else if building_type == "shed" {
|
||||
building_height = 2;
|
||||
building_height = ((2.0 * scale_factor) as i32).max(3);
|
||||
|
||||
if element.tags.contains_key("bicycle_parking") {
|
||||
let ground_block: Block = OAK_PLANKS;
|
||||
@@ -131,9 +182,13 @@ pub fn generate_buildings(
|
||||
let floor_area: Vec<(i32, i32)> =
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
let Some(y) = ground.min_level(element.nodes.iter().map(|n| n.xz())) else {
|
||||
return;
|
||||
};
|
||||
|
||||
// Fill the floor area
|
||||
for (x, z) in floor_area.iter() {
|
||||
editor.set_block(ground_block, *x, ground_level, *z, None, None);
|
||||
editor.set_block(ground_block, *x, y, *z, None, None);
|
||||
}
|
||||
|
||||
// Place fences and roof slabs at each corner node directly
|
||||
@@ -141,22 +196,118 @@ pub fn generate_buildings(
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
|
||||
for y in 1..=4 {
|
||||
editor.set_block(ground_block, x, ground_level, z, None, None);
|
||||
editor.set_block(OAK_FENCE, x, ground_level + y, z, None, None);
|
||||
for dy in 1..=4 {
|
||||
editor.set_block(OAK_FENCE, x, y + dy, z, None, None);
|
||||
}
|
||||
editor.set_block(roof_block, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(roof_block, x, y + 5, z, None, None);
|
||||
}
|
||||
|
||||
// Flood fill the roof area
|
||||
let roof_height: i32 = ground_level + 5;
|
||||
let roof_height: i32 = y + 5;
|
||||
for (x, z) in floor_area.iter() {
|
||||
editor.set_block(roof_block, *x, roof_height, *z, None, None);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
} else if building_type == "parking"
|
||||
|| element
|
||||
.tags
|
||||
.get("parking")
|
||||
.is_some_and(|p| p == "multi-storey")
|
||||
{
|
||||
// Parking building structure
|
||||
|
||||
// Ensure minimum height
|
||||
building_height = building_height.max(16);
|
||||
|
||||
let polygon_coords: Vec<(i32, i32)> = element
|
||||
.nodes
|
||||
.iter()
|
||||
.map(|n: &crate::osm_parser::ProcessedNode| (n.x, n.z))
|
||||
.collect();
|
||||
let floor_area: Vec<(i32, i32)> =
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
let Some(ground_level) = ground.min_level(element.nodes.iter().map(|n| n.xz())) else {
|
||||
return;
|
||||
};
|
||||
|
||||
for level in 0..=(building_height / 4) {
|
||||
let current_level = ground_level + level * 4;
|
||||
|
||||
// Build walls
|
||||
for node in &element.nodes {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
|
||||
// Build walls up to the current level
|
||||
for y in (current_level + 1)..=(current_level + 4) {
|
||||
editor.set_block(STONE_BRICKS, x, y, z, None, None);
|
||||
}
|
||||
}
|
||||
|
||||
// Fill the floor area for each level
|
||||
for (x, z) in &floor_area {
|
||||
if level == 0 {
|
||||
editor.set_block(SMOOTH_STONE, *x, current_level, *z, None, None);
|
||||
} else {
|
||||
editor.set_block(COBBLESTONE, *x, current_level, *z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Outline for each level
|
||||
for level in 0..=(building_height / 4) {
|
||||
let current_level = ground_level + level * 4;
|
||||
|
||||
// Use the nodes to create the outline
|
||||
let mut prev_outline = None;
|
||||
for node in &element.nodes {
|
||||
let x = node.x;
|
||||
let z = node.z;
|
||||
|
||||
if let Some((prev_x, prev_z)) = prev_outline {
|
||||
let outline_points =
|
||||
bresenham_line(prev_x, current_level, prev_z, x, current_level, z);
|
||||
for (bx, _, bz) in outline_points {
|
||||
editor.set_block(
|
||||
SMOOTH_STONE,
|
||||
bx,
|
||||
current_level,
|
||||
bz,
|
||||
Some(&[COBBLESTONE, COBBLESTONE_WALL]),
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
bx,
|
||||
current_level + 2,
|
||||
bz,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
if bx % 2 == 0 {
|
||||
editor.set_block(
|
||||
COBBLESTONE_WALL,
|
||||
bx,
|
||||
current_level + 1,
|
||||
bz,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
prev_outline = Some((x, z));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
} else if building_type == "roof" {
|
||||
let Some(ground_level) = ground.min_level(element.nodes.iter().map(|n| n.xz())) else {
|
||||
return;
|
||||
};
|
||||
let roof_height: i32 = ground_level + 5;
|
||||
|
||||
// Iterate through the nodes to create the roof edges using Bresenham's line algorithm
|
||||
@@ -198,16 +349,16 @@ pub fn generate_buildings(
|
||||
return;
|
||||
} else if building_type == "apartments" {
|
||||
// If building has no height attribute, assign a defined height
|
||||
if building_height == 6 {
|
||||
building_height = 15
|
||||
if building_height == ((6.0 * scale_factor) as i32).max(3) {
|
||||
building_height = ((15.0 * scale_factor) as i32).max(3);
|
||||
}
|
||||
} else if building_type == "hospital" {
|
||||
// If building has no height attribute, assign a defined height
|
||||
if building_height == 6 {
|
||||
building_height = 23
|
||||
if building_height == ((6.0 * scale_factor) as i32).max(3) {
|
||||
building_height = ((23.0 * scale_factor) as i32).max(3);
|
||||
}
|
||||
} else if building_type == "bridge" {
|
||||
generate_bridge(editor, element, ground_level, args.timeout.as_ref());
|
||||
generate_bridge(editor, element, ground, args.timeout.as_ref());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -219,28 +370,26 @@ pub fn generate_buildings(
|
||||
|
||||
if let Some(prev) = previous_node {
|
||||
// Calculate walls and corners using Bresenham line
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level, prev.1, x, ground_level, z);
|
||||
let bresenham_points = bresenham_line(prev.0, start_level, prev.1, x, start_level, z);
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
for h in (ground_level + 1)..=(ground_level + building_height) {
|
||||
for h in (start_level + 1)..=(start_level + building_height) {
|
||||
if element.nodes[0].x == bx && element.nodes[0].x == bz {
|
||||
editor.set_block(corner_block, bx, h, bz, None, None); // Corner block
|
||||
// Corner Block
|
||||
editor.set_block(corner_block, bx, h, bz, None, None);
|
||||
} else {
|
||||
// Add windows to the walls at intervals
|
||||
if h > ground_level + 1 && h % 4 != 0 && (bx + bz) % 6 < 3 {
|
||||
if h > start_level + 1 && h % 4 != 0 && (bx + bz) % 6 < 3 {
|
||||
editor.set_block(window_block, bx, h, bz, None, None);
|
||||
// Window block
|
||||
} else {
|
||||
editor.set_block(wall_block, bx, h, bz, None, None);
|
||||
// Wall block
|
||||
}
|
||||
}
|
||||
}
|
||||
// Ceiling cobblestone
|
||||
|
||||
editor.set_block(
|
||||
COBBLESTONE,
|
||||
bx,
|
||||
ground_level + building_height + 1,
|
||||
start_level + building_height + 1,
|
||||
bz,
|
||||
None,
|
||||
None,
|
||||
@@ -249,9 +398,9 @@ pub fn generate_buildings(
|
||||
if args.winter {
|
||||
editor.set_block(
|
||||
SNOW_LAYER,
|
||||
x,
|
||||
ground_level + building_height + 2,
|
||||
z,
|
||||
bx,
|
||||
start_level + building_height + 2,
|
||||
bz,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
@@ -276,27 +425,28 @@ pub fn generate_buildings(
|
||||
|
||||
for (x, z) in floor_area {
|
||||
if processed_points.insert((x, z)) {
|
||||
editor.set_block(floor_block, x, ground_level, z, None, None); // Set floor
|
||||
// Set floor at start_level
|
||||
editor.set_block(floor_block, x, start_level, z, None, None);
|
||||
|
||||
// Set level ceilings if height > 4
|
||||
if building_height > 4 {
|
||||
for h in (ground_level + 2 + 4..ground_level + building_height).step_by(4) {
|
||||
for h in (start_level + 2 + 4..start_level + building_height).step_by(4) {
|
||||
if x % 6 == 0 && z % 6 == 0 {
|
||||
editor.set_block(GLOWSTONE, x, h, z, None, None); // Light fixtures
|
||||
// Light fixtures
|
||||
editor.set_block(GLOWSTONE, x, h, z, None, None);
|
||||
} else {
|
||||
editor.set_block(floor_block, x, h, z, None, None);
|
||||
}
|
||||
}
|
||||
} else if x % 6 == 0 && z % 6 == 0 {
|
||||
editor.set_block(GLOWSTONE, x, ground_level + building_height, z, None, None);
|
||||
// Light fixtures
|
||||
editor.set_block(GLOWSTONE, x, start_level + building_height, z, None, None);
|
||||
}
|
||||
|
||||
// Set the house ceiling
|
||||
// Set ceiling at proper height
|
||||
editor.set_block(
|
||||
floor_block,
|
||||
x,
|
||||
ground_level + building_height + 1,
|
||||
start_level + building_height + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
@@ -306,7 +456,7 @@ pub fn generate_buildings(
|
||||
editor.set_block(
|
||||
SNOW_LAYER,
|
||||
x,
|
||||
ground_level + building_height + 2,
|
||||
start_level + building_height + 2,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
@@ -320,18 +470,25 @@ pub fn generate_buildings(
|
||||
pub fn generate_building_from_relation(
|
||||
editor: &mut WorldEditor,
|
||||
relation: &ProcessedRelation,
|
||||
ground_level: i32,
|
||||
ground: &Ground,
|
||||
args: &Args,
|
||||
) {
|
||||
// Extract levels from relation tags
|
||||
let relation_levels = relation
|
||||
.tags
|
||||
.get("building:levels")
|
||||
.and_then(|l| l.parse::<i32>().ok())
|
||||
.unwrap_or(2); // Default to 2 levels
|
||||
|
||||
// Process the outer way to create the building walls
|
||||
for member in &relation.members {
|
||||
if member.role == ProcessedMemberRole::Outer {
|
||||
generate_buildings(editor, &member.way, ground_level, args);
|
||||
generate_buildings(editor, &member.way, ground, args, Some(relation_levels));
|
||||
}
|
||||
}
|
||||
|
||||
// Handle inner ways (holes, courtyards, etc.)
|
||||
for member in &relation.members {
|
||||
/*for member in &relation.members {
|
||||
if member.role == ProcessedMemberRole::Inner {
|
||||
let polygon_coords: Vec<(i32, i32)> =
|
||||
member.way.nodes.iter().map(|n| (n.x, n.z)).collect();
|
||||
@@ -343,7 +500,7 @@ pub fn generate_building_from_relation(
|
||||
editor.set_block(AIR, x, ground_level, z, None, Some(&[SPONGE]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
fn find_nearest_block_in_color_map(
|
||||
@@ -360,17 +517,9 @@ fn find_nearest_block_in_color_map(
|
||||
fn generate_bridge(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedWay,
|
||||
base_level: i32,
|
||||
ground: &Ground,
|
||||
floodfill_timeout: Option<&Duration>,
|
||||
) {
|
||||
// Calculate the bridge level
|
||||
let mut bridge_level: i32 = base_level;
|
||||
if let Some(level_str) = element.tags.get("level") {
|
||||
if let Ok(level) = level_str.parse::<i32>() {
|
||||
bridge_level += (level * 3) + 1; // Adjust height by levels
|
||||
}
|
||||
}
|
||||
|
||||
let floor_block: Block = STONE;
|
||||
let railing_block: Block = STONE_BRICKS;
|
||||
|
||||
@@ -380,26 +529,56 @@ fn generate_bridge(
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
|
||||
// Calculate the dynamic bridge level based on the ground level
|
||||
let mut bridge_level = ground.level(XZPoint::new(x, z));
|
||||
|
||||
// Adjust the bridge level based on the "level" tag
|
||||
if let Some(level_str) = element.tags.get("level") {
|
||||
if let Ok(level) = level_str.parse::<i32>() {
|
||||
bridge_level += (level * 3) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Create bridge path using Bresenham's line
|
||||
if let Some(prev) = previous_node {
|
||||
let bridge_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, bridge_level, prev.1, x, bridge_level, z);
|
||||
|
||||
for (bx, by, bz) in bridge_points {
|
||||
// Place railing blocks
|
||||
editor.set_block(railing_block, bx, by + 1, bz, None, None);
|
||||
editor.set_block(railing_block, bx, by, bz, None, None);
|
||||
}
|
||||
}
|
||||
|
||||
previous_node = Some((x, z));
|
||||
}
|
||||
|
||||
// Flood fill the area between the bridge path nodes
|
||||
let polygon_coords: Vec<(i32, i32)> = element
|
||||
.nodes
|
||||
.iter()
|
||||
.map(|n: &crate::osm_parser::ProcessedNode| (n.x, n.z))
|
||||
.collect();
|
||||
let bridge_area: Vec<(i32, i32)> = flood_fill_area(&polygon_coords, floodfill_timeout);
|
||||
for (x, z) in bridge_area {
|
||||
editor.set_block(floor_block, x, bridge_level, z, None, None);
|
||||
let polygon_coords: Vec<XZPoint> = element.nodes.iter().map(|n| n.xz()).collect();
|
||||
let bridge_area: Vec<XZPoint> = flood_fill_area(
|
||||
&polygon_coords
|
||||
.iter()
|
||||
.map(|pt| (pt.x, pt.z))
|
||||
.collect::<Vec<_>>(),
|
||||
floodfill_timeout,
|
||||
)
|
||||
.into_iter()
|
||||
.map(|(x, z)| XZPoint::new(x, z))
|
||||
.collect();
|
||||
|
||||
for pt in bridge_area {
|
||||
// Calculate the bridge's floor level dynamically
|
||||
let mut bridge_level = ground.level(pt);
|
||||
|
||||
// Adjust the bridge level based on the "level" tag
|
||||
if let Some(level_str) = element.tags.get("level") {
|
||||
if let Ok(level) = level_str.parse::<i32>() {
|
||||
bridge_level += (level * 3) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Place floor blocks
|
||||
editor.set_block(floor_block, pt.x, bridge_level, pt.z, None, None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use crate::block_definitions::*;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedNode;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_doors(editor: &mut WorldEditor, element: &ProcessedNode, ground_level: i32) {
|
||||
pub fn generate_doors(editor: &mut WorldEditor, element: &ProcessedNode, ground: &Ground) {
|
||||
// Check if the element is a door or entrance
|
||||
if element.tags.contains_key("door") || element.tags.contains_key("entrance") {
|
||||
// Check for the "level" tag and skip doors that are not at ground level
|
||||
@@ -17,6 +19,9 @@ pub fn generate_doors(editor: &mut WorldEditor, element: &ProcessedNode, ground_
|
||||
let x: i32 = element.x;
|
||||
let z: i32 = element.z;
|
||||
|
||||
// Calculate the dynamic ground level
|
||||
let ground_level = ground.level(XZPoint::new(x, z));
|
||||
|
||||
// Set the ground block and the door blocks
|
||||
editor.set_block(GRAY_CONCRETE, x, ground_level, z, None, None);
|
||||
editor.set_block(DARK_OAK_DOOR_LOWER, x, ground_level + 1, z, None, None);
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::{ProcessedElement, ProcessedWay};
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_highways(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedElement,
|
||||
ground_level: i32,
|
||||
ground: &Ground,
|
||||
args: &Args,
|
||||
) {
|
||||
if let Some(highway_type) = element.tags().get("highway") {
|
||||
@@ -16,11 +18,12 @@ pub fn generate_highways(
|
||||
// Handle street lamps
|
||||
if let ProcessedElement::Node(first_node) = element {
|
||||
let x: i32 = first_node.x;
|
||||
let y: i32 = ground.level(first_node.xz());
|
||||
let z: i32 = first_node.z;
|
||||
for y in 1..=4 {
|
||||
editor.set_block(OAK_FENCE, x, ground_level + y, z, None, None);
|
||||
for dy in 1..=4 {
|
||||
editor.set_block(OAK_FENCE, x, y + dy, z, None, None);
|
||||
}
|
||||
editor.set_block(GLOWSTONE, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(GLOWSTONE, x, y + 5, z, None, None);
|
||||
}
|
||||
} else if highway_type == "crossing" {
|
||||
// Handle traffic signals for crossings
|
||||
@@ -28,17 +31,19 @@ pub fn generate_highways(
|
||||
if crossing_type == "traffic_signals" {
|
||||
if let ProcessedElement::Node(node) = element {
|
||||
let x: i32 = node.x;
|
||||
let y: i32 = ground.level(node.xz());
|
||||
let z: i32 = node.z;
|
||||
for y in 1..=3 {
|
||||
editor.set_block(COBBLESTONE_WALL, x, ground_level + y, z, None, None);
|
||||
|
||||
for dy in 1..=3 {
|
||||
editor.set_block(COBBLESTONE_WALL, x, y + dy, z, None, None);
|
||||
}
|
||||
|
||||
editor.set_block(GREEN_WOOL, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(YELLOW_WOOL, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(RED_WOOL, x, ground_level + 6, z, None, None);
|
||||
editor.set_block(GREEN_WOOL, x, y + 4, z, None, None);
|
||||
editor.set_block(YELLOW_WOOL, x, y + 5, z, None, None);
|
||||
editor.set_block(RED_WOOL, x, y + 6, z, None, None);
|
||||
|
||||
if args.winter {
|
||||
editor.set_block(SNOW_LAYER, x, ground_level + 7, z, None, None);
|
||||
editor.set_block(SNOW_LAYER, x, y + 7, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,19 +51,20 @@ pub fn generate_highways(
|
||||
} else if highway_type == "bus_stop" {
|
||||
// Handle bus stops
|
||||
if let ProcessedElement::Node(node) = element {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
for y in 1..=3 {
|
||||
editor.set_block(COBBLESTONE_WALL, x, ground_level + y, z, None, None);
|
||||
let x = node.x;
|
||||
let y = ground.level(node.xz());
|
||||
let z = node.z;
|
||||
for dy in 1..=3 {
|
||||
editor.set_block(COBBLESTONE_WALL, x, y + dy, z, None, None);
|
||||
}
|
||||
|
||||
editor.set_block(WHITE_WOOL, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(WHITE_WOOL, x + 1, ground_level + 4, z, None, None);
|
||||
editor.set_block(WHITE_WOOL, x, y + 4, z, None, None);
|
||||
editor.set_block(WHITE_WOOL, x + 1, y + 4, z, None, None);
|
||||
}
|
||||
} else if element
|
||||
.tags()
|
||||
.get("area")
|
||||
.map_or(false, |v: &String| v == "yes")
|
||||
.is_some_and(|v: &String| v == "yes")
|
||||
{
|
||||
let ProcessedElement::Way(way) = element else {
|
||||
return;
|
||||
@@ -99,7 +105,14 @@ pub fn generate_highways(
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
for (x, z) in filled_area {
|
||||
editor.set_block(surface_block, x, ground_level, z, None, None);
|
||||
editor.set_block(
|
||||
surface_block,
|
||||
x,
|
||||
ground.level(XZPoint::new(x, z)),
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
@@ -132,7 +145,10 @@ pub fn generate_highways(
|
||||
}
|
||||
"motorway" | "primary" => {
|
||||
block_range = 5;
|
||||
add_stripe = true; // Add stripes for motorways and primary roads
|
||||
add_stripe = true;
|
||||
}
|
||||
"tertiary" => {
|
||||
add_stripe = true;
|
||||
}
|
||||
"track" => {
|
||||
block_range = 1;
|
||||
@@ -166,8 +182,10 @@ pub fn generate_highways(
|
||||
let z2: i32 = node.z;
|
||||
|
||||
// Generate the line of coordinates between the two nodes
|
||||
// we don't care about the y because it's going to get overwritten
|
||||
// I'm not sure if we'll keep it this way
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(x1, ground_level, z1, x2, ground_level, z2);
|
||||
bresenham_line(x1, 0, z1, x2, 0, z2);
|
||||
|
||||
// Variables to manage dashed line pattern
|
||||
let mut stripe_length: i32 = 0;
|
||||
@@ -192,7 +210,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
WHITE_CONCRETE,
|
||||
set_x,
|
||||
ground_level,
|
||||
ground.level(XZPoint::new(set_x, set_z)),
|
||||
set_z,
|
||||
Some(&[BLACK_CONCRETE]),
|
||||
None,
|
||||
@@ -201,7 +219,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
BLACK_CONCRETE,
|
||||
set_x,
|
||||
ground_level,
|
||||
ground.level(XZPoint::new(set_x, set_z)),
|
||||
set_z,
|
||||
None,
|
||||
None,
|
||||
@@ -211,7 +229,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
WHITE_CONCRETE,
|
||||
set_x,
|
||||
ground_level,
|
||||
ground.level(XZPoint::new(set_x, set_z)),
|
||||
set_z,
|
||||
Some(&[BLACK_CONCRETE]),
|
||||
None,
|
||||
@@ -220,7 +238,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
BLACK_CONCRETE,
|
||||
set_x,
|
||||
ground_level,
|
||||
ground.level(XZPoint::new(set_x, set_z)),
|
||||
set_z,
|
||||
None,
|
||||
None,
|
||||
@@ -230,7 +248,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
block_type,
|
||||
set_x,
|
||||
ground_level,
|
||||
ground.level(XZPoint::new(set_x, set_z)),
|
||||
set_z,
|
||||
None,
|
||||
Some(&[BLACK_CONCRETE, WHITE_CONCRETE]),
|
||||
@@ -247,7 +265,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
WHITE_CONCRETE,
|
||||
stripe_x,
|
||||
ground_level,
|
||||
ground.level(XZPoint::new(stripe_x, stripe_z)),
|
||||
stripe_z,
|
||||
Some(&[BLACK_CONCRETE]),
|
||||
None,
|
||||
@@ -269,31 +287,66 @@ pub fn generate_highways(
|
||||
}
|
||||
|
||||
/// Generates a siding using stone brick slabs
|
||||
pub fn generate_siding(editor: &mut WorldEditor, element: &ProcessedWay, ground_level: i32) {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
pub fn generate_siding(editor: &mut WorldEditor, element: &ProcessedWay, ground: &Ground) {
|
||||
let mut previous_node: Option<XZPoint> = None;
|
||||
let siding_block: Block = STONE_BRICK_SLAB;
|
||||
|
||||
for node in &element.nodes {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
let current_node = node.xz();
|
||||
|
||||
// Draw the siding using Bresenham's line algorithm between nodes
|
||||
if let Some(prev) = previous_node {
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level + 1, prev.1, x, ground_level + 1, z);
|
||||
for (bx, by, bz) in bresenham_points {
|
||||
if let Some(prev_node) = previous_node {
|
||||
let bresenham_points: Vec<(i32, i32, i32)> = bresenham_line(
|
||||
prev_node.x,
|
||||
0,
|
||||
prev_node.z,
|
||||
current_node.x,
|
||||
0,
|
||||
current_node.z,
|
||||
);
|
||||
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
let ground_level = ground.level(XZPoint::new(bx, bz)) + 1;
|
||||
|
||||
if !editor.check_for_block(
|
||||
bx,
|
||||
by - 1,
|
||||
ground_level - 1,
|
||||
bz,
|
||||
None,
|
||||
Some(&[BLACK_CONCRETE, WHITE_CONCRETE]),
|
||||
) {
|
||||
editor.set_block(siding_block, bx, by, bz, None, None);
|
||||
editor.set_block(siding_block, bx, ground_level, bz, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
previous_node = Some((x, z));
|
||||
previous_node = Some(current_node);
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates an aeroway
|
||||
pub fn generate_aeroway(editor: &mut WorldEditor, way: &ProcessedWay, ground: &Ground) {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let surface_block = LIGHT_GRAY_CONCRETE;
|
||||
|
||||
for node in &way.nodes {
|
||||
if let Some(prev) = previous_node {
|
||||
let (x1, z1) = prev;
|
||||
let x2 = node.x;
|
||||
let z2 = node.z;
|
||||
let points = bresenham_line(x1, 0, z1, x2, 0, z2);
|
||||
|
||||
for (x, _, z) in points {
|
||||
for dx in -12..=12 {
|
||||
for dz in -12..=12 {
|
||||
let set_x = x + dx;
|
||||
let set_z = z + dz;
|
||||
let y = ground.level(XZPoint::new(set_x, set_z));
|
||||
editor.set_block(surface_block, set_x, y, set_z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
previous_node = Some((node.x, node.z));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::element_processing::tree::create_tree;
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedWay;
|
||||
use crate::world_editor::WorldEditor;
|
||||
use rand::Rng;
|
||||
@@ -10,13 +11,9 @@ use rand::Rng;
|
||||
pub fn generate_landuse(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedWay,
|
||||
ground_level: i32,
|
||||
ground: &Ground,
|
||||
args: &Args,
|
||||
) {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let mut corner_addup: (i32, i32, i32) = (0, 0, 0);
|
||||
let mut current_landuse: Vec<(i32, i32)> = vec![];
|
||||
|
||||
// Determine block type based on landuse tag
|
||||
let binding: String = "".to_string();
|
||||
let landuse_tag: &String = element.tags.get("landuse").unwrap_or(&binding);
|
||||
@@ -56,318 +53,293 @@ pub fn generate_landuse(
|
||||
}
|
||||
};
|
||||
|
||||
let bresenham_block: Block = if args.winter { SNOW_BLOCK } else { GRASS_BLOCK };
|
||||
// Get the area of the landuse element
|
||||
let polygon_coords: Vec<(i32, i32)> = element.nodes.iter().map(|n| (n.x, n.z)).collect();
|
||||
let floor_area: Vec<(i32, i32)> = flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
// Process landuse nodes to fill the area
|
||||
for node in &element.nodes {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
|
||||
if let Some(prev) = previous_node {
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level, prev.1, x, ground_level, z);
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
editor.set_block(bresenham_block, bx, ground_level, bz, None, None);
|
||||
}
|
||||
|
||||
current_landuse.push((x, z));
|
||||
corner_addup = (corner_addup.0 + x, corner_addup.1 + z, corner_addup.2 + 1);
|
||||
for (x, z) in floor_area {
|
||||
let ground_level = ground.level(XZPoint::new(x, z));
|
||||
if landuse_tag == "traffic_island" {
|
||||
editor.set_block(block_type, x, ground_level + 1, z, None, None);
|
||||
} else if landuse_tag == "construction" || landuse_tag == "railway" {
|
||||
editor.set_block(block_type, x, ground_level, z, None, Some(&[SPONGE]));
|
||||
} else {
|
||||
editor.set_block(block_type, x, ground_level, z, None, None);
|
||||
}
|
||||
|
||||
previous_node = Some((x, z));
|
||||
}
|
||||
|
||||
// If there are landuse nodes, flood-fill the area
|
||||
if !current_landuse.is_empty() {
|
||||
let polygon_coords: Vec<(i32, i32)> = element.nodes.iter().map(|n| (n.x, n.z)).collect();
|
||||
let floor_area: Vec<(i32, i32)> = flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
|
||||
for (x, z) in floor_area {
|
||||
if landuse_tag == "traffic_island" {
|
||||
editor.set_block(block_type, x, ground_level + 1, z, None, None);
|
||||
} else if landuse_tag == "construction" || landuse_tag == "railway" {
|
||||
editor.set_block(block_type, x, ground_level, z, None, Some(&[SPONGE]));
|
||||
} else {
|
||||
editor.set_block(block_type, x, ground_level, z, None, None);
|
||||
}
|
||||
|
||||
// Add specific features for different landuse types
|
||||
match landuse_tag.as_str() {
|
||||
"cemetery" => {
|
||||
if (x % 3 == 0) && (z % 3 == 0) {
|
||||
let random_choice: i32 = rng.gen_range(0..100);
|
||||
if random_choice < 15 {
|
||||
// Place graves
|
||||
if editor.check_for_block(x, ground_level, z, Some(&[PODZOL]), None) {
|
||||
if rng.gen_bool(0.5) {
|
||||
editor.set_block(
|
||||
COBBLESTONE,
|
||||
x - 1,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x - 1,
|
||||
ground_level + 2,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x + 1,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
} else {
|
||||
editor.set_block(
|
||||
COBBLESTONE,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z - 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 2,
|
||||
z - 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z + 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if random_choice < 30 {
|
||||
if editor.check_for_block(x, ground_level, z, Some(&[PODZOL]), None) {
|
||||
editor.set_block(RED_FLOWER, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
} else if random_choice < 33 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
"forest" => {
|
||||
if !editor.check_for_block(x, ground_level, z, None, Some(&[WATER])) {
|
||||
let random_choice: i32 = rng.gen_range(0..21);
|
||||
if random_choice == 20 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if random_choice == 2 {
|
||||
let flower_block: Block = match rng.gen_range(1..=4) {
|
||||
1 => RED_FLOWER,
|
||||
2 => BLUE_FLOWER,
|
||||
3 => YELLOW_FLOWER,
|
||||
_ => WHITE_FLOWER,
|
||||
};
|
||||
editor.set_block(flower_block, x, ground_level + 1, z, None, None);
|
||||
} else if random_choice <= 1 {
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"farmland" => {
|
||||
// Check if the current block is not water or another undesired block
|
||||
if !editor.check_for_block(x, ground_level, z, None, Some(&[WATER])) {
|
||||
if x % 15 == 0 || z % 15 == 0 {
|
||||
// Place water on the edges
|
||||
editor.set_block(WATER, x, ground_level, z, Some(&[FARMLAND]), None);
|
||||
editor.set_block(
|
||||
AIR,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
Some(&[GRASS, WHEAT, CARROTS, POTATOES]),
|
||||
None,
|
||||
);
|
||||
} else {
|
||||
// Set the block below as farmland
|
||||
editor.set_block(FARMLAND, x, ground_level, z, None, None);
|
||||
|
||||
// If a random condition is met, place a special object
|
||||
if rng.gen_range(0..76) == 0 {
|
||||
let special_choice: i32 = rng.gen_range(1..=10);
|
||||
if special_choice <= 2 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if special_choice <= 6 {
|
||||
editor.set_block(HAY_BALE, x, ground_level + 1, z, None, None);
|
||||
} else {
|
||||
editor.set_block(
|
||||
OAK_LEAVES,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Set crops only if the block below is farmland
|
||||
if editor.check_for_block(
|
||||
x,
|
||||
ground_level,
|
||||
// Add specific features for different landuse types
|
||||
match landuse_tag.as_str() {
|
||||
"cemetery" => {
|
||||
if (x % 3 == 0) && (z % 3 == 0) {
|
||||
let random_choice: i32 = rng.gen_range(0..100);
|
||||
if random_choice < 15 {
|
||||
// Place graves
|
||||
if editor.check_for_block(x, ground_level, z, Some(&[PODZOL]), None) {
|
||||
if rng.gen_bool(0.5) {
|
||||
editor.set_block(
|
||||
COBBLESTONE,
|
||||
x - 1,
|
||||
ground_level + 1,
|
||||
z,
|
||||
Some(&[FARMLAND]),
|
||||
None,
|
||||
) {
|
||||
let crop_choice =
|
||||
[WHEAT, CARROTS, POTATOES][rng.gen_range(0..3)];
|
||||
editor.set_block(
|
||||
crop_choice,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x - 1,
|
||||
ground_level + 2,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x + 1,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
} else {
|
||||
editor.set_block(
|
||||
COBBLESTONE,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z - 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 2,
|
||||
z - 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z + 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"construction" => {
|
||||
let random_choice: i32 = rng.gen_range(0..1501);
|
||||
if random_choice < 6 {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 1, z, None, None);
|
||||
if random_choice < 2 {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 3, z, None, None);
|
||||
} else if random_choice < 4 {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 3, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 1, z + 1, None, None);
|
||||
} else {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 3, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x - 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(
|
||||
SCAFFOLDING,
|
||||
x + 1,
|
||||
ground_level + 1,
|
||||
z - 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
} else if random_choice < 30 {
|
||||
let construction_items: [Block; 11] = [
|
||||
OAK_LOG,
|
||||
COBBLESTONE,
|
||||
GRAVEL,
|
||||
GLOWSTONE,
|
||||
STONE,
|
||||
COBBLESTONE_WALL,
|
||||
BLACK_CONCRETE,
|
||||
SAND,
|
||||
OAK_PLANKS,
|
||||
DIRT,
|
||||
BRICK,
|
||||
];
|
||||
editor.set_block(
|
||||
construction_items[rng.gen_range(0..construction_items.len())],
|
||||
if editor.check_for_block(x, ground_level, z, Some(&[PODZOL]), None) {
|
||||
editor.set_block(RED_FLOWER, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
} else if random_choice < 33 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if random_choice < 35 {
|
||||
if random_choice < 30 {
|
||||
editor.set_block(DIRT, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(DIRT, x + 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 1, z + 1, None, None);
|
||||
} else {
|
||||
editor.set_block(DIRT, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(DIRT, x - 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 1, z - 1, None, None);
|
||||
}
|
||||
} else if random_choice < 150 {
|
||||
editor.set_block(AIR, x, ground_level, z, None, Some(&[SPONGE]));
|
||||
}
|
||||
}
|
||||
"grass" => {
|
||||
if rng.gen_range(1..=7) != 1
|
||||
&& !editor.check_for_block(x, ground_level, z, None, Some(&[WATER]))
|
||||
{
|
||||
}
|
||||
"forest" => {
|
||||
if !editor.check_for_block(x, ground_level, z, None, Some(&[WATER])) {
|
||||
let random_choice: i32 = rng.gen_range(0..21);
|
||||
if random_choice == 20 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if random_choice == 2 {
|
||||
let flower_block: Block = match rng.gen_range(1..=4) {
|
||||
1 => RED_FLOWER,
|
||||
2 => BLUE_FLOWER,
|
||||
3 => YELLOW_FLOWER,
|
||||
_ => WHITE_FLOWER,
|
||||
};
|
||||
editor.set_block(flower_block, x, ground_level + 1, z, None, None);
|
||||
} else if random_choice <= 1 {
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"meadow" => {
|
||||
if !editor.check_for_block(x, ground_level, z, None, Some(&[WATER])) {
|
||||
let random_choice: i32 = rng.gen_range(0..1001);
|
||||
if random_choice < 5 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if random_choice < 800 {
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
"farmland" => {
|
||||
// Check if the current block is not water or another undesired block
|
||||
if !editor.check_for_block(x, ground_level, z, None, Some(&[WATER])) {
|
||||
if x % 15 == 0 || z % 15 == 0 {
|
||||
// Place water on the edges
|
||||
editor.set_block(WATER, x, ground_level, z, Some(&[FARMLAND]), None);
|
||||
editor.set_block(
|
||||
AIR,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
Some(&[GRASS, WHEAT, CARROTS, POTATOES]),
|
||||
None,
|
||||
);
|
||||
} else {
|
||||
// Set the block below as farmland
|
||||
editor.set_block(FARMLAND, x, ground_level, z, None, None);
|
||||
|
||||
// If a random condition is met, place a special object
|
||||
if rng.gen_range(0..76) == 0 {
|
||||
let special_choice: i32 = rng.gen_range(1..=10);
|
||||
if special_choice <= 2 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if special_choice <= 6 {
|
||||
editor.set_block(
|
||||
HAY_BALE,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
Some(&[SPONGE]),
|
||||
);
|
||||
} else {
|
||||
editor.set_block(
|
||||
OAK_LEAVES,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
Some(&[SPONGE]),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Set crops only if the block below is farmland
|
||||
if editor.check_for_block(x, ground_level, z, Some(&[FARMLAND]), None) {
|
||||
let crop_choice = [WHEAT, CARROTS, POTATOES][rng.gen_range(0..3)];
|
||||
editor.set_block(crop_choice, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
"construction" => {
|
||||
let random_choice: i32 = rng.gen_range(0..1501);
|
||||
if random_choice < 6 {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 1, z, None, None);
|
||||
if random_choice < 2 {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 3, z, None, None);
|
||||
} else if random_choice < 4 {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 3, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 1, z + 1, None, None);
|
||||
} else {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 3, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x - 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x + 1, ground_level + 1, z - 1, None, None);
|
||||
}
|
||||
} else if random_choice < 30 {
|
||||
let construction_items: [Block; 11] = [
|
||||
OAK_LOG,
|
||||
COBBLESTONE,
|
||||
GRAVEL,
|
||||
GLOWSTONE,
|
||||
STONE,
|
||||
COBBLESTONE_WALL,
|
||||
BLACK_CONCRETE,
|
||||
SAND,
|
||||
OAK_PLANKS,
|
||||
DIRT,
|
||||
BRICK,
|
||||
];
|
||||
editor.set_block(
|
||||
construction_items[rng.gen_range(0..construction_items.len())],
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
} else if random_choice < 35 {
|
||||
if random_choice < 30 {
|
||||
editor.set_block(DIRT, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(DIRT, x + 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 1, z + 1, None, None);
|
||||
} else {
|
||||
editor.set_block(DIRT, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(DIRT, x - 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 1, z - 1, None, None);
|
||||
}
|
||||
} else if random_choice < 150 {
|
||||
editor.set_block(AIR, x, ground_level, z, None, Some(&[SPONGE]));
|
||||
}
|
||||
}
|
||||
"grass" => {
|
||||
if rng.gen_range(1..=7) != 1
|
||||
&& editor.check_for_block(
|
||||
x,
|
||||
ground_level,
|
||||
z,
|
||||
Some(&[GRASS_BLOCK, SNOW_BLOCK]),
|
||||
None,
|
||||
)
|
||||
{
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"meadow" => {
|
||||
if editor.check_for_block(
|
||||
x,
|
||||
ground_level,
|
||||
z,
|
||||
Some(&[GRASS_BLOCK, SNOW_BLOCK]),
|
||||
None,
|
||||
) {
|
||||
let random_choice: i32 = rng.gen_range(0..1001);
|
||||
if random_choice < 5 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if random_choice < 800 {
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::element_processing::tree::create_tree;
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::osm_parser::ProcessedWay;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::{ProcessedMemberRole, ProcessedRelation, ProcessedWay};
|
||||
use crate::world_editor::WorldEditor;
|
||||
use rand::Rng;
|
||||
|
||||
pub fn generate_leisure(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedWay,
|
||||
ground_level: i32,
|
||||
ground: &Ground,
|
||||
args: &Args,
|
||||
) {
|
||||
if let Some(leisure_type) = element.tags.get("leisure") {
|
||||
@@ -61,12 +63,12 @@ pub fn generate_leisure(
|
||||
if let Some(prev) = previous_node {
|
||||
// Draw a line between the current and previous node
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level, prev.1, node.x, ground_level, node.z);
|
||||
bresenham_line(prev.0, 0, prev.1, node.x, 0, node.z);
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
editor.set_block(
|
||||
block_type,
|
||||
bx,
|
||||
ground_level,
|
||||
ground.level(XZPoint::new(bx, bz)),
|
||||
bz,
|
||||
Some(&[
|
||||
GRASS_BLOCK,
|
||||
@@ -99,6 +101,7 @@ pub fn generate_leisure(
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
for (x, z) in filled_area {
|
||||
let ground_level = ground.level(XZPoint::new(x, z));
|
||||
editor.set_block(block_type, x, ground_level, z, Some(&[GRASS_BLOCK]), None);
|
||||
|
||||
// Add decorative elements for parks and gardens
|
||||
@@ -192,3 +195,37 @@ pub fn generate_leisure(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_leisure_from_relation(
|
||||
editor: &mut WorldEditor,
|
||||
rel: &ProcessedRelation,
|
||||
ground: &Ground,
|
||||
args: &Args,
|
||||
) {
|
||||
if rel.tags.get("leisure") == Some(&"park".to_string()) {
|
||||
// First generate individual ways with their original tags
|
||||
for member in &rel.members {
|
||||
if member.role == ProcessedMemberRole::Outer {
|
||||
generate_leisure(editor, &member.way, ground, args);
|
||||
}
|
||||
}
|
||||
|
||||
// Then combine all outer ways into one
|
||||
let mut combined_nodes = Vec::new();
|
||||
for member in &rel.members {
|
||||
if member.role == ProcessedMemberRole::Outer {
|
||||
combined_nodes.extend(member.way.nodes.clone());
|
||||
}
|
||||
}
|
||||
|
||||
// Create combined way with relation tags
|
||||
let combined_way = ProcessedWay {
|
||||
id: rel.id,
|
||||
nodes: combined_nodes,
|
||||
tags: rel.tags.clone(),
|
||||
};
|
||||
|
||||
// Generate leisure area from combined way
|
||||
generate_leisure(editor, &combined_way, ground, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::element_processing::tree::create_tree;
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedElement;
|
||||
use crate::world_editor::WorldEditor;
|
||||
use rand::Rng;
|
||||
@@ -10,7 +12,7 @@ use rand::Rng;
|
||||
pub fn generate_natural(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedElement,
|
||||
ground_level: i32,
|
||||
ground: &Ground,
|
||||
args: &Args,
|
||||
) {
|
||||
if let Some(natural_type) = element.tags().get("natural") {
|
||||
@@ -23,7 +25,7 @@ pub fn generate_natural(
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
ground.level(node.xz()) + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
@@ -73,9 +75,16 @@ pub fn generate_natural(
|
||||
if let Some(prev) = previous_node {
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level, prev.1, x, ground_level, z);
|
||||
bresenham_line(prev.0, 0, prev.1, x, 0, z);
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
editor.set_block(block_type, bx, ground_level, bz, None, None);
|
||||
editor.set_block(
|
||||
block_type,
|
||||
bx,
|
||||
ground.level(XZPoint::new(bx, bz)),
|
||||
bz,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
current_natural.push((x, z));
|
||||
@@ -98,24 +107,19 @@ pub fn generate_natural(
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
|
||||
for (x, z) in filled_area {
|
||||
editor.set_block(block_type, x, ground_level, z, None, None);
|
||||
let y = ground.level(XZPoint::new(x, z));
|
||||
|
||||
editor.set_block(block_type, x, y, z, None, None);
|
||||
|
||||
// Generate elements for "wood" and "tree_row"
|
||||
if natural_type == "wood" || natural_type == "tree_row" {
|
||||
if editor.check_for_block(x, ground_level, z, None, Some(&[WATER])) {
|
||||
if editor.check_for_block(x, y, z, None, Some(&[WATER])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let random_choice: i32 = rng.gen_range(0..26);
|
||||
if random_choice == 25 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
create_tree(editor, x, y + 1, z, rng.gen_range(1..=3), args.winter);
|
||||
} else if random_choice == 2 {
|
||||
let flower_block = match rng.gen_range(1..=4) {
|
||||
1 => RED_FLOWER,
|
||||
@@ -123,9 +127,9 @@ pub fn generate_natural(
|
||||
3 => YELLOW_FLOWER,
|
||||
_ => WHITE_FLOWER,
|
||||
};
|
||||
editor.set_block(flower_block, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(flower_block, x, y + 1, z, None, None);
|
||||
} else if random_choice <= 1 {
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(GRASS, x, y + 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedWay;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_railways(editor: &mut WorldEditor, element: &ProcessedWay, ground_level: i32) {
|
||||
pub fn generate_railways(editor: &mut WorldEditor, element: &ProcessedWay, ground: &Ground) {
|
||||
if let Some(railway_type) = element.tags.get("railway") {
|
||||
if ["proposed", "abandoned", "subway", "construction"].contains(&railway_type.as_str()) {
|
||||
if [
|
||||
"proposed",
|
||||
"abandoned",
|
||||
"subway",
|
||||
"construction",
|
||||
"razed",
|
||||
"turntable",
|
||||
]
|
||||
.contains(&railway_type.as_str())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,22 +33,36 @@ pub fn generate_railways(editor: &mut WorldEditor, element: &ProcessedWay, groun
|
||||
}
|
||||
|
||||
for i in 1..element.nodes.len() {
|
||||
let prev: &crate::osm_parser::ProcessedNode = &element.nodes[i - 1];
|
||||
let x1: i32 = prev.x;
|
||||
let z1: i32 = prev.z;
|
||||
let prev_node = element.nodes[i - 1].xz();
|
||||
let cur_node = element.nodes[i].xz();
|
||||
|
||||
let cur: &crate::osm_parser::ProcessedNode = &element.nodes[i];
|
||||
let x2: i32 = cur.x;
|
||||
let z2: i32 = cur.z;
|
||||
let points = bresenham_line(prev_node.x, 0, prev_node.z, cur_node.x, 0, cur_node.z);
|
||||
let smoothed_points = smooth_diagonal_rails(&points);
|
||||
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(x1, ground_level, z1, x2, ground_level, z2);
|
||||
for j in 0..smoothed_points.len() {
|
||||
let (bx, _, bz) = smoothed_points[j];
|
||||
let ground_level = ground.level(XZPoint::new(bx, bz));
|
||||
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
// TODO: Set direction of rail
|
||||
editor.set_block(IRON_BLOCK, bx, ground_level, bz, None, None);
|
||||
editor.set_block(RAIL, bx, ground_level + 1, bz, None, None);
|
||||
|
||||
let prev = if j > 0 {
|
||||
Some(smoothed_points[j - 1])
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let next = if j < smoothed_points.len() - 1 {
|
||||
Some(smoothed_points[j + 1])
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let rail_block = determine_rail_direction(
|
||||
(bx, bz),
|
||||
prev.map(|(x, _, z)| (x, z)),
|
||||
next.map(|(x, _, z)| (x, z)),
|
||||
);
|
||||
|
||||
editor.set_block(rail_block, bx, ground_level + 1, bz, None, None);
|
||||
|
||||
if bx % 4 == 0 {
|
||||
editor.set_block(OAK_LOG, bx, ground_level, bz, None, None);
|
||||
@@ -46,3 +71,109 @@ pub fn generate_railways(editor: &mut WorldEditor, element: &ProcessedWay, groun
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn smooth_diagonal_rails(points: &[(i32, i32, i32)]) -> Vec<(i32, i32, i32)> {
|
||||
let mut smoothed = Vec::new();
|
||||
|
||||
for i in 0..points.len() {
|
||||
let current = points[i];
|
||||
smoothed.push(current);
|
||||
|
||||
if i + 1 >= points.len() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let next = points[i + 1];
|
||||
let (x1, y1, z1) = current;
|
||||
let (x2, _, z2) = next;
|
||||
|
||||
// If points are diagonally adjacent
|
||||
if (x2 - x1).abs() == 1 && (z2 - z1).abs() == 1 {
|
||||
// Look ahead to determine best intermediate point
|
||||
let look_ahead = if i + 2 < points.len() {
|
||||
Some(points[i + 2])
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Look behind
|
||||
let look_behind = if i > 0 { Some(points[i - 1]) } else { None };
|
||||
|
||||
// Choose intermediate point based on the overall curve direction
|
||||
let intermediate = if let Some((prev_x, _, _prev_z)) = look_behind {
|
||||
if prev_x == x1 {
|
||||
// Coming from vertical, keep x constant
|
||||
(x1, y1, z2)
|
||||
} else {
|
||||
// Coming from horizontal, keep z constant
|
||||
(x2, y1, z1)
|
||||
}
|
||||
} else if let Some((next_x, _, _next_z)) = look_ahead {
|
||||
if next_x == x2 {
|
||||
// Going to vertical, keep x constant
|
||||
(x2, y1, z1)
|
||||
} else {
|
||||
// Going to horizontal, keep z constant
|
||||
(x1, y1, z2)
|
||||
}
|
||||
} else {
|
||||
// Default to horizontal first if no context
|
||||
(x2, y1, z1)
|
||||
};
|
||||
|
||||
smoothed.push(intermediate);
|
||||
}
|
||||
}
|
||||
|
||||
smoothed
|
||||
}
|
||||
|
||||
fn determine_rail_direction(
|
||||
current: (i32, i32),
|
||||
prev: Option<(i32, i32)>,
|
||||
next: Option<(i32, i32)>,
|
||||
) -> Block {
|
||||
let (x, z) = current;
|
||||
|
||||
match (prev, next) {
|
||||
(Some((px, pz)), Some((nx, nz))) => {
|
||||
if px == nx {
|
||||
RAIL_NORTH_SOUTH
|
||||
} else if pz == nz {
|
||||
RAIL_EAST_WEST
|
||||
} else {
|
||||
// Calculate relative movements
|
||||
let from_prev = (px - x, pz - z);
|
||||
let to_next = (nx - x, nz - z);
|
||||
|
||||
match (from_prev, to_next) {
|
||||
// East to North or North to East
|
||||
((-1, 0), (0, -1)) | ((0, -1), (-1, 0)) => RAIL_NORTH_WEST,
|
||||
// West to North or North to West
|
||||
((1, 0), (0, -1)) | ((0, -1), (1, 0)) => RAIL_NORTH_EAST,
|
||||
// East to South or South to East
|
||||
((-1, 0), (0, 1)) | ((0, 1), (-1, 0)) => RAIL_SOUTH_WEST,
|
||||
// West to South or South to West
|
||||
((1, 0), (0, 1)) | ((0, 1), (1, 0)) => RAIL_SOUTH_EAST,
|
||||
_ => {
|
||||
if (px - x).abs() > (pz - z).abs() {
|
||||
RAIL_EAST_WEST
|
||||
} else {
|
||||
RAIL_NORTH_SOUTH
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(Some((px, pz)), None) | (None, Some((px, pz))) => {
|
||||
if px == x {
|
||||
RAIL_NORTH_SOUTH
|
||||
} else if pz == z {
|
||||
RAIL_EAST_WEST
|
||||
} else {
|
||||
RAIL_NORTH_SOUTH
|
||||
}
|
||||
}
|
||||
(None, None) => RAIL_NORTH_SOUTH,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use crate::block_definitions::*;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedNode;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_tourisms(editor: &mut WorldEditor, element: &ProcessedNode, ground_level: i32) {
|
||||
pub fn generate_tourisms(editor: &mut WorldEditor, element: &ProcessedNode, ground: &Ground) {
|
||||
// Skip if 'layer' or 'level' is negative in the tags
|
||||
if let Some(layer) = element.tags.get("layer") {
|
||||
if layer.parse::<i32>().unwrap_or(0) < 0 {
|
||||
@@ -20,10 +22,15 @@ pub fn generate_tourisms(editor: &mut WorldEditor, element: &ProcessedNode, grou
|
||||
let x: i32 = element.x;
|
||||
let z: i32 = element.z;
|
||||
|
||||
// Calculate the dynamic ground level
|
||||
let ground_level = ground.level(XZPoint::new(x, z));
|
||||
|
||||
if tourism_type == "information" {
|
||||
if let Some("board") = element.tags.get("information").map(|x: &String| x.as_str()) {
|
||||
// TODO draw a sign
|
||||
editor.set_block(OAK_PLANKS, x, ground_level + 1, z, None, None);
|
||||
// Draw an information board
|
||||
// TODO draw a sign with text
|
||||
editor.set_block(COBBLESTONE_WALL, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(OAK_PLANKS, x, ground_level + 2, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
use geo::{Contains, Intersects, LineString, Point, Polygon, Rect};
|
||||
use std::time::Instant;
|
||||
|
||||
use crate::{
|
||||
block_definitions::WATER,
|
||||
cartesian::XZPoint,
|
||||
ground::Ground,
|
||||
osm_parser::{ProcessedMemberRole, ProcessedNode, ProcessedRelation},
|
||||
world_editor::WorldEditor,
|
||||
};
|
||||
@@ -9,13 +12,15 @@ use crate::{
|
||||
pub fn generate_water_areas(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedRelation,
|
||||
ground_level: i32,
|
||||
ground: &Ground,
|
||||
) {
|
||||
let start_time = Instant::now();
|
||||
|
||||
if !element.tags.contains_key("water") {
|
||||
return;
|
||||
}
|
||||
|
||||
// don't handle water below layer 0
|
||||
// Don't handle water below layer 0
|
||||
if let Some(layer) = element.tags.get("layer") {
|
||||
if layer.parse::<i32>().map(|x| x < 0).unwrap_or(false) {
|
||||
return;
|
||||
@@ -43,24 +48,16 @@ pub fn generate_water_areas(
|
||||
}
|
||||
|
||||
let (max_x, max_z) = editor.get_max_coords();
|
||||
let outers: Vec<Vec<(f64, f64)>> = outers
|
||||
let outers: Vec<Vec<XZPoint>> = outers
|
||||
.iter()
|
||||
.map(|x: &Vec<ProcessedNode>| {
|
||||
x.iter()
|
||||
.map(|y: &ProcessedNode| (y.x as f64, y.z as f64))
|
||||
.collect()
|
||||
})
|
||||
.map(|x| x.iter().map(|y| y.xz()).collect::<Vec<_>>())
|
||||
.collect();
|
||||
let inners: Vec<Vec<(f64, f64)>> = inners
|
||||
let inners: Vec<Vec<XZPoint>> = inners
|
||||
.iter()
|
||||
.map(|x: &Vec<ProcessedNode>| {
|
||||
x.iter()
|
||||
.map(|y: &ProcessedNode| (y.x as f64, y.z as f64))
|
||||
.collect()
|
||||
})
|
||||
.map(|x| x.iter().map(|y| y.xz()).collect::<Vec<_>>())
|
||||
.collect();
|
||||
|
||||
inverse_floodfill(max_x, max_z, outers, inners, editor, ground_level);
|
||||
inverse_floodfill(max_x, max_z, outers, inners, editor, ground, start_time);
|
||||
}
|
||||
|
||||
// Merges ways that share nodes into full loops
|
||||
@@ -153,42 +150,68 @@ fn verify_loopy_loops(loops: &[Vec<ProcessedNode>]) -> bool {
|
||||
fn inverse_floodfill(
|
||||
max_x: i32,
|
||||
max_z: i32,
|
||||
outers: Vec<Vec<(f64, f64)>>,
|
||||
inners: Vec<Vec<(f64, f64)>>,
|
||||
outers: Vec<Vec<XZPoint>>,
|
||||
inners: Vec<Vec<XZPoint>>,
|
||||
editor: &mut WorldEditor,
|
||||
ground_level: i32,
|
||||
ground: &Ground,
|
||||
start_time: Instant,
|
||||
) {
|
||||
let min_x: i32 = 0;
|
||||
let min_z: i32 = 0;
|
||||
|
||||
let inners: Vec<_> = inners
|
||||
.into_iter()
|
||||
.map(|x: Vec<(f64, f64)>| Polygon::new(LineString::from(x), vec![]))
|
||||
.map(|x| {
|
||||
Polygon::new(
|
||||
LineString::from(
|
||||
x.iter()
|
||||
.map(|pt| (pt.x as f64, pt.z as f64))
|
||||
.collect::<Vec<_>>(),
|
||||
),
|
||||
vec![],
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let outers: Vec<_> = outers
|
||||
.into_iter()
|
||||
.map(|x: Vec<(f64, f64)>| Polygon::new(LineString::from(x), vec![]))
|
||||
.map(|x| {
|
||||
Polygon::new(
|
||||
LineString::from(
|
||||
x.iter()
|
||||
.map(|pt| (pt.x as f64, pt.z as f64))
|
||||
.collect::<Vec<_>>(),
|
||||
),
|
||||
vec![],
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
inverse_floodfill_recursive(
|
||||
(min_x, min_z),
|
||||
(max_x, max_z),
|
||||
ground_level,
|
||||
&outers,
|
||||
&inners,
|
||||
editor,
|
||||
ground,
|
||||
start_time,
|
||||
);
|
||||
}
|
||||
|
||||
fn inverse_floodfill_recursive(
|
||||
min: (i32, i32),
|
||||
max: (i32, i32),
|
||||
ground_level: i32,
|
||||
outers: &[Polygon],
|
||||
inners: &[Polygon],
|
||||
editor: &mut WorldEditor,
|
||||
ground: &Ground,
|
||||
start_time: Instant,
|
||||
) {
|
||||
// Check if we've exceeded 25 seconds
|
||||
if start_time.elapsed().as_secs() > 25 {
|
||||
println!("Water area generation exceeded 25 seconds, continuing anyway");
|
||||
}
|
||||
|
||||
const ITERATIVE_THRES: i32 = 10_000;
|
||||
|
||||
if min.0 > max.0 || min.1 > max.1 {
|
||||
@@ -196,8 +219,8 @@ fn inverse_floodfill_recursive(
|
||||
}
|
||||
|
||||
if (max.0 - min.0) * (max.1 - min.1) < ITERATIVE_THRES {
|
||||
let ground_level = ground.level(XZPoint::new(min.0, min.1));
|
||||
inverse_floodfill_iterative(min, max, ground_level, outers, inners, editor);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -219,40 +242,31 @@ fn inverse_floodfill_recursive(
|
||||
if outers.iter().any(|outer: &Polygon| outer.contains(&rect))
|
||||
&& !inners.iter().any(|inner: &Polygon| inner.intersects(&rect))
|
||||
{
|
||||
// every block in rect is water
|
||||
// so we can safely just set the whole thing to water
|
||||
|
||||
let ground_level = ground.level(XZPoint::new(min_x, min_z));
|
||||
rect_fill(min_x, max_x, min_z, max_z, ground_level, editor);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// When we recurse, we only really need the polygons we potentially intersect with
|
||||
// This saves on processing time
|
||||
let outers_intersects: Vec<_> = outers
|
||||
.iter()
|
||||
.filter(|poly: &&Polygon| poly.intersects(&rect))
|
||||
.filter(|poly| poly.intersects(&rect))
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
// Moving this inside the below `if` statement makes it slower for some reason.
|
||||
// I assume it changes how the compiler is able to optimize it
|
||||
let inners_intersects: Vec<_> = inners
|
||||
.iter()
|
||||
.filter(|poly: &&Polygon| poly.intersects(&rect))
|
||||
.filter(|poly| poly.intersects(&rect))
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
if !outers_intersects.is_empty() {
|
||||
// recurse
|
||||
|
||||
inverse_floodfill_recursive(
|
||||
(min_x, min_z),
|
||||
(max_x, max_z),
|
||||
ground_level,
|
||||
&outers_intersects,
|
||||
&inners_intersects,
|
||||
editor,
|
||||
ground,
|
||||
start_time,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::cartesian::XZPoint;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedWay;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_waterways(editor: &mut WorldEditor, element: &ProcessedWay, ground_level: i32) {
|
||||
pub fn generate_waterways(editor: &mut WorldEditor, element: &ProcessedWay, ground: &Ground) {
|
||||
if let Some(_waterway_type) = element.tags.get("waterway") {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let mut previous_node: Option<XZPoint> = None;
|
||||
let mut waterway_width: i32 = 4; // Default waterway width
|
||||
|
||||
// Check for custom width in tags
|
||||
@@ -20,6 +22,8 @@ pub fn generate_waterways(editor: &mut WorldEditor, element: &ProcessedWay, grou
|
||||
|
||||
// Process nodes to create waterways
|
||||
for node in &element.nodes {
|
||||
let current_node = node.xz();
|
||||
|
||||
if let Some(prev) = previous_node {
|
||||
// Skip layers below the ground level
|
||||
if !matches!(
|
||||
@@ -28,11 +32,16 @@ pub fn generate_waterways(editor: &mut WorldEditor, element: &ProcessedWay, grou
|
||||
) {
|
||||
// Draw a line between the current and previous node
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level, prev.1, node.x, ground_level, node.z);
|
||||
bresenham_line(prev.x, 0, prev.z, current_node.x, 0, current_node.z);
|
||||
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
let ground_level = ground.level(XZPoint::new(bx, bz));
|
||||
|
||||
for x in (bx - waterway_width / 2)..=(bx + waterway_width / 2) {
|
||||
for z in (bz - waterway_width / 2)..=(bz + waterway_width / 2) {
|
||||
editor.set_block(WATER, x, ground_level, z, None, None); // Set water block
|
||||
// Set water block at the ground level
|
||||
editor.set_block(WATER, x, ground_level, z, None, None);
|
||||
// Clear vegetation above the water
|
||||
editor.set_block(
|
||||
AIR,
|
||||
x,
|
||||
@@ -46,7 +55,7 @@ pub fn generate_waterways(editor: &mut WorldEditor, element: &ProcessedWay, grou
|
||||
}
|
||||
}
|
||||
}
|
||||
previous_node = Some((node.x, node.z));
|
||||
previous_node = Some(current_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
424
src/ground.rs
Normal file
424
src/ground.rs
Normal file
@@ -0,0 +1,424 @@
|
||||
use crate::cartesian::XZPoint;
|
||||
use image::{Rgb, RgbImage};
|
||||
|
||||
/// Minimum Y coordinate in Minecraft (bedrock level)
|
||||
const MIN_Y: i32 = -62;
|
||||
/// Maximum Y coordinate in Minecraft (build height limit)
|
||||
const MAX_Y: i32 = 256;
|
||||
/// Scale factor for converting real elevation to Minecraft heights
|
||||
const BASE_HEIGHT_SCALE: f64 = 0.6;
|
||||
/// Mapbox API access token for terrain data
|
||||
const MAPBOX_PUBKEY: &str =
|
||||
"pk.eyJ1IjoibG91aXMtZSIsImEiOiJjbWF0cWlycjEwYWNvMmtxeHFwdDQ5NnJoIn0.6A0AKg0iucvoGhYuCkeOjA";
|
||||
/// Minimum zoom level for terrain tiles
|
||||
const MIN_ZOOM: u8 = 10;
|
||||
/// Maximum zoom level for terrain tiles
|
||||
const MAX_ZOOM: u8 = 15;
|
||||
|
||||
/// Represents terrain data and elevation settings
|
||||
pub struct Ground {
|
||||
pub elevation_enabled: bool,
|
||||
ground_level: i32,
|
||||
elevation_data: Option<ElevationData>,
|
||||
}
|
||||
|
||||
/// Holds processed elevation data and metadata
|
||||
#[derive(Clone)]
|
||||
struct ElevationData {
|
||||
/// Height values in Minecraft Y coordinates
|
||||
heights: Vec<Vec<i32>>,
|
||||
/// Width of the elevation grid
|
||||
width: usize,
|
||||
/// Height of the elevation grid
|
||||
height: usize,
|
||||
}
|
||||
|
||||
impl Ground {
|
||||
pub fn new(args: &crate::args::Args) -> Self {
|
||||
let mut elevation_enabled: bool = args.terrain;
|
||||
let elevation_data: Option<ElevationData> = if elevation_enabled && args.bbox.is_some() {
|
||||
match Self::fetch_elevation_data(args.bbox.as_deref().unwrap(), args.scale) {
|
||||
Ok(data) => {
|
||||
if args.debug {
|
||||
Self::save_debug_image(&data.heights, "elevation_debug");
|
||||
}
|
||||
Some(data)
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Warning: Failed to fetch elevation data: {}", e);
|
||||
elevation_enabled = false;
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
Self {
|
||||
elevation_enabled,
|
||||
ground_level: args.ground_level,
|
||||
elevation_data,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the ground level at the given coordinates
|
||||
#[inline(always)]
|
||||
pub fn level(&self, coord: XZPoint) -> i32 {
|
||||
if !self.elevation_enabled || self.elevation_data.is_none() {
|
||||
return self.ground_level;
|
||||
}
|
||||
|
||||
let data: &ElevationData = self.elevation_data.as_ref().unwrap();
|
||||
let (x_ratio, z_ratio) = self.get_data_coordinates(coord, data);
|
||||
self.interpolate_height(x_ratio, z_ratio, data)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn min_level<I: Iterator<Item = XZPoint>>(&self, coords: I) -> Option<i32> {
|
||||
if !self.elevation_enabled {
|
||||
return Some(self.ground_level);
|
||||
}
|
||||
coords.map(|c: XZPoint| self.level(c)).min()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn max_level<I: Iterator<Item = XZPoint>>(&self, coords: I) -> Option<i32> {
|
||||
if !self.elevation_enabled {
|
||||
return Some(self.ground_level);
|
||||
}
|
||||
coords.map(|c: XZPoint| self.level(c)).max()
|
||||
}
|
||||
|
||||
/// Converts game coordinates to elevation data coordinates
|
||||
#[inline(always)]
|
||||
fn get_data_coordinates(&self, coord: XZPoint, data: &ElevationData) -> (f64, f64) {
|
||||
let x_ratio: f64 = coord.x as f64 / data.width as f64;
|
||||
let z_ratio: f64 = coord.z as f64 / data.height as f64;
|
||||
(x_ratio.clamp(0.0, 1.0), z_ratio.clamp(0.0, 1.0))
|
||||
}
|
||||
|
||||
/// Interpolates height value from the elevation grid
|
||||
#[inline(always)]
|
||||
fn interpolate_height(&self, x_ratio: f64, z_ratio: f64, data: &ElevationData) -> i32 {
|
||||
let x: usize = ((x_ratio * (data.width - 1) as f64).round() as usize).min(data.width - 1);
|
||||
let z: usize = ((z_ratio * (data.height - 1) as f64).round() as usize).min(data.height - 1);
|
||||
data.heights[z][x]
|
||||
}
|
||||
|
||||
/// Calculates appropriate zoom level for the given bounding box
|
||||
fn calculate_zoom_level(bbox: (f64, f64, f64, f64)) -> u8 {
|
||||
let lat_diff: f64 = (bbox.2 - bbox.0).abs();
|
||||
let lng_diff: f64 = (bbox.3 - bbox.1).abs();
|
||||
let max_diff: f64 = lat_diff.max(lng_diff);
|
||||
let zoom: u8 = (-max_diff.log2() + 20.0) as u8;
|
||||
zoom.clamp(MIN_ZOOM, MAX_ZOOM)
|
||||
}
|
||||
|
||||
fn lat_lng_to_tile(lat: f64, lng: f64, zoom: u8) -> (u32, u32) {
|
||||
let lat_rad: f64 = lat.to_radians();
|
||||
let n: f64 = 2.0_f64.powi(zoom as i32);
|
||||
let x: u32 = ((lng + 180.0) / 360.0 * n).floor() as u32;
|
||||
let y: u32 =
|
||||
((1.0 - lat_rad.tan().asinh() / std::f64::consts::PI) / 2.0 * n).floor() as u32;
|
||||
(x, y)
|
||||
}
|
||||
|
||||
fn fetch_elevation_data(
|
||||
bbox_str: &str,
|
||||
scale: f64,
|
||||
) -> Result<ElevationData, Box<dyn std::error::Error>> {
|
||||
let coords: Vec<f64> = bbox_str
|
||||
.split_whitespace()
|
||||
.map(|s: &str| s.parse::<f64>())
|
||||
.collect::<Result<Vec<f64>, _>>()?;
|
||||
|
||||
let (min_lat, min_lng, max_lat, max_lng) = (coords[0], coords[1], coords[2], coords[3]);
|
||||
|
||||
// Use OSM parser's scale calculation and apply user scale factor
|
||||
let (scale_factor_z, scale_factor_x) =
|
||||
crate::osm_parser::geo_distance(min_lat, max_lat, min_lng, max_lng);
|
||||
let scale_factor_x: f64 = scale_factor_x * scale;
|
||||
let scale_factor_z: f64 = scale_factor_z * scale;
|
||||
|
||||
// Calculate zoom and tiles
|
||||
let zoom: u8 = Self::calculate_zoom_level((min_lat, min_lng, max_lat, max_lng));
|
||||
let tiles: Vec<(u32, u32)> =
|
||||
Self::get_tile_coordinates(min_lat, min_lng, max_lat, max_lng, zoom);
|
||||
|
||||
// Calculate tile boundaries
|
||||
let x_min: &u32 = tiles.iter().map(|(x, _)| x).min().unwrap();
|
||||
let x_max: &u32 = tiles.iter().map(|(x, _)| x).max().unwrap();
|
||||
let y_min: &u32 = tiles.iter().map(|(_, y)| y).min().unwrap();
|
||||
let y_max: &u32 = tiles.iter().map(|(_, y)| y).max().unwrap();
|
||||
|
||||
// Match grid dimensions with Minecraft world size
|
||||
let grid_width: usize = scale_factor_x.round() as usize;
|
||||
let grid_height: usize = scale_factor_z.round() as usize;
|
||||
|
||||
// Calculate total tile dimensions
|
||||
let total_tile_width: u32 = (x_max - x_min + 1) * 256;
|
||||
let total_tile_height: u32 = (y_max - y_min + 1) * 256;
|
||||
|
||||
// Calculate scaling factors to match the desired grid dimensions
|
||||
let x_scale: f64 = grid_width as f64 / total_tile_width as f64;
|
||||
let y_scale: f64 = grid_height as f64 / total_tile_height as f64;
|
||||
|
||||
// Initialize height grid with proper dimensions
|
||||
let mut height_grid: Vec<Vec<f64>> = vec![vec![f64::NAN; grid_width]; grid_height];
|
||||
|
||||
let client: reqwest::blocking::Client = reqwest::blocking::Client::new();
|
||||
let access_token: &str = MAPBOX_PUBKEY;
|
||||
|
||||
// Fetch and process each tile
|
||||
for (tile_x, tile_y) in &tiles {
|
||||
let url: String = format!(
|
||||
"https://api.mapbox.com/v4/mapbox.terrain-rgb/{}/{}/{}.pngraw?access_token={}",
|
||||
zoom, tile_x, tile_y, access_token
|
||||
);
|
||||
|
||||
let response: reqwest::blocking::Response = client.get(&url).send()?;
|
||||
let img: image::DynamicImage = image::load_from_memory(&response.bytes()?)?;
|
||||
let rgb_img: image::ImageBuffer<Rgb<u8>, Vec<u8>> = img.to_rgb8();
|
||||
|
||||
// Calculate position in the scaled grid
|
||||
let base_x: f64 = ((*tile_x - x_min) * 256) as f64;
|
||||
let base_y: f64 = ((*tile_y - y_min) * 256) as f64;
|
||||
|
||||
// Process tile data with scaling
|
||||
for (y, row) in rgb_img.rows().enumerate() {
|
||||
for (x, pixel) in row.enumerate() {
|
||||
let scaled_x: usize = ((base_x + x as f64) * x_scale) as usize;
|
||||
let scaled_y: usize = ((base_y + y as f64) * y_scale) as usize;
|
||||
|
||||
if scaled_y >= grid_height || scaled_x >= grid_width {
|
||||
continue;
|
||||
}
|
||||
|
||||
let height: f64 = -10000.0
|
||||
+ ((pixel[0] as f64 * 256.0 * 256.0
|
||||
+ pixel[1] as f64 * 256.0
|
||||
+ pixel[2] as f64)
|
||||
* 0.1);
|
||||
|
||||
height_grid[scaled_y][scaled_x] = height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fill in any NaN values by interpolating from nearest valid values
|
||||
Self::fill_nan_values(&mut height_grid);
|
||||
|
||||
// Continue with the existing blur and conversion to Minecraft heights...
|
||||
let blurred_heights: Vec<Vec<f64>> = Self::apply_gaussian_blur(&height_grid, 1.0);
|
||||
|
||||
let mut mc_heights: Vec<Vec<i32>> = Vec::with_capacity(blurred_heights.len());
|
||||
|
||||
// Find min/max in raw data
|
||||
let mut min_height: f64 = f64::MAX;
|
||||
let mut max_height: f64 = f64::MIN;
|
||||
for row in &blurred_heights {
|
||||
for &height in row {
|
||||
min_height = min_height.min(height);
|
||||
max_height = max_height.max(height);
|
||||
}
|
||||
}
|
||||
|
||||
let height_range: f64 = max_height - min_height;
|
||||
// Apply scale factor to height scaling
|
||||
let height_scale: f64 = BASE_HEIGHT_SCALE * scale.sqrt(); // sqrt to make height scaling less extreme
|
||||
let scaled_range: f64 = height_range * height_scale;
|
||||
|
||||
// Convert to scaled Minecraft Y coordinates
|
||||
for row in blurred_heights {
|
||||
let mc_row: Vec<i32> = row
|
||||
.iter()
|
||||
.map(|&h| {
|
||||
// Scale the height differences
|
||||
let relative_height: f64 = (h - min_height) / height_range;
|
||||
let scaled_height: f64 = relative_height * scaled_range;
|
||||
((MIN_Y as f64 + scaled_height).round() as i32).clamp(MIN_Y, MAX_Y)
|
||||
})
|
||||
.collect();
|
||||
mc_heights.push(mc_row);
|
||||
}
|
||||
|
||||
Ok(ElevationData {
|
||||
heights: mc_heights,
|
||||
width: grid_width,
|
||||
height: grid_height,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_tile_coordinates(
|
||||
min_lat: f64,
|
||||
min_lng: f64,
|
||||
max_lat: f64,
|
||||
max_lng: f64,
|
||||
zoom: u8,
|
||||
) -> Vec<(u32, u32)> {
|
||||
// Convert lat/lng to tile coordinates
|
||||
let (x1, y1) = Self::lat_lng_to_tile(min_lat, min_lng, zoom);
|
||||
let (x2, y2) = Self::lat_lng_to_tile(max_lat, max_lng, zoom);
|
||||
|
||||
let mut tiles: Vec<(u32, u32)> = Vec::new();
|
||||
for x in x1.min(x2)..=x1.max(x2) {
|
||||
for y in y1.min(y2)..=y1.max(y2) {
|
||||
tiles.push((x, y));
|
||||
}
|
||||
}
|
||||
tiles
|
||||
}
|
||||
|
||||
fn apply_gaussian_blur(heights: &[Vec<f64>], sigma: f64) -> Vec<Vec<f64>> {
|
||||
let kernel_size: usize = (sigma * 3.0).ceil() as usize * 2 + 1;
|
||||
let kernel: Vec<f64> = Self::create_gaussian_kernel(kernel_size, sigma);
|
||||
|
||||
// Apply blur
|
||||
let mut blurred: Vec<Vec<f64>> = heights.to_owned();
|
||||
|
||||
// Horizontal pass
|
||||
for row in blurred.iter_mut() {
|
||||
let mut temp: Vec<f64> = row.clone();
|
||||
for (i, val) in temp.iter_mut().enumerate() {
|
||||
let mut sum: f64 = 0.0;
|
||||
let mut weight_sum: f64 = 0.0;
|
||||
for (j, k) in kernel.iter().enumerate() {
|
||||
let idx: i32 = i as i32 + j as i32 - kernel_size as i32 / 2;
|
||||
if idx >= 0 && idx < row.len() as i32 {
|
||||
sum += row[idx as usize] * k;
|
||||
weight_sum += k;
|
||||
}
|
||||
}
|
||||
*val = sum / weight_sum;
|
||||
}
|
||||
*row = temp;
|
||||
}
|
||||
|
||||
// Vertical pass
|
||||
let height: usize = blurred.len();
|
||||
let width: usize = blurred[0].len();
|
||||
for x in 0..width {
|
||||
let temp: Vec<_> = blurred
|
||||
.iter()
|
||||
.take(height)
|
||||
.map(|row: &Vec<f64>| row[x])
|
||||
.collect();
|
||||
|
||||
for (y, row) in blurred.iter_mut().enumerate().take(height) {
|
||||
let mut sum: f64 = 0.0;
|
||||
let mut weight_sum: f64 = 0.0;
|
||||
for (j, k) in kernel.iter().enumerate() {
|
||||
let idx: i32 = y as i32 + j as i32 - kernel_size as i32 / 2;
|
||||
if idx >= 0 && idx < height as i32 {
|
||||
sum += temp[idx as usize] * k;
|
||||
weight_sum += k;
|
||||
}
|
||||
}
|
||||
row[x] = sum / weight_sum;
|
||||
}
|
||||
}
|
||||
|
||||
blurred
|
||||
}
|
||||
|
||||
fn create_gaussian_kernel(size: usize, sigma: f64) -> Vec<f64> {
|
||||
let mut kernel: Vec<f64> = vec![0.0; size];
|
||||
let center: f64 = size as f64 / 2.0;
|
||||
|
||||
for (i, value) in kernel.iter_mut().enumerate() {
|
||||
let x: f64 = i as f64 - center;
|
||||
*value = (-x * x / (2.0 * sigma * sigma)).exp();
|
||||
}
|
||||
|
||||
let sum: f64 = kernel.iter().sum();
|
||||
for k in kernel.iter_mut() {
|
||||
*k /= sum;
|
||||
}
|
||||
|
||||
kernel
|
||||
}
|
||||
|
||||
fn fill_nan_values(height_grid: &mut [Vec<f64>]) {
|
||||
let height: usize = height_grid.len();
|
||||
let width: usize = height_grid[0].len();
|
||||
|
||||
let mut changes_made: bool = true;
|
||||
while changes_made {
|
||||
changes_made = false;
|
||||
|
||||
for y in 0..height {
|
||||
for x in 0..width {
|
||||
if height_grid[y][x].is_nan() {
|
||||
let mut sum: f64 = 0.0;
|
||||
let mut count: i32 = 0;
|
||||
|
||||
// Check neighboring cells
|
||||
for dy in -1..=1 {
|
||||
for dx in -1..=1 {
|
||||
let ny: i32 = y as i32 + dy;
|
||||
let nx: i32 = x as i32 + dx;
|
||||
|
||||
if ny >= 0 && ny < height as i32 && nx >= 0 && nx < width as i32 {
|
||||
let val: f64 = height_grid[ny as usize][nx as usize];
|
||||
if !val.is_nan() {
|
||||
sum += val;
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if count > 0 {
|
||||
height_grid[y][x] = sum / count as f64;
|
||||
changes_made = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn save_debug_image(heights: &Vec<Vec<i32>>, filename: &str) {
|
||||
if heights.is_empty() || heights[0].is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
let height: usize = heights.len();
|
||||
let width: usize = heights[0].len();
|
||||
let mut img: image::ImageBuffer<Rgb<u8>, Vec<u8>> =
|
||||
RgbImage::new(width as u32, height as u32);
|
||||
|
||||
let mut min_height: i32 = i32::MAX;
|
||||
let mut max_height: i32 = i32::MIN;
|
||||
|
||||
for row in heights {
|
||||
for &h in row {
|
||||
min_height = min_height.min(h);
|
||||
max_height = max_height.max(h);
|
||||
}
|
||||
}
|
||||
|
||||
for (y, row) in heights.iter().enumerate() {
|
||||
for (x, &h) in row.iter().enumerate() {
|
||||
let normalized: u8 =
|
||||
(((h - min_height) as f64 / (max_height - min_height) as f64) * 255.0) as u8;
|
||||
img.put_pixel(
|
||||
x as u32,
|
||||
y as u32,
|
||||
Rgb([normalized, normalized, normalized]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure filename has .png extension
|
||||
let filename: String = if !filename.ends_with(".png") {
|
||||
format!("{}.png", filename)
|
||||
} else {
|
||||
filename.to_string()
|
||||
};
|
||||
|
||||
if let Err(e) = img.save(&filename) {
|
||||
eprintln!("Failed to save debug image: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
167
src/main.rs
167
src/main.rs
@@ -3,12 +3,24 @@
|
||||
mod args;
|
||||
mod block_definitions;
|
||||
mod bresenham;
|
||||
mod cartesian;
|
||||
mod colors;
|
||||
mod data_processing;
|
||||
mod element_processing;
|
||||
mod floodfill;
|
||||
mod ground;
|
||||
mod osm_parser;
|
||||
#[cfg(feature = "gui")]
|
||||
mod progress;
|
||||
// If the user does not want the GUI, it's easiest to just mock the progress module to do nothing
|
||||
#[cfg(not(feature = "gui"))]
|
||||
mod progress {
|
||||
pub fn emit_gui_error(_message: &str) {}
|
||||
pub fn emit_gui_progress_update(_progress: f64, _message: &str) {}
|
||||
pub fn is_running_with_gui() -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
mod retrieve_data;
|
||||
mod version_check;
|
||||
mod world_editor;
|
||||
@@ -18,14 +30,19 @@ use clap::Parser;
|
||||
use colored::*;
|
||||
use fastnbt::Value;
|
||||
use flate2::read::GzDecoder;
|
||||
use fs2::FileExt;
|
||||
use log::{error, LevelFilter};
|
||||
use rfd::FileDialog;
|
||||
use std::{
|
||||
env,
|
||||
fs::{self, File},
|
||||
io::{Read, Write},
|
||||
panic,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
#[cfg(feature = "gui")]
|
||||
use tauri_plugin_log::{Builder as LogBuilder, Target, TargetKind};
|
||||
#[cfg(target_os = "windows")]
|
||||
use windows::Win32::System::Console::{AttachConsole, FreeConsole, ATTACH_PARENT_PROCESS};
|
||||
|
||||
fn print_banner() {
|
||||
let version: &str = env!("CARGO_PKG_VERSION");
|
||||
@@ -51,6 +68,14 @@ fn print_banner() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// If on Windows, free and reattach to the parent console when using as a CLI tool
|
||||
// Either of these can fail, but if they do it is not an issue, so the return value is ignored
|
||||
#[cfg(target_os = "windows")]
|
||||
unsafe {
|
||||
let _ = FreeConsole();
|
||||
let _ = AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
}
|
||||
|
||||
// Parse arguments to decide whether to launch the UI or CLI
|
||||
let raw_args: Vec<String> = std::env::args().collect();
|
||||
|
||||
@@ -118,29 +143,65 @@ fn main() {
|
||||
let _ =
|
||||
data_processing::generate_world(parsed_elements, &args, scale_factor_x, scale_factor_z);
|
||||
} else {
|
||||
// Launch the UI
|
||||
println!("Launching UI...");
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
gui_select_world,
|
||||
gui_start_generation,
|
||||
gui_get_version,
|
||||
gui_check_for_updates
|
||||
])
|
||||
.setup(|app| {
|
||||
let app_handle = app.handle();
|
||||
let main_window = tauri::Manager::get_webview_window(app_handle, "main")
|
||||
.expect("Failed to get main window");
|
||||
progress::set_main_window(main_window);
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("Error while starting the application UI (Tauri)");
|
||||
#[cfg(not(feature = "gui"))]
|
||||
{
|
||||
panic!("This version of arnis was not built with GUI enabled");
|
||||
}
|
||||
|
||||
#[cfg(feature = "gui")]
|
||||
{
|
||||
// Launch the UI
|
||||
println!("Launching UI...");
|
||||
|
||||
// Set a custom panic hook to log panic information
|
||||
panic::set_hook(Box::new(|panic_info| {
|
||||
let message = format!("Application panicked: {:?}", panic_info);
|
||||
error!("{}", message);
|
||||
std::process::exit(1);
|
||||
}));
|
||||
|
||||
// Workaround WebKit2GTK issue with NVIDIA drivers (likely explicit sync related?)
|
||||
// Source: https://github.com/tauri-apps/tauri/issues/10702 (TODO: Remove this later)
|
||||
#[cfg(target_os = "linux")]
|
||||
unsafe {
|
||||
env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
||||
}
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(
|
||||
LogBuilder::default()
|
||||
.level(LevelFilter::Warn)
|
||||
.targets([
|
||||
Target::new(TargetKind::LogDir {
|
||||
file_name: Some("arnis".into()),
|
||||
}),
|
||||
Target::new(TargetKind::Stdout),
|
||||
])
|
||||
.build(),
|
||||
)
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
gui_select_world,
|
||||
gui_start_generation,
|
||||
gui_get_version,
|
||||
gui_check_for_updates
|
||||
])
|
||||
.setup(|app| {
|
||||
let app_handle = app.handle();
|
||||
let main_window = tauri::Manager::get_webview_window(app_handle, "main")
|
||||
.expect("Failed to get main window");
|
||||
progress::set_main_window(main_window);
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("Error while starting the application UI (Tauri)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gui")]
|
||||
#[tauri::command]
|
||||
fn gui_select_world(generate_new: bool) -> Result<String, String> {
|
||||
fn gui_select_world(generate_new: bool) -> Result<String, i32> {
|
||||
// Determine the default Minecraft 'saves' directory based on the OS
|
||||
let default_dir: Option<PathBuf> = if cfg!(target_os = "windows") {
|
||||
env::var("APPDATA")
|
||||
@@ -152,7 +213,14 @@ fn gui_select_world(generate_new: bool) -> Result<String, String> {
|
||||
.join("saves")
|
||||
})
|
||||
} else if cfg!(target_os = "linux") {
|
||||
dirs::home_dir().map(|home: PathBuf| home.join(".minecraft").join("saves"))
|
||||
dirs::home_dir().map(|home| {
|
||||
let flatpak_path = home.join(".var/app/com.mojang.Minecraft/.minecraft/saves");
|
||||
if flatpak_path.exists() {
|
||||
flatpak_path
|
||||
} else {
|
||||
home.join(".minecraft/saves")
|
||||
}
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -162,12 +230,12 @@ fn gui_select_world(generate_new: bool) -> Result<String, String> {
|
||||
if let Some(default_path) = &default_dir {
|
||||
if default_path.exists() {
|
||||
// Call create_new_world and return the result
|
||||
create_new_world(default_path)
|
||||
create_new_world(default_path).map_err(|_| 1) // Error code 1: Minecraft directory not found
|
||||
} else {
|
||||
Err("Minecraft directory not found".to_string())
|
||||
Err(1) // Error code 1: Minecraft directory not found
|
||||
}
|
||||
} else {
|
||||
Err("Minecraft directory not found".to_string())
|
||||
Err(1) // Error code 1: Minecraft directory not found
|
||||
}
|
||||
} else {
|
||||
// Handle existing world selection
|
||||
@@ -187,11 +255,11 @@ fn gui_select_world(generate_new: bool) -> Result<String, String> {
|
||||
if session_lock_path.exists() {
|
||||
// Try to acquire a lock on the session.lock file
|
||||
if let Ok(file) = File::open(&session_lock_path) {
|
||||
if file.try_lock_shared().is_err() {
|
||||
return Err("The selected world is currently in use".to_string());
|
||||
if fs2::FileExt::try_lock_shared(&file).is_err() {
|
||||
return Err(2); // Error code 2: The selected world is currently in use
|
||||
} else {
|
||||
// Release the lock immediately
|
||||
let _ = file.unlock();
|
||||
let _ = fs2::FileExt::unlock(&file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,12 +267,12 @@ fn gui_select_world(generate_new: bool) -> Result<String, String> {
|
||||
return Ok(path.display().to_string());
|
||||
} else {
|
||||
// No Minecraft directory found, generating new world in custom user selected directory
|
||||
return create_new_world(&path);
|
||||
return create_new_world(&path).map_err(|_| 3); // Error code 3: Failed to create new world
|
||||
}
|
||||
}
|
||||
|
||||
// If no folder was selected, return an error message
|
||||
Err("No world selected".to_string())
|
||||
Err(4) // Error code 4: No world selected
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +314,7 @@ fn create_new_world(base_path: &Path) -> Result<String, String> {
|
||||
let mut level_data: Value = fastnbt::from_bytes(&decompressed_data)
|
||||
.map_err(|e| format!("Failed to parse level.dat template: {}", e))?;
|
||||
|
||||
// Modify the LevelName and LastPlayed fields
|
||||
// Modify the LevelName, LastPlayed and player position fields
|
||||
if let Value::Compound(ref mut root) = level_data {
|
||||
if let Some(Value::Compound(ref mut data)) = root.get_mut("Data") {
|
||||
// Update LevelName
|
||||
@@ -258,6 +326,27 @@ fn create_new_world(base_path: &Path) -> Result<String, String> {
|
||||
.map_err(|e| format!("Failed to get current time: {}", e))?;
|
||||
let current_time_millis = current_time.as_millis() as i64;
|
||||
data.insert("LastPlayed".to_string(), Value::Long(current_time_millis));
|
||||
|
||||
// Update player position and rotation
|
||||
if let Some(Value::Compound(ref mut player)) = data.get_mut("Player") {
|
||||
if let Some(Value::List(ref mut pos)) = player.get_mut("Pos") {
|
||||
if let Value::Double(ref mut x) = pos.get_mut(0).unwrap() {
|
||||
*x = -5.0;
|
||||
}
|
||||
if let Value::Double(ref mut y) = pos.get_mut(1).unwrap() {
|
||||
*y = -61.0;
|
||||
}
|
||||
if let Value::Double(ref mut z) = pos.get_mut(2).unwrap() {
|
||||
*z = -5.0;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(Value::List(ref mut rot)) = player.get_mut("Rotation") {
|
||||
if let Value::Float(ref mut x) = rot.get_mut(0).unwrap() {
|
||||
*x = -45.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,11 +375,13 @@ fn create_new_world(base_path: &Path) -> Result<String, String> {
|
||||
Ok(new_world_path.display().to_string())
|
||||
}
|
||||
|
||||
#[cfg(feature = "gui")]
|
||||
#[tauri::command]
|
||||
fn gui_get_version() -> String {
|
||||
env!("CARGO_PKG_VERSION").to_string()
|
||||
}
|
||||
|
||||
#[cfg(feature = "gui")]
|
||||
#[tauri::command]
|
||||
fn gui_check_for_updates() -> Result<bool, String> {
|
||||
match version_check::check_for_updates() {
|
||||
@@ -299,6 +390,7 @@ fn gui_check_for_updates() -> Result<bool, String> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gui")]
|
||||
#[tauri::command]
|
||||
fn gui_start_generation(
|
||||
bbox_text: String,
|
||||
@@ -307,6 +399,7 @@ fn gui_start_generation(
|
||||
ground_level: i32,
|
||||
winter_mode: bool,
|
||||
floodfill_timeout: u64,
|
||||
terrain_enabled: bool,
|
||||
) -> Result<(), String> {
|
||||
tauri::async_runtime::spawn(async move {
|
||||
if let Err(e) = tokio::task::spawn_blocking(move || {
|
||||
@@ -333,6 +426,7 @@ fn gui_start_generation(
|
||||
downloader: "requests".to_string(),
|
||||
scale: world_scale,
|
||||
ground_level,
|
||||
terrain: terrain_enabled,
|
||||
winter: winter_mode,
|
||||
debug: false,
|
||||
timeout: Some(std::time::Duration::from_secs(floodfill_timeout)),
|
||||
@@ -346,8 +440,17 @@ fn gui_start_generation(
|
||||
Ok(raw_data) => {
|
||||
let (mut parsed_elements, scale_factor_x, scale_factor_z) =
|
||||
osm_parser::parse_osm_data(&raw_data, reordered_bbox, &args);
|
||||
parsed_elements.sort_by_key(|element: &osm_parser::ProcessedElement| {
|
||||
osm_parser::get_priority(element)
|
||||
parsed_elements.sort_by(|el1, el2| {
|
||||
let (el1_priority, el2_priority) =
|
||||
(osm_parser::get_priority(el1), osm_parser::get_priority(el2));
|
||||
match (
|
||||
el1.tags().contains_key("landuse"),
|
||||
el2.tags().contains_key("landuse"),
|
||||
) {
|
||||
(true, false) => std::cmp::Ordering::Greater,
|
||||
(false, true) => std::cmp::Ordering::Less,
|
||||
_ => el1_priority.cmp(&el2_priority),
|
||||
}
|
||||
});
|
||||
|
||||
let _ = data_processing::generate_world(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{args::Args, progress::emit_gui_progress_update};
|
||||
use crate::{args::Args, cartesian::XZPoint, progress::emit_gui_progress_update};
|
||||
use colored::Colorize;
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
@@ -44,6 +44,15 @@ pub struct ProcessedNode {
|
||||
pub z: i32,
|
||||
}
|
||||
|
||||
impl ProcessedNode {
|
||||
pub fn xz(&self) -> XZPoint {
|
||||
XZPoint {
|
||||
x: self.x,
|
||||
z: self.z,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ProcessedWay {
|
||||
pub id: u64,
|
||||
@@ -65,9 +74,9 @@ pub struct ProcessedMember {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ProcessedRelation {
|
||||
id: u64,
|
||||
pub members: Vec<ProcessedMember>,
|
||||
pub id: u64,
|
||||
pub tags: HashMap<String, String>,
|
||||
pub members: Vec<ProcessedMember>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -240,12 +249,7 @@ pub fn parse_osm_data(
|
||||
let role = match mem.role.as_str() {
|
||||
"outer" => ProcessedMemberRole::Outer,
|
||||
"inner" => ProcessedMemberRole::Inner,
|
||||
_ => {
|
||||
// We only care about outer/inner because
|
||||
// we just want multipolygons at the current time
|
||||
|
||||
return None;
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
let way: ProcessedWay = ways_map
|
||||
@@ -286,7 +290,8 @@ pub fn get_priority(element: &ProcessedElement) -> usize {
|
||||
}
|
||||
|
||||
// (lat meters, lon meters)
|
||||
fn geo_distance(lat1: f64, lat2: f64, lon1: f64, lon2: f64) -> (f64, f64) {
|
||||
#[inline]
|
||||
pub fn geo_distance(lat1: f64, lat2: f64, lon1: f64, lon2: f64) -> (f64, f64) {
|
||||
let z: f64 = lat_distance(lat1, lat2);
|
||||
|
||||
// distance between two lons depends on their latitude. In this case we'll just average them
|
||||
|
||||
@@ -12,7 +12,7 @@ use std::time::Duration;
|
||||
/// Function to download data using reqwest
|
||||
fn download_with_reqwest(url: &str, query: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let client: Client = ClientBuilder::new()
|
||||
.timeout(Duration::from_secs(1800))
|
||||
.timeout(Duration::from_secs(360))
|
||||
.build()?;
|
||||
|
||||
let response: Result<reqwest::blocking::Response, reqwest::Error> =
|
||||
@@ -20,8 +20,13 @@ fn download_with_reqwest(url: &str, query: &str) -> Result<String, Box<dyn std::
|
||||
|
||||
match response {
|
||||
Ok(resp) => {
|
||||
emit_gui_progress_update(3.0, "Downloading data...");
|
||||
if resp.status().is_success() {
|
||||
Ok(resp.text()?)
|
||||
let text = resp.text()?;
|
||||
if text.is_empty() {
|
||||
return Err("Error! Received invalid from server".into());
|
||||
}
|
||||
Ok(text)
|
||||
} else {
|
||||
Err(format!("Error! Received response code: {}", resp.status()).into())
|
||||
}
|
||||
@@ -36,15 +41,11 @@ fn download_with_reqwest(url: &str, query: &str) -> Result<String, Box<dyn std::
|
||||
);
|
||||
emit_gui_error("Request timed out. Try selecting a smaller area.");
|
||||
} else {
|
||||
eprintln!("{}", format!("Error! {}", e).red().bold());
|
||||
emit_gui_error(&e.to_string());
|
||||
}
|
||||
|
||||
if !is_running_with_gui() {
|
||||
std::process::exit(1);
|
||||
} else {
|
||||
Ok("".to_string())
|
||||
eprintln!("{}", format!("Error! {:.52}", e).red().bold());
|
||||
emit_gui_error(&format!("{:.52}", e.to_string()));
|
||||
}
|
||||
// Always propagate errors
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,14 +93,16 @@ pub fn fetch_data(
|
||||
"https://overpass-api.de/api/interpreter",
|
||||
"https://lz4.overpass-api.de/api/interpreter",
|
||||
"https://z.overpass-api.de/api/interpreter",
|
||||
"https://overpass.kumi.systems/api/interpreter",
|
||||
"https://overpass.private.coffee/api/interpreter",
|
||||
//"https://overpass.kumi.systems/api/interpreter", // This server is not reliable anymore
|
||||
//"https://overpass.private.coffee/api/interpreter", // This server is not reliable anymore
|
||||
];
|
||||
let url: &&str = api_servers.choose(&mut rand::thread_rng()).unwrap();
|
||||
let fallback_api_servers: Vec<&str> =
|
||||
vec!["https://maps.mail.ru/osm/tools/overpass/api/interpreter"];
|
||||
let mut url: &&str = api_servers.choose(&mut rand::thread_rng()).unwrap();
|
||||
|
||||
// Generate Overpass API query for bounding box
|
||||
let query: String = format!(
|
||||
r#"[out:json][timeout:1800][bbox:{},{},{},{}];
|
||||
r#"[out:json][timeout:360][bbox:{},{},{},{}];
|
||||
(
|
||||
nwr["building"];
|
||||
nwr["highway"];
|
||||
@@ -138,11 +141,30 @@ pub fn fetch_data(
|
||||
Ok(data)
|
||||
} else {
|
||||
// Fetch data from Overpass API
|
||||
let response: String = match download_method {
|
||||
"requests" => download_with_reqwest(url, &query)?,
|
||||
"curl" => download_with_curl(url, &query)?,
|
||||
"wget" => download_with_wget(url, &query)?,
|
||||
_ => download_with_reqwest(url, &query)?, // Default to requests
|
||||
let mut attempt = 0;
|
||||
let max_attempts = 1;
|
||||
let response: String = loop {
|
||||
let result = match download_method {
|
||||
"requests" => download_with_reqwest(url, &query),
|
||||
"curl" => download_with_curl(url, &query).map_err(|e| e.into()),
|
||||
"wget" => download_with_wget(url, &query).map_err(|e| e.into()),
|
||||
_ => download_with_reqwest(url, &query), // Default to requests
|
||||
};
|
||||
|
||||
match result {
|
||||
Ok(response) => break response,
|
||||
Err(error) => {
|
||||
if attempt >= max_attempts {
|
||||
return Err(error);
|
||||
}
|
||||
|
||||
println!("Request failed. Switching to fallback url...");
|
||||
url = fallback_api_servers
|
||||
.choose(&mut rand::thread_rng())
|
||||
.unwrap();
|
||||
attempt += 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let data: Value = serde_json::from_str(&response)?;
|
||||
@@ -169,9 +191,11 @@ pub fn fetch_data(
|
||||
// General case for when there are no elements and no specific remark
|
||||
eprintln!(
|
||||
"{}",
|
||||
"Error! No data available in this region.".red().bold()
|
||||
"Error! API returned no data. Please try again!"
|
||||
.red()
|
||||
.bold()
|
||||
);
|
||||
emit_gui_error("No data available in this region.");
|
||||
emit_gui_error("API returned no data. Please try again!");
|
||||
}
|
||||
|
||||
if debug {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::progress::emit_gui_progress_update;
|
||||
use colored::Colorize;
|
||||
@@ -6,10 +5,12 @@ use fastanvil::Region;
|
||||
use fastnbt::{LongArray, Value};
|
||||
use fnv::FnvHashMap;
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
use rayon::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -226,23 +227,21 @@ impl WorldToModify {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WorldEditor<'a> {
|
||||
pub struct WorldEditor {
|
||||
region_dir: String,
|
||||
world: WorldToModify,
|
||||
scale_factor_x: f64,
|
||||
scale_factor_z: f64,
|
||||
args: &'a Args,
|
||||
}
|
||||
|
||||
impl<'a> WorldEditor<'a> {
|
||||
impl WorldEditor {
|
||||
/// Initializes the WorldEditor with the region directory and template region path.
|
||||
pub fn new(region_dir: &str, scale_factor_x: f64, scale_factor_z: f64, args: &'a Args) -> Self {
|
||||
pub fn new(region_dir: &str, scale_factor_x: f64, scale_factor_z: f64) -> Self {
|
||||
Self {
|
||||
region_dir: region_dir.to_string(),
|
||||
world: WorldToModify::default(),
|
||||
scale_factor_x,
|
||||
scale_factor_z,
|
||||
args,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,12 +270,11 @@ impl<'a> WorldEditor<'a> {
|
||||
(self.scale_factor_x as i32, self.scale_factor_x as i32)
|
||||
}
|
||||
|
||||
// Unused and not tested
|
||||
/*pub fn block_at(&self, x: i32, y: i32, z: i32) -> bool {
|
||||
pub fn block_at(&self, x: i32, y: i32, z: i32) -> bool {
|
||||
self.world.get_block(x, y, z).is_some()
|
||||
}*/
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[allow(clippy::too_many_arguments, dead_code)]
|
||||
pub fn set_sign(
|
||||
&mut self,
|
||||
line1: String,
|
||||
@@ -432,15 +430,95 @@ impl<'a> WorldEditor<'a> {
|
||||
false
|
||||
}
|
||||
|
||||
/// Helper function to create a base chunk with grass blocks at Y -62
|
||||
fn create_base_chunk(abs_chunk_x: i32, abs_chunk_z: i32) -> (Vec<u8>, bool) {
|
||||
let mut chunk = ChunkToModify::default();
|
||||
|
||||
// Fill the bottom layer with grass blocks at Y -62
|
||||
for x in 0..16 {
|
||||
for z in 0..16 {
|
||||
chunk.set_block(x, -62, z, GRASS_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare chunk data
|
||||
let chunk_data = Chunk {
|
||||
sections: chunk.sections().collect(),
|
||||
x_pos: abs_chunk_x,
|
||||
z_pos: abs_chunk_z,
|
||||
is_light_on: 0,
|
||||
other: chunk.other,
|
||||
};
|
||||
|
||||
// Create the Level wrapper
|
||||
let level_data = HashMap::from([(
|
||||
"Level".to_string(),
|
||||
Value::Compound(HashMap::from([
|
||||
("xPos".to_string(), Value::Int(abs_chunk_x)),
|
||||
("zPos".to_string(), Value::Int(abs_chunk_z)),
|
||||
("isLightOn".to_string(), Value::Byte(0)),
|
||||
(
|
||||
"sections".to_string(),
|
||||
Value::List(
|
||||
chunk_data
|
||||
.sections
|
||||
.iter()
|
||||
.map(|section| {
|
||||
Value::Compound(HashMap::from([
|
||||
("Y".to_string(), Value::Byte(section.y)),
|
||||
(
|
||||
"block_states".to_string(),
|
||||
Value::Compound(HashMap::from([
|
||||
(
|
||||
"palette".to_string(),
|
||||
Value::List(
|
||||
section
|
||||
.block_states
|
||||
.palette
|
||||
.iter()
|
||||
.map(|item| {
|
||||
Value::Compound(HashMap::from([(
|
||||
"Name".to_string(),
|
||||
Value::String(item.name.clone()),
|
||||
)]))
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
),
|
||||
(
|
||||
"data".to_string(),
|
||||
Value::LongArray(
|
||||
section
|
||||
.block_states
|
||||
.data
|
||||
.clone()
|
||||
.unwrap_or_else(|| LongArray::new(vec![])),
|
||||
),
|
||||
),
|
||||
])),
|
||||
),
|
||||
]))
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
),
|
||||
])),
|
||||
)]);
|
||||
|
||||
// Serialize the chunk with Level wrapper
|
||||
let mut ser_buffer = Vec::with_capacity(8192);
|
||||
fastnbt::to_writer(&mut ser_buffer, &level_data).unwrap();
|
||||
|
||||
(ser_buffer, true)
|
||||
}
|
||||
|
||||
/// Saves all changes made to the world by writing modified chunks to the appropriate region files.
|
||||
pub fn save(&mut self) {
|
||||
println!("{} Saving world...", "[5/5]".bold());
|
||||
emit_gui_progress_update(90.0, "Saving world...");
|
||||
|
||||
let _debug: bool = self.args.debug;
|
||||
let total_regions: u64 = self.world.regions.len() as u64;
|
||||
|
||||
let save_pb: ProgressBar = ProgressBar::new(total_regions);
|
||||
let total_regions = self.world.regions.len() as u64;
|
||||
let save_pb = ProgressBar::new(total_regions);
|
||||
save_pb.set_style(
|
||||
ProgressStyle::default_bar()
|
||||
.template(
|
||||
@@ -452,50 +530,223 @@ impl<'a> WorldEditor<'a> {
|
||||
|
||||
let total_steps: f64 = 9.0;
|
||||
let progress_increment_save: f64 = total_steps / total_regions as f64;
|
||||
let mut current_progress_save: f64 = 90.0;
|
||||
let mut last_emitted_progress: f64 = current_progress_save;
|
||||
let current_progress = AtomicU64::new(900);
|
||||
let regions_processed = AtomicU64::new(0);
|
||||
|
||||
for ((region_x, region_z), region_to_modify) in &self.world.regions {
|
||||
let mut region: Region<File> = self.create_region(*region_x, *region_z);
|
||||
self.world
|
||||
.regions
|
||||
.par_iter()
|
||||
.for_each(|((region_x, region_z), region_to_modify)| {
|
||||
let mut region = self.create_region(*region_x, *region_z);
|
||||
let mut ser_buffer = Vec::with_capacity(8192);
|
||||
|
||||
for chunk_x in 0..32 {
|
||||
for chunk_z in 0..32 {
|
||||
let data: Vec<u8> = region
|
||||
.read_chunk(chunk_x as usize, chunk_z as usize)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
for (&(chunk_x, chunk_z), chunk_to_modify) in ®ion_to_modify.chunks {
|
||||
if !chunk_to_modify.sections.is_empty() || !chunk_to_modify.other.is_empty() {
|
||||
// Read existing chunk data if it exists
|
||||
let existing_data = region
|
||||
.read_chunk(chunk_x as usize, chunk_z as usize)
|
||||
.unwrap()
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut chunk: Chunk = fastnbt::from_bytes(&data).unwrap();
|
||||
// Parse existing chunk or create new one
|
||||
let mut chunk: Chunk = if !existing_data.is_empty() {
|
||||
fastnbt::from_bytes(&existing_data).unwrap()
|
||||
} else {
|
||||
Chunk {
|
||||
sections: Vec::new(),
|
||||
x_pos: chunk_x + (region_x * 32),
|
||||
z_pos: chunk_z + (region_z * 32),
|
||||
is_light_on: 0,
|
||||
other: FnvHashMap::default(),
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(chunk_to_modify) = region_to_modify.get_chunk(chunk_x, chunk_z) {
|
||||
chunk.sections = chunk_to_modify.sections().collect();
|
||||
chunk.other.extend(chunk_to_modify.other.clone());
|
||||
// Update sections while preserving existing data
|
||||
let new_sections: Vec<Section> = chunk_to_modify.sections().collect();
|
||||
for new_section in new_sections {
|
||||
if let Some(existing_section) =
|
||||
chunk.sections.iter_mut().find(|s| s.y == new_section.y)
|
||||
{
|
||||
// Merge block states
|
||||
existing_section.block_states.palette =
|
||||
new_section.block_states.palette;
|
||||
existing_section.block_states.data = new_section.block_states.data;
|
||||
} else {
|
||||
// Add new section if it doesn't exist
|
||||
chunk.sections.push(new_section);
|
||||
}
|
||||
}
|
||||
|
||||
// Preserve existing block entities and merge with new ones
|
||||
if let Some(existing_entities) = chunk.other.get_mut("block_entities") {
|
||||
if let Some(new_entities) = chunk_to_modify.other.get("block_entities")
|
||||
{
|
||||
if let (Value::List(existing), Value::List(new)) =
|
||||
(existing_entities, new_entities)
|
||||
{
|
||||
// Remove old entities that are replaced by new ones
|
||||
existing.retain(|e| {
|
||||
if let Value::Compound(map) = e {
|
||||
let (x, y, z) = get_entity_coords(map);
|
||||
!new.iter().any(|new_e| {
|
||||
if let Value::Compound(new_map) = new_e {
|
||||
let (nx, ny, nz) = get_entity_coords(new_map);
|
||||
x == nx && y == ny && z == nz
|
||||
} else {
|
||||
false
|
||||
}
|
||||
})
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
// Add new entities
|
||||
existing.extend(new.clone());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If no existing entities, just add the new ones
|
||||
if let Some(new_entities) = chunk_to_modify.other.get("block_entities")
|
||||
{
|
||||
chunk
|
||||
.other
|
||||
.insert("block_entities".to_string(), new_entities.clone());
|
||||
}
|
||||
}
|
||||
|
||||
// Update chunk coordinates and flags
|
||||
chunk.x_pos = chunk_x + (region_x * 32);
|
||||
chunk.z_pos = chunk_z + (region_z * 32);
|
||||
|
||||
// Create Level wrapper and save
|
||||
let level_data = create_level_wrapper(&chunk);
|
||||
ser_buffer.clear();
|
||||
fastnbt::to_writer(&mut ser_buffer, &level_data).unwrap();
|
||||
region
|
||||
.write_chunk(chunk_x as usize, chunk_z as usize, &ser_buffer)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
chunk.x_pos = chunk_x + region_x * 32;
|
||||
chunk.z_pos = chunk_z + region_z * 32;
|
||||
chunk.is_light_on = 0; // Force minecraft to recompute
|
||||
|
||||
let ser: Vec<u8> = fastnbt::to_bytes(&chunk).unwrap();
|
||||
|
||||
// Write chunk data back to the correct location, ensuring correct chunk coordinates
|
||||
let expected_chunk_location: (usize, usize) =
|
||||
((chunk_x as usize) & 31, (chunk_z as usize) & 31);
|
||||
region
|
||||
.write_chunk(expected_chunk_location.0, expected_chunk_location.1, &ser)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
save_pb.inc(1);
|
||||
// Second pass: ensure all chunks exist
|
||||
for chunk_x in 0..32 {
|
||||
for chunk_z in 0..32 {
|
||||
let abs_chunk_x = chunk_x + (region_x * 32);
|
||||
let abs_chunk_z = chunk_z + (region_z * 32);
|
||||
|
||||
current_progress_save += progress_increment_save;
|
||||
if (current_progress_save - last_emitted_progress).abs() > 0.25 {
|
||||
emit_gui_progress_update(current_progress_save, "Saving world...");
|
||||
last_emitted_progress = current_progress_save;
|
||||
}
|
||||
}
|
||||
// Check if chunk exists in our modifications
|
||||
let chunk_exists =
|
||||
region_to_modify.chunks.contains_key(&(chunk_x, chunk_z));
|
||||
|
||||
// If chunk doesn't exist, create it with base layer
|
||||
if !chunk_exists {
|
||||
let (ser_buffer, _) = Self::create_base_chunk(abs_chunk_x, abs_chunk_z);
|
||||
region
|
||||
.write_chunk(chunk_x as usize, chunk_z as usize, &ser_buffer)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update progress
|
||||
let regions_done = regions_processed.fetch_add(1, Ordering::SeqCst);
|
||||
let new_progress = (90.0 + (regions_done as f64 * progress_increment_save)) * 10.0;
|
||||
let prev_progress =
|
||||
current_progress.fetch_max(new_progress as u64, Ordering::SeqCst);
|
||||
|
||||
if new_progress as u64 - prev_progress > 1 {
|
||||
emit_gui_progress_update(new_progress / 10.0, "Saving world...");
|
||||
}
|
||||
|
||||
save_pb.inc(1);
|
||||
});
|
||||
|
||||
save_pb.finish();
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to get entity coordinates
|
||||
fn get_entity_coords(entity: &HashMap<String, Value>) -> (i32, i32, i32) {
|
||||
let x = if let Value::Int(x) = entity.get("x").unwrap_or(&Value::Int(0)) {
|
||||
*x
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let y = if let Value::Int(y) = entity.get("y").unwrap_or(&Value::Int(0)) {
|
||||
*y
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let z = if let Value::Int(z) = entity.get("z").unwrap_or(&Value::Int(0)) {
|
||||
*z
|
||||
} else {
|
||||
0
|
||||
};
|
||||
(x, y, z)
|
||||
}
|
||||
|
||||
fn create_level_wrapper(chunk: &Chunk) -> HashMap<String, Value> {
|
||||
HashMap::from([(
|
||||
"Level".to_string(),
|
||||
Value::Compound(HashMap::from([
|
||||
("xPos".to_string(), Value::Int(chunk.x_pos)),
|
||||
("zPos".to_string(), Value::Int(chunk.z_pos)),
|
||||
(
|
||||
"isLightOn".to_string(),
|
||||
Value::Byte(i8::try_from(chunk.is_light_on).unwrap()),
|
||||
),
|
||||
(
|
||||
"sections".to_string(),
|
||||
Value::List(
|
||||
chunk
|
||||
.sections
|
||||
.iter()
|
||||
.map(|section| {
|
||||
Value::Compound(HashMap::from([
|
||||
("Y".to_string(), Value::Byte(section.y)),
|
||||
(
|
||||
"block_states".to_string(),
|
||||
Value::Compound(HashMap::from([
|
||||
(
|
||||
"palette".to_string(),
|
||||
Value::List(
|
||||
section
|
||||
.block_states
|
||||
.palette
|
||||
.iter()
|
||||
.map(|item| {
|
||||
let mut palette_item = HashMap::from([(
|
||||
"Name".to_string(),
|
||||
Value::String(item.name.clone()),
|
||||
)]);
|
||||
if let Some(props) = &item.properties {
|
||||
palette_item.insert(
|
||||
"Properties".to_string(),
|
||||
props.clone(),
|
||||
);
|
||||
}
|
||||
Value::Compound(palette_item)
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
),
|
||||
(
|
||||
"data".to_string(),
|
||||
Value::LongArray(
|
||||
section
|
||||
.block_states
|
||||
.data
|
||||
.clone()
|
||||
.unwrap_or_else(|| LongArray::new(vec![])),
|
||||
),
|
||||
),
|
||||
])),
|
||||
),
|
||||
]))
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
),
|
||||
])),
|
||||
)])
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Arnis",
|
||||
"version": "2.1.2",
|
||||
"version": "2.2.1",
|
||||
"identifier": "com.louisdev.arnis",
|
||||
"build": {
|
||||
"frontendDist": "gui-src"
|
||||
|
||||
Reference in New Issue
Block a user