Fix bug with minimizing crashing the game

main
Elijah C. Voigt 2 years ago
parent 2946c89f36
commit 974e878763

@ -1,3 +1,6 @@
###
# Credits text, rendered as-is from the "Credits" menu button
###
[credits]
text = """
# Martian Chess
@ -29,6 +32,9 @@ Space Blanket Folds - https://www.textures.com/download/PBR0152/133187
Background 2D art by NASA: LINK HERE
"""
###
# Intro text, typed out during normal gameplay
###
[intro]
# Higher rate is slower typing speed. Integers only!
rate = 5
@ -43,6 +49,9 @@ But Can you adapt?
Will you be a part of the universal rhyme, and if so, which side are you on?
"""
###
# Tutorial text, revealed interactively based on context
###
[tutorial]
intro = [
"""
@ -233,4 +242,4 @@ tonemapping = "ReinhardLuminance"
exposure = 2.0
gamma = 1.0
pre_saturation = 1.0
post_saturation = 1.0
post_saturation = 1.0

@ -11,10 +11,11 @@ impl Plugin for UiPlugin {
(
manage_cursor.run_if(any_component_changed::<Interaction>),
interactive_button.run_if(any_component_changed::<Interaction>),
scale_ui
.run_if(any_component_changed::<Window>)
.run_if(resource_exists::<tweak::GameTweaks>()),
scale_ui.run_if(on_event::<AssetEvent<tweak::Tweaks>>()),
scale_ui.run_if(
on_event::<AssetEvent<tweak::Tweaks>>()
.or_else(any_component_changed::<Window>)
.and_then(resource_exists::<tweak::GameTweaks>()),
),
),
);
}
@ -90,12 +91,15 @@ fn scale_ui(
*resolution_set = true;
}
// Setting UI Scale based on ratio of expected to current ratio
let width_ratio = w.resolution.width() / width;
let height_ratio = w.resolution.height() / height;
let new_scale = (width_ratio).min(height_ratio) as f64;
if ui_scale.0 != new_scale {
ui_scale.0 = new_scale;
// Check if window is minimized
if w.resolution.height() > 0.0 && w.resolution.height() > 0.0 {
// Setting UI Scale based on ratio of expected to current ratio
let width_ratio = w.resolution.width() / width;
let height_ratio = w.resolution.height() / height;
let new_scale = (width_ratio).min(height_ratio) as f64;
if ui_scale.0 != new_scale {
ui_scale.0 = new_scale;
}
}
});
}

Loading…
Cancel
Save