kitgit

tirbofish/dropbear · commit

7e2ec0f7a276fa0ecf97fba51683776d8a8a75bf

fix: window resizing, done for today jarvis, run github actions

Unverified

Thribhu K <4tkbytes@pm.me> · 2026-02-21 10:45

view full diff

diff --git a/crates/eucalyptus-editor/src/about.rs b/crates/eucalyptus-editor/src/about.rs
index 43057d8..d5c7c38 100644
--- a/crates/eucalyptus-editor/src/about.rs
+++ b/crates/eucalyptus-editor/src/about.rs
@@ -45,38 +45,28 @@ impl Scene for AboutWindow {
         graphics: std::sync::Arc<dropbear_engine::graphics::SharedGraphicsContext>,
     ) {
         CentralPanel::default().show(&graphics.get_egui_context(), |ui| {
-            ui.centered_and_justified(|ui| {
+            ui.vertical_centered(|ui| {
                 ui.add_space(8.0);
-
                 ui.heading("eucalyptus editor");
                 ui.label(egui::RichText::new("Built on the dropbear engine").weak());
-
                 ui.add_space(12.0);
-
-                ui.label("Made with love by tirbofish ♥️");
-
+                ui.label("Made with love by tirbofish ♥");
                 ui.add_space(12.0);
-
-                ui.horizontal(|ui| {
+                ui.horizontal_wrapped(|ui| {
                     ui.label("Check out the repository at");
-                    if ui.label("https://github.com/tirbofish/dropbear").clicked() {
-                        let _ = open::that("https://github.com/tirbofish/dropbear");
-                    }
+                    ui.hyperlink("https://github.com/tirbofish/dropbear")
                 });
-
                 ui.add_space(12.0);
-
                 ui.label(
                     egui::RichText::new(format!(
                         "Built on commit {} with {}",
                         env!("GIT_HASH"),
                         rustc_version_runtime::version_meta().short_version_string
                     ))
-                    .weak()
-                    .italics()
-                    .small(),
+                        .weak()
+                        .italics()
+                        .small(),
                 );
-
                 ui.add_space(8.0);
             });
         });
diff --git a/crates/redback-runtime/src/lib.rs b/crates/redback-runtime/src/lib.rs
index a3a174f..60297d6 100644
--- a/crates/redback-runtime/src/lib.rs
+++ b/crates/redback-runtime/src/lib.rs
@@ -565,58 +565,79 @@ impl DisplaySettings {
             graphics.viewport_texture.size.width,
             graphics.viewport_texture.size.height,
         );
+        let mut window_mode_changed = self.window_mode != self.last_window_mode;
 
-        let needs_update = self.window_mode != self.last_window_mode
-            || self.vsync != self.last_vsync
-            || size != self.last_size;
+        if !window_mode_changed {
+            let actual_mode = if let Some(fullscreen) = window.fullscreen() {
+                match fullscreen {
+                    Fullscreen::Exclusive(_) => WindowMode::Fullscreen,
+                    Fullscreen::Borderless(_) => WindowMode::BorderlessFullscreen,
+                }
+            } else if window.is_maximized() {
+                WindowMode::Maximized
+            } else {
+                WindowMode::Windowed
+            };
+
+            if actual_mode != self.window_mode {
+                self.window_mode = actual_mode;
+                window_mode_changed = true;
+            }
+        }
 
-        if !needs_update {
+        let size_changed = size != self.last_size;
+        let vsync_changed = self.vsync != self.last_vsync;
+        let needs_config_update = window_mode_changed || vsync_changed || size_changed;
+
+        if !window_mode_changed && !needs_config_update {
             return;
         }
 
-        match self.window_mode {
-            WindowMode::Windowed => {
-                window.set_fullscreen(None);
-                window.set_maximized(false);
-            }
-            WindowMode::Maximized => {
-                window.set_fullscreen(None);
-                window.set_maximized(true);
-            }
-            WindowMode::Fullscreen => {
-                let monitor = window.current_monitor();
-                let fullscreen = monitor
-                    .as_ref()
-                    .and_then(|m| m.video_modes().next())
-                    .map(Fullscreen::Exclusive)
-                    .or_else(|| Some(Fullscreen::Borderless(monitor)));
-
-                window.set_fullscreen(fullscreen);
-                window.set_maximized(false);
-            }
-            WindowMode::BorderlessFullscreen => {
-                let monitor = window.current_monitor();
-                window.set_fullscreen(Some(Fullscreen::Borderless(monitor)));
-                window.set_maximized(false);
+        if window_mode_changed {
+            match self.window_mode {
+                WindowMode::Windowed => {
+                    window.set_fullscreen(None);
+                    window.set_maximized(false);
+                }
+                WindowMode::Maximized => {
+                    window.set_fullscreen(None);
+                    window.set_maximized(true);
+                }
+                WindowMode::Fullscreen => {
+                    let monitor = window.current_monitor();
+                    let fullscreen = monitor
+                        .as_ref()
+                        .and_then(|m| m.video_modes().next())
+                        .map(Fullscreen::Exclusive)
+                        .or_else(|| Some(Fullscreen::Borderless(monitor)));
+
+                    window.set_fullscreen(fullscreen);
+                    window.set_maximized(false);
+                }
+                WindowMode::BorderlessFullscreen => {
+                    let monitor = window.current_monitor();
+                    window.set_fullscreen(Some(Fullscreen::Borderless(monitor)));
+                    window.set_maximized(false);
+                }
             }
         }
 
-        let config = SurfaceConfiguration {
-            usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
-            format: graphics.surface_format,
-            width: graphics.viewport_texture.size.width,
-            height: graphics.viewport_texture.size.height,
-            present_mode: if self.vsync {
-                wgpu::PresentMode::AutoVsync
-            } else {
-                wgpu::PresentMode::AutoNoVsync
-            },
-            alpha_mode: wgpu::CompositeAlphaMode::Auto,
-            view_formats: vec![],
-            desired_maximum_frame_latency: 2,
-        };
+        if needs_config_update {
+            let config = SurfaceConfiguration {
+                usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
+                format: graphics.surface_format,
+                width: graphics.viewport_texture.size.width,
+                height: graphics.viewport_texture.size.height,
+                present_mode: if self.vsync {
+                    wgpu::PresentMode::AutoVsync
+                } else {
+                    wgpu::PresentMode::AutoNoVsync
+                },
+                alpha_mode: wgpu::CompositeAlphaMode::Auto,
+                view_formats: vec![],
+                desired_maximum_frame_latency: 2,
+            };
 
-        {
             let mut cfg = graphics.surface_config.write();
             *cfg = config;
         }
diff --git a/crates/redback-runtime/src/scene.rs b/crates/redback-runtime/src/scene.rs
index 57d2b0c..7b3edf3 100644
--- a/crates/redback-runtime/src/scene.rs
+++ b/crates/redback-runtime/src/scene.rs
@@ -286,6 +286,30 @@ impl Scene for PlayMode {
 
         self.display_settings.update(graphics.clone());
 
+        if matches!(self.scene_command, SceneCommand::None) {
+            let window_size = graphics.window.inner_size();
+            if window_size.width > 0 && window_size.height > 0 {
+                let current = graphics.viewport_texture.size;
+                if current.width != window_size.width || current.height != window_size.height {
+                    self.scene_command =
+                        SceneCommand::ResizeViewport((window_size.width, window_size.height));
+                }
+            }
+        }
+
+        {
+            let window_size = graphics.window.inner_size();
+            let size_changed = window_size.width != self.display_settings.last_size.0
+                || window_size.height != self.display_settings.last_size.1;
+            if size_changed && window_size.height > 0 {
+                if let Some(active_camera) = self.active_camera {
+                    if let Ok(cam) = self.world.query_one_mut::<&mut Camera>(active_camera) {
+                        cam.aspect = window_size.width as f64 / window_size.height as f64;
+                    }
+                }
+            }
+        }
+
         {
             if let Some(fps) = PROJECT.read().runtime_settings.target_fps.get() {
                 log_once::debug_once!("setting new fps for play mode session: {}", fps);
diff --git a/scripting/commonMain/kotlin/com/dropbear/animation/AnimationComponent.kt b/scripting/commonMain/kotlin/com/dropbear/animation/AnimationComponent.kt
index 8994769..c35c2e4 100644
--- a/scripting/commonMain/kotlin/com/dropbear/animation/AnimationComponent.kt
+++ b/scripting/commonMain/kotlin/com/dropbear/animation/AnimationComponent.kt
@@ -54,10 +54,10 @@ class AnimationComponent(val parentEntity: EntityId) : Component(parentEntity, "
         time = 0.0
     }
 
-    fun setAnimation(index: Int, speed: Double = 1.0) = setActiveAnimationIndex(index).let { setSpeed(speed) }
-    fun setAnimation(animationName: String, speed: Double = 1.0) {
+    fun setAnimation(index: Int) = setActiveAnimationIndex(index)
+    fun setAnimation(animationName: String) {
         val index = getIndexFromString(animationName) ?: return
-        setActiveAnimationIndex(index).let { setSpeed(speed) }
+        setActiveAnimationIndex(index)
     }
 
     companion object : ComponentType<AnimationComponent> {