summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp17
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.cpp93
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.h25
-rw-r--r--editor/plugins/theme_editor_plugin.cpp6
4 files changed, 87 insertions, 54 deletions
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 281c9028f2..220003eb73 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -491,7 +491,7 @@ void AnimationPlayerEditor::_animation_name_edited() {
String new_name = name->get_text();
if (new_name == "" || new_name.find(":") != -1 || new_name.find("/") != -1) {
- error_dialog->set_text(TTR("ERROR: Invalid animation name!"));
+ error_dialog->set_text(TTR("Invalid animation name!"));
error_dialog->popup_centered_minsize();
return;
}
@@ -502,7 +502,7 @@ void AnimationPlayerEditor::_animation_name_edited() {
}
if (player->has_animation(new_name)) {
- error_dialog->set_text(TTR("ERROR: Animation name already exists!"));
+ error_dialog->set_text(TTR("Animation name already exists!"));
error_dialog->popup_centered_minsize();
return;
}
@@ -811,6 +811,8 @@ void AnimationPlayerEditor::_update_player() {
play_bw->set_disabled(animlist.size() == 0);
play_bw_from->set_disabled(animlist.size() == 0);
play_from->set_disabled(animlist.size() == 0);
+ frame->set_editable(animlist.size() != 0);
+ animation->set_disabled(animlist.size() == 0);
autoplay->set_disabled(animlist.size() == 0);
duplicate_anim->set_disabled(animlist.size() == 0);
rename_anim->set_disabled(animlist.size() == 0);
@@ -1088,7 +1090,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
case TOOL_COPY_ANIM: {
if (!animation->get_item_count()) {
- error_dialog->set_text(TTR("ERROR: No animation to copy!"));
+ error_dialog->set_text(TTR("No animation to copy!"));
error_dialog->popup_centered_minsize();
return;
}
@@ -1103,7 +1105,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
Ref<Animation> anim = EditorSettings::get_singleton()->get_resource_clipboard();
if (!anim.is_valid()) {
- error_dialog->set_text(TTR("ERROR: No animation resource on clipboard!"));
+ error_dialog->set_text(TTR("No animation resource on clipboard!"));
error_dialog->popup_centered_minsize();
return;
}
@@ -1134,7 +1136,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
case TOOL_EDIT_RESOURCE: {
if (!animation->get_item_count()) {
- error_dialog->set_text(TTR("ERROR: No animation to edit!"));
+ error_dialog->set_text(TTR("No animation to edit!"));
error_dialog->popup_centered_minsize();
return;
}
@@ -1611,7 +1613,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
hb->add_child(load_anim);
save_anim = memnew(MenuButton);
- save_anim->set_tooltip(TTR("Save the current animation"));
+ save_anim->set_tooltip(TTR("Save the current animation."));
save_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save", TTR("Save")), ANIM_SAVE);
save_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save_as", TTR("Save As")), ANIM_SAVE_AS);
save_anim->set_focus_mode(Control::FOCUS_NONE);
@@ -1691,6 +1693,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
pin = memnew(ToolButton);
pin->set_toggle_mode(true);
+ pin->set_tooltip(TTR("Pin AnimationPlayer"));
hb->add_child(pin);
resource_edit_anim = memnew(Button);
@@ -1718,7 +1721,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
error_dialog = memnew(ConfirmationDialog);
error_dialog->get_ok()->set_text(TTR("Close"));
- error_dialog->set_text(TTR("Error!"));
+ error_dialog->set_title(TTR("Error!"));
add_child(error_dialog);
name_dialog->connect("confirmed", this, "_animation_name_edited");
diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp
index 4410242d9c..e837359d0c 100644
--- a/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -33,10 +33,12 @@
#include "canvas_item_editor_plugin.h"
#include "editor/editor_settings.h"
#include "os/file_access.h"
+#include "os/input.h"
+#include "os/keyboard.h"
#include "scene/3d/camera.h"
#include "spatial_editor_plugin.h"
-void CollisionPolygonEditor::_notification(int p_what) {
+void Polygon3DEditor::_notification(int p_what) {
switch (p_what) {
@@ -53,15 +55,15 @@ void CollisionPolygonEditor::_notification(int p_what) {
return;
}
- if (node->get_depth() != prev_depth) {
+ if (_get_depth() != prev_depth) {
_polygon_draw();
- prev_depth = node->get_depth();
+ prev_depth = _get_depth();
}
} break;
}
}
-void CollisionPolygonEditor::_node_removed(Node *p_node) {
+void Polygon3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
@@ -72,7 +74,7 @@ void CollisionPolygonEditor::_node_removed(Node *p_node) {
}
}
-void CollisionPolygonEditor::_menu_option(int p_option) {
+void Polygon3DEditor::_menu_option(int p_option) {
switch (p_option) {
@@ -91,10 +93,10 @@ void CollisionPolygonEditor::_menu_option(int p_option) {
}
}
-void CollisionPolygonEditor::_wip_close() {
+void Polygon3DEditor::_wip_close() {
undo_redo->create_action(TTR("Create Poly3D"));
- undo_redo->add_undo_method(node, "set_polygon", node->get_polygon());
+ undo_redo->add_undo_method(node, "set_polygon", node->call("get_polygon"));
undo_redo->add_do_method(node, "set_polygon", wip);
undo_redo->add_do_method(this, "_polygon_draw");
undo_redo->add_undo_method(this, "_polygon_draw");
@@ -107,14 +109,14 @@ void CollisionPolygonEditor::_wip_close() {
undo_redo->commit_action();
}
-bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
+bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!node)
return false;
Transform gt = node->get_global_transform();
Transform gi = gt.affine_inverse();
- float depth = node->get_depth() * 0.5;
+ float depth = _get_depth() * 0.5;
Vector3 n = gt.basis.get_axis(2).normalized();
Plane p(gt.origin + n * depth, n);
@@ -135,9 +137,11 @@ bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const R
Vector2 cpoint(spoint.x, spoint.y);
- cpoint = CanvasItemEditor::get_singleton()->snap_point(cpoint);
+ //DO NOT snap here, it's confusing in 3D for adding points.
+ //Let the snap happen when the point is being moved, instead.
+ //cpoint = CanvasItemEditor::get_singleton()->snap_point(cpoint);
- Vector<Vector2> poly = node->get_polygon();
+ Vector<Vector2> poly = node->call("get_polygon");
//first check if a point is to be added (segment split)
real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
@@ -154,6 +158,7 @@ bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const R
wip.push_back(cpoint);
wip_active = true;
edited_point_pos = cpoint;
+ snap_ignore = false;
_polygon_draw();
edited_point = 1;
return true;
@@ -168,6 +173,7 @@ bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const R
wip.push_back(cpoint);
edited_point = wip.size();
+ snap_ignore = false;
_polygon_draw();
return true;
}
@@ -226,8 +232,10 @@ bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const R
poly.insert(closest_idx + 1, cpoint);
edited_point = closest_idx + 1;
edited_point_pos = cpoint;
- node->set_polygon(poly);
+ node->call("set_polygon", poly);
_polygon_draw();
+ snap_ignore = true;
+
return true;
}
} else {
@@ -255,11 +263,14 @@ bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const R
edited_point = closest_idx;
edited_point_pos = poly[closest_idx];
_polygon_draw();
+ snap_ignore = false;
return true;
}
}
} else {
+ snap_ignore = false;
+
if (edited_point != -1) {
//apply
@@ -315,7 +326,6 @@ bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const R
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
if (edited_point != -1 && (wip_active || mm->get_button_mask() & BUTTON_MASK_LEFT)) {
Vector2 gpoint = mm->get_position();
@@ -332,7 +342,13 @@ bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const R
Vector2 cpoint(spoint.x, spoint.y);
- cpoint = CanvasItemEditor::get_singleton()->snap_point(cpoint);
+ if (snap_ignore && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ snap_ignore = false;
+ }
+
+ if (!snap_ignore) {
+ cpoint = CanvasItemEditor::get_singleton()->snap_point(cpoint);
+ }
edited_point_pos = cpoint;
_polygon_draw();
@@ -341,7 +357,16 @@ bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const R
return false;
}
-void CollisionPolygonEditor::_polygon_draw() {
+
+float Polygon3DEditor::_get_depth() {
+
+ if (bool(node->call("_has_editable_3d_polygon_no_depth")))
+ return 0;
+
+ return float(node->call("get_depth"));
+}
+
+void Polygon3DEditor::_polygon_draw() {
if (!node)
return;
@@ -351,9 +376,9 @@ void CollisionPolygonEditor::_polygon_draw() {
if (wip_active)
poly = wip;
else
- poly = node->get_polygon();
+ poly = node->call("get_polygon");
- float depth = node->get_depth() * 0.5;
+ float depth = _get_depth() * 0.5;
imgeom->clear();
imgeom->set_material_override(line_material);
@@ -464,13 +489,13 @@ void CollisionPolygonEditor::_polygon_draw() {
m->surface_set_material(0, handle_material);
}
-void CollisionPolygonEditor::edit(Node *p_collision_polygon) {
+void Polygon3DEditor::edit(Node *p_collision_polygon) {
if (p_collision_polygon) {
- node = Object::cast_to<CollisionPolygon>(p_collision_polygon);
+ node = Object::cast_to<Spatial>(p_collision_polygon);
//Enable the pencil tool if the polygon is empty
- if (node->get_polygon().size() == 0) {
+ if (Vector<Vector2>(node->call("get_polygon")).size() == 0) {
_menu_option(MODE_CREATE);
}
wip.clear();
@@ -491,14 +516,14 @@ void CollisionPolygonEditor::edit(Node *p_collision_polygon) {
}
}
-void CollisionPolygonEditor::_bind_methods() {
+void Polygon3DEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_menu_option"), &CollisionPolygonEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_polygon_draw"), &CollisionPolygonEditor::_polygon_draw);
- ClassDB::bind_method(D_METHOD("_node_removed"), &CollisionPolygonEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_menu_option"), &Polygon3DEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_polygon_draw"), &Polygon3DEditor::_polygon_draw);
+ ClassDB::bind_method(D_METHOD("_node_removed"), &Polygon3DEditor::_node_removed);
}
-CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) {
+Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
node = NULL;
editor = p_editor;
@@ -543,24 +568,26 @@ CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) {
m.instance();
pointsm->set_mesh(m);
pointsm->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001)));
+
+ snap_ignore = false;
}
-CollisionPolygonEditor::~CollisionPolygonEditor() {
+Polygon3DEditor::~Polygon3DEditor() {
memdelete(imgeom);
}
-void CollisionPolygonEditorPlugin::edit(Object *p_object) {
+void Polygon3DEditorPlugin::edit(Object *p_object) {
collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
-bool CollisionPolygonEditorPlugin::handles(Object *p_object) const {
+bool Polygon3DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("CollisionPolygon");
+ return Object::cast_to<Spatial>(p_object) && bool(p_object->call("_is_editable_3d_polygon"));
}
-void CollisionPolygonEditorPlugin::make_visible(bool p_visible) {
+void Polygon3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
collision_polygon_editor->show();
@@ -571,14 +598,14 @@ void CollisionPolygonEditorPlugin::make_visible(bool p_visible) {
}
}
-CollisionPolygonEditorPlugin::CollisionPolygonEditorPlugin(EditorNode *p_node) {
+Polygon3DEditorPlugin::Polygon3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
- collision_polygon_editor = memnew(CollisionPolygonEditor(p_node));
+ collision_polygon_editor = memnew(Polygon3DEditor(p_node));
SpatialEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
collision_polygon_editor->hide();
}
-CollisionPolygonEditorPlugin::~CollisionPolygonEditorPlugin() {
+Polygon3DEditorPlugin::~Polygon3DEditorPlugin() {
}
diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_editor_plugin.h
index f1f215b092..4229808e2f 100644
--- a/editor/plugins/collision_polygon_editor_plugin.h
+++ b/editor/plugins/collision_polygon_editor_plugin.h
@@ -44,9 +44,9 @@
class CanvasItemEditor;
-class CollisionPolygonEditor : public HBoxContainer {
+class Polygon3DEditor : public HBoxContainer {
- GDCLASS(CollisionPolygonEditor, HBoxContainer);
+ GDCLASS(Polygon3DEditor, HBoxContainer);
UndoRedo *undo_redo;
enum Mode {
@@ -66,7 +66,7 @@ class CollisionPolygonEditor : public HBoxContainer {
EditorNode *editor;
Panel *panel;
- CollisionPolygon *node;
+ Spatial *node;
ImmediateGeometry *imgeom;
MeshInstance *pointsm;
Ref<ArrayMesh> m;
@@ -78,6 +78,7 @@ class CollisionPolygonEditor : public HBoxContainer {
Vector<Vector2> pre_move_edit;
Vector<Vector2> wip;
bool wip_active;
+ bool snap_ignore;
float prev_depth;
@@ -85,6 +86,8 @@ class CollisionPolygonEditor : public HBoxContainer {
void _polygon_draw();
void _menu_option(int p_option);
+ float _get_depth();
+
protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
@@ -93,28 +96,28 @@ protected:
public:
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
void edit(Node *p_collision_polygon);
- CollisionPolygonEditor(EditorNode *p_editor);
- ~CollisionPolygonEditor();
+ Polygon3DEditor(EditorNode *p_editor);
+ ~Polygon3DEditor();
};
-class CollisionPolygonEditorPlugin : public EditorPlugin {
+class Polygon3DEditorPlugin : public EditorPlugin {
- GDCLASS(CollisionPolygonEditorPlugin, EditorPlugin);
+ GDCLASS(Polygon3DEditorPlugin, EditorPlugin);
- CollisionPolygonEditor *collision_polygon_editor;
+ Polygon3DEditor *collision_polygon_editor;
EditorNode *editor;
public:
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); }
- virtual String get_name() const { return "CollisionPolygon"; }
+ virtual String get_name() const { return "Polygon3DEditor"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
- CollisionPolygonEditorPlugin(EditorNode *p_node);
- ~CollisionPolygonEditorPlugin();
+ Polygon3DEditorPlugin(EditorNode *p_node);
+ ~Polygon3DEditorPlugin();
};
#endif // COLLISION_POLYGON_EDITOR_PLUGIN_H
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 111154cf32..2427cd966b 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -691,11 +691,11 @@ ThemeEditor::ThemeEditor() {
test_menu_button->get_popup()->add_separator();
test_menu_button->get_popup()->add_check_item(TTR("Check Item"));
test_menu_button->get_popup()->add_check_item(TTR("Checked Item"));
- test_menu_button->get_popup()->set_item_checked(2, true);
+ test_menu_button->get_popup()->set_item_checked(3, true);
test_menu_button->get_popup()->add_separator();
- test_menu_button->get_popup()->add_check_item(TTR("Radio Item"));
+ test_menu_button->get_popup()->add_radio_check_item(TTR("Radio Item"));
test_menu_button->get_popup()->add_radio_check_item(TTR("Checked Radio Item"));
- test_menu_button->get_popup()->set_item_checked(5, true);
+ test_menu_button->get_popup()->set_item_checked(6, true);
first_vb->add_child(test_menu_button);
OptionButton *test_option_button = memnew(OptionButton);