0.20 development start
This commit is contained in:
parent
6c7497eee6
commit
6b17e33b76
@ -1,6 +1,6 @@
|
||||
{
|
||||
"id": "base",
|
||||
"title": "Base",
|
||||
"version": "0.19",
|
||||
"version": "0.20",
|
||||
"description": "basic content package"
|
||||
}
|
||||
|
||||
@ -2,10 +2,13 @@
|
||||
#define SRC_CONSTANTS_H_
|
||||
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include "typedefs.h"
|
||||
|
||||
const int ENGINE_VERSION_MAJOR = 0;
|
||||
const int ENGINE_VERSION_MINOR = 19;
|
||||
const int ENGINE_VERSION_MINOR = 20;
|
||||
const bool ENGINE_VERSION_INDEV = true;
|
||||
#define ENGINE_VERSION_STRING "0.20"
|
||||
|
||||
const int BLOCK_AIR = 0;
|
||||
const int ITEM_EMPTY = 0;
|
||||
|
||||
@ -75,6 +75,9 @@ Engine::Engine(EngineSettings& settings, EnginePaths* paths)
|
||||
gui = std::make_unique<gui::GUI>();
|
||||
if (settings.ui.language == "auto") {
|
||||
settings.ui.language = langs::locale_by_envlocale(platform::detect_locale(), paths->getResources());
|
||||
}
|
||||
if (ENGINE_VERSION_INDEV) {
|
||||
menus::create_version_label(this);
|
||||
}
|
||||
setLanguage(settings.ui.language);
|
||||
}
|
||||
|
||||
@ -82,6 +82,20 @@ static std::shared_ptr<Button> create_button(
|
||||
return btn;
|
||||
}
|
||||
|
||||
|
||||
void menus::create_version_label(Engine* engine) {
|
||||
auto gui = engine->getGUI();
|
||||
auto vlabel = std::make_shared<gui::Label>(
|
||||
util::str2wstr_utf8(ENGINE_VERSION_STRING " development build ")
|
||||
);
|
||||
vlabel->setZIndex(1000);
|
||||
vlabel->setColor(glm::vec4(1, 1, 1, 0.5f));
|
||||
vlabel->setPositionFunc([=]() {
|
||||
return glm::vec2(Window::width-vlabel->getSize().x, 2);
|
||||
});
|
||||
gui->add(vlabel);
|
||||
}
|
||||
|
||||
static void show_content_missing(
|
||||
Engine* engine,
|
||||
const Content* content,
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
class Engine;
|
||||
|
||||
namespace menus {
|
||||
void create_version_label(Engine* engine);
|
||||
void create_menus(Engine* engine);
|
||||
void refresh_menus(Engine* engine);
|
||||
}
|
||||
|
||||
@ -11,7 +11,19 @@
|
||||
lua::luaerror::luaerror(const std::string& message) : std::runtime_error(message) {
|
||||
}
|
||||
|
||||
void lua::LuaState::removeLibFuncs(const char* libname, const char* funcs[]) {
|
||||
if (getglobal(libname)) {
|
||||
for (uint i = 0; funcs[i]; i++) {
|
||||
pushnil();
|
||||
setfield(funcs[i], -2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lua::LuaState::LuaState() {
|
||||
std::cout << LUA_VERSION << std::endl;
|
||||
std::cout << LUAJIT_VERSION << std::endl;
|
||||
|
||||
L = luaL_newstate();
|
||||
if (L == nullptr) {
|
||||
throw lua::luaerror("could not to initialize Lua");
|
||||
@ -25,10 +37,19 @@ lua::LuaState::LuaState() {
|
||||
luaopen_jit(L);
|
||||
luaopen_bit(L);
|
||||
|
||||
std::cout << LUA_VERSION << std::endl;
|
||||
std::cout << LUAJIT_VERSION << std::endl;
|
||||
luaopen_os(L);
|
||||
const char* removed_os[] {
|
||||
"execute",
|
||||
"exit",
|
||||
"remove",
|
||||
"rename",
|
||||
"setlocale",
|
||||
"tmpname",
|
||||
nullptr
|
||||
};
|
||||
removeLibFuncs("os", removed_os);
|
||||
|
||||
createFuncs();
|
||||
createLibs();
|
||||
|
||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||
setglobal(envName(0));
|
||||
@ -94,7 +115,7 @@ void lua::LuaState::remove(const std::string& name) {
|
||||
lua_setglobal(L, name.c_str());
|
||||
}
|
||||
|
||||
void lua::LuaState::createFuncs() {
|
||||
void lua::LuaState::createLibs() {
|
||||
openlib("pack", packlib, 0);
|
||||
openlib("world", worldlib, 0);
|
||||
openlib("player", playerlib, 0);
|
||||
|
||||
@ -21,6 +21,9 @@ namespace lua {
|
||||
|
||||
void logError(const std::string& text);
|
||||
void initEnvironment();
|
||||
|
||||
void removeLibFuncs(const char* libname, const char* funcs[]);
|
||||
void createLibs();
|
||||
public:
|
||||
LuaState();
|
||||
~LuaState();
|
||||
@ -55,7 +58,6 @@ namespace lua {
|
||||
bool hasglobal(const std::string& name);
|
||||
bool rename(const std::string& from, const std::string& to);
|
||||
void remove(const std::string& name);;
|
||||
void createFuncs();
|
||||
int createEnvironment(int parent);
|
||||
void removeEnvironment(int id);
|
||||
const std::string storeAnonymous();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user