Rename instances of the word "theme" to "mesh_library" in GridMap and MeshLibrary editors
This commit is contained in:
parent
334acc017f
commit
5c6be1aea5
@ -40,11 +40,11 @@
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "spatial_editor_plugin.h"
|
||||
|
||||
void MeshLibraryEditor::edit(const Ref<MeshLibrary> &p_theme) {
|
||||
void MeshLibraryEditor::edit(const Ref<MeshLibrary> &p_mesh_library) {
|
||||
|
||||
theme = p_theme;
|
||||
if (theme.is_valid())
|
||||
menu->get_popup()->set_item_disabled(menu->get_popup()->get_item_index(MENU_OPTION_UPDATE_FROM_SCENE), !theme->has_meta("_editor_source_scene"));
|
||||
mesh_library = p_mesh_library;
|
||||
if (mesh_library.is_valid())
|
||||
menu->get_popup()->set_item_disabled(menu->get_popup()->get_item_index(MENU_OPTION_UPDATE_FROM_SCENE), !mesh_library->has_meta("_editor_source_scene"));
|
||||
}
|
||||
|
||||
void MeshLibraryEditor::_menu_confirm() {
|
||||
@ -53,10 +53,10 @@ void MeshLibraryEditor::_menu_confirm() {
|
||||
|
||||
case MENU_OPTION_REMOVE_ITEM: {
|
||||
|
||||
theme->remove_item(to_erase);
|
||||
mesh_library->remove_item(to_erase);
|
||||
} break;
|
||||
case MENU_OPTION_UPDATE_FROM_SCENE: {
|
||||
String existing = theme->get_meta("_editor_source_scene");
|
||||
String existing = mesh_library->get_meta("_editor_source_scene");
|
||||
ERR_FAIL_COND(existing == "");
|
||||
_import_scene_cbk(existing);
|
||||
|
||||
@ -175,10 +175,10 @@ void MeshLibraryEditor::_import_scene_cbk(const String &p_str) {
|
||||
ERR_FAIL_COND(ps.is_null());
|
||||
Node *scene = ps->instance();
|
||||
|
||||
_import_scene(scene, theme, option == MENU_OPTION_UPDATE_FROM_SCENE);
|
||||
_import_scene(scene, mesh_library, option == MENU_OPTION_UPDATE_FROM_SCENE);
|
||||
|
||||
memdelete(scene);
|
||||
theme->set_meta("_editor_source_scene", p_str);
|
||||
mesh_library->set_meta("_editor_source_scene", p_str);
|
||||
menu->get_popup()->set_item_disabled(menu->get_popup()->get_item_index(MENU_OPTION_UPDATE_FROM_SCENE), false);
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ void MeshLibraryEditor::_menu_cbk(int p_option) {
|
||||
|
||||
case MENU_OPTION_ADD_ITEM: {
|
||||
|
||||
theme->create_item(theme->get_last_unused_item_id());
|
||||
mesh_library->create_item(mesh_library->get_last_unused_item_id());
|
||||
} break;
|
||||
case MENU_OPTION_REMOVE_ITEM: {
|
||||
|
||||
@ -213,7 +213,7 @@ void MeshLibraryEditor::_menu_cbk(int p_option) {
|
||||
} break;
|
||||
case MENU_OPTION_UPDATE_FROM_SCENE: {
|
||||
|
||||
cd->set_text("Update from existing scene?:\n" + String(theme->get_meta("_editor_source_scene")));
|
||||
cd->set_text("Update from existing scene?:\n" + String(mesh_library->get_meta("_editor_source_scene")));
|
||||
cd->popup_centered(Size2(500, 60));
|
||||
} break;
|
||||
}
|
||||
@ -265,10 +265,10 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
|
||||
void MeshLibraryEditorPlugin::edit(Object *p_node) {
|
||||
|
||||
if (Object::cast_to<MeshLibrary>(p_node)) {
|
||||
theme_editor->edit(Object::cast_to<MeshLibrary>(p_node));
|
||||
theme_editor->show();
|
||||
mesh_library_editor->edit(Object::cast_to<MeshLibrary>(p_node));
|
||||
mesh_library_editor->show();
|
||||
} else
|
||||
theme_editor->hide();
|
||||
mesh_library_editor->hide();
|
||||
}
|
||||
|
||||
bool MeshLibraryEditorPlugin::handles(Object *p_node) const {
|
||||
@ -279,21 +279,21 @@ bool MeshLibraryEditorPlugin::handles(Object *p_node) const {
|
||||
void MeshLibraryEditorPlugin::make_visible(bool p_visible) {
|
||||
|
||||
if (p_visible) {
|
||||
theme_editor->show();
|
||||
theme_editor->get_menu_button()->show();
|
||||
mesh_library_editor->show();
|
||||
mesh_library_editor->get_menu_button()->show();
|
||||
} else {
|
||||
theme_editor->hide();
|
||||
theme_editor->get_menu_button()->hide();
|
||||
mesh_library_editor->hide();
|
||||
mesh_library_editor->get_menu_button()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
MeshLibraryEditorPlugin::MeshLibraryEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
EDITOR_DEF("editors/grid_map/preview_size", 64);
|
||||
theme_editor = memnew(MeshLibraryEditor(p_node));
|
||||
mesh_library_editor = memnew(MeshLibraryEditor(p_node));
|
||||
|
||||
p_node->get_viewport()->add_child(theme_editor);
|
||||
theme_editor->set_anchors_and_margins_preset(Control::PRESET_TOP_WIDE);
|
||||
theme_editor->set_end(Point2(0, 22));
|
||||
theme_editor->hide();
|
||||
p_node->get_viewport()->add_child(mesh_library_editor);
|
||||
mesh_library_editor->set_anchors_and_margins_preset(Control::PRESET_TOP_WIDE);
|
||||
mesh_library_editor->set_end(Point2(0, 22));
|
||||
mesh_library_editor->hide();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class MeshLibraryEditor : public Control {
|
||||
|
||||
GDCLASS(MeshLibraryEditor, Control);
|
||||
|
||||
Ref<MeshLibrary> theme;
|
||||
Ref<MeshLibrary> mesh_library;
|
||||
|
||||
EditorNode *editor;
|
||||
MenuButton *menu;
|
||||
@ -67,7 +67,7 @@ protected:
|
||||
public:
|
||||
MenuButton *get_menu_button() const { return menu; }
|
||||
|
||||
void edit(const Ref<MeshLibrary> &p_theme);
|
||||
void edit(const Ref<MeshLibrary> &p_mesh_library);
|
||||
static Error update_library_file(Node *p_base_scene, Ref<MeshLibrary> ml, bool p_merge = true);
|
||||
|
||||
MeshLibraryEditor(EditorNode *p_editor);
|
||||
@ -77,7 +77,7 @@ class MeshLibraryEditorPlugin : public EditorPlugin {
|
||||
|
||||
GDCLASS(MeshLibraryEditorPlugin, EditorPlugin);
|
||||
|
||||
MeshLibraryEditor *theme_editor;
|
||||
MeshLibraryEditor *mesh_library_editor;
|
||||
EditorNode *editor;
|
||||
|
||||
public:
|
||||
|
@ -208,21 +208,35 @@ bool GridMap::get_collision_layer_bit(int p_bit) const {
|
||||
return get_collision_layer() & (1 << p_bit);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
void GridMap::set_theme(const Ref<MeshLibrary> &p_theme) {
|
||||
|
||||
if (!theme.is_null())
|
||||
theme->unregister_owner(this);
|
||||
theme = p_theme;
|
||||
if (!theme.is_null())
|
||||
theme->register_owner(this);
|
||||
|
||||
_recreate_octant_data();
|
||||
_change_notify("theme");
|
||||
WARN_PRINTS("GridMap.theme/set_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/set_mesh_library() instead.");
|
||||
set_mesh_library(p_theme);
|
||||
}
|
||||
|
||||
Ref<MeshLibrary> GridMap::get_theme() const {
|
||||
|
||||
return theme;
|
||||
WARN_PRINTS("GridMap.theme/get_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/get_mesh_library() instead.");
|
||||
return get_mesh_library();
|
||||
}
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
void GridMap::set_mesh_library(const Ref<MeshLibrary> &p_mesh_library) {
|
||||
|
||||
if (!mesh_library.is_null())
|
||||
mesh_library->unregister_owner(this);
|
||||
mesh_library = p_mesh_library;
|
||||
if (!mesh_library.is_null())
|
||||
mesh_library->register_owner(this);
|
||||
|
||||
_recreate_octant_data();
|
||||
_change_notify("mesh_library");
|
||||
}
|
||||
|
||||
Ref<MeshLibrary> GridMap::get_mesh_library() const {
|
||||
|
||||
return mesh_library;
|
||||
}
|
||||
|
||||
void GridMap::set_cell_size(const Vector3 &p_size) {
|
||||
@ -469,7 +483,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
|
||||
ERR_CONTINUE(!cell_map.has(E->get()));
|
||||
const Cell &c = cell_map[E->get()];
|
||||
|
||||
if (!theme.is_valid() || !theme->has_item(c.item))
|
||||
if (!mesh_library.is_valid() || !mesh_library->has_item(c.item))
|
||||
continue;
|
||||
|
||||
//print_line("OCTANT, CELLS: "+itos(ii.cells.size()));
|
||||
@ -488,7 +502,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
|
||||
xform.set_origin(cellpos * cell_size + ofs);
|
||||
xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale));
|
||||
if (baked_meshes.size() == 0) {
|
||||
if (theme->get_item_mesh(c.item).is_valid()) {
|
||||
if (mesh_library->get_item_mesh(c.item).is_valid()) {
|
||||
if (!multimesh_items.has(c.item)) {
|
||||
multimesh_items[c.item] = List<Pair<Transform, IndexKey> >();
|
||||
}
|
||||
@ -500,7 +514,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
|
||||
}
|
||||
}
|
||||
|
||||
Vector<MeshLibrary::ShapeData> shapes = theme->get_item_shapes(c.item);
|
||||
Vector<MeshLibrary::ShapeData> shapes = mesh_library->get_item_shapes(c.item);
|
||||
// add the item's shape at given xform to octant's static_body
|
||||
for (int i = 0; i < shapes.size(); i++) {
|
||||
// add the item's shape
|
||||
@ -515,7 +529,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
|
||||
}
|
||||
|
||||
// add the item's navmesh at given xform to GridMap's Navigation ancestor
|
||||
Ref<NavigationMesh> navmesh = theme->get_item_navmesh(c.item);
|
||||
Ref<NavigationMesh> navmesh = mesh_library->get_item_navmesh(c.item);
|
||||
if (navmesh.is_valid()) {
|
||||
Octant::NavMesh nm;
|
||||
nm.xform = xform;
|
||||
@ -537,7 +551,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
|
||||
|
||||
RID mm = VS::get_singleton()->multimesh_create();
|
||||
VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_NONE);
|
||||
VS::get_singleton()->multimesh_set_mesh(mm, theme->get_item_mesh(E->key())->get_rid());
|
||||
VS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid());
|
||||
|
||||
int idx = 0;
|
||||
for (List<Pair<Transform, IndexKey> >::Element *F = E->get().front(); F; F = F->next()) {
|
||||
@ -612,11 +626,11 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
|
||||
VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
|
||||
}
|
||||
|
||||
if (navigation && theme.is_valid()) {
|
||||
if (navigation && mesh_library.is_valid()) {
|
||||
for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
|
||||
|
||||
if (cell_map.has(F->key()) && F->get().id < 0) {
|
||||
Ref<NavigationMesh> nm = theme->get_item_navmesh(cell_map[F->key()].item);
|
||||
Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[F->key()].item);
|
||||
if (nm.is_valid()) {
|
||||
F->get().id = navigation->navmesh_add(nm, F->get().xform, this);
|
||||
}
|
||||
@ -846,8 +860,13 @@ void GridMap::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &GridMap::set_collision_layer_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &GridMap::get_collision_layer_bit);
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
ClassDB::bind_method(D_METHOD("set_theme", "theme"), &GridMap::set_theme);
|
||||
ClassDB::bind_method(D_METHOD("get_theme"), &GridMap::get_theme);
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_mesh_library", "mesh_library"), &GridMap::set_mesh_library);
|
||||
ClassDB::bind_method(D_METHOD("get_mesh_library"), &GridMap::get_mesh_library);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_cell_size", "size"), &GridMap::set_cell_size);
|
||||
ClassDB::bind_method(D_METHOD("get_cell_size"), &GridMap::get_cell_size);
|
||||
@ -865,7 +884,6 @@ void GridMap::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("world_to_map", "pos"), &GridMap::world_to_map);
|
||||
ClassDB::bind_method(D_METHOD("map_to_world", "x", "y", "z"), &GridMap::map_to_world);
|
||||
|
||||
//ClassDB::bind_method(D_METHOD("_recreate_octants"),&GridMap::_recreate_octants);
|
||||
ClassDB::bind_method(D_METHOD("_update_octants_callback"), &GridMap::_update_octants_callback);
|
||||
ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &GridMap::resource_changed);
|
||||
|
||||
@ -889,7 +907,11 @@ void GridMap::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("clear_baked_meshes"), &GridMap::clear_baked_meshes);
|
||||
ClassDB::bind_method(D_METHOD("make_baked_meshes", "gen_lightmap_uv", "lightmap_uv_texel_size"), &GridMap::make_baked_meshes, DEFVAL(false), DEFVAL(0.1));
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"), "set_theme", "get_theme");
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary", PROPERTY_USAGE_NOEDITOR), "set_theme", "get_theme");
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh_library", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"), "set_mesh_library", "get_mesh_library");
|
||||
ADD_GROUP("Cell", "cell_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "cell_size"), "set_cell_size", "get_cell_size");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_octant_size", PROPERTY_HINT_RANGE, "1,1024,1"), "set_octant_size", "get_octant_size");
|
||||
@ -952,7 +974,7 @@ Array GridMap::get_used_cells() const {
|
||||
|
||||
Array GridMap::get_meshes() {
|
||||
|
||||
if (theme.is_null())
|
||||
if (mesh_library.is_null())
|
||||
return Array();
|
||||
|
||||
Vector3 ofs = _get_offset();
|
||||
@ -961,9 +983,9 @@ Array GridMap::get_meshes() {
|
||||
for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) {
|
||||
|
||||
int id = E->get().item;
|
||||
if (!theme->has_item(id))
|
||||
if (!mesh_library->has_item(id))
|
||||
continue;
|
||||
Ref<Mesh> mesh = theme->get_item_mesh(id);
|
||||
Ref<Mesh> mesh = mesh_library->get_item_mesh(id);
|
||||
if (mesh.is_null())
|
||||
continue;
|
||||
|
||||
@ -1004,7 +1026,7 @@ void GridMap::clear_baked_meshes() {
|
||||
|
||||
void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texel_size) {
|
||||
|
||||
if (!theme.is_valid())
|
||||
if (!mesh_library.is_valid())
|
||||
return;
|
||||
|
||||
//generate
|
||||
@ -1015,10 +1037,10 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe
|
||||
IndexKey key = E->key();
|
||||
|
||||
int item = E->get().item;
|
||||
if (!theme->has_item(item))
|
||||
if (!mesh_library->has_item(item))
|
||||
continue;
|
||||
|
||||
Ref<Mesh> mesh = theme->get_item_mesh(item);
|
||||
Ref<Mesh> mesh = mesh_library->get_item_mesh(item);
|
||||
if (!mesh.is_valid())
|
||||
continue;
|
||||
|
||||
@ -1137,8 +1159,8 @@ GridMap::GridMap() {
|
||||
|
||||
GridMap::~GridMap() {
|
||||
|
||||
if (!theme.is_null())
|
||||
theme->unregister_owner(this);
|
||||
if (!mesh_library.is_null())
|
||||
mesh_library->unregister_owner(this);
|
||||
|
||||
clear();
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ class GridMap : public Spatial {
|
||||
|
||||
Vector3::Axis clip_axis;
|
||||
|
||||
Ref<MeshLibrary> theme;
|
||||
Ref<MeshLibrary> mesh_library;
|
||||
|
||||
Map<OctantKey, Octant *> octant_map;
|
||||
Map<IndexKey, Cell> cell_map;
|
||||
@ -227,8 +227,13 @@ public:
|
||||
void set_collision_mask_bit(int p_bit, bool p_value);
|
||||
bool get_collision_mask_bit(int p_bit) const;
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
void set_theme(const Ref<MeshLibrary> &p_theme);
|
||||
Ref<MeshLibrary> get_theme() const;
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
void set_mesh_library(const Ref<MeshLibrary> &p_mesh_library);
|
||||
Ref<MeshLibrary> get_mesh_library() const;
|
||||
|
||||
void set_cell_size(const Vector3 &p_size);
|
||||
Vector3 get_cell_size() const;
|
||||
|
@ -43,7 +43,7 @@ void GridMapEditor::_node_removed(Node *p_node) {
|
||||
if (p_node == node) {
|
||||
node = NULL;
|
||||
hide();
|
||||
theme_pallete->hide();
|
||||
mesh_library_palette->hide();
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,12 +320,12 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
|
||||
if (!spatial_editor)
|
||||
return false;
|
||||
|
||||
if (selected_pallete < 0 && input_action != INPUT_COPY && input_action != INPUT_SELECT && input_action != INPUT_DUPLICATE)
|
||||
if (selected_palette < 0 && input_action != INPUT_COPY && input_action != INPUT_SELECT && input_action != INPUT_DUPLICATE)
|
||||
return false;
|
||||
Ref<MeshLibrary> theme = node->get_theme();
|
||||
if (theme.is_null())
|
||||
Ref<MeshLibrary> mesh_library = node->get_mesh_library();
|
||||
if (mesh_library.is_null())
|
||||
return false;
|
||||
if (input_action != INPUT_COPY && input_action != INPUT_SELECT && input_action != INPUT_DUPLICATE && !theme->has_item(selected_pallete))
|
||||
if (input_action != INPUT_COPY && input_action != INPUT_SELECT && input_action != INPUT_DUPLICATE && !mesh_library->has_item(selected_palette))
|
||||
return false;
|
||||
|
||||
Camera *camera = p_camera;
|
||||
@ -407,9 +407,9 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
|
||||
|
||||
int item = node->get_cell_item(cell[0], cell[1], cell[2]);
|
||||
if (item >= 0) {
|
||||
selected_pallete = item;
|
||||
theme_pallete->set_current(item);
|
||||
update_pallete();
|
||||
selected_palette = item;
|
||||
mesh_library_palette->set_current(item);
|
||||
update_palette();
|
||||
_update_cursor_instance();
|
||||
}
|
||||
return true;
|
||||
@ -417,12 +417,12 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
|
||||
if (input_action == INPUT_PAINT) {
|
||||
SetItem si;
|
||||
si.pos = Vector3(cell[0], cell[1], cell[2]);
|
||||
si.new_value = selected_pallete;
|
||||
si.new_value = selected_palette;
|
||||
si.new_orientation = cursor_rot;
|
||||
si.old_value = node->get_cell_item(cell[0], cell[1], cell[2]);
|
||||
si.old_orientation = node->get_cell_item_orientation(cell[0], cell[1], cell[2]);
|
||||
set_items.push_back(si);
|
||||
node->set_cell_item(cell[0], cell[1], cell[2], selected_pallete, cursor_rot);
|
||||
node->set_cell_item(cell[0], cell[1], cell[2], selected_palette, cursor_rot);
|
||||
return true;
|
||||
} else if (input_action == INPUT_ERASE) {
|
||||
SetItem si;
|
||||
@ -474,7 +474,7 @@ void GridMapEditor::_fill_selection() {
|
||||
|
||||
for (int k = selection.begin.z; k <= selection.end.z; k++) {
|
||||
|
||||
undo_redo->add_do_method(node, "set_cell_item", i, j, k, selected_pallete, cursor_rot);
|
||||
undo_redo->add_do_method(node, "set_cell_item", i, j, k, selected_palette, cursor_rot);
|
||||
undo_redo->add_undo_method(node, "set_cell_item", i, j, k, node->get_cell_item(i, j, k), node->get_cell_item_orientation(i, j, k));
|
||||
}
|
||||
}
|
||||
@ -712,42 +712,42 @@ void GridMapEditor::_set_display_mode(int p_mode) {
|
||||
|
||||
display_mode = p_mode;
|
||||
|
||||
update_pallete();
|
||||
update_palette();
|
||||
}
|
||||
|
||||
void GridMapEditor::update_pallete() {
|
||||
int selected = theme_pallete->get_current();
|
||||
void GridMapEditor::update_palette() {
|
||||
int selected = mesh_library_palette->get_current();
|
||||
|
||||
theme_pallete->clear();
|
||||
mesh_library_palette->clear();
|
||||
if (display_mode == DISPLAY_THUMBNAIL) {
|
||||
theme_pallete->set_max_columns(0);
|
||||
theme_pallete->set_icon_mode(ItemList::ICON_MODE_TOP);
|
||||
mesh_library_palette->set_max_columns(0);
|
||||
mesh_library_palette->set_icon_mode(ItemList::ICON_MODE_TOP);
|
||||
} else if (display_mode == DISPLAY_LIST) {
|
||||
theme_pallete->set_max_columns(1);
|
||||
theme_pallete->set_icon_mode(ItemList::ICON_MODE_LEFT);
|
||||
mesh_library_palette->set_max_columns(1);
|
||||
mesh_library_palette->set_icon_mode(ItemList::ICON_MODE_LEFT);
|
||||
}
|
||||
|
||||
float min_size = EDITOR_DEF("editors/grid_map/preview_size", 64);
|
||||
theme_pallete->set_fixed_icon_size(Size2(min_size, min_size));
|
||||
theme_pallete->set_fixed_column_width(min_size * 3 / 2);
|
||||
theme_pallete->set_max_text_lines(2);
|
||||
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_max_text_lines(2);
|
||||
|
||||
Ref<MeshLibrary> theme = node->get_theme();
|
||||
Ref<MeshLibrary> mesh_library = node->get_mesh_library();
|
||||
|
||||
if (theme.is_null()) {
|
||||
last_theme = NULL;
|
||||
if (mesh_library.is_null()) {
|
||||
last_mesh_library = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector<int> ids;
|
||||
ids = theme->get_item_list();
|
||||
ids = mesh_library->get_item_list();
|
||||
|
||||
List<_CGMEItemSort> il;
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
|
||||
_CGMEItemSort is;
|
||||
is.id = ids[i];
|
||||
is.name = theme->get_item_name(ids[i]);
|
||||
is.name = mesh_library->get_item_name(ids[i]);
|
||||
il.push_back(is);
|
||||
}
|
||||
il.sort();
|
||||
@ -757,28 +757,28 @@ void GridMapEditor::update_pallete() {
|
||||
for (List<_CGMEItemSort>::Element *E = il.front(); E; E = E->next()) {
|
||||
int id = E->get().id;
|
||||
|
||||
theme_pallete->add_item("");
|
||||
mesh_library_palette->add_item("");
|
||||
|
||||
String name = theme->get_item_name(id);
|
||||
Ref<Texture> preview = theme->get_item_preview(id);
|
||||
String name = mesh_library->get_item_name(id);
|
||||
Ref<Texture> preview = mesh_library->get_item_preview(id);
|
||||
|
||||
if (!preview.is_null()) {
|
||||
theme_pallete->set_item_icon(item, preview);
|
||||
theme_pallete->set_item_tooltip(item, name);
|
||||
mesh_library_palette->set_item_icon(item, preview);
|
||||
mesh_library_palette->set_item_tooltip(item, name);
|
||||
}
|
||||
if (name != "") {
|
||||
theme_pallete->set_item_text(item, name);
|
||||
mesh_library_palette->set_item_text(item, name);
|
||||
}
|
||||
theme_pallete->set_item_metadata(item, id);
|
||||
mesh_library_palette->set_item_metadata(item, id);
|
||||
|
||||
item++;
|
||||
}
|
||||
|
||||
if (selected != -1) {
|
||||
theme_pallete->select(selected);
|
||||
mesh_library_palette->select(selected);
|
||||
}
|
||||
|
||||
last_theme = theme.operator->();
|
||||
last_mesh_library = mesh_library.operator->();
|
||||
}
|
||||
|
||||
void GridMapEditor::edit(GridMap *p_gridmap) {
|
||||
@ -805,7 +805,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_pallete();
|
||||
update_palette();
|
||||
|
||||
set_process(true);
|
||||
|
||||
@ -914,7 +914,7 @@ void GridMapEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
theme_pallete->connect("item_selected", this, "_item_selected_cbk");
|
||||
mesh_library_palette->connect("item_selected", this, "_item_selected_cbk");
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
grid[i] = VS::get_singleton()->mesh_create();
|
||||
@ -959,9 +959,9 @@ void GridMapEditor::_notification(int p_what) {
|
||||
}
|
||||
grid_xform = xf;
|
||||
}
|
||||
Ref<MeshLibrary> cgmt = node->get_theme();
|
||||
if (cgmt.operator->() != last_theme)
|
||||
update_pallete();
|
||||
Ref<MeshLibrary> cgmt = node->get_mesh_library();
|
||||
if (cgmt.operator->() != last_mesh_library)
|
||||
update_palette();
|
||||
|
||||
if (lock_view) {
|
||||
|
||||
@ -994,10 +994,10 @@ void GridMapEditor::_update_cursor_instance() {
|
||||
VisualServer::get_singleton()->free(cursor_instance);
|
||||
cursor_instance = RID();
|
||||
|
||||
if (selected_pallete >= 0) {
|
||||
if (selected_palette >= 0) {
|
||||
|
||||
if (node && !node->get_theme().is_null()) {
|
||||
Ref<Mesh> mesh = node->get_theme()->get_item_mesh(selected_pallete);
|
||||
if (node && !node->get_mesh_library().is_null()) {
|
||||
Ref<Mesh> mesh = node->get_mesh_library()->get_item_mesh(selected_palette);
|
||||
if (!mesh.is_null() && mesh->get_rid().is_valid()) {
|
||||
|
||||
cursor_instance = VisualServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario());
|
||||
@ -1008,7 +1008,7 @@ void GridMapEditor::_update_cursor_instance() {
|
||||
}
|
||||
|
||||
void GridMapEditor::_item_selected_cbk(int idx) {
|
||||
selected_pallete = theme_pallete->get_item_metadata(idx);
|
||||
selected_palette = mesh_library_palette->get_item_metadata(idx);
|
||||
|
||||
_update_cursor_instance();
|
||||
}
|
||||
@ -1146,9 +1146,9 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
|
||||
|
||||
display_mode = DISPLAY_THUMBNAIL;
|
||||
|
||||
theme_pallete = memnew(ItemList);
|
||||
add_child(theme_pallete);
|
||||
theme_pallete->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
mesh_library_palette = memnew(ItemList);
|
||||
add_child(mesh_library_palette);
|
||||
mesh_library_palette->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
|
||||
edit_axis = Vector3::AXIS_Y;
|
||||
edit_floor[0] = -1;
|
||||
@ -1156,7 +1156,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
|
||||
edit_floor[2] = -1;
|
||||
|
||||
cursor_visible = false;
|
||||
selected_pallete = -1;
|
||||
selected_palette = -1;
|
||||
lock_view = false;
|
||||
cursor_rot = 0;
|
||||
last_mouseover = Vector3(-1, -1, -1);
|
||||
|
@ -97,7 +97,7 @@ class GridMapEditor : public VBoxContainer {
|
||||
List<SetItem> set_items;
|
||||
|
||||
GridMap *node;
|
||||
MeshLibrary *last_theme;
|
||||
MeshLibrary *last_mesh_library;
|
||||
ClipMode clip_mode;
|
||||
|
||||
bool lock_view;
|
||||
@ -141,7 +141,7 @@ class GridMapEditor : public VBoxContainer {
|
||||
Vector3 last_mouseover;
|
||||
|
||||
int display_mode;
|
||||
int selected_pallete;
|
||||
int selected_palette;
|
||||
int cursor_rot;
|
||||
|
||||
enum Menu {
|
||||
@ -185,9 +185,9 @@ class GridMapEditor : public VBoxContainer {
|
||||
void update_grid();
|
||||
void _configure();
|
||||
void _menu_option(int);
|
||||
void update_pallete();
|
||||
void update_palette();
|
||||
void _set_display_mode(int p_mode);
|
||||
ItemList *theme_pallete;
|
||||
ItemList *mesh_library_palette;
|
||||
void _item_selected_cbk(int idx);
|
||||
void _update_cursor_transform();
|
||||
void _update_cursor_instance();
|
||||
@ -207,7 +207,6 @@ class GridMapEditor : public VBoxContainer {
|
||||
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
|
||||
|
||||
friend class GridMapEditorPlugin;
|
||||
Panel *theme_panel;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
Loading…
Reference in New Issue
Block a user