Replace Engine version API by preexisting OS one

It outputs a single Dictionary with all relevant information as
keys, that will less bloat the documentation and provide all details
in one function call.
This commit is contained in:
Rémi Verschelde 2017-01-13 18:25:43 +01:00
parent de8cc309d6
commit d2aae675e9
6 changed files with 83 additions and 126 deletions

View file

@ -986,11 +986,6 @@ void _OS::alert(const String& p_alert,const String& p_title) {
OS::get_singleton()->alert(p_alert,p_title);
}
Dictionary _OS::get_engine_version() const {
return OS::get_singleton()->get_engine_version();
}
_OS *_OS::singleton=NULL;
void _OS::_bind_methods() {
@ -1134,8 +1129,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(_MD("set_use_vsync","enable"),&_OS::set_use_vsync);
ClassDB::bind_method(_MD("is_vsync_enabled"),&_OS::is_vsync_enabled);
ClassDB::bind_method(_MD("get_engine_version"),&_OS::get_engine_version);
BIND_CONSTANT( DAY_SUNDAY );
BIND_CONSTANT( DAY_MONDAY );
BIND_CONSTANT( DAY_TUESDAY );
@ -2596,42 +2589,9 @@ MainLoop *_Engine::get_main_loop() const {
return OS::get_singleton()->get_main_loop();
}
String _Engine::get_version() const {
return Engine::get_singleton()->get_version();
}
String _Engine::get_version_name() const{
return Engine::get_singleton()->get_version_name();
}
String _Engine::get_version_short_name() const{
return Engine::get_singleton()->get_version_short_name();
}
int _Engine::get_version_major() const{
return Engine::get_singleton()->get_version_major();
}
int _Engine::get_version_minor() const{
return Engine::get_singleton()->get_version_minor();
}
String _Engine::get_version_revision() const{
return Engine::get_singleton()->get_version_revision();
}
String _Engine::get_version_status() const{
return Engine::get_singleton()->get_version_status();
}
int _Engine::get_version_year() const{
return Engine::get_singleton()->get_version_year();
Dictionary _Engine::get_version_info() const {
return Engine::get_singleton()->get_version_info();
}
@ -2652,14 +2612,7 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(_MD("get_main_loop:MainLoop"),&_Engine::get_main_loop);
ClassDB::bind_method(_MD("get_version"),&_Engine::get_version);
ClassDB::bind_method(_MD("get_version_name"),&_Engine::get_version_name);
ClassDB::bind_method(_MD("get_version_short_name"),&_Engine::get_version_short_name);
ClassDB::bind_method(_MD("get_version_major"),&_Engine::get_version_major);
ClassDB::bind_method(_MD("get_version_minor"),&_Engine::get_version_minor);
ClassDB::bind_method(_MD("get_version_revision"),&_Engine::get_version_revision);
ClassDB::bind_method(_MD("get_version_status"),&_Engine::get_version_status);
ClassDB::bind_method(_MD("get_version_year"),&_Engine::get_version_year);
ClassDB::bind_method(_MD("get_version_info"),&_Engine::get_version_info);
}

View file

@ -309,8 +309,6 @@ public:
void set_use_vsync(bool p_enable);
bool is_vsync_enabled() const;
Dictionary get_engine_version() const;
static _OS *get_singleton() { return singleton; }
_OS();
@ -647,15 +645,7 @@ public:
MainLoop *get_main_loop() const;
String get_version() const;
String get_version_name() const;
String get_version_short_name() const;
int get_version_major() const;
int get_version_minor() const;
String get_version_revision() const;
String get_version_status() const;
int get_version_year() const;
Dictionary get_version_info() const;
_Engine();
};

View file

@ -1,3 +1,31 @@
/*************************************************************************/
/* engine.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "engine.h"
#include "version.h"
@ -43,39 +71,27 @@ float Engine::get_time_scale() const {
return _time_scale;
}
Dictionary Engine::get_version_info() const {
String Engine::get_version() const {
Dictionary dict;
dict["major"] = VERSION_MAJOR;
dict["minor"] = VERSION_MINOR;
#ifdef VERSION_PATCH
dict["patch"] = VERSION_PATCH;
#else
dict["patch"] = 0;
#endif
dict["status"] = _MKSTR(VERSION_STATUS);
dict["revision"] = _MKSTR(VERSION_REVISION);
dict["year"] = VERSION_YEAR;
return VERSION_FULL_NAME;
}
String Engine::get_version_name() const{
String stringver = String(dict["major"]) + "." + String(dict["minor"]);
if ((int)dict["patch"] != 0)
stringver += "." + String(dict["patch"]);
stringver += "-" + String(dict["status"]) + " (" + String(dict["revision"]) + ")";
dict["string"] = stringver;
return _MKSTR(VERSION_NAME);
}
String Engine::get_version_short_name() const{
return _MKSTR(VERSION_SHORT_NAME);
}
int Engine::get_version_major() const{
return VERSION_MAJOR;
}
int Engine::get_version_minor() const{
return VERSION_MINOR;
}
String Engine::get_version_revision() const{
return _MKSTR(VERSION_REVISION);
}
String Engine::get_version_status() const{
return _MKSTR(VERSION_STATUS);
}
int Engine::get_version_year() const{
return VERSION_YEAR;
return dict;
}

View file

@ -1,3 +1,31 @@
/*************************************************************************/
/* engine.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 ENGINE_H
#define ENGINE_H
@ -52,14 +80,7 @@ public:
_FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; }
String get_version() const;
String get_version_name() const;
String get_version_short_name() const;
int get_version_major() const;
int get_version_minor() const;
String get_version_revision() const;
String get_version_status() const;
int get_version_year() const;
Dictionary get_version_info() const;
Engine();
};

View file

@ -27,13 +27,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "os.h"
#include "os/file_access.h"
#include <stdarg.h>
#include "dir_access.h"
#include "globals.h"
#include "input.h"
// For get_engine_version, could be removed if it's moved to a new Engine singleton
#include "version.h"
#include "os/file_access.h"
#include <stdarg.h>
OS* OS::singleton=NULL;
@ -512,27 +512,6 @@ bool OS::is_vsync_enabled() const{
return true;
}
Dictionary OS::get_engine_version() const {
Dictionary dict;
dict["major"] = _MKSTR(VERSION_MAJOR);
dict["minor"] = _MKSTR(VERSION_MINOR);
#ifdef VERSION_PATCH
dict["patch"] = _MKSTR(VERSION_PATCH);
#else
dict["patch"] = "";
#endif
dict["status"] = _MKSTR(VERSION_STATUS);
dict["revision"] = _MKSTR(VERSION_REVISION);
String stringver = String(dict["major"]) + "." + String(dict["minor"]);
if (dict["patch"] != "")
stringver += "." + String(dict["patch"]);
stringver += "-" + String(dict["status"]) + " (" + String(dict["revision"]) + ")";
dict["string"] = stringver;
return dict;
}
OS::OS() {
last_error=NULL;

View file

@ -402,8 +402,6 @@ public:
virtual void set_use_vsync(bool p_enable);
virtual bool is_vsync_enabled() const;
Dictionary get_engine_version() const;
bool is_hidpi_allowed() const { return _allow_hidpi; }
OS();
virtual ~OS();