Skip to content

Fix float editing in environment editor + fix logic issue in FloatEdit + add class_name #823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ func set_value(index, variable, value, force = false):
environments[index][variable] = serialized_value
if variable == "hdri_url":
await read_hdr(index, value)
emit_signal("environment_updated", index)
environment_updated.emit(index)
elif variable == "name":
emit_signal("name_updated", index, value)
name_updated.emit(index, value)
else:
emit_signal("environment_updated", index)
environment_updated.emit(index)
update_thumbnail(index)

func apply_environment(index: int, e: Environment, s: DirectionalLight3D, bg_color := Color.TRANSPARENT, force_color := false) -> void:
Expand Down
5 changes: 3 additions & 2 deletions material_maker/widgets/float_edit/float_edit.gd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
class_name FloatEdit
extends Container

var float_value: float = 0.5
Expand Down Expand Up @@ -59,9 +60,9 @@ var mode := Modes.IDLE:
var editable := true:
set(val):
if val:
mode = Modes.UNEDITABLE
else:
mode = Modes.IDLE
else:
mode = Modes.UNEDITABLE
get:
return mode != Modes.UNEDITABLE

Expand Down
2 changes: 1 addition & 1 deletion material_maker/widgets/float_edit/float_edit.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://rflulhsuy3ax"]

[ext_resource type="Script" path="res://material_maker/widgets/float_edit/float_edit.gd" id="1"]
[ext_resource type="Script" uid="uid://c4own5hljyjue" path="res://material_maker/widgets/float_edit/float_edit.gd" id="1"]

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_t5q7m"]
content_margin_left = 3.0
Expand Down
15 changes: 8 additions & 7 deletions material_maker/windows/environment_editor/environment_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ func _unhandled_input(event: InputEvent) -> void:

func connect_controls() -> void:
for c in ui.get_children():
if c is LineEdit:
if c.get_script() == preload("res://material_maker/widgets/float_edit/float_edit.gd"):
c.connect("value_changed", Callable(self, "set_environment_value").bind(c.name))
else:
c.connect("text_submitted", Callable(self, "set_environment_value").bind(c.name))
if c is FloatEdit:
c.value_changed.connect(set_environment_value.bind(c.name))
elif c is LineEdit:
c.text_submitted.connect(set_environment_value.bind(c.name))
elif c is ColorPickerButton:
c.connect("color_changed", Callable(self, "set_environment_value").bind(c.name))
c.color_changed.connect(set_environment_value.bind(c.name))
elif c is CheckBox:
c.connect("toggled", Callable(self, "set_environment_value").bind(c.name))
c.toggled.connect(set_environment_value.bind(c.name))

func set_environment_value(value, variable):
environment_manager.set_value(current_environment, variable, value)
Expand Down Expand Up @@ -111,6 +110,8 @@ func set_current_environment(index : int) -> void:
for c in ui.get_children():
if c is LineEdit:
c.editable = !read_only
elif c is FloatEdit:
c.editable = !read_only
elif c is ColorPickerButton or c is CheckBox:
c.disabled = read_only

Expand Down