Skip to content

Commit

Permalink
Add integer scaling to Multiple resolutions demo (#985)
Browse files Browse the repository at this point in the history
This also adds pixel art reference images for comparing results
with various stretch settings.
  • Loading branch information
Calinou authored Feb 7, 2024
1 parent ddf6d60 commit 196df0c
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gui/multiple_resolutions/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,7 @@ func _on_window_scale_factor_drag_ended(_value_changed):
scale_factor = $"Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowScaleFactor/HSlider".value
$"Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowScaleFactor/Value".text = "%d%%" % (scale_factor * 100)
get_viewport().content_scale_factor = scale_factor


func _on_window_stretch_scale_mode_item_selected(index: int) -> void:
get_viewport().content_scale_stretch = index
85 changes: 84 additions & 1 deletion gui/multiple_resolutions/main.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://1cywl1qtanq3"]
[gd_scene load_steps=7 format=3 uid="uid://1cywl1qtanq3"]

[ext_resource type="Script" path="res://main.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://dnhldrc8cymrs" path="res://pixel_art_example.webp" id="2_mfq7n"]
[ext_resource type="Texture2D" uid="uid://cok02ms2cxmut" path="res://pixel_art_text_example.webp" id="3_0qxym"]
[ext_resource type="Texture2D" uid="uid://c43k4wledw7py" path="res://pixel_art_checkerboard_example.webp" id="3_unurd"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vvbdh"]
draw_center = false
Expand Down Expand Up @@ -107,6 +110,61 @@ grow_horizontal = 0
grow_vertical = 0
color = Color(1, 1, 1, 0.25098)

[node name="PixelArtExample" type="TextureRect" parent="Panel/AspectRatioContainer/Panel"]
texture_filter = 1
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -88.0
offset_top = 16.0
offset_right = -56.0
offset_bottom = 48.0
grow_horizontal = 0
texture = ExtResource("2_mfq7n")

[node name="PixelArtExample2" type="TextureRect" parent="Panel/AspectRatioContainer/Panel"]
texture_filter = 1
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -48.0
offset_top = 16.0
offset_right = -16.0
offset_bottom = 48.0
grow_horizontal = 0
rotation = 0.785398
pivot_offset = Vector2(16, 16)
texture = ExtResource("2_mfq7n")

[node name="PixelArtCheckerboardExample" type="TextureRect" parent="Panel/AspectRatioContainer/Panel"]
modulate = Color(1, 1, 1, 0.752941)
texture_filter = 1
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -136.0
offset_top = 16.0
offset_right = -104.0
offset_bottom = 48.0
grow_horizontal = 0
texture = ExtResource("3_unurd")

[node name="PixelArtTextExample" type="TextureRect" parent="Panel/AspectRatioContainer/Panel"]
texture_filter = 1
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -215.0
offset_top = 56.0
offset_right = -16.0
offset_bottom = 75.0
grow_horizontal = 0
texture = ExtResource("3_0qxym")

[node name="CenterContainer" type="CenterContainer" parent="Panel/AspectRatioContainer/Panel"]
layout_mode = 1
anchors_preset = 15
Expand All @@ -130,6 +188,7 @@ horizontal_alignment = 1
layout_mode = 2

[node name="Label" type="Label" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowBaseSize"]
custom_minimum_size = Vector2(220, 0)
layout_mode = 2
text = "Window Base Size"

Expand Down Expand Up @@ -159,6 +218,7 @@ popup/item_7/id = 7
layout_mode = 2

[node name="Label" type="Label" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchMode"]
custom_minimum_size = Vector2(220, 0)
layout_mode = 2
text = "Window Stretch Mode"

Expand All @@ -178,6 +238,7 @@ popup/item_2/id = 2
layout_mode = 2

[node name="Label" type="Label" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchAspect"]
custom_minimum_size = Vector2(220, 0)
layout_mode = 2
text = "Window Stretch Aspect"

Expand All @@ -201,6 +262,7 @@ popup/item_4/id = 4
layout_mode = 2

[node name="Label" type="Label" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowScaleFactor"]
custom_minimum_size = Vector2(220, 0)
layout_mode = 2
text = "Window Scale Factor"

Expand All @@ -218,13 +280,32 @@ layout_mode = 2
size_flags_horizontal = 3
text = "100%"

[node name="WindowStretchScaleMode" type="HBoxContainer" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options"]
layout_mode = 2

[node name="Label" type="Label" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchScaleMode"]
custom_minimum_size = Vector2(220, 0)
layout_mode = 2
text = "Window Stretch Scale Mode"

[node name="OptionButton" type="OptionButton" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchScaleMode"]
layout_mode = 2
size_flags_horizontal = 3
item_count = 2
selected = 0
popup/item_0/text = "Fractional"
popup/item_0/id = 0
popup/item_1/text = "Integer"
popup/item_1/id = 1

[node name="HSeparator" type="HSeparator" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options"]
layout_mode = 2

[node name="GUIMaxAspectRatio" type="HBoxContainer" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options"]
layout_mode = 2

[node name="Label" type="Label" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMaxAspectRatio"]
custom_minimum_size = Vector2(220, 0)
layout_mode = 2
text = "GUI Max Aspect Ratio"

Expand Down Expand Up @@ -252,6 +333,7 @@ popup/item_6/id = 6
layout_mode = 2

[node name="Label" type="Label" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMargin"]
custom_minimum_size = Vector2(220, 0)
layout_mode = 2
text = "GUI Margin"

Expand All @@ -270,5 +352,6 @@ text = "0"
[connection signal="item_selected" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchMode/OptionButton" to="." method="_on_window_stretch_mode_item_selected"]
[connection signal="item_selected" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchAspect/OptionButton" to="." method="_on_window_stretch_aspect_item_selected"]
[connection signal="drag_ended" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowScaleFactor/HSlider" to="." method="_on_window_scale_factor_drag_ended"]
[connection signal="item_selected" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchScaleMode/OptionButton" to="." method="_on_window_stretch_scale_mode_item_selected"]
[connection signal="item_selected" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMaxAspectRatio/OptionButton" to="." method="_on_gui_aspect_ratio_item_selected"]
[connection signal="drag_ended" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMargin/HSlider" to="." method="_on_gui_margin_drag_ended"]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://c43k4wledw7py"
path="res://.godot/imported/pixel_art_checkerboard_example.webp-6f8f9ae2343a90f4ff1c14b66b34ee14.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://pixel_art_checkerboard_example.webp"
dest_files=["res://.godot/imported/pixel_art_checkerboard_example.webp-6f8f9ae2343a90f4ff1c14b66b34ee14.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added gui/multiple_resolutions/pixel_art_example.webp
Binary file not shown.
34 changes: 34 additions & 0 deletions gui/multiple_resolutions/pixel_art_example.webp.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dnhldrc8cymrs"
path="res://.godot/imported/pixel_art_example.webp-cbf401b3e4c2305f24ee0e78bd5f54d8.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://pixel_art_example.webp"
dest_files=["res://.godot/imported/pixel_art_example.webp-cbf401b3e4c2305f24ee0e78bd5f54d8.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added gui/multiple_resolutions/pixel_art_text_example.webp
Binary file not shown.
34 changes: 34 additions & 0 deletions gui/multiple_resolutions/pixel_art_text_example.webp.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cok02ms2cxmut"
path="res://.godot/imported/pixel_art_text_example.webp-3f539541de3c402a34e5c1c555729154.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://pixel_art_text_example.webp"
dest_files=["res://.godot/imported/pixel_art_text_example.webp-3f539541de3c402a34e5c1c555729154.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

0 comments on commit 196df0c

Please sign in to comment.