summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bind/core_bind.cpp5
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/os/os.cpp3
-rw-r--r--core/os/os.h4
-rw-r--r--main/main.cpp16
-rw-r--r--servers/visual/visual_server_raster.cpp26
-rw-r--r--servers/visual/visual_server_raster.h2
-rw-r--r--servers/visual/visual_server_wrap_mt.h2
-rw-r--r--servers/visual_server.h2
9 files changed, 51 insertions, 10 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 439855fbb7..cde328bc6f 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -500,6 +500,10 @@ uint32_t _OS::get_ticks_msec() const {
return OS::get_singleton()->get_ticks_msec();
}
+uint32_t _OS::get_splash_tick_msec() const {
+
+ return OS::get_singleton()->get_splash_tick_msec();
+}
bool _OS::can_use_threads() const {
@@ -765,6 +769,7 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("delay_usec","usec"),&_OS::delay_usec);
ObjectTypeDB::bind_method(_MD("delay_msec","msec"),&_OS::delay_msec);
ObjectTypeDB::bind_method(_MD("get_ticks_msec"),&_OS::get_ticks_msec);
+ ObjectTypeDB::bind_method(_MD("get_splash_tick_msec"),&_OS::get_splash_tick_msec);
ObjectTypeDB::bind_method(_MD("get_locale"),&_OS::get_locale);
ObjectTypeDB::bind_method(_MD("get_model_name"),&_OS::get_model_name);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index f3601e35fb..ea8ca9af92 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -210,6 +210,7 @@ public:
void delay_usec(uint32_t p_usec) const;
void delay_msec(uint32_t p_msec) const;
uint32_t get_ticks_msec() const;
+ uint32_t get_splash_tick_msec() const;
bool can_use_threads() const;
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 5e0e5eed77..5fa7e87d06 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -43,6 +43,9 @@ OS* OS::get_singleton() {
uint32_t OS::get_ticks_msec() const
{ return get_ticks_usec()/1000; }
+uint64_t OS::get_splash_tick_msec() const {
+ return _msec_splash;
+}
uint64_t OS::get_unix_time() const {
return 0;
diff --git a/core/os/os.h b/core/os/os.h
index d4ac433644..b52a37ede7 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -51,6 +51,7 @@ class OS {
String _local_clipboard;
uint64_t frames_drawn;
uint32_t _frame_delay;
+ uint64_t _msec_splash;
bool _no_window;
int _exit_code;
int _orientation;
@@ -251,6 +252,7 @@ public:
virtual void delay_usec(uint32_t p_usec) const=0;
virtual uint64_t get_ticks_usec() const=0;
uint32_t get_ticks_msec() const;
+ uint64_t get_splash_tick_msec() const;
void set_frame_delay(uint32_t p_msec);
uint32_t get_frame_delay() const;
@@ -384,6 +386,8 @@ public:
void set_time_scale(float p_scale);
float get_time_scale() const;
+
+
OS();
virtual ~OS();
diff --git a/main/main.cpp b/main/main.cpp
index f0e376a045..517ccaec08 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -767,13 +767,23 @@ Error Main::setup2() {
#endif
if (show_logo) { //boot logo!
- Image boot_logo=GLOBAL_DEF("application/boot_logo",Image());
+ String boot_logo_path=GLOBAL_DEF("application/boot_splash",String());
+ bool boot_logo_scale=GLOBAL_DEF("application/boot_splash_fullsize",true);
+ Globals::get_singleton()->set_custom_property_info("application/boot_splash",PropertyInfo(Variant::STRING,"application/boot_splash",PROPERTY_HINT_FILE,"*.png"));
+
+
+ Image boot_logo;
+
+ if (boot_logo_path.strip_edges()!="" && FileAccess::exists(boot_logo_path)) {
+ boot_logo.load(boot_logo_path);
+ }
if (!boot_logo.empty()) {
+ OS::get_singleton()->_msec_splash=OS::get_singleton()->get_ticks_msec();
Color clear = GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3));
VisualServer::get_singleton()->set_default_clear_color(clear);
Color boot_bg = GLOBAL_DEF("application/boot_bg_color", clear);
- VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg);
+ VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg,boot_logo_scale);
#ifndef TOOLS_ENABLED
//no tools, so free the boot logo (no longer needed)
Globals::get_singleton()->set("application/boot_logo",Image());
@@ -788,7 +798,7 @@ Error Main::setup2() {
MAIN_PRINT("Main: ClearColor");
VisualServer::get_singleton()->set_default_clear_color(boot_splash_bg_color);
MAIN_PRINT("Main: Image");
- VisualServer::get_singleton()->set_boot_image(splash, boot_splash_bg_color);
+ VisualServer::get_singleton()->set_boot_image(splash, boot_splash_bg_color,false);
#endif
MAIN_PRINT("Main: DCC");
VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3)));
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 7a9db4ba11..5aca15958b 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -7391,7 +7391,7 @@ void VisualServerRaster::set_default_clear_color(const Color& p_color) {
clear_color=p_color;
}
-void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_color) {
+void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_color,bool p_scale) {
if (p_image.empty())
return;
@@ -7413,9 +7413,27 @@ void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_col
texture_set_data(texture,p_image);
rasterizer->canvas_begin_rect(Matrix32());
Rect2 imgrect(0,0,p_image.get_width(),p_image.get_height());
- Rect2 screenrect=imgrect;
- screenrect.pos+=((Size2(vr.width,vr.height)-screenrect.size)/2.0).floor();
- rasterizer->canvas_draw_rect(screenrect,0,imgrect,texture,Color(1,1,1,0));
+ Rect2 screenrect;
+ if (p_scale) {
+
+ if (window_w > window_h) {
+ //scale horizontally
+ screenrect.size.y = window_h;
+ screenrect.size.x = imgrect.size.x * window_h / imgrect.size.y;
+ screenrect.pos.x = (window_w - screenrect.size.x)/2;
+
+ } else {
+ //scale vertically
+ screenrect.size.x = window_w;
+ screenrect.size.y = imgrect.size.y * window_w / imgrect.size.x;
+ screenrect.pos.y = (window_h - screenrect.size.y)/2;
+ }
+ } else {
+
+ screenrect=imgrect;
+ screenrect.pos+=((Size2(vr.width,vr.height)-screenrect.size)/2.0).floor();
+
+ }
rasterizer->canvas_draw_rect(screenrect,0,imgrect,texture,Color(1,1,1,1));
rasterizer->canvas_end_rect();
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index a89a685e30..5587af23d8 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -1251,7 +1251,7 @@ public:
RID get_test_cube();
- virtual void set_boot_image(const Image& p_image, const Color& p_color);
+ virtual void set_boot_image(const Image& p_image, const Color& p_color, bool p_scale);
virtual void set_default_clear_color(const Color& p_color);
VisualServerRaster(Rasterizer *p_rasterizer);
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index 6cd374aa08..585199818d 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -1233,7 +1233,7 @@ public:
FUNC1R(int,get_render_info,RenderInfo );
virtual bool has_feature(Features p_feature) const { return visual_server->has_feature(p_feature); }
- FUNC2(set_boot_image,const Image& , const Color& );
+ FUNC3(set_boot_image,const Image& , const Color&,bool );
FUNC1(set_default_clear_color,const Color& );
FUNC0R(RID,get_test_cube );
diff --git a/servers/visual_server.h b/servers/visual_server.h
index e9425afbab..0a4428b7e9 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -1137,7 +1137,7 @@ public:
virtual void mesh_add_surface_from_mesh_data( RID p_mesh, const Geometry::MeshData& p_mesh_data);
virtual void mesh_add_surface_from_planes( RID p_mesh, const DVector<Plane>& p_planes);
- virtual void set_boot_image(const Image& p_image, const Color& p_color)=0;
+ virtual void set_boot_image(const Image& p_image, const Color& p_color,bool p_scale)=0;
virtual void set_default_clear_color(const Color& p_color)=0;
enum Features {