2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* grid_map_editor_plugin.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2017-01-01 21:01:57 +00:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-07 22:11:42 +00:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#ifndef GRID_MAP_EDITOR_PLUGIN_H
|
|
|
|
#define GRID_MAP_EDITOR_PLUGIN_H
|
|
|
|
|
2017-03-05 13:21:25 +00:00
|
|
|
#include "editor/editor_node.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "editor/editor_plugin.h"
|
2017-03-05 13:21:25 +00:00
|
|
|
#include "editor/pane_drag.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "grid_map.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
/**
|
|
|
|
@author Juan Linietsky <reduzio@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
class SpatialEditorPlugin;
|
|
|
|
|
|
|
|
class GridMapEditor : public VBoxContainer {
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(GridMapEditor, VBoxContainer);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
GRID_CURSOR_SIZE = 50
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum InputAction {
|
|
|
|
|
|
|
|
INPUT_NONE,
|
|
|
|
INPUT_PAINT,
|
|
|
|
INPUT_ERASE,
|
|
|
|
INPUT_COPY,
|
|
|
|
INPUT_SELECT,
|
|
|
|
INPUT_DUPLICATE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ClipMode {
|
|
|
|
|
|
|
|
CLIP_DISABLED,
|
|
|
|
CLIP_ABOVE,
|
|
|
|
CLIP_BELOW
|
|
|
|
};
|
|
|
|
|
2015-06-22 13:05:03 +00:00
|
|
|
enum DisplayMode {
|
2017-03-05 15:44:50 +00:00
|
|
|
DISPLAY_THUMBNAIL,
|
|
|
|
DISPLAY_LIST
|
2015-06-22 13:05:03 +00:00
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
UndoRedo *undo_redo;
|
|
|
|
InputAction input_action;
|
|
|
|
Panel *panel;
|
2017-03-05 15:44:50 +00:00
|
|
|
MenuButton *options;
|
2014-02-10 01:10:30 +00:00
|
|
|
SpinBox *floor;
|
2015-06-22 13:05:03 +00:00
|
|
|
ToolButton *mode_thumbnail;
|
|
|
|
ToolButton *mode_list;
|
2014-02-10 01:10:30 +00:00
|
|
|
HBoxContainer *spatial_editor_hb;
|
2015-07-10 02:51:49 +00:00
|
|
|
ConfirmationDialog *settings_dialog;
|
|
|
|
VBoxContainer *settings_vbc;
|
|
|
|
SpinBox *settings_pick_distance;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
struct SetItem {
|
|
|
|
|
|
|
|
Vector3 pos;
|
|
|
|
int new_value;
|
|
|
|
int new_orientation;
|
|
|
|
int old_value;
|
|
|
|
int old_orientation;
|
|
|
|
};
|
|
|
|
|
|
|
|
List<SetItem> set_items;
|
|
|
|
|
|
|
|
GridMap *node;
|
2017-03-05 15:44:50 +00:00
|
|
|
MeshLibrary *last_theme;
|
2014-02-10 01:10:30 +00:00
|
|
|
ClipMode clip_mode;
|
|
|
|
|
|
|
|
bool lock_view;
|
|
|
|
Transform grid_xform;
|
|
|
|
Transform edit_grid_xform;
|
|
|
|
Vector3::Axis edit_axis;
|
|
|
|
int edit_floor[3];
|
|
|
|
Vector3 grid_ofs;
|
|
|
|
|
|
|
|
RID grid[3];
|
|
|
|
RID grid_instance[3];
|
|
|
|
RID cursor_instance;
|
|
|
|
RID selection_mesh;
|
|
|
|
RID selection_instance;
|
2017-08-27 19:00:59 +00:00
|
|
|
RID selection_level_mesh[3];
|
|
|
|
RID selection_level_instance[3];
|
2014-02-10 01:10:30 +00:00
|
|
|
RID duplicate_mesh;
|
|
|
|
RID duplicate_instance;
|
|
|
|
|
2017-04-07 02:36:37 +00:00
|
|
|
Ref<SpatialMaterial> indicator_mat;
|
|
|
|
Ref<SpatialMaterial> inner_mat;
|
|
|
|
Ref<SpatialMaterial> outer_mat;
|
2017-08-27 19:00:59 +00:00
|
|
|
Ref<SpatialMaterial> selection_floor_mat;
|
2015-04-20 22:38:02 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
bool updating;
|
|
|
|
|
|
|
|
struct Selection {
|
|
|
|
|
|
|
|
Vector3 click;
|
|
|
|
Vector3 current;
|
|
|
|
Vector3 begin;
|
|
|
|
Vector3 end;
|
|
|
|
int duplicate_rot;
|
|
|
|
bool active;
|
|
|
|
} selection;
|
|
|
|
|
|
|
|
bool cursor_visible;
|
|
|
|
Transform cursor_transform;
|
|
|
|
|
|
|
|
Vector3 cursor_origin;
|
|
|
|
Vector3 last_mouseover;
|
|
|
|
|
2015-06-22 13:05:03 +00:00
|
|
|
int display_mode;
|
2014-02-10 01:10:30 +00:00
|
|
|
int selected_pallete;
|
|
|
|
int cursor_rot;
|
|
|
|
|
|
|
|
enum Menu {
|
|
|
|
|
|
|
|
MENU_OPTION_CONFIGURE,
|
|
|
|
MENU_OPTION_NEXT_LEVEL,
|
|
|
|
MENU_OPTION_PREV_LEVEL,
|
|
|
|
MENU_OPTION_LOCK_VIEW,
|
|
|
|
MENU_OPTION_CLIP_DISABLED,
|
|
|
|
MENU_OPTION_CLIP_ABOVE,
|
|
|
|
MENU_OPTION_CLIP_BELOW,
|
|
|
|
MENU_OPTION_X_AXIS,
|
|
|
|
MENU_OPTION_Y_AXIS,
|
|
|
|
MENU_OPTION_Z_AXIS,
|
|
|
|
MENU_OPTION_CURSOR_ROTATE_Y,
|
|
|
|
MENU_OPTION_CURSOR_ROTATE_X,
|
|
|
|
MENU_OPTION_CURSOR_ROTATE_Z,
|
|
|
|
MENU_OPTION_CURSOR_BACK_ROTATE_Y,
|
|
|
|
MENU_OPTION_CURSOR_BACK_ROTATE_X,
|
|
|
|
MENU_OPTION_CURSOR_BACK_ROTATE_Z,
|
|
|
|
MENU_OPTION_CURSOR_CLEAR_ROTATION,
|
|
|
|
MENU_OPTION_DUPLICATE_SELECTS,
|
|
|
|
MENU_OPTION_SELECTION_MAKE_AREA,
|
|
|
|
MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR,
|
2016-08-21 01:34:39 +00:00
|
|
|
MENU_OPTION_SELECTION_DUPLICATE,
|
2014-02-10 01:10:30 +00:00
|
|
|
MENU_OPTION_SELECTION_CLEAR,
|
2015-07-10 02:51:49 +00:00
|
|
|
MENU_OPTION_REMOVE_AREA,
|
|
|
|
MENU_OPTION_GRIDMAP_SETTINGS
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
SpatialEditorPlugin *spatial_editor;
|
|
|
|
|
|
|
|
struct AreaDisplay {
|
|
|
|
|
|
|
|
RID mesh;
|
|
|
|
RID instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
void update_grid();
|
|
|
|
void _configure();
|
|
|
|
void _menu_option(int);
|
|
|
|
void update_pallete();
|
2015-06-22 13:05:03 +00:00
|
|
|
void _set_display_mode(int p_mode);
|
|
|
|
ItemList *theme_pallete;
|
|
|
|
void _item_selected_cbk(int idx);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _update_cursor_transform();
|
|
|
|
void _update_cursor_instance();
|
|
|
|
void _update_clip();
|
|
|
|
|
|
|
|
void _update_duplicate_indicator();
|
|
|
|
void _duplicate_paste();
|
|
|
|
void _update_selection_transform();
|
|
|
|
void _validate_selection();
|
|
|
|
|
|
|
|
void _floor_changed(float p_value);
|
|
|
|
|
|
|
|
void _delete_selection();
|
|
|
|
|
|
|
|
EditorNode *editor;
|
2017-03-05 15:44:50 +00:00
|
|
|
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
friend class GridMapEditorPlugin;
|
2014-02-10 01:10:30 +00:00
|
|
|
Panel *theme_panel;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
void _node_removed(Node *p_node);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2017-05-20 15:38:03 +00:00
|
|
|
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void edit(GridMap *p_gridmap);
|
|
|
|
GridMapEditor() {}
|
|
|
|
GridMapEditor(EditorNode *p_editor);
|
|
|
|
~GridMapEditor();
|
|
|
|
};
|
|
|
|
|
|
|
|
class GridMapEditorPlugin : public EditorPlugin {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(GridMapEditorPlugin, EditorPlugin);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
GridMapEditor *gridmap_editor;
|
|
|
|
EditorNode *editor;
|
|
|
|
|
|
|
|
public:
|
2017-08-27 19:00:59 +00:00
|
|
|
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return gridmap_editor->forward_spatial_input_event(p_camera, p_event); }
|
2014-02-10 01:10:30 +00:00
|
|
|
virtual String get_name() const { return "GridMap"; }
|
|
|
|
bool has_main_screen() const { return false; }
|
2017-08-12 16:52:50 +00:00
|
|
|
virtual void edit(Object *p_object);
|
|
|
|
virtual bool handles(Object *p_object) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
virtual void make_visible(bool p_visible);
|
|
|
|
|
|
|
|
GridMapEditorPlugin(EditorNode *p_node);
|
|
|
|
~GridMapEditorPlugin();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CUBE_GRID_MAP_EDITOR_PLUGIN_H
|