From 639963170c6e7162b24a7e23422002928f587341 Mon Sep 17 00:00:00 2001 From: Alex Hicks Date: Wed, 13 Aug 2025 18:11:58 -0400 Subject: [PATCH 1/6] Reimplement CI --- .github/workflows/build.yml | 15 ------- .github/workflows/publish.yml | 59 -------------------------- .github/workflows/push.yml | 78 +++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 74 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/push.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 832ad71..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Build and lint -on: - push: - branches: '*' -jobs: - build: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - name: Install SFML - run: sudo apt-get update && sudo apt-get install -y libsfml-dev - - name: Lint - run: cargo fmt --all -- --check - - name: Build - run: cargo build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 48db6dd..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Publish release -run-name: ${{ github.actor }} is publishing ${{ github.ref_name}} -permissions: - contents: write -on: - push: - tags: - - "v*" -jobs: - build_linux: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - name: Install SFML - run: sudo apt-get update && sudo apt-get install -y libsfml-dev - - name: Build - run: cargo build --release - - uses: actions/upload-artifact@v3 - with: - name: linux-x64 - path: ./target/release/mapgame - build_windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - name: Download SFML - run: Invoke-WebRequest -OutFile sfml.zip https://www.sfml-dev.org/files/SFML-2.5.1-windows-vc15-64-bit.zip - - name: Extract SFML - run: Expand-Archive -DestinationPath . .\sfml.zip - - name: Build - run: cargo build --release - env: - SFML_INCLUDE_DIR: ${{ github.workspace }}\SFML-2.5.1\include - SFML_LIBS_DIR: ${{ github.workspace }}\SFML-2.5.1\lib - - uses: actions/upload-artifact@v3 - with: - name: windows-x64 - path: ./target/release/mapgame.exe - publish_release: - runs-on: ubuntu-latest - needs: - - build_linux - - build_windows - steps: - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - path: bin - - name: Move artifact files - run: | - mv bin/linux-x64/mapgame mapgame-linux-x64 - mv bin/windows-x64/mapgame.exe mapgame-windows-x64.exe - - name: Publish release - uses: softprops/action-gh-release@v1 - with: - files: | - mapgame-linux-x64 - mapgame-windows-x64.exe - diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..e527133 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,78 @@ +name: CI +run-name: ${{ github.ref_type == 'tag' && format('Release {0}', github.ref_name) || format('Build {0}', github.event.head_commit.message) }} +on: push +jobs: + build-linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Install SFML + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake \ + libsfml-dev libudev-dev libopenal-dev libvorbis-dev \ + libflac-dev libx11-dev libxrandr-dev libxcursor-dev \ + libgl-dev libfreetype-dev + + - name: Lint + if: ${{ github.ref_type == 'branch' }} + run: cargo fmt --all -- --check + + - name: Build + run: cargo build ${{ github.ref_type == 'tag' && '--release' || '' }} + + - uses: actions/upload-artifact@v4 + if: ${{ github.ref_type == 'tag' }} + with: + name: linux-x64 + path: ./target/release/mapgame + + build-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Download SFML + run: Invoke-WebRequest -OutFile sfml.zip https://www.sfml-dev.org/files/SFML-2.6.2-windows-vc17-64-bit.zip + - name: Extract SFML + run: Expand-Archive -DestinationPath . .\sfml.zip + + - name: Get CMake and Ninja + uses: lukka/get-cmake@latest + with: + cmakeVersion: '3.25' + ninjaVersion: latest + - name: Build + run: cargo build ${{ github.ref_type == 'tag' && '--release' || '' }} + env: + SFML_INCLUDE_DIR: ${{ github.workspace }}\SFML-2.6.2\include + SFML_LIBS_DIR: ${{ github.workspace }}\SFML-2.6.2\lib + + - uses: actions/upload-artifact@v4 + if: ${{ github.ref_type == 'tag' }} + with: + name: windows-x64 + path: ./target/release/mapgame.exe + + publish-release: + runs-on: ubuntu-latest + if: ${{ github.ref_type == 'tag' }} + needs: + - build-linux + - build-windows + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: bin + - name: Move artifact files + run: | + mv bin/linux-x64/mapgame mapgame-linux-x64 + mv bin/windows-x64/mapgame.exe mapgame-windows-x64.exe + - name: Publish release + uses: softprops/action-gh-release@v2 + with: + files: | + mapgame-linux-x64 + mapgame-windows-x64.exe From 30296724249996f384a9dbc8d8723a9408ac0b25 Mon Sep 17 00:00:00 2001 From: Alex Hicks Date: Wed, 13 Aug 2025 18:18:59 -0400 Subject: [PATCH 2/6] Cache apt dependencies and update SFML download URL --- .github/workflows/push.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e527133..013d74e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -8,13 +8,9 @@ jobs: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Install SFML - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake \ - libsfml-dev libudev-dev libopenal-dev libvorbis-dev \ - libflac-dev libx11-dev libxrandr-dev libxcursor-dev \ - libgl-dev libfreetype-dev - + uses: awalsh128/cache-apt-pkgs-action@v1 + with: + packages: build-essential cmake libsfml-dev libudev-dev libopenal-dev libvorbis-dev libflac-dev libx11-dev libxrandr-dev libxcursor-dev libgl-dev libfreetype-dev - name: Lint if: ${{ github.ref_type == 'branch' }} run: cargo fmt --all -- --check @@ -34,14 +30,14 @@ jobs: - uses: actions/checkout@v4 - name: Download SFML - run: Invoke-WebRequest -OutFile sfml.zip https://www.sfml-dev.org/files/SFML-2.6.2-windows-vc17-64-bit.zip + run: Invoke-WebRequest -OutFile sfml.zip https://github.com/SFML/SFML/releases/download/2.6.2/SFML-2.6.2-windows-vc17-64-bit.zip - name: Extract SFML run: Expand-Archive -DestinationPath . .\sfml.zip - name: Get CMake and Ninja uses: lukka/get-cmake@latest with: - cmakeVersion: '3.25' + cmakeVersion: '3.31' ninjaVersion: latest - name: Build run: cargo build ${{ github.ref_type == 'tag' && '--release' || '' }} From e8254f4b010fa804b2b60cde22e2751f380526e5 Mon Sep 17 00:00:00 2001 From: Alex Hicks Date: Wed, 13 Aug 2025 20:45:12 -0400 Subject: [PATCH 3/6] Fix compilation error on Windows --- .github/workflows/push.yml | 2 +- Cargo.lock | 52 +++++++++++++++++++------------------- Cargo.toml | 2 +- src/main.rs | 4 ++- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 013d74e..7d3a222 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,5 +1,5 @@ name: CI -run-name: ${{ github.ref_type == 'tag' && format('Release {0}', github.ref_name) || format('Build {0}', github.event.head_commit.message) }} +run-name: ${{ github.ref_type == 'tag' && format('Release "{0}"', github.ref_name) || format('Build "{0}"', github.event.head_commit.message) }} on: push jobs: build-linux: diff --git a/Cargo.lock b/Cargo.lock index 74eef87..6030713 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,21 +13,21 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "cc" -version = "1.2.17" +version = "1.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e" dependencies = [ "shlex", ] @@ -43,9 +43,9 @@ dependencies = [ [[package]] name = "geo-types" -version = "0.7.16" +version = "0.7.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ddb1950450d67efee2bbc5e429c68d052a822de3aad010d28b351fbb705224" +checksum = "75a4dcd69d35b2c87a7c83bce9af69fd65c9d68d3833a0ded568983928f3fc99" dependencies = [ "approx", "num-traits", @@ -73,15 +73,15 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "libc" -version = "0.2.171" +version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "libflac-sys" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0d9b582c1affe84b051d5a0faf3665e4da0c0b7b0e3b391213e3a5a670365b" +checksum = "01b01d08e4f670c184ffe3c3e5efbf0bd6e88c8cca796c278c86bbf49583545c" dependencies = [ "cmake", "libc", @@ -89,9 +89,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.11" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "link-cplusplus" @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "num-traits" @@ -142,9 +142,9 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "d61789d7719defeb74ea5fe81f2fdfdbd28a803847077cecce2ff14e1472f6f1" dependencies = [ "unicode-ident", ] @@ -186,9 +186,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" dependencies = [ "itoa", "memchr", @@ -220,9 +220,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "syn" -version = "2.0.100" +version = "2.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "7bc3fcb250e53458e712715cf74285c1f889686520d79294a9ef3bd7aa1fc619" dependencies = [ "proc-macro2", "quote", @@ -231,18 +231,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.12" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +checksum = "0b0949c3a6c842cbde3f1686d6eea5a010516deb7085f79db747562d4102f41e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.12" +version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +checksum = "cc5b44b4ab9c2fdd0e0512e6bece8388e214c0749f5862b114cc5b7a25daf227" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 73b03e1..a723a56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "mapgame" version = "0.1.0" authors = ["Alex Hicks "] -edition = "2021" +edition = "2024" license = "MIT" publish = false diff --git a/src/main.rs b/src/main.rs index 64deb05..c031716 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,6 @@ -// #![deny(elided_lifetimes_in_paths)] +#[cfg(target_os = "windows")] +#[link(name = "Advapi32")] +unsafe extern "system" {} pub mod config; pub mod errors; From 5c92ed30fff9b57d11b8e637a0c5a2887d4512f1 Mon Sep 17 00:00:00 2001 From: Alex Hicks Date: Wed, 13 Aug 2025 20:46:48 -0400 Subject: [PATCH 4/6] lint --- src/game.rs | 4 ++-- src/geo_drawable.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game.rs b/src/game.rs index ef5daa0..c63ed35 100644 --- a/src/game.rs +++ b/src/game.rs @@ -1,10 +1,10 @@ use crate::{config::Config, player::Player, world_map::WorldMap}; use sfml::{ + SfResult, cpp::FBox, graphics::{Color, Rect, RenderTarget, RenderWindow, View}, system::Vector2f, - window::{mouse::Button, Event, Style}, - SfResult, + window::{Event, Style, mouse::Button}, }; use std::error::Error; diff --git a/src/geo_drawable.rs b/src/geo_drawable.rs index 512192f..de36db0 100644 --- a/src/geo_drawable.rs +++ b/src/geo_drawable.rs @@ -2,7 +2,7 @@ use crate::{ errors::MapLoadError, math::{polygon_area, polygon_contains}, }; -use geojson::{feature::Id, Feature, JsonValue, Value}; +use geojson::{Feature, JsonValue, Value, feature::Id}; use sfml::{ graphics::{Color, PrimitiveType, Rect, RenderStates, Vertex}, system::Vector2f, From 365e14881106ac93b036700433caf9f93fe56678 Mon Sep 17 00:00:00 2001 From: Alex Hicks Date: Wed, 13 Aug 2025 21:04:45 -0400 Subject: [PATCH 5/6] Fix release job perms --- .github/workflows/push.yml | 4 ++++ README.md | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 7d3a222..90bdbf1 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,6 +1,7 @@ name: CI run-name: ${{ github.ref_type == 'tag' && format('Release "{0}"', github.ref_name) || format('Build "{0}"', github.event.head_commit.message) }} on: push + jobs: build-linux: runs-on: ubuntu-latest @@ -26,6 +27,7 @@ jobs: build-windows: runs-on: windows-latest + if: ${{ github.ref_type == 'tag' }} steps: - uses: actions/checkout@v4 @@ -57,6 +59,8 @@ jobs: needs: - build-linux - build-windows + permissions: + contents: write steps: - name: Download artifacts uses: actions/download-artifact@v4 diff --git a/README.md b/README.md index fe3a978..7bd6dc5 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Play strategy, on a map. 1. Install [Rust](https://www.rust-lang.org/tools/install) 2. Install dependencies: `apt install build-essential pkg-config unzip cmake` - - Also see [rust-sfml](https://github.com/jeremyletang/rust-sfml#prerequisites)'s dependencies. -3. Download [SFML 2.6.0](https://www.sfml-dev.org/download/sfml/2.6.0/) and extract it to `./sfml` + a. Also see [rust-sfml](https://github.com/jeremyletang/rust-sfml#prerequisites)'s dependencies. +3. Download [SFML 2.6.2](https://github.com/SFML/SFML/releases/2.6.2) and extract it to `./sfml` 4. Execute `cargo run` ## Todo From f67f43fcf6fbfeac5fe1e3188d22544be538ee0e Mon Sep 17 00:00:00 2001 From: Alex Hicks Date: Wed, 13 Aug 2025 21:27:34 -0400 Subject: [PATCH 6/6] Fix size issue on Windows --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/game.rs | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6030713..ed128c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,7 +110,7 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "mapgame" -version = "0.1.0" +version = "0.0.8" dependencies = [ "geojson", "serde", diff --git a/Cargo.toml b/Cargo.toml index a723a56..a46248b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mapgame" -version = "0.1.0" +version = "0.0.8" authors = ["Alex Hicks "] edition = "2024" license = "MIT" diff --git a/src/game.rs b/src/game.rs index c63ed35..65e3b53 100644 --- a/src/game.rs +++ b/src/game.rs @@ -17,10 +17,12 @@ pub struct Game { impl Game { pub fn new(config: Config) -> Result> { - let world_map = Box::new(WorldMap::new(&config.map)?); + let mut world_map = Box::new(WorldMap::new(&config.map)?); let mut window = RenderWindow::new((1920, 1080), "mapgame", Style::CLOSE, &Default::default())?; window.set_framerate_limit(60); let player = Player::new(); + let size = Rect::new(0f32, 0f32, 1920f32, 1080f32); + world_map.on_resize(&size); Ok(Game { config, window,