Merge branch 'master' of https://github.com/godotengine/godot into issue1

This commit is contained in:
Siddharth 2019-03-23 20:09:08 +05:30
commit 13ead635d9
14 changed files with 136 additions and 145 deletions

View File

@ -39,7 +39,7 @@
// va_copy, otherwise you have to use the internal version (__va_copy).
#if !defined(va_copy)
#if defined(__GNUC__)
#define va_copy(d, s) __va_copy(d, s)
#define va_copy(d, s) __va_copy((d), (s))
#else
#define va_copy(d, s) ((d) = (s))
#endif

View File

@ -515,7 +515,7 @@ static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, i
Vector3(1,1,1),
};
*/
#define vert(m_idx) Vector3((m_idx & 4) >> 2, (m_idx & 2) >> 1, m_idx & 1)
#define vert(m_idx) Vector3(((m_idx)&4) >> 2, ((m_idx)&2) >> 1, (m_idx)&1)
static const uint8_t indices[6][4] = {
{ 7, 6, 4, 5 },

View File

@ -137,7 +137,7 @@ T *_nullptr() {
/** Generic swap template */
#ifndef SWAP
#define SWAP(m_x, m_y) __swap_tmpl(m_x, m_y)
#define SWAP(m_x, m_y) __swap_tmpl((m_x), (m_y))
template <class T>
inline void __swap_tmpl(T &x, T &y) {

View File

@ -1085,6 +1085,79 @@ void CodeTextEditor::clone_lines_down() {
text_editor->update();
}
void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
text_editor->begin_complex_operation();
if (text_editor->is_selection_active()) {
int begin = text_editor->get_selection_from_line();
int end = text_editor->get_selection_to_line();
// End of selection ends on the first column of the last line, ignore it.
if (text_editor->get_selection_to_column() == 0)
end -= 1;
int col_to = text_editor->get_selection_to_column();
int cursor_pos = text_editor->cursor_get_column();
// Check if all lines in the selected block are commented
bool is_commented = true;
for (int i = begin; i <= end; i++) {
if (!text_editor->get_line(i).begins_with(delimiter)) {
is_commented = false;
break;
}
}
for (int i = begin; i <= end; i++) {
String line_text = text_editor->get_line(i);
if (line_text.strip_edges().empty()) {
line_text = delimiter;
} else {
if (is_commented) {
line_text = line_text.substr(delimiter.length(), line_text.length());
} else {
line_text = delimiter + line_text;
}
}
text_editor->set_line(i, line_text);
}
// Adjust selection & cursor position.
int offset = (is_commented ? -1 : 1) * delimiter.length();
int col_from = text_editor->get_selection_from_column() > 0 ? text_editor->get_selection_from_column() + offset : 0;
if (is_commented && text_editor->cursor_get_column() == text_editor->get_line(text_editor->cursor_get_line()).length() + 1)
cursor_pos += 1;
if (text_editor->get_selection_to_column() != 0 && col_to != text_editor->get_line(text_editor->get_selection_to_line()).length() + 1)
col_to += offset;
if (text_editor->cursor_get_column() != 0)
cursor_pos += offset;
text_editor->select(begin, col_from, text_editor->get_selection_to_line(), col_to);
text_editor->cursor_set_column(cursor_pos);
} else {
int begin = text_editor->cursor_get_line();
String line_text = text_editor->get_line(begin);
int delimiter_length = delimiter.length();
int col = text_editor->cursor_get_column();
if (line_text.begins_with(delimiter)) {
line_text = line_text.substr(delimiter_length, line_text.length());
col -= delimiter_length;
} else {
line_text = delimiter + line_text;
col += delimiter_length;
}
text_editor->set_line(begin, line_text);
text_editor->cursor_set_column(col);
}
text_editor->end_complex_operation();
text_editor->update();
}
void CodeTextEditor::goto_line(int p_line) {
text_editor->deselect();
text_editor->unfold_line(p_line);

View File

@ -211,6 +211,10 @@ public:
void delete_lines();
void clone_lines_down();
/// Toggle inline comment on currently selected lines, or on current line if nothing is selected,
/// by adding or removing comment delimiter
void toggle_inline_comment(const String &delimiter);
void goto_line(int p_line);
void goto_line_selection(int p_line, int p_begin, int p_end);

View File

@ -124,7 +124,6 @@ private:
ToolButton *fav_up;
ToolButton *fav_down;
ToolButton *fav_rm;
ItemList *favorites;
ItemList *recent;

View File

@ -336,9 +336,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/theme/icon_and_font_color", 0);
hints["interface/theme/icon_and_font_color"] = PropertyInfo(Variant::INT, "interface/theme/icon_and_font_color", PROPERTY_HINT_ENUM, "Auto,Dark,Light", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/theme/base_color", Color::html("#323b4f"));
hints["interface/theme/accent_color"] = PropertyInfo(Variant::COLOR, "interface/theme/accent_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/theme/accent_color", Color::html("#699ce8"));
hints["interface/theme/base_color"] = PropertyInfo(Variant::COLOR, "interface/theme/base_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/theme/accent_color", Color::html("#699ce8"));
hints["interface/theme/accent_color"] = PropertyInfo(Variant::COLOR, "interface/theme/accent_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/theme/contrast", 0.25);
hints["interface/theme/contrast"] = PropertyInfo(Variant::REAL, "interface/theme/contrast", PROPERTY_HINT_RANGE, "0.01, 1, 0.01");
_initial_set("interface/theme/relationship_line_opacity", 0.1);

View File

@ -1951,8 +1951,9 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
if (is_visible_in_tree())
se->ensure_focus();
if (p_line >= 0)
if (p_line > 0) {
se->goto_line(p_line - 1);
}
}
return true;
}
@ -2012,8 +2013,9 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
_test_script_times_on_disk(p_resource);
_update_modified_scripts_for_external_editor(p_resource);
if (p_line >= 0)
if (p_line > 0) {
se->goto_line(p_line - 1);
}
notify_script_changed(p_resource);
_add_recent_script(p_resource->get_path());

View File

@ -796,92 +796,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case EDIT_TOGGLE_COMMENT: {
Ref<Script> scr = script;
if (scr.is_null())
return;
String delimiter = "#";
List<String> comment_delimiters;
scr->get_language()->get_comment_delimiters(&comment_delimiters);
for (List<String>::Element *E = comment_delimiters.front(); E; E = E->next()) {
String script_delimiter = E->get();
if (script_delimiter.find(" ") == -1) {
delimiter = script_delimiter;
break;
}
}
tx->begin_complex_operation();
if (tx->is_selection_active()) {
int begin = tx->get_selection_from_line();
int end = tx->get_selection_to_line();
// End of selection ends on the first column of the last line, ignore it.
if (tx->get_selection_to_column() == 0)
end -= 1;
int col_to = tx->get_selection_to_column();
int cursor_pos = tx->cursor_get_column();
// Check if all lines in the selected block are commented
bool is_commented = true;
for (int i = begin; i <= end; i++) {
if (!tx->get_line(i).begins_with(delimiter)) {
is_commented = false;
break;
}
}
for (int i = begin; i <= end; i++) {
String line_text = tx->get_line(i);
if (line_text.strip_edges().empty()) {
line_text = delimiter;
} else {
if (is_commented) {
line_text = line_text.substr(delimiter.length(), line_text.length());
} else {
line_text = delimiter + line_text;
}
}
tx->set_line(i, line_text);
}
// Adjust selection & cursor position.
int offset = is_commented ? -1 : 1;
int col_from = tx->get_selection_from_column() > 0 ? tx->get_selection_from_column() + offset : 0;
if (is_commented && tx->cursor_get_column() == tx->get_line(tx->cursor_get_line()).length() + 1)
cursor_pos += 1;
if (tx->get_selection_to_column() != 0 && col_to != tx->get_line(tx->get_selection_to_line()).length() + 1)
col_to += offset;
if (tx->cursor_get_column() != 0)
cursor_pos += offset;
tx->select(begin, col_from, tx->get_selection_to_line(), col_to);
tx->cursor_set_column(cursor_pos);
} else {
int begin = tx->cursor_get_line();
String line_text = tx->get_line(begin);
int col = tx->cursor_get_column();
if (line_text.begins_with(delimiter)) {
line_text = line_text.substr(delimiter.length(), line_text.length());
col -= 1;
} else {
line_text = delimiter + line_text;
col += 1;
}
tx->set_line(begin, line_text);
tx->cursor_set_column(col);
}
tx->end_complex_operation();
tx->update();
_edit_option_toggle_inline_comment();
} break;
case EDIT_COMPLETE: {
@ -1068,6 +983,25 @@ void ScriptTextEditor::_edit_option(int p_op) {
}
}
void ScriptTextEditor::_edit_option_toggle_inline_comment() {
if (script.is_null())
return;
String delimiter = "#";
List<String> comment_delimiters;
script->get_language()->get_comment_delimiters(&comment_delimiters);
for (List<String>::Element *E = comment_delimiters.front(); E; E = E->next()) {
String script_delimiter = E->get();
if (script_delimiter.find(" ") == -1) {
delimiter = script_delimiter;
break;
}
}
code_editor->toggle_inline_comment(delimiter);
}
void ScriptTextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter) {
highlighters[p_highlighter->get_name()] = p_highlighter;
highlighter_menu->add_radio_check_item(p_highlighter->get_name());

View File

@ -136,6 +136,7 @@ protected:
void _change_syntax_highlighter(int p_idx);
void _edit_option(int p_op);
void _edit_option_toggle_inline_comment();
void _make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition);
void _text_edit_gui_input(const Ref<InputEvent> &ev);
void _color_changed(const Color &p_color);

View File

@ -248,19 +248,19 @@ void ShaderEditor::_menu_option(int p_option) {
} break;
case EDIT_INDENT_LEFT: {
TextEdit *tx = shader_editor->get_text_edit();
if (shader.is_null())
return;
TextEdit *tx = shader_editor->get_text_edit();
tx->indent_left();
} break;
case EDIT_INDENT_RIGHT: {
TextEdit *tx = shader_editor->get_text_edit();
if (shader.is_null())
return;
TextEdit *tx = shader_editor->get_text_edit();
tx->indent_right();
} break;
@ -272,54 +272,10 @@ void ShaderEditor::_menu_option(int p_option) {
} break;
case EDIT_TOGGLE_COMMENT: {
TextEdit *tx = shader_editor->get_text_edit();
if (shader.is_null())
return;
tx->begin_complex_operation();
if (tx->is_selection_active()) {
int begin = tx->get_selection_from_line();
int end = tx->get_selection_to_line();
// End of selection ends on the first column of the last line, ignore it.
if (tx->get_selection_to_column() == 0)
end -= 1;
// Check if all lines in the selected block are commented
bool is_commented = true;
for (int i = begin; i <= end; i++) {
if (!tx->get_line(i).begins_with("//")) {
is_commented = false;
break;
}
}
for (int i = begin; i <= end; i++) {
String line_text = tx->get_line(i);
if (line_text.strip_edges().empty()) {
line_text = "//";
} else {
if (is_commented) {
line_text = line_text.substr(2, line_text.length());
} else {
line_text = "//" + line_text;
}
}
tx->set_line(i, line_text);
}
} else {
int begin = tx->cursor_get_line();
String line_text = tx->get_line(begin);
if (line_text.begins_with("//"))
line_text = line_text.substr(2, line_text.length());
else
line_text = "//" + line_text;
tx->set_line(begin, line_text);
}
tx->end_complex_operation();
tx->update();
//tx->deselect();
shader_editor->toggle_inline_comment("//");
} break;
case EDIT_COMPLETE: {

View File

@ -266,6 +266,20 @@ Error ScriptClassParser::_skip_generic_type_params() {
if (tk == TK_IDENTIFIER) {
tk = get_token();
// Type specifications can end with "?" to denote nullable types, such as IList<int?>
if (tk == TK_SYMBOL) {
tk = get_token();
if (value.operator String() != "?") {
error_str = "Expected " + get_token_name(TK_IDENTIFIER) + ", found unexpected symbol '" + value + "'";
error = true;
return ERR_PARSE_ERROR;
}
if (tk != TK_OP_GREATER && tk != TK_COMMA) {
error_str = "Nullable type symbol '?' is only allowed after an identifier, but found " + get_token_name(tk) + " next.";
error = true;
return ERR_PARSE_ERROR;
}
}
if (tk == TK_PERIOD) {
while (true) {

View File

@ -29,6 +29,7 @@
/*************************************************************************/
#include "mono_reg_utils.h"
#include "core/os/dir_access.h"
#ifdef WINDOWS_ENABLED
@ -200,6 +201,13 @@ String find_msbuild_tools_path() {
val += "\\";
}
// Since VS2019, the directory is simply named "Current"
String msBuildDirectory = val + "MSBuild\\Current\\Bin";
if (DirAccess::exists(msBuildDirectory)) {
return msBuildDirectory;
}
// Directory name "15.0" is used in VS 2017
return val + "MSBuild\\15.0\\Bin";
}
}

View File

@ -199,7 +199,7 @@ real_t StaticBody2D::get_constant_angular_velocity() const {
#ifndef DISABLE_DEPRECATED
void StaticBody2D::set_friction(real_t p_friction) {
if (p_friction == 1.0) { // default value, don't create an override for that
if (p_friction == 1.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
@ -229,7 +229,7 @@ real_t StaticBody2D::get_friction() const {
void StaticBody2D::set_bounce(real_t p_bounce) {
if (p_bounce == 0.0) { // default value, don't create an override for that
if (p_bounce == 0.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
@ -626,7 +626,7 @@ real_t RigidBody2D::get_weight() const {
#ifndef DISABLE_DEPRECATED
void RigidBody2D::set_friction(real_t p_friction) {
if (p_friction == 1.0) { // default value, don't create an override for that
if (p_friction == 1.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
@ -655,7 +655,7 @@ real_t RigidBody2D::get_friction() const {
void RigidBody2D::set_bounce(real_t p_bounce) {
if (p_bounce == 0.0) { // default value, don't create an override for that
if (p_bounce == 0.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}