-
-
Notifications
You must be signed in to change notification settings - Fork 2
Put the visgroup rename, variant delete and power change on screen #643
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,11 @@ static func setup_visgroup_ui(dock: Object) -> void: | |
| dock.visgroup_rem_sel_btn.tooltip_text = ("Remove selected brushes/entities from the highlighted visgroup") | ||
| dock.visgroup_rem_sel_btn.pressed.connect(dock._on_visgroup_remove_selection) | ||
| visgroup_buttons.add_child(dock.visgroup_rem_sel_btn) | ||
| dock.visgroup_rename_btn = Button.new() | ||
| dock.visgroup_rename_btn.text = "Rename" | ||
| dock.visgroup_rename_btn.tooltip_text = "Rename the highlighted visgroup" | ||
| dock.visgroup_rename_btn.pressed.connect(dock._on_visgroup_rename) | ||
| visgroup_buttons.add_child(dock.visgroup_rename_btn) | ||
| dock.visgroup_delete_btn = Button.new() | ||
| dock.visgroup_delete_btn.text = "Delete" | ||
| dock.visgroup_delete_btn.tooltip_text = "Delete the highlighted visgroup" | ||
|
|
@@ -213,6 +218,54 @@ static func on_visgroup_delete(dock: Object) -> void: | |
| refresh_visgroup_ui(dock) | ||
|
|
||
|
|
||
| ## Rename the highlighted visgroup. | ||
| ## | ||
| ## The system has always been able to do this, carefully: it refuses a name that | ||
| ## is taken rather than merging two visgroups, and it rewrites the membership | ||
| ## metadata on every node that carried the old name. Nothing outside the suite | ||
| ## could ask for it (#615), so a mapper who named one `roof` and then wanted | ||
| ## `roof_upper` had to make a new one, re-add every member and delete the old. | ||
| ## | ||
| ## The collision is checked here rather than left to the refusal, because | ||
| ## `_commit_state_action()` cannot see a return value and would otherwise push an | ||
| ## undo step for a rename that did not happen. | ||
| static func on_visgroup_rename(dock: Object) -> void: | ||
| if dock == null or not dock.level_root: | ||
| return | ||
| var current_name := require_visgroup_name(dock, "Rename Visgroup") | ||
| if current_name == "": | ||
| return | ||
| var row := get_selected_visgroup_index(dock) | ||
| var dialog := AcceptDialog.new() | ||
| dialog.title = "Rename Visgroup" | ||
| var line_edit := LineEdit.new() | ||
| line_edit.text = current_name | ||
| line_edit.select_all() | ||
| dialog.add_child(line_edit) | ||
| dialog.confirmed.connect( | ||
| func(): | ||
| if not is_instance_valid(dock) or not dock.level_root: | ||
| return | ||
| var new_name: String = line_edit.text.strip_edges() | ||
| if new_name == "" or new_name == current_name: | ||
| return | ||
| if Array(dock.level_root.get_visgroup_names()).has(new_name): | ||
| if dock.has_method("show_toast"): | ||
| dock.show_toast('A visgroup is already called "%s"' % new_name, 2) | ||
| return | ||
| dock._commit_state_action( | ||
| "Rename Visgroup", "rename_visgroup", [current_name, new_name] | ||
| ) | ||
| refresh_visgroup_ui(dock) | ||
| reselect_visgroup_row(dock, row) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the renamed visgroup is not the last entry, renaming removes its old dictionary key and appends the new key, so rebuilding the list changes its row. Reselecting the old numeric row highlights a different visgroup; the next Add Sel, Rem Sel, or Delete can then affect that group instead. Locate and select Useful? React with 👍 / 👎. |
||
| ) | ||
| dialog.canceled.connect(func(): dialog.queue_free()) | ||
| dialog.confirmed.connect(func(): dialog.queue_free(), CONNECT_DEFERRED) | ||
| dock.add_child(dialog) | ||
| dialog.popup_centered(Vector2i(300, 80)) | ||
| line_edit.grab_focus() | ||
|
|
||
|
|
||
| static func on_group_selection(dock: Object) -> void: | ||
| if dock == null or not dock.level_root or dock._selection_nodes.size() < 2: | ||
| return | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -972,6 +972,15 @@ func remove_visgroup(vg_name: String) -> void: | |
| visgroup_system.remove_visgroup(vg_name) | ||
|
|
||
|
|
||
| ## Refuses a name that is taken, which is why it answers rather than returning | ||
| ## nothing: renaming onto an existing visgroup would merge two of them, and that | ||
| ## is a different operation (#615). | ||
| func rename_visgroup(old_name: String, new_name: String) -> bool: | ||
| if not visgroup_system: | ||
| return false | ||
| return visgroup_system.rename_visgroup(old_name, new_name) | ||
|
|
||
|
|
||
| func set_visgroup_visible(vg_name: String, visible: bool) -> void: | ||
| if visgroup_system: | ||
| visgroup_system.set_visgroup_visible(vg_name, visible) | ||
|
|
@@ -1679,6 +1688,17 @@ func destroy_displacement(brush_id: String, face_index: int) -> bool: | |
| return ok | ||
|
|
||
|
|
||
| ## Change an existing displacement's subdivision without losing the sculpt. | ||
| ## | ||
| ## The system resamples the old grid into the new one, which is the whole reason | ||
| ## this is not Destroy and Create (#615). | ||
| func set_displacement_power(brush_id: String, face_index: int, power: int) -> bool: | ||
| var ok: bool = displacement_system.set_power(brush_id, face_index, power) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the selected displacement contains alpha painting or custom offset directions, this newly reachable call silently destroys that data: Useful? React with 👍 / 👎. |
||
| if ok: | ||
| tag_brush_dirty(brush_id) | ||
| return ok | ||
|
|
||
|
|
||
| func set_displacement_elevation(brush_id: String, face_index: int, elevation: float) -> bool: | ||
| return displacement_system.set_elevation(brush_id, face_index, elevation) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a placed prefab instance currently uses the variant being removed, this only rewrites the source file and leaves its
PrefabInstanceRecord.variant_namepointing at a name that no longer exists. A later live-link propagation substitutes base geometry while retaining the invalid name, andpush_instance_to_source()can recreate the supposedly deleted variant; either migrate affected instances tobaseor refuse deletion while the variant is referenced.Useful? React with 👍 / 👎.