summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/OptionButton.xml19
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp6
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.h2
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp59
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.h1
-rw-r--r--platform/uwp/os_uwp.cpp4
-rw-r--r--platform/windows/os_windows.cpp4
-rw-r--r--scene/gui/option_button.cpp7
-rw-r--r--scene/gui/option_button.h1
-rw-r--r--scene/gui/popup.cpp35
10 files changed, 79 insertions, 59 deletions
diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml
index c58c932b61..09b9167149 100644
--- a/doc/classes/OptionButton.xml
+++ b/doc/classes/OptionButton.xml
@@ -71,9 +71,18 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Return the ID of the item at index "idx".
- </description>
- </method>
+ Return the ID of the item at index [code]idx[/code].
+ </description>
+ </method>
+ <method name="get_item_index" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="id" type="int">
+ </argument>
+ <description>
+ Return the index of the item with the given [code]id[/code].
+ </description>
+ </method>
<method name="get_item_metadata" qualifiers="const">
<return type="Variant">
</return>
@@ -198,14 +207,14 @@
<argument index="0" name="ID" type="int">
</argument>
<description>
- This signal is emitted when user navigated to an item using [code]ui_up[/code] or [code]ui_down[/code] action. ID of the item selected is passed as argument (if no IDs were added, ID will be just the item index).
+ This signal is emitted when user navigated to an item using [code]ui_up[/code] or [code]ui_down[/code] action. ID of the item selected is passed as argument.
</description>
</signal>
<signal name="item_selected">
<argument index="0" name="ID" type="int">
</argument>
<description>
- This signal is emitted when the current item was changed by the user. ID of the item selected is passed as argument (if no IDs were added, ID will be just the item index).
+ This signal is emitted when the current item was changed by the user. Index of the item selected is passed as argument.
</description>
</signal>
</signals>
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index 41e2062ab2..8f6f244e8f 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -297,6 +297,12 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
if (mb.is_valid()) {
+ String cant_edit = _why_cant_edit_polygon();
+ if (cant_edit != String()) {
+ EditorNode::get_singleton()->show_warning(cant_edit);
+ return true;
+ }
+
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
Vector2 gpoint = mb->get_position();
diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h
index 289c2785b1..f10af4ee6e 100644
--- a/editor/plugins/abstract_polygon_2d_editor.h
+++ b/editor/plugins/abstract_polygon_2d_editor.h
@@ -134,6 +134,8 @@ protected:
virtual bool _has_resource() const;
virtual void _create_resource();
+ virtual String _why_cant_edit_polygon() const { return String(); }
+
public:
bool forward_gui_input(const Ref<InputEvent> &p_event);
void forward_canvas_draw_over_viewport(Control *p_overlay);
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 1d7b4ffa41..28a17d0bef 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -52,6 +52,16 @@ Vector2 Polygon2DEditor::_get_offset(int p_idx) const {
return node->get_offset();
}
+String Polygon2DEditor::_why_cant_edit_polygon() const {
+
+ if (node->get_internal_vertex_count() > 0) {
+
+ return TTR("Polygon 2D has internal vertices, so it can no longer be edited in the viewport.");
+ }
+
+ return String();
+}
+
int Polygon2DEditor::_get_polygon_count() const {
if (node->get_internal_vertex_count() > 0) {
return 0; //do not edit if internal vertices exist
@@ -1028,6 +1038,9 @@ void Polygon2DEditor::_uv_draw() {
Ref<Texture> internal_handle = get_icon("EditorInternalHandle", "EditorIcons");
Color poly_line_color = Color(0.9, 0.5, 0.5);
+ if (polygons.size() || polygon_create.size()) {
+ poly_line_color.a *= 0.25;
+ }
Color polygon_line_color = Color(0.5, 0.5, 0.9);
Vector<Color> polygon_fill_color;
{
@@ -1041,6 +1054,30 @@ void Polygon2DEditor::_uv_draw() {
int uv_draw_max = uvs.size();
+ uv_draw_max -= node->get_internal_vertex_count();
+ if (uv_draw_max < 0) {
+ uv_draw_max = 0;
+ }
+
+ for (int i = 0; i < uvs.size(); i++) {
+
+ int next = uv_draw_max > 0 ? (i + 1) % uv_draw_max : 0;
+
+ if (i < uv_draw_max && uv_drag && uv_move_current == UV_MODE_EDIT_POINT && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) {
+ uv_edit_draw->draw_line(mtx.xform(points_prev[i]), mtx.xform(points_prev[next]), prev_color, 2 * EDSCALE);
+ }
+
+ Vector2 next_point = uvs[next];
+ if (uv_create && i == uvs.size() - 1) {
+ next_point = uv_create_to;
+ }
+ if (i < uv_draw_max /*&& polygons.size() == 0 && polygon_create.size() == 0*/) { //if using or creating polygons, do not show outline (will show polygons instead)
+ uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(next_point), poly_line_color, 2 * EDSCALE);
+ }
+
+ rect.expand_to(mtx.basis_xform(uvs[i]));
+ }
+
for (int i = 0; i < polygons.size(); i++) {
PoolVector<int> points = polygons[i];
@@ -1063,27 +1100,8 @@ void Polygon2DEditor::_uv_draw() {
}
}
- uv_draw_max -= node->get_internal_vertex_count();
- if (uv_draw_max < 0) {
- uv_draw_max = 0;
- }
-
for (int i = 0; i < uvs.size(); i++) {
- int next = uv_draw_max > 0 ? (i + 1) % uv_draw_max : 0;
-
- if (i < uv_draw_max && uv_drag && uv_move_current == UV_MODE_EDIT_POINT && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) {
- uv_edit_draw->draw_line(mtx.xform(points_prev[i]), mtx.xform(points_prev[next]), prev_color, 2 * EDSCALE);
- }
-
- Vector2 next_point = uvs[next];
- if (uv_create && i == uvs.size() - 1) {
- next_point = uv_create_to;
- }
- if (i < uv_draw_max && polygons.size() == 0 && polygon_create.size() == 0) { //if using or creating polygons, do not show outline (will show polygons instead)
- uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(next_point), poly_line_color, 2 * EDSCALE);
- }
-
if (weight_r.ptr()) {
Vector2 draw_pos = mtx.xform(uvs[i]);
float weight = weight_r[i];
@@ -1095,14 +1113,13 @@ void Polygon2DEditor::_uv_draw() {
uv_edit_draw->draw_texture(internal_handle, mtx.xform(uvs[i]) - internal_handle->get_size() * 0.5);
}
}
- rect.expand_to(mtx.basis_xform(uvs[i]));
}
if (polygon_create.size()) {
for (int i = 0; i < polygon_create.size(); i++) {
Vector2 from = uvs[polygon_create[i]];
Vector2 to = (i + 1) < polygon_create.size() ? uvs[polygon_create[i + 1]] : uv_create_to;
- uv_edit_draw->draw_line(mtx.xform(from), mtx.xform(to), poly_line_color, 2);
+ uv_edit_draw->draw_line(mtx.xform(from), mtx.xform(to), polygon_line_color, 2);
}
}
diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h
index d1849dd09b..d3277e90f7 100644
--- a/editor/plugins/polygon_2d_editor_plugin.h
+++ b/editor/plugins/polygon_2d_editor_plugin.h
@@ -152,6 +152,7 @@ protected:
virtual void _set_node(Node *p_polygon);
virtual Vector2 _get_offset(int p_idx) const;
+ virtual String _why_cant_edit_polygon() const;
virtual bool _has_uv() const { return true; };
virtual void _commit_action();
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 9c9280ac7e..520e179611 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -579,7 +579,9 @@ OS::TimeZoneInfo OS_UWP::get_time_zone_info() const {
ret.name = info.StandardName;
}
- ret.bias = info.Bias;
+ // Bias value returned by GetTimeZoneInformation is inverted of what we expect
+ // For example on GMT-3 GetTimeZoneInformation return a Bias of 180, so invert the value to get -180
+ ret.bias = -info.Bias;
return ret;
}
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 3de33da8f5..b8a6de1fd1 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -2137,7 +2137,9 @@ OS::TimeZoneInfo OS_Windows::get_time_zone_info() const {
ret.name = info.StandardName;
}
- ret.bias = info.Bias;
+ // Bias value returned by GetTimeZoneInformation is inverted of what we expect
+ // For example on GMT-3 GetTimeZoneInformation return a Bias of 180, so invert the value to get -180
+ ret.bias = -info.Bias;
return ret;
}
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 98f427cc07..b9b270ce0c 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -160,6 +160,12 @@ int OptionButton::get_item_id(int p_idx) const {
return popup->get_item_id(p_idx);
}
+
+int OptionButton::get_item_index(int p_id) const {
+
+ return popup->get_item_index(p_id);
+}
+
Variant OptionButton::get_item_metadata(int p_idx) const {
return popup->get_item_metadata(p_idx);
@@ -306,6 +312,7 @@ void OptionButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_text", "idx"), &OptionButton::get_item_text);
ClassDB::bind_method(D_METHOD("get_item_icon", "idx"), &OptionButton::get_item_icon);
ClassDB::bind_method(D_METHOD("get_item_id", "idx"), &OptionButton::get_item_id);
+ ClassDB::bind_method(D_METHOD("get_item_index", "id"), &OptionButton::get_item_index);
ClassDB::bind_method(D_METHOD("get_item_metadata", "idx"), &OptionButton::get_item_metadata);
ClassDB::bind_method(D_METHOD("is_item_disabled", "idx"), &OptionButton::is_item_disabled);
ClassDB::bind_method(D_METHOD("get_item_count"), &OptionButton::get_item_count);
diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h
index 121b4c002d..63b451377a 100644
--- a/scene/gui/option_button.h
+++ b/scene/gui/option_button.h
@@ -71,6 +71,7 @@ public:
String get_item_text(int p_idx) const;
Ref<Texture> get_item_icon(int p_idx) const;
int get_item_id(int p_idx) const;
+ int get_item_index(int p_id) const;
Variant get_item_metadata(int p_idx) const;
bool is_item_disabled(int p_idx) const;
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 2d2c54594a..80ec7049fc 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -124,49 +124,22 @@ void Popup::popup_centered_minsize(const Size2 &p_minsize) {
void Popup::popup_centered(const Size2 &p_size) {
- Point2 window_size = get_viewport_rect().size;
-
- emit_signal("about_to_show");
Rect2 rect;
+ Size2 window_size = get_viewport_rect().size;
rect.size = p_size == Size2() ? get_size() : p_size;
-
rect.position = ((window_size - rect.size) / 2.0).floor();
- set_position(rect.position);
- set_size(rect.size);
-
- show_modal(exclusive);
- _fix_size();
- Control *focusable = find_next_valid_focus();
- if (focusable)
- focusable->grab_focus();
-
- _post_popup();
- notification(NOTIFICATION_POST_POPUP);
- popped_up = true;
+ popup(rect);
}
void Popup::popup_centered_ratio(float p_screen_ratio) {
- emit_signal("about_to_show");
-
Rect2 rect;
- Point2 window_size = get_viewport_rect().size;
+ Size2 window_size = get_viewport_rect().size;
rect.size = (window_size * p_screen_ratio).floor();
rect.position = ((window_size - rect.size) / 2.0).floor();
- set_position(rect.position);
- set_size(rect.size);
- show_modal(exclusive);
- _fix_size();
-
- Control *focusable = find_next_valid_focus();
- if (focusable)
- focusable->grab_focus();
-
- _post_popup();
- notification(NOTIFICATION_POST_POPUP);
- popped_up = true;
+ popup(rect);
}
void Popup::popup(const Rect2 &p_bounds) {