Merge pull request #64468 from aaronfranke/editor-prop-visual-shader-mode

Rename `EditorPropertyShaderMode` to `EditorPropertyVisualShaderMode`
This commit is contained in:
Clay John 2022-08-18 14:14:12 -06:00 committed by GitHub
commit d60db2dba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 16 deletions

View file

@ -6151,7 +6151,7 @@ EditorNode::EditorNode() {
rmp.instantiate(); rmp.instantiate();
EditorInspector::add_inspector_plugin(rmp); EditorInspector::add_inspector_plugin(rmp);
Ref<EditorInspectorShaderModePlugin> smp; Ref<EditorInspectorVisualShaderModePlugin> smp;
smp.instantiate(); smp.instantiate();
EditorInspector::add_inspector_plugin(smp); EditorInspector::add_inspector_plugin(smp);
} }

View file

@ -6063,7 +6063,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par
return editor; return editor;
} }
void EditorPropertyShaderMode::_option_selected(int p_which) { void EditorPropertyVisualShaderMode::_option_selected(int p_which) {
Ref<VisualShader> visual_shader(Object::cast_to<VisualShader>(get_edited_object())); Ref<VisualShader> visual_shader(Object::cast_to<VisualShader>(get_edited_object()));
if (visual_shader->get_mode() == p_which) { if (visual_shader->get_mode() == p_which) {
return; return;
@ -6149,39 +6149,39 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
undo_redo->commit_action(); undo_redo->commit_action();
} }
void EditorPropertyShaderMode::update_property() { void EditorPropertyVisualShaderMode::update_property() {
int which = get_edited_object()->get(get_edited_property()); int which = get_edited_object()->get(get_edited_property());
options->select(which); options->select(which);
} }
void EditorPropertyShaderMode::setup(const Vector<String> &p_options) { void EditorPropertyVisualShaderMode::setup(const Vector<String> &p_options) {
for (int i = 0; i < p_options.size(); i++) { for (int i = 0; i < p_options.size(); i++) {
options->add_item(p_options[i], i); options->add_item(p_options[i], i);
} }
} }
void EditorPropertyShaderMode::set_option_button_clip(bool p_enable) { void EditorPropertyVisualShaderMode::set_option_button_clip(bool p_enable) {
options->set_clip_text(p_enable); options->set_clip_text(p_enable);
} }
void EditorPropertyShaderMode::_bind_methods() { void EditorPropertyVisualShaderMode::_bind_methods() {
} }
EditorPropertyShaderMode::EditorPropertyShaderMode() { EditorPropertyVisualShaderMode::EditorPropertyVisualShaderMode() {
options = memnew(OptionButton); options = memnew(OptionButton);
options->set_clip_text(true); options->set_clip_text(true);
add_child(options); add_child(options);
add_focusable(options); add_focusable(options);
options->connect("item_selected", callable_mp(this, &EditorPropertyShaderMode::_option_selected)); options->connect("item_selected", callable_mp(this, &EditorPropertyVisualShaderMode::_option_selected));
} }
bool EditorInspectorShaderModePlugin::can_handle(Object *p_object) { bool EditorInspectorVisualShaderModePlugin::can_handle(Object *p_object) {
return true; // Can handle everything. return true; // Can handle everything.
} }
bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) { bool EditorInspectorVisualShaderModePlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
if (p_path == "mode" && p_object->is_class("VisualShader") && p_type == Variant::INT) { if (p_path == "mode" && p_object->is_class("VisualShader") && p_type == Variant::INT) {
EditorPropertyShaderMode *mode_editor = memnew(EditorPropertyShaderMode); EditorPropertyVisualShaderMode *mode_editor = memnew(EditorPropertyVisualShaderMode);
Vector<String> options = p_hint_text.split(","); Vector<String> options = p_hint_text.split(",");
mode_editor->setup(options); mode_editor->setup(options);
add_property_editor(p_path, mode_editor); add_property_editor(p_path, mode_editor);

View file

@ -529,8 +529,8 @@ public:
virtual Control *create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) override; virtual Control *create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) override;
}; };
class EditorPropertyShaderMode : public EditorProperty { class EditorPropertyVisualShaderMode : public EditorProperty {
GDCLASS(EditorPropertyShaderMode, EditorProperty); GDCLASS(EditorPropertyVisualShaderMode, EditorProperty);
OptionButton *options = nullptr; OptionButton *options = nullptr;
void _option_selected(int p_which); void _option_selected(int p_which);
@ -542,11 +542,11 @@ public:
void setup(const Vector<String> &p_options); void setup(const Vector<String> &p_options);
virtual void update_property() override; virtual void update_property() override;
void set_option_button_clip(bool p_enable); void set_option_button_clip(bool p_enable);
EditorPropertyShaderMode(); EditorPropertyVisualShaderMode();
}; };
class EditorInspectorShaderModePlugin : public EditorInspectorPlugin { class EditorInspectorVisualShaderModePlugin : public EditorInspectorPlugin {
GDCLASS(EditorInspectorShaderModePlugin, EditorInspectorPlugin); GDCLASS(EditorInspectorVisualShaderModePlugin, EditorInspectorPlugin);
public: public:
virtual bool can_handle(Object *p_object) override; virtual bool can_handle(Object *p_object) override;