summaryrefslogtreecommitdiff
path: root/modules/gridmap
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gridmap')
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml6
-rw-r--r--modules/gridmap/grid_map.cpp6
-rw-r--r--modules/gridmap/grid_map.h4
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp73
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h11
-rw-r--r--modules/gridmap/register_types.cpp4
-rw-r--r--modules/gridmap/register_types.h4
7 files changed, 79 insertions, 29 deletions
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index dd2628a7fd..f8f9fc1af9 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GridMap" inherits="Spatial" category="Core" version="3.1">
+<class name="GridMap" inherits="Spatial" category="Core" version="3.2">
<brief_description>
Node for 3D tile-based maps.
</brief_description>
@@ -12,8 +12,6 @@
<tutorials>
<link>https://docs.godotengine.org/en/latest/tutorials/3d/using_gridmaps.html</link>
</tutorials>
- <demos>
- </demos>
<methods>
<method name="clear">
<return type="void">
@@ -52,7 +50,7 @@
<argument index="2" name="z" type="int">
</argument>
<description>
- The [MeshLibrary] item index located at the grid-based X, Y and Z coordinates. If the cell is empty, [INVALID_CELL_ITEM] will be returned.
+ The [MeshLibrary] item index located at the grid-based X, Y and Z coordinates. If the cell is empty, [constant INVALID_CELL_ITEM] will be returned.
</description>
</method>
<method name="get_cell_item_orientation" qualifiers="const">
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 274a2f0249..32a014e76d 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -517,7 +517,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
Ref<NavigationMesh> navmesh = mesh_library->get_item_navmesh(c.item);
if (navmesh.is_valid()) {
Octant::NavMesh nm;
- nm.xform = xform;
+ nm.xform = xform * mesh_library->get_item_navmesh_transform(c.item);
if (navigation) {
nm.id = navigation->navmesh_add(navmesh, xform, this);
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 3d8be5c9c7..f4407099f5 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 126b49832a..17eb6f674c 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -289,11 +289,11 @@ void GridMapEditor::_update_selection_transform() {
scale *= node->get_cell_size();
pos *= node->get_cell_size();
- Transform xf;
- xf.basis.scale(scale);
- xf.origin = pos;
+ Transform xf2;
+ xf2.basis.scale(scale);
+ xf2.origin = pos;
- VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf);
+ VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf2);
}
}
}
@@ -631,7 +631,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
(mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) {
if (set_items.size()) {
- undo_redo->create_action("GridMap Paint");
+ undo_redo->create_action(TTR("GridMap Paint"));
for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) {
const SetItem &si = E->get();
@@ -717,6 +717,26 @@ void GridMapEditor::_set_display_mode(int p_mode) {
update_palette();
}
+void GridMapEditor::_text_changed(const String &p_text) {
+ update_palette();
+}
+
+void GridMapEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
+
+ Ref<InputEventKey> k = p_ie;
+
+ if (k.is_valid() && (k->get_scancode() == KEY_UP || k->get_scancode() == KEY_DOWN || k->get_scancode() == KEY_PAGEUP || k->get_scancode() == KEY_PAGEDOWN)) {
+
+ mesh_library_palette->call("_gui_input", k);
+ search_box->accept_event();
+ }
+}
+
+void GridMapEditor::_icon_size_changed(float p_value) {
+ mesh_library_palette->set_icon_scale(p_value);
+ update_palette();
+}
+
void GridMapEditor::update_palette() {
int selected = mesh_library_palette->get_current();
@@ -730,8 +750,9 @@ void GridMapEditor::update_palette() {
}
float min_size = EDITOR_DEF("editors/grid_map/preview_size", 64);
+ min_size *= EDSCALE;
mesh_library_palette->set_fixed_icon_size(Size2(min_size, min_size));
- mesh_library_palette->set_fixed_column_width(min_size * 3 / 2);
+ mesh_library_palette->set_fixed_column_width(min_size * MAX(size_slider->get_value(), 1.5));
mesh_library_palette->set_max_text_lines(2);
Ref<MeshLibrary> mesh_library = node->get_mesh_library();
@@ -754,23 +775,28 @@ void GridMapEditor::update_palette() {
}
il.sort();
+ String filter = search_box->get_text().strip_edges();
+
int item = 0;
for (List<_CGMEItemSort>::Element *E = il.front(); E; E = E->next()) {
int id = E->get().id;
-
- mesh_library_palette->add_item("");
-
String name = mesh_library->get_item_name(id);
Ref<Texture> preview = mesh_library->get_item_preview(id);
+ if (name == "") {
+ name = "#" + itos(id);
+ }
+
+ if (filter != "" && !filter.is_subsequence_ofi(name))
+ continue;
+
+ mesh_library_palette->add_item("");
if (!preview.is_null()) {
mesh_library_palette->set_item_icon(item, preview);
mesh_library_palette->set_item_tooltip(item, name);
}
- if (name != "") {
- mesh_library_palette->set_item_text(item, name);
- }
+ mesh_library_palette->set_item_text(item, name);
mesh_library_palette->set_item_metadata(item, id);
item++;
@@ -985,6 +1011,7 @@ void GridMapEditor::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
options->set_icon(get_icon("GridMap", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
} break;
}
}
@@ -1031,6 +1058,9 @@ void GridMapEditor::_floor_changed(float p_value) {
void GridMapEditor::_bind_methods() {
+ ClassDB::bind_method("_text_changed", &GridMapEditor::_text_changed);
+ ClassDB::bind_method("_sbox_input", &GridMapEditor::_sbox_input);
+ ClassDB::bind_method("_icon_size_changed", &GridMapEditor::_icon_size_changed);
ClassDB::bind_method("_menu_option", &GridMapEditor::_menu_option);
ClassDB::bind_method("_configure", &GridMapEditor::_configure);
ClassDB::bind_method("_item_selected_cbk", &GridMapEditor::_item_selected_cbk);
@@ -1132,6 +1162,12 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
add_child(hb);
hb->set_h_size_flags(SIZE_EXPAND_FILL);
+ search_box = memnew(LineEdit);
+ search_box->set_h_size_flags(SIZE_EXPAND_FILL);
+ hb->add_child(search_box);
+ search_box->connect("text_changed", this, "_text_changed");
+ search_box->connect("gui_input", this, "_sbox_input");
+
mode_thumbnail = memnew(ToolButton);
mode_thumbnail->set_toggle_mode(true);
mode_thumbnail->set_pressed(true);
@@ -1146,6 +1182,15 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
hb->add_child(mode_list);
mode_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST));
+ size_slider = memnew(HSlider);
+ size_slider->set_h_size_flags(SIZE_EXPAND_FILL);
+ size_slider->set_min(0.1f);
+ size_slider->set_max(4.0f);
+ size_slider->set_step(0.1f);
+ size_slider->set_value(1.0f);
+ size_slider->connect("value_changed", this, "_icon_size_changed");
+ add_child(size_slider);
+
EDITOR_DEF("editors/grid_map/preview_size", 64);
display_mode = DISPLAY_THUMBNAIL;
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index 663274f46e..59b8ac13da 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -79,6 +79,8 @@ class GridMapEditor : public VBoxContainer {
double accumulated_floor_delta;
ToolButton *mode_thumbnail;
ToolButton *mode_list;
+ LineEdit *search_box;
+ HSlider *size_slider;
HBoxContainer *spatial_editor_hb;
ConfirmationDialog *settings_dialog;
VBoxContainer *settings_vbc;
@@ -193,6 +195,11 @@ class GridMapEditor : public VBoxContainer {
void _update_cursor_instance();
void _update_clip();
+ void _text_changed(const String &p_text);
+ void _sbox_input(const Ref<InputEvent> &p_ie);
+
+ void _icon_size_changed(float p_value);
+
void _update_duplicate_indicator();
void _duplicate_paste();
void _update_selection_transform();
diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp
index 030286d651..03db5d323e 100644
--- a/modules/gridmap/register_types.cpp
+++ b/modules/gridmap/register_types.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/modules/gridmap/register_types.h b/modules/gridmap/register_types.h
index 4ff107bec8..5a07ea84d9 100644
--- a/modules/gridmap/register_types.h
+++ b/modules/gridmap/register_types.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */