mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
-Changed bootsplash option to use a file, fixes #1539
-Added OS.get_splash_tick_msec() to query when splash appeared
This commit is contained in:
parent
2dfa1279ea
commit
3e20391bf6
@ -500,6 +500,10 @@ uint32_t _OS::get_ticks_msec() const {
|
|||||||
return OS::get_singleton()->get_ticks_msec();
|
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 {
|
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_usec","usec"),&_OS::delay_usec);
|
||||||
ObjectTypeDB::bind_method(_MD("delay_msec","msec"),&_OS::delay_msec);
|
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_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_locale"),&_OS::get_locale);
|
||||||
ObjectTypeDB::bind_method(_MD("get_model_name"),&_OS::get_model_name);
|
ObjectTypeDB::bind_method(_MD("get_model_name"),&_OS::get_model_name);
|
||||||
|
|
||||||
|
@ -210,6 +210,7 @@ public:
|
|||||||
void delay_usec(uint32_t p_usec) const;
|
void delay_usec(uint32_t p_usec) const;
|
||||||
void delay_msec(uint32_t p_msec) const;
|
void delay_msec(uint32_t p_msec) const;
|
||||||
uint32_t get_ticks_msec() const;
|
uint32_t get_ticks_msec() const;
|
||||||
|
uint32_t get_splash_tick_msec() const;
|
||||||
|
|
||||||
bool can_use_threads() const;
|
bool can_use_threads() const;
|
||||||
|
|
||||||
|
@ -43,6 +43,9 @@ OS* OS::get_singleton() {
|
|||||||
uint32_t OS::get_ticks_msec() const
|
uint32_t OS::get_ticks_msec() const
|
||||||
{ return get_ticks_usec()/1000; }
|
{ return get_ticks_usec()/1000; }
|
||||||
|
|
||||||
|
uint64_t OS::get_splash_tick_msec() const {
|
||||||
|
return _msec_splash;
|
||||||
|
}
|
||||||
uint64_t OS::get_unix_time() const {
|
uint64_t OS::get_unix_time() const {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -51,6 +51,7 @@ class OS {
|
|||||||
String _local_clipboard;
|
String _local_clipboard;
|
||||||
uint64_t frames_drawn;
|
uint64_t frames_drawn;
|
||||||
uint32_t _frame_delay;
|
uint32_t _frame_delay;
|
||||||
|
uint64_t _msec_splash;
|
||||||
bool _no_window;
|
bool _no_window;
|
||||||
int _exit_code;
|
int _exit_code;
|
||||||
int _orientation;
|
int _orientation;
|
||||||
@ -251,6 +252,7 @@ public:
|
|||||||
virtual void delay_usec(uint32_t p_usec) const=0;
|
virtual void delay_usec(uint32_t p_usec) const=0;
|
||||||
virtual uint64_t get_ticks_usec() const=0;
|
virtual uint64_t get_ticks_usec() const=0;
|
||||||
uint32_t get_ticks_msec() const;
|
uint32_t get_ticks_msec() const;
|
||||||
|
uint64_t get_splash_tick_msec() const;
|
||||||
|
|
||||||
void set_frame_delay(uint32_t p_msec);
|
void set_frame_delay(uint32_t p_msec);
|
||||||
uint32_t get_frame_delay() const;
|
uint32_t get_frame_delay() const;
|
||||||
@ -384,6 +386,8 @@ public:
|
|||||||
void set_time_scale(float p_scale);
|
void set_time_scale(float p_scale);
|
||||||
float get_time_scale() const;
|
float get_time_scale() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
OS();
|
OS();
|
||||||
virtual ~OS();
|
virtual ~OS();
|
||||||
|
|
||||||
|
@ -767,13 +767,23 @@ Error Main::setup2() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (show_logo) { //boot logo!
|
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()) {
|
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));
|
Color clear = GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3));
|
||||||
VisualServer::get_singleton()->set_default_clear_color(clear);
|
VisualServer::get_singleton()->set_default_clear_color(clear);
|
||||||
Color boot_bg = GLOBAL_DEF("application/boot_bg_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
|
#ifndef TOOLS_ENABLED
|
||||||
//no tools, so free the boot logo (no longer needed)
|
//no tools, so free the boot logo (no longer needed)
|
||||||
Globals::get_singleton()->set("application/boot_logo",Image());
|
Globals::get_singleton()->set("application/boot_logo",Image());
|
||||||
@ -788,7 +798,7 @@ Error Main::setup2() {
|
|||||||
MAIN_PRINT("Main: ClearColor");
|
MAIN_PRINT("Main: ClearColor");
|
||||||
VisualServer::get_singleton()->set_default_clear_color(boot_splash_bg_color);
|
VisualServer::get_singleton()->set_default_clear_color(boot_splash_bg_color);
|
||||||
MAIN_PRINT("Main: Image");
|
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
|
#endif
|
||||||
MAIN_PRINT("Main: DCC");
|
MAIN_PRINT("Main: DCC");
|
||||||
VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3)));
|
VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3)));
|
||||||
|
@ -7391,7 +7391,7 @@ void VisualServerRaster::set_default_clear_color(const Color& p_color) {
|
|||||||
clear_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())
|
if (p_image.empty())
|
||||||
return;
|
return;
|
||||||
@ -7413,9 +7413,27 @@ void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_col
|
|||||||
texture_set_data(texture,p_image);
|
texture_set_data(texture,p_image);
|
||||||
rasterizer->canvas_begin_rect(Matrix32());
|
rasterizer->canvas_begin_rect(Matrix32());
|
||||||
Rect2 imgrect(0,0,p_image.get_width(),p_image.get_height());
|
Rect2 imgrect(0,0,p_image.get_width(),p_image.get_height());
|
||||||
Rect2 screenrect=imgrect;
|
Rect2 screenrect;
|
||||||
screenrect.pos+=((Size2(vr.width,vr.height)-screenrect.size)/2.0).floor();
|
if (p_scale) {
|
||||||
rasterizer->canvas_draw_rect(screenrect,0,imgrect,texture,Color(1,1,1,0));
|
|
||||||
|
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_draw_rect(screenrect,0,imgrect,texture,Color(1,1,1,1));
|
||||||
rasterizer->canvas_end_rect();
|
rasterizer->canvas_end_rect();
|
||||||
|
|
||||||
|
@ -1251,7 +1251,7 @@ public:
|
|||||||
|
|
||||||
RID get_test_cube();
|
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);
|
virtual void set_default_clear_color(const Color& p_color);
|
||||||
|
|
||||||
VisualServerRaster(Rasterizer *p_rasterizer);
|
VisualServerRaster(Rasterizer *p_rasterizer);
|
||||||
|
@ -1233,7 +1233,7 @@ public:
|
|||||||
FUNC1R(int,get_render_info,RenderInfo );
|
FUNC1R(int,get_render_info,RenderInfo );
|
||||||
virtual bool has_feature(Features p_feature) const { return visual_server->has_feature(p_feature); }
|
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& );
|
FUNC1(set_default_clear_color,const Color& );
|
||||||
|
|
||||||
FUNC0R(RID,get_test_cube );
|
FUNC0R(RID,get_test_cube );
|
||||||
|
@ -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_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 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;
|
virtual void set_default_clear_color(const Color& p_color)=0;
|
||||||
|
|
||||||
enum Features {
|
enum Features {
|
||||||
|
Loading…
Reference in New Issue
Block a user