Skip to content

Commit a043e5a

Browse files
committed
Update preview texture resolution ratio
1 parent f8e6528 commit a043e5a

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

addons/gaea/editor/editor_settings.gd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const LINE_CURVATURE := "gaea/graph/line_curvature"
77
const LINE_THICKNESS := "gaea/graph/line_thickness"
88
const MINIMAP_OPACITY := "gaea/graph/minimap_opacity"
99
const GRID_PATTERN := "gaea/graph/grid_pattern"
10+
const PREVIEW_RESOLUTION := "gaea/graph/preview_resolution"
1011
const OUTPUT_TITLE_COLOR := "gaea/graph/output_title_color"
1112
const COLOR_BASE := "gaea/graph/slot_colors/%s"
1213
const ICON_BASE := "gaea/graph/slot_icons/%s"
@@ -49,6 +50,9 @@ func add_settings() -> void:
4950
"hint": PROPERTY_HINT_ENUM,
5051
"hint_string": "Lines,Dots"
5152
})
53+
_add_setting(PREVIEW_RESOLUTION, 64, {
54+
"type": TYPE_INT
55+
})
5256

5357
_add_setting(OUTPUT_TITLE_COLOR, Color("632639"), {"type": TYPE_COLOR, "hint": PROPERTY_HINT_COLOR_NO_ALPHA})
5458

@@ -122,3 +126,7 @@ static func get_minimap_opacity() -> float:
122126

123127
static func get_grid_pattern() -> int:
124128
return EditorInterface.get_editor_settings().get_setting(GRID_PATTERN)
129+
130+
131+
static func get_preview_resolution() -> int:
132+
return EditorInterface.get_editor_settings().get_setting(PREVIEW_RESOLUTION)

addons/gaea/graph/components/preview_texture.gd

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
extends TextureRect
33

44

5-
const RESOLUTION: Vector2i = Vector2i(64, 64)
6-
75
var selected_output: StringName
86
var node: GaeaGraphNode
97
var slider_container: HBoxContainer
@@ -15,8 +13,8 @@ func _ready() -> void:
1513
if is_part_of_edited_scene():
1614
return
1715

18-
expand_mode = EXPAND_FIT_HEIGHT
19-
stretch_mode = STRETCH_SCALE
16+
expand_mode = EXPAND_FIT_HEIGHT_PROPORTIONAL
17+
stretch_mode = STRETCH_KEEP_ASPECT
2018

2119
await get_tree().process_frame
2220

@@ -50,8 +48,8 @@ func _ready() -> void:
5048

5149
get_parent().add_child(slider_container)
5250

53-
texture = ImageTexture.create_from_image(Image.create_empty(RESOLUTION.x, RESOLUTION.y, true, Image.FORMAT_RGBA8))
54-
51+
var preview_resolution = GaeaEditorSettings.get_preview_resolution()
52+
texture = ImageTexture.create_from_image(Image.create_empty(preview_resolution, preview_resolution, true, Image.FORMAT_RGBA8))
5553

5654
func toggle(for_output: StringName) -> void:
5755
if not get_parent().visible:
@@ -71,9 +69,10 @@ func update() -> void:
7169
if not is_visible_in_tree():
7270
return
7371

74-
var resolution: Vector2i = RESOLUTION
72+
var preview_resolution = GaeaEditorSettings.get_preview_resolution()
73+
var resolution := Vector2i(preview_resolution, preview_resolution)
7574
if is_instance_valid(node.generator):
76-
resolution = resolution.min(Vector2i(node.generator.world_size.x, node.generator.world_size.y))
75+
resolution.x = roundi(float(resolution.x) * float(node.generator.world_size.x) / float(node.generator.world_size.y))
7776

7877
var data: Dictionary = node.resource.traverse(
7978
selected_output,

0 commit comments

Comments
 (0)