Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,29 @@ jobs:
name: coverage
path: coverage/**

- name: Upload Rust coverage to Codecov
- name: Upload Rust coverage to Codecov (Cobertura)
if: ${{ always() }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/rust/cobertura.xml
flags: rust
name: rust-coverage
fail_ci_if_error: true
fail_ci_if_error: false
verbose: true
disable_search: true

- name: Upload Rust coverage to Codecov (LCOV fallback)
if: ${{ always() && hashFiles('coverage/rust/lcov.info') != '' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/rust/lcov.info
flags: rust
name: rust-coverage-lcov
fail_ci_if_error: false
verbose: true
disable_search: true

- name: Upload Python coverage to Codecov
if: ${{ always() }}
Expand All @@ -93,7 +107,9 @@ jobs:
files: coverage/python/coverage.xml
flags: python
name: python-coverage
fail_ci_if_error: true
fail_ci_if_error: false
verbose: true
disable_search: true

- name: Upload Frontend coverage to Codecov (if present)
if: ${{ hashFiles('coverage/frontend/lcov.info') != '' || hashFiles('coverage/frontend/coverage-final.json') != '' }}
Expand All @@ -105,4 +121,6 @@ jobs:
coverage/frontend/coverage-final.json
flags: frontend
name: frontend-coverage
fail_ci_if_error: true
fail_ci_if_error: false
verbose: true
disable_search: true
10 changes: 8 additions & 2 deletions .github/workflows/tauri-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
matrix:
include:
- runner: ubuntu-latest
tauriArgs: '-b deb rpm'
tauriArgs: '-b appimage deb rpm'
artifactSuffix: linux
- runner: windows-latest
tauriArgs: ''
Expand All @@ -41,6 +41,9 @@ jobs:
- name: Install UI deps
run: npm ci --prefix apps/tauri/ui

- name: Build UI
run: npm run build --prefix apps/tauri/ui

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

Expand Down Expand Up @@ -118,7 +121,7 @@ jobs:
matrix:
include:
- runner: ubuntu-latest
tauriArgs: '-b deb rpm'
tauriArgs: '-b appimage deb rpm'
- runner: windows-latest
tauriArgs: ''
- runner: macos-14
Expand All @@ -137,6 +140,9 @@ jobs:
- name: Install UI deps
run: npm ci --prefix apps/tauri/ui

- name: Build UI
run: npm run build --prefix apps/tauri/ui

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

Expand Down
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rusty_runways_tauri"
version = "2.2.1"
version = "3.0.0"
edition = "2021"

[dependencies]
Expand Down
Binary file added apps/tauri/src-tauri/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/128x128@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/Square142x142Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/Square150x150Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/Square284x284Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/Square30x30Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/Square310x310Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/Square44x44Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/Square71x71Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/Square89x89Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/tauri/src-tauri/icons/icon.icns
Binary file not shown.
Binary file added apps/tauri/src-tauri/icons/icon.ico
Binary file not shown.
Binary file added apps/tauri/src-tauri/icons/icon.png
93 changes: 86 additions & 7 deletions apps/tauri/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::sync::Mutex;

use rusty_runways_core::game::Observation;
use rusty_runways_core::statistics::DailyStats;
use rusty_runways_core::utils::airplanes::models::AirplaneModel;
use rusty_runways_core::Game;
use serde::{Deserialize, Serialize};
Expand All @@ -11,6 +12,16 @@ use std::path::Path;
use strum::IntoEnumIterator;
use tauri::State;

#[derive(Serialize)]
struct PlayerSnapshotDto {
cash: f32,
fleet_size: usize,
orders_delivered: usize,
daily_income: f32,
daily_expenses: f32,
day: u64,
}

#[derive(Default)]
struct AppState {
game: Mutex<Option<Game>>,
Expand Down Expand Up @@ -74,6 +85,27 @@ fn advance(state: State<AppState>, hours: u64) -> Result<Observation, String> {
Ok(game.observe())
}

#[tauri::command]
fn stats_cmd(state: State<AppState>) -> Result<Vec<DailyStats>, String> {
let guard = state.game.lock().map_err(|_| "state poisoned")?;
let game = guard.as_ref().ok_or("no game running")?;
Ok(game.stats.clone())
}

#[tauri::command]
fn player_snapshot(state: State<AppState>) -> Result<PlayerSnapshotDto, String> {
let guard = state.game.lock().map_err(|_| "state poisoned")?;
let g = guard.as_ref().ok_or("no game running")?;
Ok(PlayerSnapshotDto {
cash: g.player.cash,
fleet_size: g.player.fleet_size,
orders_delivered: g.player.orders_delivered,
daily_income: g.daily_income,
daily_expenses: g.daily_expenses,
day: g.time / 24,
})
}

#[tauri::command]
fn depart_plane(state: State<AppState>, plane: usize, dest: usize) -> Result<(), String> {
let mut guard = state.game.lock().map_err(|_| "state poisoned")?;
Expand All @@ -95,6 +127,13 @@ fn unload_order(state: State<AppState>, order: usize, plane: usize) -> Result<()
game.unload_order(order, plane).map_err(|e| e.to_string())
}

#[tauri::command]
fn unload_orders(state: State<AppState>, orders: Vec<usize>, plane: usize) -> Result<(), String> {
let mut guard = state.game.lock().map_err(|_| "state poisoned")?;
let game = guard.as_mut().ok_or("no game running")?;
game.unload_orders(orders, plane).map_err(|e| e.to_string())
}

#[tauri::command]
fn unload_all(state: State<AppState>, plane: usize) -> Result<(), String> {
let mut guard = state.game.lock().map_err(|_| "state poisoned")?;
Expand Down Expand Up @@ -129,9 +168,11 @@ struct OrderDto {
id: usize,
destination_id: usize,
value: f32,
weight: f32,
deadline: u64,
cargo_type: String,
payload_kind: String,
cargo_type: Option<String>,
weight: Option<f32>,
passenger_count: Option<u32>,
}

#[derive(Serialize)]
Expand All @@ -145,6 +186,8 @@ struct PlaneInfoDto {
fuel_capacity: f32,
payload_current: f32,
payload_capacity: f32,
passenger_current: u32,
passenger_capacity: u32,
current_airport_id: Option<usize>,
manifest: Vec<OrderDto>,
}
Expand Down Expand Up @@ -173,9 +216,11 @@ fn plane_info(state: State<AppState>, plane_id: usize) -> Result<PlaneInfoDto, S
id: o.id,
destination_id: o.destination_id,
value: o.value,
weight: o.weight,
deadline: o.deadline,
cargo_type: format!("{:?}", o.name),
payload_kind: o.payload.kind_label().to_string(),
cargo_type: o.cargo_type().map(|c| format!("{:?}", c)),
weight: o.cargo_weight(),
passenger_count: o.passenger_count(),
})
.collect();

Expand All @@ -189,6 +234,8 @@ fn plane_info(state: State<AppState>, plane_id: usize) -> Result<PlaneInfoDto, S
fuel_capacity: plane.specs.fuel_capacity,
payload_current: plane.current_payload,
payload_capacity: plane.specs.payload_capacity,
passenger_current: plane.current_passengers,
passenger_capacity: plane.specs.passenger_capacity,
current_airport_id,
manifest,
})
Expand All @@ -210,9 +257,11 @@ fn airport_orders(state: State<AppState>, airport_id: usize) -> Result<Vec<Order
id: o.id,
destination_id: o.destination_id,
value: o.value,
weight: o.weight,
deadline: o.deadline,
cargo_type: format!("{:?}", o.name),
payload_kind: o.payload.kind_label().to_string(),
cargo_type: o.cargo_type().map(|c| format!("{:?}", c)),
weight: o.cargo_weight(),
passenger_count: o.passenger_count(),
})
.collect();
Ok(orders)
Expand All @@ -227,12 +276,37 @@ struct ModelDto {
fuel_consumption: f32,
operating_cost: f32,
payload_capacity: f32,
passenger_capacity: u32,
purchase_price: f32,
min_runway_length: f32,
role: String,
}

#[tauri::command]
fn list_models() -> Vec<ModelDto> {
fn list_models(state: State<AppState>) -> Vec<ModelDto> {
// If a game is running, use its catalog; otherwise fall back to built-ins
if let Ok(guard) = state.game.lock() {
if let Some(game) = guard.as_ref() {
return game
.available_models()
.into_iter()
.map(|(name, s)| ModelDto {
name,
mtow: s.mtow,
cruise_speed: s.cruise_speed,
fuel_capacity: s.fuel_capacity,
fuel_consumption: s.fuel_consumption,
operating_cost: s.operating_cost,
payload_capacity: s.payload_capacity,
passenger_capacity: s.passenger_capacity,
purchase_price: s.purchase_price,
min_runway_length: s.min_runway_length,
role: format!("{:?}", s.role),
})
.collect();
}
}

AirplaneModel::iter()
.map(|m| {
let s = m.specs();
Expand All @@ -244,8 +318,10 @@ fn list_models() -> Vec<ModelDto> {
fuel_consumption: s.fuel_consumption,
operating_cost: s.operating_cost,
payload_capacity: s.payload_capacity,
passenger_capacity: s.passenger_capacity,
purchase_price: s.purchase_price,
min_runway_length: s.min_runway_length,
role: format!("{:?}", s.role),
}
})
.collect()
Expand Down Expand Up @@ -364,6 +440,7 @@ fn main() {
depart_plane,
load_order,
unload_order,
unload_orders,
unload_all,
refuel_plane,
maintenance,
Expand All @@ -377,6 +454,8 @@ fn main() {
start_from_config_yaml,
start_from_config_path,
list_saves,
stats_cmd,
player_snapshot,
])
.setup(|_app| Ok(()))
.run(tauri::generate_context!())
Expand Down
7 changes: 2 additions & 5 deletions apps/tauri/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "RustyRunways",
"version": "2.2.1",
"version": "3.0.0",
"identifier": "com.rustyrunways.desktop",
"build": {
"beforeDevCommand": "npm run dev -- --host localhost --port 5173 --strictPort",
"beforeBuildCommand": "npm run build",
"devUrl": "http://localhost:5173",
"frontendDist": "../ui/dist"
},
Expand All @@ -26,8 +24,7 @@
"active": true,
"icon": [
"icons/icon.icns",
"icons/icon.ico",
"icons/icon.png"
"icons/icon.ico"
]
}
}
2 changes: 1 addition & 1 deletion apps/tauri/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vite_react_shadcn_ts",
"private": true,
"version": "2.2.1",
"version": "3.0.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
Loading
Loading