Skip to content

Commit 196df0c

Browse files
authored
Add integer scaling to Multiple resolutions demo (#985)
This also adds pixel art reference images for comparing results with various stretch settings.
1 parent ddf6d60 commit 196df0c

File tree

8 files changed

+190
-1
lines changed

8 files changed

+190
-1
lines changed

gui/multiple_resolutions/main.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,7 @@ func _on_window_scale_factor_drag_ended(_value_changed):
129129
scale_factor = $"Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowScaleFactor/HSlider".value
130130
$"Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowScaleFactor/Value".text = "%d%%" % (scale_factor * 100)
131131
get_viewport().content_scale_factor = scale_factor
132+
133+
134+
func _on_window_stretch_scale_mode_item_selected(index: int) -> void:
135+
get_viewport().content_scale_stretch = index

gui/multiple_resolutions/main.tscn

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
[gd_scene load_steps=4 format=3 uid="uid://1cywl1qtanq3"]
1+
[gd_scene load_steps=7 format=3 uid="uid://1cywl1qtanq3"]
22

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

58
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vvbdh"]
69
draw_center = false
@@ -107,6 +110,61 @@ grow_horizontal = 0
107110
grow_vertical = 0
108111
color = Color(1, 1, 1, 0.25098)
109112

113+
[node name="PixelArtExample" type="TextureRect" parent="Panel/AspectRatioContainer/Panel"]
114+
texture_filter = 1
115+
layout_mode = 1
116+
anchors_preset = 1
117+
anchor_left = 1.0
118+
anchor_right = 1.0
119+
offset_left = -88.0
120+
offset_top = 16.0
121+
offset_right = -56.0
122+
offset_bottom = 48.0
123+
grow_horizontal = 0
124+
texture = ExtResource("2_mfq7n")
125+
126+
[node name="PixelArtExample2" type="TextureRect" parent="Panel/AspectRatioContainer/Panel"]
127+
texture_filter = 1
128+
layout_mode = 1
129+
anchors_preset = 1
130+
anchor_left = 1.0
131+
anchor_right = 1.0
132+
offset_left = -48.0
133+
offset_top = 16.0
134+
offset_right = -16.0
135+
offset_bottom = 48.0
136+
grow_horizontal = 0
137+
rotation = 0.785398
138+
pivot_offset = Vector2(16, 16)
139+
texture = ExtResource("2_mfq7n")
140+
141+
[node name="PixelArtCheckerboardExample" type="TextureRect" parent="Panel/AspectRatioContainer/Panel"]
142+
modulate = Color(1, 1, 1, 0.752941)
143+
texture_filter = 1
144+
layout_mode = 1
145+
anchors_preset = 1
146+
anchor_left = 1.0
147+
anchor_right = 1.0
148+
offset_left = -136.0
149+
offset_top = 16.0
150+
offset_right = -104.0
151+
offset_bottom = 48.0
152+
grow_horizontal = 0
153+
texture = ExtResource("3_unurd")
154+
155+
[node name="PixelArtTextExample" type="TextureRect" parent="Panel/AspectRatioContainer/Panel"]
156+
texture_filter = 1
157+
layout_mode = 1
158+
anchors_preset = 1
159+
anchor_left = 1.0
160+
anchor_right = 1.0
161+
offset_left = -215.0
162+
offset_top = 56.0
163+
offset_right = -16.0
164+
offset_bottom = 75.0
165+
grow_horizontal = 0
166+
texture = ExtResource("3_0qxym")
167+
110168
[node name="CenterContainer" type="CenterContainer" parent="Panel/AspectRatioContainer/Panel"]
111169
layout_mode = 1
112170
anchors_preset = 15
@@ -130,6 +188,7 @@ horizontal_alignment = 1
130188
layout_mode = 2
131189

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

@@ -159,6 +218,7 @@ popup/item_7/id = 7
159218
layout_mode = 2
160219

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

@@ -178,6 +238,7 @@ popup/item_2/id = 2
178238
layout_mode = 2
179239

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

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

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

@@ -218,13 +280,32 @@ layout_mode = 2
218280
size_flags_horizontal = 3
219281
text = "100%"
220282

283+
[node name="WindowStretchScaleMode" type="HBoxContainer" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options"]
284+
layout_mode = 2
285+
286+
[node name="Label" type="Label" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchScaleMode"]
287+
custom_minimum_size = Vector2(220, 0)
288+
layout_mode = 2
289+
text = "Window Stretch Scale Mode"
290+
291+
[node name="OptionButton" type="OptionButton" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchScaleMode"]
292+
layout_mode = 2
293+
size_flags_horizontal = 3
294+
item_count = 2
295+
selected = 0
296+
popup/item_0/text = "Fractional"
297+
popup/item_0/id = 0
298+
popup/item_1/text = "Integer"
299+
popup/item_1/id = 1
300+
221301
[node name="HSeparator" type="HSeparator" parent="Panel/AspectRatioContainer/Panel/CenterContainer/Options"]
222302
layout_mode = 2
223303

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

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

@@ -252,6 +333,7 @@ popup/item_6/id = 6
252333
layout_mode = 2
253334

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

@@ -270,5 +352,6 @@ text = "0"
270352
[connection signal="item_selected" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchMode/OptionButton" to="." method="_on_window_stretch_mode_item_selected"]
271353
[connection signal="item_selected" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchAspect/OptionButton" to="." method="_on_window_stretch_aspect_item_selected"]
272354
[connection signal="drag_ended" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowScaleFactor/HSlider" to="." method="_on_window_scale_factor_drag_ended"]
355+
[connection signal="item_selected" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/WindowStretchScaleMode/OptionButton" to="." method="_on_window_stretch_scale_mode_item_selected"]
273356
[connection signal="item_selected" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMaxAspectRatio/OptionButton" to="." method="_on_gui_aspect_ratio_item_selected"]
274357
[connection signal="drag_ended" from="Panel/AspectRatioContainer/Panel/CenterContainer/Options/GUIMargin/HSlider" to="." method="_on_gui_margin_drag_ended"]
48 Bytes
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://c43k4wledw7py"
6+
path="res://.godot/imported/pixel_art_checkerboard_example.webp-6f8f9ae2343a90f4ff1c14b66b34ee14.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://pixel_art_checkerboard_example.webp"
14+
dest_files=["res://.godot/imported/pixel_art_checkerboard_example.webp-6f8f9ae2343a90f4ff1c14b66b34ee14.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1
144 Bytes
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://dnhldrc8cymrs"
6+
path="res://.godot/imported/pixel_art_example.webp-cbf401b3e4c2305f24ee0e78bd5f54d8.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://pixel_art_example.webp"
14+
dest_files=["res://.godot/imported/pixel_art_example.webp-cbf401b3e4c2305f24ee0e78bd5f54d8.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1
166 Bytes
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://cok02ms2cxmut"
6+
path="res://.godot/imported/pixel_art_text_example.webp-3f539541de3c402a34e5c1c555729154.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://pixel_art_text_example.webp"
14+
dest_files=["res://.godot/imported/pixel_art_text_example.webp-3f539541de3c402a34e5c1c555729154.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1

0 commit comments

Comments
 (0)