summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/resource_import.cpp36
-rw-r--r--core/io/resource_import.h4
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp4
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp4
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h1
-rw-r--r--drivers/gles3/shaders/scene.glsl4
-rw-r--r--editor/editor_node.cpp5
-rw-r--r--editor/import/resource_importer_bitmask.cpp91
-rw-r--r--editor/import/resource_importer_bitmask.h29
-rw-r--r--modules/gdnative/gdnative.cpp2
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp9
-rw-r--r--modules/gdnative/nativescript/nativescript.h2
-rw-r--r--modules/pbm/SCsub8
-rw-r--r--modules/pbm/bitmap_loader_pbm.cpp237
-rw-r--r--modules/pbm/bitmap_loader_pbm.h48
-rw-r--r--modules/pbm/config.py5
-rw-r--r--modules/pbm/register_types.cpp46
-rw-r--r--modules/pbm/register_types.h32
-rw-r--r--platform/osx/os_osx.mm84
-rw-r--r--scene/gui/popup_menu.cpp59
-rw-r--r--scene/gui/popup_menu.h1
-rw-r--r--scene/gui/tree.cpp5
-rw-r--r--scene/resources/bit_mask.cpp4
-rw-r--r--scene/resources/bit_mask.h1
-rw-r--r--servers/visual/visual_server_scene.cpp2
25 files changed, 237 insertions, 486 deletions
diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp
index 58de944e6c..cfe6655504 100644
--- a/core/io/resource_import.cpp
+++ b/core/io/resource_import.cpp
@@ -138,9 +138,9 @@ void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extension
Set<String> found;
- for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) {
+ for (int i = 0; i < importers.size(); i++) {
List<String> local_exts;
- E->get()->get_recognized_extensions(&local_exts);
+ importers[i]->get_recognized_extensions(&local_exts);
for (List<String>::Element *F = local_exts.front(); F; F = F->next()) {
if (!found.has(F->get())) {
p_extensions->push_back(F->get());
@@ -158,8 +158,8 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_
Set<String> found;
- for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) {
- String res_type = E->get()->get_resource_type();
+ for (int i = 0; i < importers.size(); i++) {
+ String res_type = importers[i]->get_resource_type();
if (res_type == String())
continue;
@@ -167,7 +167,7 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_
continue;
List<String> local_exts;
- E->get()->get_recognized_extensions(&local_exts);
+ importers[i]->get_recognized_extensions(&local_exts);
for (List<String>::Element *F = local_exts.front(); F; F = F->next()) {
if (!found.has(F->get())) {
p_extensions->push_back(F->get());
@@ -212,9 +212,9 @@ int ResourceFormatImporter::get_import_order(const String &p_path) const {
bool ResourceFormatImporter::handles_type(const String &p_type) const {
- for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) {
+ for (int i = 0; i < importers.size(); i++) {
- String res_type = E->get()->get_resource_type();
+ String res_type = importers[i]->get_resource_type();
if (res_type == String())
continue;
if (ClassDB::is_parent_class(res_type, p_type))
@@ -319,9 +319,9 @@ void ResourceFormatImporter::get_dependencies(const String &p_path, List<String>
Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String &p_name) const {
- for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) {
- if (E->get()->get_importer_name() == p_name) {
- return E->get();
+ for (int i = 0; i < importers.size(); i++) {
+ if (importers[i]->get_importer_name() == p_name) {
+ return importers[i];
}
}
@@ -330,12 +330,12 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String
void ResourceFormatImporter::get_importers_for_extension(const String &p_extension, List<Ref<ResourceImporter> > *r_importers) {
- for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) {
+ for (int i = 0; i < importers.size(); i++) {
List<String> local_exts;
- E->get()->get_recognized_extensions(&local_exts);
+ importers[i]->get_recognized_extensions(&local_exts);
for (List<String>::Element *F = local_exts.front(); F; F = F->next()) {
if (p_extension.to_lower() == F->get()) {
- r_importers->push_back(E->get());
+ r_importers->push_back(importers[i]);
}
}
}
@@ -346,14 +346,14 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const St
Ref<ResourceImporter> importer;
float priority = 0;
- for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) {
+ for (int i = 0; i < importers.size(); i++) {
List<String> local_exts;
- E->get()->get_recognized_extensions(&local_exts);
+ importers[i]->get_recognized_extensions(&local_exts);
for (List<String>::Element *F = local_exts.front(); F; F = F->next()) {
- if (p_extension.to_lower() == F->get() && E->get()->get_priority() > priority) {
- importer = E->get();
- priority = E->get()->get_priority();
+ if (p_extension.to_lower() == F->get() && importers[i]->get_priority() > priority) {
+ importer = importers[i];
+ priority = importers[i]->get_priority();
}
}
}
diff --git a/core/io/resource_import.h b/core/io/resource_import.h
index 1b681bd97a..80e0743eda 100644
--- a/core/io/resource_import.h
+++ b/core/io/resource_import.h
@@ -46,7 +46,7 @@ class ResourceFormatImporter : public ResourceFormatLoader {
static ResourceFormatImporter *singleton;
- Set<Ref<ResourceImporter> > importers;
+ Vector<Ref<ResourceImporter> > importers;
public:
static ResourceFormatImporter *get_singleton() { return singleton; }
@@ -65,7 +65,7 @@ public:
String get_internal_resource_path(const String &p_path) const;
void get_internal_resource_path_list(const String &p_path, List<String> *r_paths);
- void add_importer(const Ref<ResourceImporter> &p_importer) { importers.insert(p_importer); }
+ void add_importer(const Ref<ResourceImporter> &p_importer) { importers.push_back(p_importer); }
void remove_importer(const Ref<ResourceImporter> &p_importer) { importers.erase(p_importer); }
Ref<ResourceImporter> get_importer_by_name(const String &p_name) const;
Ref<ResourceImporter> get_importer_by_extension(const String &p_extension) const;
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 728b36ed6f..da6df7198d 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -2230,7 +2230,7 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_depth_pass, bool p_shadow_pass) {
- bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture;
+ bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture || p_material->shader->spatial.uses_depth_texture;
bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX;
bool has_alpha = has_base_alpha || has_blend_alpha;
@@ -2254,7 +2254,7 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
if (p_depth_pass) {
- if (has_blend_alpha || (has_base_alpha && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS))
+ if (has_blend_alpha || p_material->shader->spatial.uses_depth_texture || (has_base_alpha && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS))
return; //bye
if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index bf9539a26a..b63ebcba54 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -1619,6 +1619,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
p_shader->spatial.uses_time = false;
p_shader->spatial.uses_vertex_lighting = false;
p_shader->spatial.uses_screen_texture = false;
+ p_shader->spatial.uses_depth_texture = false;
p_shader->spatial.uses_vertex = false;
p_shader->spatial.writes_modelview_or_projection = false;
p_shader->spatial.uses_world_coordinates = false;
@@ -1650,6 +1651,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
shaders.actions_scene.usage_flag_pointers["SSS_STRENGTH"] = &p_shader->spatial.uses_sss;
shaders.actions_scene.usage_flag_pointers["DISCARD"] = &p_shader->spatial.uses_discard;
shaders.actions_scene.usage_flag_pointers["SCREEN_TEXTURE"] = &p_shader->spatial.uses_screen_texture;
+ shaders.actions_scene.usage_flag_pointers["DEPTH_TEXTURE"] = &p_shader->spatial.uses_depth_texture;
shaders.actions_scene.usage_flag_pointers["TIME"] = &p_shader->spatial.uses_time;
shaders.actions_scene.write_flag_pointers["MODELVIEW_MATRIX"] = &p_shader->spatial.writes_modelview_or_projection;
@@ -6904,6 +6906,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
// delete the texture
GIProbe *gi_probe = gi_probe_owner.get(p_rid);
+ gi_probe->instance_remove_deps();
gi_probe_owner.free(p_rid);
memdelete(gi_probe);
@@ -6919,6 +6922,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
// delete the texture
LightmapCapture *lightmap_capture = lightmap_capture_data_owner.get(p_rid);
+ lightmap_capture->instance_remove_deps();
gi_probe_owner.free(p_rid);
memdelete(lightmap_capture);
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index 42cb31a4fa..ef2b247266 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -473,6 +473,7 @@ public:
bool uses_discard;
bool uses_sss;
bool uses_screen_texture;
+ bool uses_depth_texture;
bool uses_time;
bool writes_modelview_or_projection;
bool uses_vertex_lighting;
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 2ccc661343..1aa28d0fd5 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -1648,7 +1648,7 @@ void main() {
#if defined(ENABLE_NORMALMAP)
- vec3 normalmap = vec3(0.0);
+ vec3 normalmap = vec3(0.5);
#endif
float normaldepth=1.0;
@@ -2003,7 +2003,7 @@ FRAGMENT_SHADER_CODE
}
#ifndef USE_LIGHTMAP
if (ambient_accum.a>0.0) {
- ambient_light+=ambient_accum.rgb/ambient_accum.a;
+ ambient_light=ambient_accum.rgb/ambient_accum.a;
}
#endif
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 8609697518..70047bc60c 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -60,6 +60,7 @@
#include "editor/editor_themes.h"
#include "editor/import/editor_import_collada.h"
#include "editor/import/editor_scene_importer_gltf.h"
+#include "editor/import/resource_importer_bitmask.h"
#include "editor/import/resource_importer_csv_translation.h"
#include "editor/import/resource_importer_obj.h"
#include "editor/import/resource_importer_scene.h"
@@ -4815,6 +4816,10 @@ EditorNode::EditorNode() {
import_gltf.instance();
import_scene->add_importer(import_gltf);
}
+
+ Ref<ResourceImporterBitMap> import_bitmap;
+ import_bitmap.instance();
+ ResourceFormatImporter::get_singleton()->add_importer(import_bitmap);
}
_pvrtc_register_compressors();
diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp
new file mode 100644
index 0000000000..3d2959c598
--- /dev/null
+++ b/editor/import/resource_importer_bitmask.cpp
@@ -0,0 +1,91 @@
+#include "resource_importer_bitmask.h"
+#include "core/image.h"
+#include "editor/editor_file_system.h"
+#include "editor/editor_node.h"
+#include "io/config_file.h"
+#include "io/image_loader.h"
+#include "scene/resources/bit_mask.h"
+#include "scene/resources/texture.h"
+
+String ResourceImporterBitMap::get_importer_name() const {
+
+ return "bitmap";
+}
+
+String ResourceImporterBitMap::get_visible_name() const {
+
+ return "BitMap";
+}
+void ResourceImporterBitMap::get_recognized_extensions(List<String> *p_extensions) const {
+
+ ImageLoader::get_recognized_extensions(p_extensions);
+}
+String ResourceImporterBitMap::get_save_extension() const {
+ return "res";
+}
+
+String ResourceImporterBitMap::get_resource_type() const {
+
+ return "BitMap";
+}
+
+bool ResourceImporterBitMap::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
+
+ return true;
+}
+
+int ResourceImporterBitMap::get_preset_count() const {
+ return 0;
+}
+String ResourceImporterBitMap::get_preset_name(int p_idx) const {
+
+ return String();
+}
+
+void ResourceImporterBitMap::get_import_options(List<ImportOption> *r_options, int p_preset) const {
+
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "create_from", PROPERTY_HINT_ENUM, "Black & White,Alpha"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.5));
+}
+
+Error ResourceImporterBitMap::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
+
+ int create_from = p_options["create_from"];
+ float threshold = p_options["threshold"];
+ Ref<Image> image;
+ image.instance();
+ Error err = ImageLoader::load_image(p_source_file, image);
+ if (err != OK)
+ return err;
+
+ int w = image->get_width();
+ int h = image->get_height();
+
+ Ref<BitMap> bitmap;
+ bitmap.instance();
+ bitmap->create(Size2(w, h));
+ image->lock();
+
+ for (int i = 0; i < h; i++) {
+ for (int j = 0; j < w; j++) {
+
+ bool bit;
+ Color c = image->get_pixel(j, i);
+ if (create_from == 0) { //b&W
+ bit = c.get_v() > threshold;
+ } else {
+ bit = c.a > threshold;
+ }
+
+ bitmap->set_bit(Vector2(i, j), bit);
+ }
+ }
+
+ return ResourceSaver::save(p_save_path + ".res", bitmap);
+}
+
+ResourceImporterBitMap::ResourceImporterBitMap() {
+}
+
+ResourceImporterBitMap::~ResourceImporterBitMap() {
+}
diff --git a/editor/import/resource_importer_bitmask.h b/editor/import/resource_importer_bitmask.h
new file mode 100644
index 0000000000..8a3cafa7ce
--- /dev/null
+++ b/editor/import/resource_importer_bitmask.h
@@ -0,0 +1,29 @@
+#ifndef RESOURCE_IMPORTER_BITMASK_H
+#define RESOURCE_IMPORTER_BITMASK_H
+
+#include "image.h"
+#include "io/resource_import.h"
+
+class StreamBitMap;
+
+class ResourceImporterBitMap : public ResourceImporter {
+ GDCLASS(ResourceImporterBitMap, ResourceImporter)
+
+public:
+ virtual String get_importer_name() const;
+ virtual String get_visible_name() const;
+ virtual void get_recognized_extensions(List<String> *p_extensions) const;
+ virtual String get_save_extension() const;
+ virtual String get_resource_type() const;
+
+ virtual int get_preset_count() const;
+ virtual String get_preset_name(int p_idx) const;
+
+ virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
+ virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
+ virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL);
+
+ ResourceImporterBitMap();
+ ~ResourceImporterBitMap();
+};
+#endif // RESOURCE_IMPORTER_BITMASK_H
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index dec42dc17a..1379083b42 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -399,7 +399,6 @@ RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_or
}
void GDNativeLibraryResourceLoader::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->clear();
p_extensions->push_back("gdnlib");
}
@@ -438,7 +437,6 @@ bool GDNativeLibraryResourceSaver::recognize(const RES &p_resource) const {
void GDNativeLibraryResourceSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
if (Object::cast_to<GDNativeLibrary>(*p_resource) != NULL) {
- p_extensions->clear();
p_extensions->push_back("gdnlib");
}
}
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index 2d94599ea0..e9e3180835 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -790,8 +790,13 @@ NativeScriptInstance::~NativeScriptInstance() {
NativeScriptLanguage *NativeScriptLanguage::singleton;
-void NativeScriptLanguage::_unload_stuff() {
+void NativeScriptLanguage::_unload_stuff(bool p_reload) {
for (Map<String, Map<StringName, NativeScriptDesc> >::Element *L = library_classes.front(); L; L = L->next()) {
+
+ if (p_reload && !library_gdnatives[L->key()]->get_library()->is_reloadable()) {
+ continue;
+ }
+
for (Map<StringName, NativeScriptDesc>::Element *C = L->get().front(); C; C = C->next()) {
// free property stuff first
@@ -1108,7 +1113,7 @@ void NativeReloadNode::_notification(int p_what) {
#ifndef NO_THREADS
MutexLock lock(NSL->mutex);
#endif
- NSL->_unload_stuff();
+ NSL->_unload_stuff(true);
for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
Ref<GDNative> gdn = L->get();
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 38f77aea55..ac94c84bc4 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -205,7 +205,7 @@ class NativeScriptLanguage : public ScriptLanguage {
private:
static NativeScriptLanguage *singleton;
- void _unload_stuff();
+ void _unload_stuff(bool p_reload = false);
#ifndef NO_THREADS
Mutex *mutex;
diff --git a/modules/pbm/SCsub b/modules/pbm/SCsub
deleted file mode 100644
index fa328be025..0000000000
--- a/modules/pbm/SCsub
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-Import('env_modules')
-
-env_pbm = env_modules.Clone()
-
-env_pbm.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/pbm/bitmap_loader_pbm.cpp b/modules/pbm/bitmap_loader_pbm.cpp
deleted file mode 100644
index 805528ebfe..0000000000
--- a/modules/pbm/bitmap_loader_pbm.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/*************************************************************************/
-/* bitmap_loader_pbm.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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. */
-/*************************************************************************/
-
-#include "bitmap_loader_pbm.h"
-#include "os/file_access.h"
-#include "scene/resources/bit_mask.h"
-
-static bool _get_token(FileAccessRef &f, uint8_t &saved, PoolVector<uint8_t> &r_token, bool p_binary = false, bool p_single_chunk = false) {
-
- int token_max = r_token.size();
- PoolVector<uint8_t>::Write w;
- if (token_max)
- w = r_token.write();
- int ofs = 0;
- bool lf = false;
-
- while (true) {
-
- uint8_t b;
- if (saved) {
- b = saved;
- saved = 0;
- } else {
- b = f->get_8();
- }
- if (f->eof_reached()) {
- if (ofs) {
- w = PoolVector<uint8_t>::Write();
- r_token.resize(ofs);
- return true;
- } else {
- return false;
- }
- }
-
- if (!ofs && !p_binary && b == '#') {
- //skip comment
- while (b != '\n') {
- if (f->eof_reached()) {
- return false;
- }
-
- b = f->get_8();
- }
-
- lf = true;
-
- } else if (b <= 32 && !(p_binary && (ofs || lf))) {
-
- if (b == '\n') {
- lf = true;
- }
-
- if (ofs && !p_single_chunk) {
- w = PoolVector<uint8_t>::Write();
- r_token.resize(ofs);
- saved = b;
-
- return true;
- }
- } else {
-
- bool resized = false;
- while (ofs >= token_max) {
- if (token_max)
- token_max <<= 1;
- else
- token_max = 1;
- resized = true;
- }
- if (resized) {
- // Note: Certain C++ static analyzers might point out that the following assigment is unnecessary.
- // This is wrong since PoolVector<class T>::Write has an operator= method where the lhs gets updated under certain conditions.
- // See core/dvector.h.
- w = PoolVector<uint8_t>::Write();
- r_token.resize(token_max);
- w = r_token.write();
- }
- w[ofs++] = b;
- }
- }
-
- return false;
-}
-
-static int _get_number_from_token(PoolVector<uint8_t> &r_token) {
-
- int len = r_token.size();
- PoolVector<uint8_t>::Read r = r_token.read();
- return String::to_int((const char *)r.ptr(), len);
-}
-
-RES ResourceFormatPBM::load(const String &p_path, const String &p_original_path, Error *r_error) {
-
-#define _RETURN(m_err) \
- { \
- if (r_error) \
- *r_error = m_err; \
- ERR_FAIL_V(RES()); \
- }
-
- FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
- uint8_t saved = 0;
- if (!f)
- _RETURN(ERR_CANT_OPEN);
-
- PoolVector<uint8_t> token;
-
- if (!_get_token(f, saved, token)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- if (token.size() != 2) {
- _RETURN(ERR_FILE_CORRUPT);
- }
- if (token[0] != 'P') {
- _RETURN(ERR_FILE_CORRUPT);
- }
- if (token[1] != '1' && token[1] != '4') {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- bool bits = token[1] == '4';
-
- if (!_get_token(f, saved, token)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- int width = _get_number_from_token(token);
- if (width <= 0) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- if (!_get_token(f, saved, token)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- int height = _get_number_from_token(token);
- if (height <= 0) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- Ref<BitMap> bm;
- bm.instance();
- bm->create(Size2i(width, height));
-
- if (!bits) {
-
- int required_bytes = width * height;
- if (!_get_token(f, saved, token, false, true)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- if (token.size() < required_bytes) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- PoolVector<uint8_t>::Read r = token.read();
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
-
- char num = r[i * width + j];
- bm->set_bit(Point2i(j, i), num == '0');
- }
- }
-
- } else {
- //a single, entire token of bits!
- if (!_get_token(f, saved, token, true)) {
- _RETURN(ERR_PARSE_ERROR);
- }
- int required_bytes = Math::ceil((width * height) / 8.0);
- if (token.size() < required_bytes) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- PoolVector<uint8_t>::Read r = token.read();
- int bitwidth = width;
- if (bitwidth % 8)
- bitwidth += 8 - (bitwidth % 8);
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
-
- int ofs = bitwidth * i + j;
-
- uint8_t byte = r[ofs / 8];
- bool bit = (byte >> (7 - (ofs % 8))) & 1;
-
- bm->set_bit(Point2i(j, i), !bit);
- }
- }
- }
-
- return bm;
-}
-
-void ResourceFormatPBM::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back("pbm");
-}
-bool ResourceFormatPBM::handles_type(const String &p_type) const {
- return p_type == "BitMap";
-}
-String ResourceFormatPBM::get_resource_type(const String &p_path) const {
-
- if (p_path.get_extension().to_lower() == "pbm")
- return "BitMap";
- return "";
-}
diff --git a/modules/pbm/bitmap_loader_pbm.h b/modules/pbm/bitmap_loader_pbm.h
deleted file mode 100644
index a93c482ece..0000000000
--- a/modules/pbm/bitmap_loader_pbm.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*************************************************************************/
-/* bitmap_loader_pbm.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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 BITMAP_LOADER_PBM_H
-#define BITMAP_LOADER_PBM_H
-
-#include "io/resource_loader.h"
-
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-class ResourceFormatPBM : public ResourceFormatLoader {
-
-public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String &p_type) const;
- virtual String get_resource_type(const String &p_path) const;
-};
-
-#endif
diff --git a/modules/pbm/config.py b/modules/pbm/config.py
deleted file mode 100644
index 5f133eba90..0000000000
--- a/modules/pbm/config.py
+++ /dev/null
@@ -1,5 +0,0 @@
-def can_build(platform):
- return True
-
-def configure(env):
- pass
diff --git a/modules/pbm/register_types.cpp b/modules/pbm/register_types.cpp
deleted file mode 100644
index 37d8915fd6..0000000000
--- a/modules/pbm/register_types.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*************************************************************************/
-/* register_types.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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. */
-/*************************************************************************/
-
-#include "register_types.h"
-
-#include "bitmap_loader_pbm.h"
-
-static ResourceFormatPBM *pbm_loader = NULL;
-
-void register_pbm_types() {
-
- pbm_loader = memnew(ResourceFormatPBM);
- ResourceLoader::add_resource_format_loader(pbm_loader);
-}
-
-void unregister_pbm_types() {
-
- memdelete(pbm_loader);
-}
diff --git a/modules/pbm/register_types.h b/modules/pbm/register_types.h
deleted file mode 100644
index 408c7da275..0000000000
--- a/modules/pbm/register_types.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*************************************************************************/
-/* register_types.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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. */
-/*************************************************************************/
-
-void register_pbm_types();
-void unregister_pbm_types();
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 852e9834d4..662bd4d8a9 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -58,25 +58,34 @@
#include <unistd.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
+#define NSEventMaskAny NSAnyEventMask
+#define NSEventTypeKeyDown NSKeyDown
+#define NSEventTypeKeyUp NSKeyUp
+#define NSEventModifierFlagShift NSShiftKeyMask
+#define NSEventModifierFlagCommand NSCommandKeyMask
+#define NSEventModifierFlagControl NSControlKeyMask
+#define NSEventModifierFlagOption NSAlternateKeyMask
+#define NSWindowStyleMaskTitled NSTitledWindowMask
+#define NSWindowStyleMaskResizable NSResizableWindowMask
+#define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
+#define NSWindowStyleMaskClosable NSClosableWindowMask
#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
#endif
static NSRect convertRectToBacking(NSRect contentRect) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
return [OS_OSX::singleton->window_view convertRectToBacking:contentRect];
else
-#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
return contentRect;
}
static void get_key_modifier_state(unsigned int p_osx_state, Ref<InputEventWithModifiers> state) {
- state->set_shift((p_osx_state & NSShiftKeyMask));
- state->set_control((p_osx_state & NSControlKeyMask));
- state->set_alt((p_osx_state & NSAlternateKeyMask));
- state->set_metakey((p_osx_state & NSCommandKeyMask));
+ state->set_shift((p_osx_state & NSEventModifierFlagShift));
+ state->set_control((p_osx_state & NSEventModifierFlagControl));
+ state->set_alt((p_osx_state & NSEventModifierFlagOption));
+ state->set_metakey((p_osx_state & NSEventModifierFlagCommand));
}
static int mouse_x = 0;
@@ -104,7 +113,7 @@ static Vector2 get_mouse_pos(NSEvent *event) {
// special case handling of command-period, which is traditionally a special
// shortcut in macOS and doesn't arrive at our regular keyDown handler.
- if ([event type] == NSKeyDown) {
+ if ([event type] == NSEventTypeKeyDown) {
if (([event modifierFlags] & NSEventModifierFlagCommand) && [event keyCode] == 0x2f) {
Ref<InputEventKey> k;
@@ -122,7 +131,7 @@ static Vector2 get_mouse_pos(NSEvent *event) {
// From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
// This works around an AppKit bug, where key up events while holding
// down the command key don't get sent to the key window.
- if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
+ if ([event type] == NSEventTypeKeyUp && ([event modifierFlags] & NSEventModifierFlagCommand))
[[self keyWindow] sendEvent:event];
else
[super sendEvent:event];
@@ -188,7 +197,6 @@ static Vector2 get_mouse_pos(NSEvent *event) {
return NO;
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- (void)windowDidEnterFullScreen:(NSNotification *)notification {
OS_OSX::singleton->zoomed = true;
}
@@ -196,7 +204,6 @@ static Vector2 get_mouse_pos(NSEvent *event) {
- (void)windowDidExitFullScreen:(NSNotification *)notification {
OS_OSX::singleton->zoomed = false;
}
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED
- (void)windowDidChangeBackingProperties:(NSNotification *)notification {
if (!OS_OSX::singleton)
@@ -390,8 +397,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)cancelComposition {
[self unmarkText];
- NSInputManager *currentInputManager = [NSInputManager currentInputManager];
- [currentInputManager markedTextAbandoned:self];
+ NSTextInputContext *currentInputContext = [NSTextInputContext currentInputContext];
+ [currentInputContext discardMarkedText];
}
- (void)insertText:(id)aString {
@@ -420,8 +427,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
NSCharacterSet *ctrlChars = [NSCharacterSet controlCharacterSet];
NSCharacterSet *wsnlChars = [NSCharacterSet whitespaceAndNewlineCharacterSet];
if ([characters rangeOfCharacterFromSet:ctrlChars].length && [characters rangeOfCharacterFromSet:wsnlChars].length == 0) {
- NSInputManager *currentInputManager = [NSInputManager currentInputManager];
- [currentInputManager markedTextAbandoned:self];
+ NSTextInputContext *currentInputContext = [NSTextInputContext currentInputContext];
+ [currentInputContext discardMarkedText];
[self cancelComposition];
return;
}
@@ -507,7 +514,7 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
}
- (void)mouseDown:(NSEvent *)event {
- if (([event modifierFlags] & NSControlKeyMask)) {
+ if (([event modifierFlags] & NSEventModifierFlagControl)) {
mouse_down_control = true;
_mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true);
} else {
@@ -808,29 +815,29 @@ static int translateKey(unsigned int key) {
int mod = [event modifierFlags];
if (key == 0x36 || key == 0x37) {
- if (mod & NSCommandKeyMask) {
- mod &= ~NSCommandKeyMask;
+ if (mod & NSEventModifierFlagCommand) {
+ mod &= ~NSEventModifierFlagCommand;
k->set_pressed(true);
} else {
k->set_pressed(false);
}
} else if (key == 0x38 || key == 0x3c) {
- if (mod & NSShiftKeyMask) {
- mod &= ~NSShiftKeyMask;
+ if (mod & NSEventModifierFlagShift) {
+ mod &= ~NSEventModifierFlagShift;
k->set_pressed(true);
} else {
k->set_pressed(false);
}
} else if (key == 0x3a || key == 0x3d) {
- if (mod & NSAlternateKeyMask) {
- mod &= ~NSAlternateKeyMask;
+ if (mod & NSEventModifierFlagOption) {
+ mod &= ~NSEventModifierFlagOption;
k->set_pressed(true);
} else {
k->set_pressed(false);
}
} else if (key == 0x3b || key == 0x3e) {
- if (mod & NSControlKeyMask) {
- mod &= ~NSControlKeyMask;
+ if (mod & NSEventModifierFlagControl) {
+ mod &= ~NSEventModifierFlagControl;
k->set_pressed(true);
} else {
k->set_pressed(false);
@@ -890,7 +897,6 @@ inline void sendPanEvent(double dx, double dy, int modifierFlags) {
- (void)scrollWheel:(NSEvent *)event {
double deltaX, deltaY;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
deltaX = [event scrollingDeltaX];
deltaY = [event scrollingDeltaY];
@@ -899,9 +905,7 @@ inline void sendPanEvent(double dx, double dy, int modifierFlags) {
deltaX *= 0.03;
deltaY *= 0.03;
}
- } else
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED
- {
+ } else {
deltaX = [event deltaX];
deltaY = [event deltaY];
}
@@ -1005,7 +1009,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
if (p_desired.borderless_window) {
styleMask = NSWindowStyleMaskBorderless;
} else {
- styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | (p_desired.resizable ? NSResizableWindowMask : 0);
+ styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (p_desired.resizable ? NSWindowStyleMaskResizable : 0);
}
window_object = [[GodotWindow alloc]
@@ -1743,9 +1747,8 @@ float OS_OSX::_display_scale(id screen) const {
if ([screen respondsToSelector:@selector(backingScaleFactor)]) {
return fmax(1.0, [screen backingScaleFactor]);
}
- } else {
- return 1.0;
}
+ return 1.0;
}
Point2 OS_OSX::get_native_window_position() const {
@@ -1820,36 +1823,27 @@ void OS_OSX::set_window_size(const Size2 p_size) {
void OS_OSX::set_window_fullscreen(bool p_enabled) {
if (zoomed != p_enabled) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
[window_object toggleFullScreen:nil];
-#else
- [window_object performZoom:nil];
-#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
}
zoomed = p_enabled;
};
bool OS_OSX::is_window_fullscreen() const {
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
- if ([window_object respondsToSelector:@selector(isZoomed)])
- return [window_object isZoomed];
-#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
-
return zoomed;
};
void OS_OSX::set_window_resizable(bool p_enabled) {
if (p_enabled)
- [window_object setStyleMask:[window_object styleMask] | NSResizableWindowMask];
+ [window_object setStyleMask:[window_object styleMask] | NSWindowStyleMaskResizable];
else
- [window_object setStyleMask:[window_object styleMask] & ~NSResizableWindowMask];
+ [window_object setStyleMask:[window_object styleMask] & ~NSWindowStyleMaskResizable];
};
bool OS_OSX::is_window_resizable() const {
- return [window_object styleMask] & NSResizableWindowMask;
+ return [window_object styleMask] & NSWindowStyleMaskResizable;
};
void OS_OSX::set_window_minimized(bool p_enabled) {
@@ -1904,7 +1898,7 @@ void OS_OSX::set_borderless_window(bool p_borderless) {
if (p_borderless) {
[window_object setStyleMask:NSWindowStyleMaskBorderless];
} else {
- [window_object setStyleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask];
+ [window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable];
// Force update of the window styles
NSRect frameRect = [window_object frame];
@@ -2028,7 +2022,7 @@ void OS_OSX::process_events() {
while (true) {
NSEvent *event = [NSApp
- nextEventMatchingMask:NSAnyEventMask
+ nextEventMatchingMask:NSEventMaskAny
untilDate:[NSDate distantPast]
inMode:NSDefaultRunLoopMode
dequeue:YES];
@@ -2220,7 +2214,7 @@ OS_OSX::OS_OSX() {
[apple_menu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
- [menu_item setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
+ [menu_item setKeyEquivalentModifierMask:(NSEventModifierFlagOption | NSEventModifierFlagCommand)];
[apple_menu addItemWithTitle:NSLocalizedString(@"Show all", nil) action:@selector(unhideAllApplications:) keyEquivalent:@""];
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 276df827d5..d7987d4a19 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -189,6 +189,26 @@ void PopupMenu::_submenu_timeout() {
submenu_over = -1;
}
+void PopupMenu::_scroll(float p_factor, const Point2 &p_over) {
+
+ const float global_y = get_global_position().y;
+
+ int vseparation = get_constant("vseparation");
+ Ref<Font> font = get_font("font");
+
+ float dy = (vseparation + font->get_height()) * 3 * p_factor;
+ if (dy > 0 && global_y < 0)
+ dy = MIN(dy, -global_y - 1);
+ else if (dy < 0 && global_y + get_size().y > get_viewport_rect().size.y)
+ dy = -MIN(-dy, global_y + get_size().y - get_viewport_rect().size.y - 1);
+ set_position(get_position() + Vector2(0, dy));
+
+ Ref<InputEventMouseMotion> ie;
+ ie.instance();
+ ie->set_position(p_over - Vector2(0, dy));
+ _gui_input(ie);
+}
+
void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
@@ -285,41 +305,11 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
case BUTTON_WHEEL_DOWN: {
- if (get_global_position().y + get_size().y > get_viewport_rect().size.y) {
-
- int vseparation = get_constant("vseparation");
- Ref<Font> font = get_font("font");
-
- Point2 pos = get_position();
- int s = (vseparation + font->get_height()) * 3;
- pos.y -= (s * b->get_factor());
- set_position(pos);
-
- //update hover
- Ref<InputEventMouseMotion> ie;
- ie.instance();
- ie->set_position(b->get_position() + Vector2(0, s));
- _gui_input(ie);
- }
+ _scroll(-b->get_factor(), b->get_position());
} break;
case BUTTON_WHEEL_UP: {
- if (get_global_position().y < 0) {
-
- int vseparation = get_constant("vseparation");
- Ref<Font> font = get_font("font");
-
- Point2 pos = get_position();
- int s = (vseparation + font->get_height()) * 3;
- pos.y += (s * b->get_factor());
- set_position(pos);
-
- //update hover
- Ref<InputEventMouseMotion> ie;
- ie.instance();
- ie->set_position(b->get_position() - Vector2(0, s));
- _gui_input(ie);
- }
+ _scroll(b->get_factor(), b->get_position());
} break;
case BUTTON_LEFT: {
@@ -387,6 +377,11 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
update();
}
}
+
+ Ref<InputEventPanGesture> pan_gesture = p_event;
+ if (pan_gesture.is_valid()) {
+ _scroll(-pan_gesture->get_delta().y, pan_gesture->get_position());
+ }
}
bool PopupMenu::has_point(const Point2 &p_point) const {
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index 321dae1bd2..60f36e95ec 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -84,6 +84,7 @@ class PopupMenu : public Popup {
String _get_accel_text(int p_item) const;
int _get_mouse_over(const Point2 &p_over) const;
virtual Size2 get_minimum_size() const;
+ void _scroll(float p_factor, const Point2 &p_over);
void _gui_input(const Ref<InputEvent> &p_event);
void _activate_submenu(int over);
void _submenu_timeout();
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 0dffc4ee9a..fd5a47d875 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -916,6 +916,7 @@ int Tree::compute_item_height(TreeItem *p_item) const {
if (p_item == root && hide_root)
return 0;
+ ERR_FAIL_COND_V(cache.font.is_null(), 0);
int height = cache.font->get_height();
for (int i = 0; i < columns.size(); i++) {
@@ -989,6 +990,8 @@ int Tree::get_item_height(TreeItem *p_item) const {
void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color) {
+ ERR_FAIL_COND(cache.font.is_null());
+
Rect2i rect = p_rect;
Ref<Font> font = cache.font;
String text = p_cell.text;
@@ -1058,6 +1061,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
//draw separation.
//if (p_item->get_parent()!=root || !hide_root)
+ ERR_FAIL_COND_V(cache.font.is_null(), -1);
Ref<Font> font = cache.font;
int font_ascent = font->get_ascent();
@@ -2794,6 +2798,7 @@ void Tree::update_scrollbars() {
int Tree::_get_title_button_height() const {
+ ERR_FAIL_COND_V(cache.font.is_null() || cache.title_button.is_null(), 0);
return show_column_titles ? cache.font->get_height() + cache.title_button->get_minimum_size().height : 0;
}
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index fd70dd2ebe..e99db8d9cb 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -112,8 +112,8 @@ int BitMap::get_true_bit_count() const {
void BitMap::set_bit(const Point2 &p_pos, bool p_value) {
- int x = Math::fast_ftoi(p_pos.x);
- int y = Math::fast_ftoi(p_pos.y);
+ int x = p_pos.x;
+ int y = p_pos.y;
ERR_FAIL_INDEX(x, width);
ERR_FAIL_INDEX(y, height);
diff --git a/scene/resources/bit_mask.h b/scene/resources/bit_mask.h
index 676ec47ed3..cf126ef96b 100644
--- a/scene/resources/bit_mask.h
+++ b/scene/resources/bit_mask.h
@@ -39,7 +39,6 @@ class BitMap : public Resource {
GDCLASS(BitMap, Resource);
OBJ_SAVE_TYPE(BitMap);
- RES_BASE_EXTENSION("pbm");
Vector<uint8_t> bitmask;
int width;
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index 8dbb765f13..8d8bbb881f 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -659,7 +659,6 @@ void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap
Instance *instance = instance_owner.get(p_instance);
ERR_FAIL_COND(!instance);
- ERR_FAIL_COND(!is_geometry_instance(instance->base_type));
if (instance->lightmap_capture) {
InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(((Instance *)instance->lightmap_capture)->base_data);
@@ -3298,6 +3297,7 @@ bool VisualServerScene::free(RID p_rid) {
Instance *instance = instance_owner.get(p_rid);
+ instance_set_use_lightmap(p_rid, RID(), RID());
instance_set_scenario(p_rid, RID());
instance_set_base(p_rid, RID());
instance_geometry_set_material_override(p_rid, RID());