summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/tile_map.cpp24
-rw-r--r--scene/2d/tile_map.h4
-rw-r--r--scene/gui/base_button.cpp4
-rw-r--r--scene/gui/popup_menu.cpp6
-rw-r--r--scene/gui/shortcut.cpp33
-rw-r--r--scene/gui/shortcut.h12
-rw-r--r--scene/resources/shader.cpp3
7 files changed, 44 insertions, 42 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 6afa0c0779..e2a415e5aa 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -1576,7 +1576,7 @@ void TileMap::set_cell(int p_layer, const Vector2i &p_coords, int p_source_id, c
_make_quadrant_dirty(Q);
}
- used_size_cache_dirty = true;
+ used_rect_cache_dirty = true;
} else {
if (!E) {
// Insert a new cell in the tile map.
@@ -1604,7 +1604,7 @@ void TileMap::set_cell(int p_layer, const Vector2i &p_coords, int p_source_id, c
c.alternative_tile = alternative_tile;
_make_quadrant_dirty(Q);
- used_size_cache_dirty = true;
+ used_rect_cache_dirty = true;
}
}
@@ -1800,7 +1800,7 @@ void TileMap::clear_layer(int p_layer) {
_clear_layer_internals(p_layer);
layers[p_layer].tile_map.clear();
- used_size_cache_dirty = true;
+ used_rect_cache_dirty = true;
}
void TileMap::clear() {
@@ -1809,7 +1809,7 @@ void TileMap::clear() {
for (unsigned int i = 0; i < layers.size(); i++) {
layers[i].tile_map.clear();
}
- used_size_cache_dirty = true;
+ used_rect_cache_dirty = true;
}
void TileMap::_set_tile_data(int p_layer, const Vector<int> &p_data) {
@@ -2666,25 +2666,31 @@ TypedArray<Vector2i> TileMap::get_used_cells(int p_layer) const {
Rect2 TileMap::get_used_rect() { // Not const because of cache
// Return the rect of the currently used area
- if (used_size_cache_dirty) {
+ if (used_rect_cache_dirty) {
bool first = true;
+ used_rect_cache = Rect2i();
+
for (unsigned int i = 0; i < layers.size(); i++) {
const Map<Vector2i, TileMapCell> &tile_map = layers[i].tile_map;
if (tile_map.size() > 0) {
if (first) {
- used_size_cache = Rect2(tile_map.front()->key().x, tile_map.front()->key().y, 1, 1);
+ used_rect_cache = Rect2i(tile_map.front()->key().x, tile_map.front()->key().y, 0, 0);
first = false;
}
for (Map<Vector2i, TileMapCell>::Element *E = tile_map.front(); E; E = E->next()) {
- used_size_cache.expand_to(Vector2(E->key().x + 1, E->key().y + 1));
+ used_rect_cache.expand_to(Vector2i(E->key().x, E->key().y));
}
}
}
- used_size_cache_dirty = false;
+
+ if (!first) { // first is true if every layer is empty.
+ used_rect_cache.size += Vector2i(1, 1); // The cache expands to top-left coordinate, so we add one full tile.
+ }
+ used_rect_cache_dirty = false;
}
- return used_size_cache;
+ return used_rect_cache;
}
// --- Override some methods of the CanvasItem class to pass the changes to the quadrants CanvasItems ---
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 4800780f94..dce18f7682 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -213,8 +213,8 @@ private:
// Rect.
Rect2 rect_cache;
bool rect_cache_dirty = true;
- Rect2 used_size_cache;
- bool used_size_cache_dirty = true;
+ Rect2i used_rect_cache;
+ bool used_rect_cache_dirty = true;
// TileMap layers.
struct TileMapLayer {
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 75a4464a40..82f4a216b8 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -345,7 +345,7 @@ void BaseButton::_unhandled_key_input(Ref<InputEvent> p_event) {
return;
}
- if (!is_disabled() && is_visible_in_tree() && !p_event->is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
+ if (!is_disabled() && is_visible_in_tree() && !p_event->is_echo() && shortcut.is_valid() && shortcut->matches_event(p_event)) {
on_action_event(p_event);
accept_event();
}
@@ -353,7 +353,7 @@ void BaseButton::_unhandled_key_input(Ref<InputEvent> p_event) {
String BaseButton::get_tooltip(const Point2 &p_pos) const {
String tooltip = Control::get_tooltip(p_pos);
- if (shortcut_in_tooltip && shortcut.is_valid() && shortcut->is_valid()) {
+ if (shortcut_in_tooltip && shortcut.is_valid() && shortcut->has_valid_event()) {
String text = shortcut->get_name() + " (" + shortcut->get_as_text() + ")";
if (tooltip != String() && shortcut->get_name().nocasecmp_to(tooltip) != 0) {
text += "\n" + tooltip;
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 490548fce0..44f7200cd7 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -74,7 +74,7 @@ Size2 PopupMenu::_get_contents_minimum_size() const {
size.width += items[i].text_buf->get_size().x;
size.height += vseparation;
- if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) {
+ if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->has_valid_event())) {
int accel_w = hseparation * 2;
accel_w += items[i].accel_text_buf->get_size().x;
accel_max_w = MAX(accel_w, accel_max_w);
@@ -635,7 +635,7 @@ void PopupMenu::_draw_items() {
}
// Accelerator / Shortcut
- if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) {
+ if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->has_valid_event())) {
if (rtl) {
item_ofs.x = scroll_width + style->get_margin(SIDE_LEFT) + item_end_padding;
} else {
@@ -1301,7 +1301,7 @@ bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_fo
continue;
}
- if (items[i].shortcut.is_valid() && items[i].shortcut->is_shortcut(p_event) && (items[i].shortcut_is_global || !p_for_global_only)) {
+ if (items[i].shortcut.is_valid() && items[i].shortcut->matches_event(p_event) && (items[i].shortcut_is_global || !p_for_global_only)) {
activate_item(i);
return true;
}
diff --git a/scene/gui/shortcut.cpp b/scene/gui/shortcut.cpp
index 962c6dcc60..885a51e058 100644
--- a/scene/gui/shortcut.cpp
+++ b/scene/gui/shortcut.cpp
@@ -32,42 +32,39 @@
#include "core/os/keyboard.h"
-void Shortcut::set_shortcut(const Ref<InputEvent> &p_shortcut) {
- shortcut = p_shortcut;
+void Shortcut::set_event(const Ref<InputEvent> &p_event) {
+ event = p_event;
emit_changed();
}
-Ref<InputEvent> Shortcut::get_shortcut() const {
- return shortcut;
+Ref<InputEvent> Shortcut::get_event() const {
+ return event;
}
-bool Shortcut::is_shortcut(const Ref<InputEvent> &p_event) const {
- return shortcut.is_valid() && shortcut->is_match(p_event, true);
+bool Shortcut::matches_event(const Ref<InputEvent> &p_event) const {
+ return event.is_valid() && event->is_match(p_event, true);
}
String Shortcut::get_as_text() const {
- if (shortcut.is_valid()) {
- return shortcut->as_text();
+ if (event.is_valid()) {
+ return event->as_text();
} else {
return "None";
}
}
-bool Shortcut::is_valid() const {
- return shortcut.is_valid();
+bool Shortcut::has_valid_event() const {
+ return event.is_valid();
}
void Shortcut::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_shortcut", "event"), &Shortcut::set_shortcut);
- ClassDB::bind_method(D_METHOD("get_shortcut"), &Shortcut::get_shortcut);
+ ClassDB::bind_method(D_METHOD("set_event", "event"), &Shortcut::set_event);
+ ClassDB::bind_method(D_METHOD("get_event"), &Shortcut::get_event);
- ClassDB::bind_method(D_METHOD("is_valid"), &Shortcut::is_valid);
+ ClassDB::bind_method(D_METHOD("has_valid_event"), &Shortcut::has_valid_event);
- ClassDB::bind_method(D_METHOD("is_shortcut", "event"), &Shortcut::is_shortcut);
+ ClassDB::bind_method(D_METHOD("matches_event", "event"), &Shortcut::matches_event);
ClassDB::bind_method(D_METHOD("get_as_text"), &Shortcut::get_as_text);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shortcut", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), "set_shortcut", "get_shortcut");
-}
-
-Shortcut::Shortcut() {
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), "set_event", "get_event");
}
diff --git a/scene/gui/shortcut.h b/scene/gui/shortcut.h
index ea91f29b5d..249dd1971f 100644
--- a/scene/gui/shortcut.h
+++ b/scene/gui/shortcut.h
@@ -37,20 +37,18 @@
class Shortcut : public Resource {
GDCLASS(Shortcut, Resource);
- Ref<InputEvent> shortcut;
+ Ref<InputEvent> event;
protected:
static void _bind_methods();
public:
- void set_shortcut(const Ref<InputEvent> &p_shortcut);
- Ref<InputEvent> get_shortcut() const;
- bool is_shortcut(const Ref<InputEvent> &p_event) const;
- bool is_valid() const;
+ void set_event(const Ref<InputEvent> &p_shortcut);
+ Ref<InputEvent> get_event() const;
+ bool matches_event(const Ref<InputEvent> &p_event) const;
+ bool has_valid_event() const;
String get_as_text() const;
-
- Shortcut();
};
#endif // SHORTCUT_H
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 424a54f344..44d524f142 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -76,8 +76,9 @@ void Shader::get_param_list(List<PropertyInfo> *p_params) const {
if (default_textures.has(pi.name)) { //do not show default textures
continue;
}
+ String original_name = pi.name;
pi.name = "shader_param/" + pi.name;
- params_cache[pi.name] = pi.name;
+ params_cache[pi.name] = original_name;
if (p_params) {
//small little hack
if (pi.type == Variant::RID) {