From d39c819000569b468cfa68977f8a8b03062ac5d9 Mon Sep 17 00:00:00 2001
From: Alexander Foremny <aforemny@posteo.de>
Date: Mon, 8 Apr 2024 13:19:15 +0200
Subject: feat: add `--scale-factor` option

---
 src/client.rs | 10 +++++++++-
 src/main.rs   |  4 ++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/client.rs b/src/client.rs
index d111732..b71b83c 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -19,6 +19,7 @@ use bevy::input::keyboard::*;
 use bevy::input::mouse::MouseButton;
 use bevy::prelude::*;
 use bevy::sprite::{MaterialMesh2dBundle, Mesh2dHandle};
+use bevy::window::*;
 use lightyear::client::connection::ConnectionManager;
 use lightyear::client::events::*;
 use lightyear::prelude::client::ClientConnection;
@@ -34,9 +35,16 @@ pub fn main(
     transport: TransportConfig,
     champion: Champion,
     faction: Faction,
+    scale_factor: f32,
 ) {
     App::new()
-        .add_plugins(DefaultPlugins)
+        .add_plugins(DefaultPlugins.set(WindowPlugin {
+            primary_window: Some(Window {
+                resolution: WindowResolution::default().with_scale_factor_override(scale_factor),
+                ..Default::default()
+            }),
+            ..Default::default()
+        }))
         .add_plugins(ClientPlugin {
             server_addr,
             client_id,
diff --git a/src/main.rs b/src/main.rs
index 210909b..4852856 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -24,6 +24,8 @@ struct Cli {
     champion: Champion,
     #[arg(long, default_value = "yellow")]
     faction: Faction,
+    #[arg(long, default_value = "1.0")]
+    scale_factor: f32,
 }
 
 fn main() {
@@ -47,6 +49,7 @@ fn main() {
             TransportConfig::UdpSocket(client_addr),
             cli.champion,
             cli.faction,
+            cli.scale_factor,
         );
     } else {
         let (from_server_send, from_server_recv) = crossbeam_channel::unbounded();
@@ -68,6 +71,7 @@ fn main() {
             },
             cli.champion,
             cli.faction,
+            cli.scale_factor,
         );
     }
 }
-- 
cgit v1.2.3