steamworks test integration (#20)

This commit is contained in:
extrawurst
2025-04-03 09:33:55 +02:00
committed by GitHub
parent 3758c47be6
commit e435738a21
8 changed files with 182 additions and 44 deletions

128
Cargo.lock generated
View File

@@ -91,7 +91,7 @@ checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
dependencies = [
"cfg-if",
"const-random",
"getrandom",
"getrandom 0.2.15",
"once_cell",
"version_check",
"zerocopy 0.7.35",
@@ -478,6 +478,18 @@ dependencies = [
"syn",
]
[[package]]
name = "bevy-steamworks"
version = "0.13.0"
source = "git+https://github.com/Laocoon7/bevy_steamworks.git#3264abd21662d031a6fc6fa2d74a32d3dd4d95ea"
dependencies = [
"bevy_app",
"bevy_ecs",
"bevy_log",
"bevy_utils",
"steamworks",
]
[[package]]
name = "bevy-ui-gradients"
version = "0.2.0"
@@ -645,9 +657,9 @@ dependencies = [
[[package]]
name = "bevy_ballistic"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fe5d0a61d5239c0bdacc0b4a917d1f485decfb5c316432e48d6f80cd2c39fc6"
checksum = "545cb49b798e5ed4c1ff71cbb6dd66799488cb7f914ded320a00327162e51044"
dependencies = [
"bevy_math",
]
@@ -1515,7 +1527,7 @@ checksum = "63c2174d43a0de99f863c98a472370047a2bfa7d1e5cec8d9d647fb500905d9d"
dependencies = [
"ahash",
"bevy_utils_proc_macros",
"getrandom",
"getrandom 0.2.15",
"hashbrown 0.14.5",
"thread_local",
"tracing",
@@ -1663,9 +1675,9 @@ checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2"
[[package]]
name = "blake3"
version = "1.7.0"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b17679a8d69b6d7fd9cd9801a536cec9fa5e5970b69f9d4747f70b39b031f5e7"
checksum = "34a796731680be7931955498a16a10b2270c7762963d5d570fdbfe02dcbf314f"
dependencies = [
"arrayref",
"arrayvec",
@@ -1725,9 +1737,9 @@ dependencies = [
[[package]]
name = "bytemuck_derive"
version = "1.9.2"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ff22c2722516255d1823ce3cc4bc0b154dbc9364be5c905d6baa6eccbbc8774"
checksum = "7ecc273b49b3205b83d648f0690daa588925572cc5063745bfe547fe7ec8e1a1"
dependencies = [
"proc-macro2",
"quote",
@@ -1918,7 +1930,7 @@ version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
dependencies = [
"getrandom",
"getrandom 0.2.15",
"once_cell",
"tiny-keccak",
]
@@ -2133,9 +2145,9 @@ checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
[[package]]
name = "darling"
version = "0.20.10"
version = "0.20.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989"
checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee"
dependencies = [
"darling_core",
"darling_macro",
@@ -2143,9 +2155,9 @@ dependencies = [
[[package]]
name = "darling_core"
version = "0.20.10"
version = "0.20.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5"
checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e"
dependencies = [
"fnv",
"ident_case",
@@ -2157,9 +2169,9 @@ dependencies = [
[[package]]
name = "darling_macro"
version = "0.20.10"
version = "0.20.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"
dependencies = [
"darling_core",
"quote",
@@ -2471,9 +2483,9 @@ dependencies = [
[[package]]
name = "event-listener-strategy"
version = "0.5.3"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2"
checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93"
dependencies = [
"event-listener 5.4.0",
"pin-project-lite",
@@ -2523,9 +2535,9 @@ checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
[[package]]
name = "flate2"
version = "1.1.0"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc"
checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece"
dependencies = [
"crc32fast",
"miniz_oxide",
@@ -2679,10 +2691,22 @@ dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi",
"wasi 0.11.0+wasi-snapshot-preview1",
"wasm-bindgen",
]
[[package]]
name = "getrandom"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"wasi 0.14.2+wasi-0.2.4",
]
[[package]]
name = "gif"
version = "0.13.1"
@@ -2740,9 +2764,9 @@ dependencies = [
[[package]]
name = "glam"
version = "0.29.2"
version = "0.29.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc46dd3ec48fdd8e693a98d2b8bafae273a2d54c1de02a2a7e3d57d501f39677"
checksum = "8babf46d4c1c9d92deac9f7be466f76dfc4482b6452fc5024b5e8daf6ffeb3ee"
dependencies = [
"bytemuck",
"rand",
@@ -2943,6 +2967,7 @@ dependencies = [
"avian3d",
"bevy",
"bevy-inspector-egui",
"bevy-steamworks",
"bevy-ui-gradients",
"bevy_asset_loader",
"bevy_ballistic",
@@ -3154,10 +3179,11 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "jobserver"
version = "0.1.32"
version = "0.1.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a"
dependencies = [
"getrandom 0.3.2",
"libc",
]
@@ -3966,9 +3992,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.21.1"
version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "orbclient"
@@ -4356,9 +4382,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]]
name = "quick-xml"
version = "0.37.3"
version = "0.37.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf763ab1c7a3aa408be466efc86efe35ed1bd3dd74173ed39d6b0d0a6f0ba148"
checksum = "a4ce8c88de324ff838700f36fb6ab86c96df0e3c4ab6ef3a9b2044465cce1369"
dependencies = [
"memchr",
]
@@ -4372,6 +4398,12 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "r-efi"
version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
[[package]]
name = "radsort"
version = "0.1.1"
@@ -4405,7 +4437,7 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
"getrandom 0.2.15",
]
[[package]]
@@ -4971,6 +5003,24 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "steamworks"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a79d6f059322f73a4586cc2d0ca595ce1583104b2b1574ae1bb87f2c05bf4c67"
dependencies = [
"bitflags 1.3.2",
"lazy_static",
"steamworks-sys",
"thiserror 1.0.69",
]
[[package]]
name = "steamworks-sys"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef6b00f8fe8eaaaff22cb9b70822a48c1a5d772bc682c202a57c0b438175845"
[[package]]
name = "strict-num"
version = "0.1.1"
@@ -5474,7 +5524,7 @@ version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b"
dependencies = [
"getrandom",
"getrandom 0.2.15",
"serde",
]
@@ -5529,6 +5579,15 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasi"
version = "0.14.2+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
dependencies = [
"wit-bindgen-rt",
]
[[package]]
name = "wasm-bindgen"
version = "0.2.100"
@@ -6395,6 +6454,15 @@ dependencies = [
"memchr",
]
[[package]]
name = "wit-bindgen-rt"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
dependencies = [
"bitflags 2.9.0",
]
[[package]]
name = "x11-dl"
version = "2.21.0"

View File

@@ -31,6 +31,7 @@ bevy_sprite3d = "4.0.0"
rand = "=0.8.5"
bevy-inspector-egui = { version = "0.30", optional = true }
bevy_polyline = "0.11.0"
bevy-steamworks = "0.13.0"
bevy_ballistic = "0.1.0"
bevy-ui-gradients = "0.2.0"
bevy_debug_log = "0.5.0"
@@ -38,3 +39,6 @@ bevy_debug_log = "0.5.0"
[lints.clippy]
too_many_arguments = "allow"
type_complexity = "allow"
[patch.crates-io]
bevy-steamworks = { git = "https://github.com/Laocoon7/bevy_steamworks.git" }

View File

@@ -7,11 +7,13 @@ get_conf:
cp ~/Library/Application\ Support/Steam/config/config.vdf config.vdf
ci_conf_macos:
zip - ~/Library/Application\ Support/Steam/config/config.vdf | base64 > config.vdf_b64
cat config.vdf | gzip | base64 | pbcopy
auth:
./builder_osx/steamcmd +login $STEAM_USR $STEAM_PWD +quit
login:
./builder_osx/steamcmd +login $STEAM_USR $STEAM_PWD +quit
./builder_osx/steamcmd +login $STEAM_USR +quit
build:
./builder_osx/steamcmd +login $STEAM_USR +run_app_build ../scripts/hedz.vdf +quit

4
build/steamos/redist/launch.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
export LD_LIBRARY_PATH="."
./hedz_reloaded "$@"

Binary file not shown.

View File

@@ -23,8 +23,20 @@
"FileMapping"
{
"LocalPath" "hedz_reloaded" // all files from contentroot folder
"DepotPath" "." // mapped into the root of the depot
"LocalPath" "hedz_reloaded"
"DepotPath" "."
}
"FileMapping"
{
"LocalPath" "../redist/libsteam_api.so"
"DepotPath" "."
}
"FileMapping"
{
"LocalPath" "../redist/launch.sh"
"DepotPath" "."
}
}
}

Binary file not shown.

View File

@@ -24,21 +24,22 @@ mod tb_entities;
mod utils;
use avian3d::prelude::*;
use bevy::audio::PlaybackMode;
use bevy::audio::Volume;
use bevy::core_pipeline::tonemapping::Tonemapping;
use bevy::prelude::*;
use bevy::render::view::ColorGrading;
use bevy::{
audio::{PlaybackMode, Volume},
core_pipeline::tonemapping::Tonemapping,
prelude::*,
render::view::ColorGrading,
};
use bevy_polyline::PolylinePlugin;
use bevy_sprite3d::Sprite3dPlugin;
use bevy_steamworks::{FriendFlags, SteamworksClient, SteamworksPlugin};
use bevy_trenchbroom::prelude::*;
use bevy_ui_gradients::UiGradientsPlugin;
use camera::MainCamera;
use control::controller::CharacterControllerPlugin;
use loading_assets::AudioAssets;
use utils::billboards;
use utils::sprite_3d_animation;
use utils::squish_animation;
use std::io::{Read, Write};
use utils::{billboards, sprite_3d_animation, squish_animation};
#[derive(Resource, Reflect, Debug)]
#[reflect(Resource)]
@@ -88,6 +89,15 @@ fn main() {
}),
);
match SteamworksPlugin::init_app(1603000) {
Ok(plugin) => {
app.add_plugins(plugin);
}
Err(e) => {
error!("steam init error: {e:?}");
}
};
app.add_plugins(bevy_debug_log::LogViewerPlugin::default());
app.add_plugins(PhysicsPlugins::default());
app.add_plugins(CharacterControllerPlugin);
@@ -142,13 +152,51 @@ fn main() {
});
app.insert_resource(ClearColor(Color::BLACK));
app.add_systems(Startup, write_trenchbroom_config);
app.add_systems(
Startup,
(
write_trenchbroom_config,
steam_system.run_if(resource_exists::<SteamworksClient>),
),
);
app.add_systems(OnEnter(GameState::Playing), music);
app.add_systems(Update, (set_materials_unlit, set_tonemapping, set_shadows));
app.run();
}
fn steam_system(steam_client: Res<SteamworksClient>) {
for friend in steam_client.friends().get_friends(FriendFlags::IMMEDIATE) {
info!(
"Steam Friend: {:?} - {}({:?})",
friend.id(),
friend.name(),
friend.state()
);
}
steam_client
.remote_storage()
.set_cloud_enabled_for_app(true);
let f = steam_client.remote_storage().file("hedz_data.dat");
if f.exists() {
let mut buf = String::new();
if let Err(e) = f.read().read_to_string(&mut buf) {
error!("File read error: {}", e);
} else {
info!("File content: {}", buf);
}
} else {
info!("File does not exist");
if let Err(e) = f.write().write_all(String::from("hello world").as_bytes()) {
error!("steam cloud error: {}", e);
} else {
info!("steam cloud saved");
}
}
}
fn music(assets: Res<AudioAssets>, mut commands: Commands) {
commands.spawn((
AudioPlayer::new(assets.music.clone()),