summaryrefslogtreecommitdiff
path: root/tools/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/plugins')
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp12
-rw-r--r--tools/editor/plugins/shader_editor_plugin.cpp1
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp79
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.h6
4 files changed, 55 insertions, 43 deletions
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 55957887dc..d90597ddfb 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -188,7 +188,7 @@ void ScriptTextEditor::apply_code() {
if (script.is_null())
return;
- print_line("applying code");
+// print_line("applying code");
script->set_source_code(get_text_edit()->get_text());
script->update_exports();
}
@@ -210,6 +210,7 @@ void ScriptTextEditor::_load_theme_settings() {
get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1)));
get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1)));
get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2)));
+ get_text_edit()->add_color_override("current_line_color",EDITOR_DEF("text_editor/current_line_color",Color(0.3,0.5,0.8,0.15)));
Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2));
@@ -1033,9 +1034,12 @@ void ScriptEditor::_menu_option(int p_option) {
editor->emit_signal("request_help", text);
} break;
case WINDOW_CLOSE: {
-
- erase_tab_confirm->set_text("Close Tab?:\n\""+current->get_name()+"\"");
- erase_tab_confirm->popup_centered(Point2(250,80));
+ if (current->get_text_edit()->get_version()!=current->get_text_edit()->get_saved_version()) {
+ erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\"");
+ erase_tab_confirm->popup_centered(Point2(250,80));
+ } else {
+ _close_current_tab();
+ }
} break;
case WINDOW_MOVE_LEFT: {
diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp
index 0349964310..81b5cd8f78 100644
--- a/tools/editor/plugins/shader_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_editor_plugin.cpp
@@ -81,6 +81,7 @@ void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1)));
get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1)));
get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2)));
+ get_text_edit()->add_color_override("current_line_color",EDITOR_DEF("text_editor/current_line_color",Color(0.3,0.5,0.8,0.15)));
Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2));
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index a7e6a0d1f9..ce5ea58124 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -73,6 +73,18 @@ int TileMapEditor::get_selected_tile() const {
return item->get_metadata(0);
}
+void TileMapEditor::set_selected_tile(int p_tile) {
+ TreeItem *item = palette->get_root()->get_children();
+ while (item) {
+ if ((int)item->get_metadata(0) == p_tile) {
+ item->select(0);
+ palette->ensure_cursor_is_visible();
+ break;
+ }
+ item = item->get_next();
+ }
+}
+
void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bool p_flip_v,bool p_with_undo) {
ERR_FAIL_COND(!node);
@@ -224,28 +236,25 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
canvas_item_editor->update();
return true;
+ } else if (mb.mod.control) {
+ tool=TOOL_PICKING;
+ set_selected_tile(node->get_cell(over_tile.x, over_tile.y));
+ canvas_item_editor->update();
+ return true;
} else {
int id = get_selected_tile();
if (id!=TileMap::INVALID_CELL) {
tool=TOOL_PAINTING;
Point2i local =node->world_to_map((xform_inv.xform(Point2(mb.x,mb.y))));
paint_undo.clear();
- CellOp op;
- op.idx = node->get_cell(local.x,local.y);
- if (op.idx>=0) {
- if (node->is_cell_x_flipped(local.x,local.y))
- op.xf=true;
- if (node->is_cell_y_flipped(local.x,local.y))
- op.yf=true;
- }
- paint_undo[local]=op;
+ paint_undo[local]=_get_op_from_cell(local);
node->set_cell(local.x,local.y,id,mirror_x->is_pressed(),mirror_y->is_pressed());
return true;
}
}
} else {
- if (tool==TOOL_PAINTING || tool == TOOL_SELECTING) {
+ if (tool==TOOL_PAINTING || tool == TOOL_SELECTING || tool == TOOL_PICKING) {
if (tool==TOOL_PAINTING) {
@@ -279,15 +288,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
tool=TOOL_ERASING;
Point2i local =node->world_to_map(xform_inv.xform(Point2(mb.x,mb.y)));
paint_undo.clear();
- CellOp op;
- op.idx = node->get_cell(local.x,local.y);
- if (op.idx>=0) {
- if (node->is_cell_x_flipped(local.x,local.y))
- op.xf=true;
- if (node->is_cell_y_flipped(local.x,local.y))
- op.yf=true;
- }
- paint_undo[local]=op;
+ paint_undo[local]=_get_op_from_cell(local);
//node->set_cell(local.x,local.y,id,mirror_x->is_pressed(),mirror_y->is_pressed());
//return true;
_set_cell(local,TileMap::INVALID_CELL);
@@ -337,15 +338,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
if (!paint_undo.has(over_tile)) {
- CellOp op;
- op.idx = node->get_cell(over_tile.x,over_tile.y);
- if (op.idx>=0) {
- if (node->is_cell_x_flipped(over_tile.x,over_tile.y))
- op.xf=true;
- if (node->is_cell_y_flipped(over_tile.x,over_tile.y))
- op.yf=true;
- }
- paint_undo[over_tile]=op;
+ paint_undo[over_tile]=_get_op_from_cell(over_tile);
}
node->set_cell(over_tile.x,over_tile.y,id,mirror_x->is_pressed(),mirror_y->is_pressed());
@@ -374,25 +367,22 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
return true;
}
+
if (tool==TOOL_ERASING) {
Point2i local =over_tile;
if (!paint_undo.has(over_tile)) {
-
- CellOp op;
- op.idx = node->get_cell(over_tile.x,over_tile.y);
- if (op.idx>=0) {
- if (node->is_cell_x_flipped(over_tile.x,over_tile.y))
- op.xf=true;
- if (node->is_cell_y_flipped(over_tile.x,over_tile.y))
- op.yf=true;
- }
- paint_undo[over_tile]=op;
+ paint_undo[over_tile]=_get_op_from_cell(over_tile);
}
//node->set_cell(over_tile.x,over_tile.y,id,mirror_x->is_pressed(),mirror_y->is_pressed());
_set_cell(local,TileMap::INVALID_CELL);
return true;
}
+ if (tool==TOOL_PICKING) {
+ set_selected_tile(node->get_cell(over_tile.x, over_tile.y));
+ canvas_item_editor->update();
+ return true;
+ }
} break;
case InputEvent::KEY: {
@@ -710,6 +700,19 @@ void TileMapEditor::_bind_methods() {
}
+TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i& p_pos)
+{
+ CellOp op;
+ op.idx = node->get_cell(p_pos.x,p_pos.y);
+ if (op.idx>=0) {
+ if (node->is_cell_x_flipped(p_pos.x,p_pos.y))
+ op.xf=true;
+ if (node->is_cell_y_flipped(p_pos.x,p_pos.y))
+ op.yf=true;
+ }
+ return op;
+}
+
TileMapEditor::TileMapEditor(EditorNode *p_editor) {
node=NULL;
diff --git a/tools/editor/plugins/tile_map_editor_plugin.h b/tools/editor/plugins/tile_map_editor_plugin.h
index ef869591bd..f3c590e228 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.h
+++ b/tools/editor/plugins/tile_map_editor_plugin.h
@@ -51,7 +51,8 @@ class TileMapEditor : public VBoxContainer {
TOOL_PAINTING,
TOOL_SELECTING,
TOOL_ERASING,
- TOOL_DUPLICATING
+ TOOL_DUPLICATING,
+ TOOL_PICKING
};
Tool tool;
@@ -81,11 +82,13 @@ class TileMapEditor : public VBoxContainer {
bool xf;
bool yf;
CellOp() { idx=-1; xf=false; yf=false; }
+ CellOp(const CellOp& p_other) : idx(p_other.idx), xf(p_other.xf), yf(p_other.yf) {}
};
Map<Point2i,CellOp> paint_undo;
int get_selected_tile() const;
+ void set_selected_tile(int p_tile);
void _update_palette();
void _canvas_draw();
@@ -102,6 +105,7 @@ protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
+ CellOp _get_op_from_cell(const Point2i& p_pos);
public:
HBoxContainer *get_canvas_item_editor_hb() const { return canvas_item_editor_hb; }