add app.set_title
This commit is contained in:
parent
d5469acb55
commit
7d367a9793
@ -47,6 +47,7 @@ local function complete_app_lib(app)
|
||||
end
|
||||
app.reset_content = core.reset_content
|
||||
app.is_content_loaded = core.is_content_loaded
|
||||
app.set_title = core.set_title
|
||||
|
||||
function app.config_packs(packs_list)
|
||||
-- Check if packs are valid and add dependencies to the configuration
|
||||
|
||||
@ -33,11 +33,12 @@ WindowControl::Result WindowControl::initialize() {
|
||||
auto& settings = engine.getSettings();
|
||||
|
||||
std::string title = project.title;
|
||||
if (title.empty()) {
|
||||
title = "VoxelCore v" +
|
||||
std::to_string(ENGINE_VERSION_MAJOR) + "." +
|
||||
std::to_string(ENGINE_VERSION_MINOR);
|
||||
if (!title.empty()) {
|
||||
title += " - ";
|
||||
}
|
||||
title += "VoxelCore v" +
|
||||
std::to_string(ENGINE_VERSION_MAJOR) + "." +
|
||||
std::to_string(ENGINE_VERSION_MINOR);
|
||||
if (ENGINE_DEBUG_BUILD) {
|
||||
title += " [debug]";
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include "graphics/ui/gui_util.hpp"
|
||||
#include "graphics/ui/GUI.hpp"
|
||||
#include "graphics/ui/elements/Menu.hpp"
|
||||
#include "window/Window.hpp"
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
@ -298,6 +299,12 @@ static int l_capture_output(lua::State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_set_title(lua::State* L) {
|
||||
auto title = lua::require_string(L, 1);
|
||||
engine->getWindow().setTitle(title);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg corelib[] = {
|
||||
{"blank", lua::wrap<l_blank>},
|
||||
{"get_version", lua::wrap<l_get_version>},
|
||||
@ -319,5 +326,6 @@ const luaL_Reg corelib[] = {
|
||||
{"open_url", lua::wrap<l_open_url>},
|
||||
{"quit", lua::wrap<l_quit>},
|
||||
{"capture_output", lua::wrap<l_capture_output>},
|
||||
{"set_title", lua::wrap<l_set_title>},
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
||||
@ -36,6 +36,7 @@ public:
|
||||
virtual void setMode(WindowMode mode) = 0;
|
||||
virtual WindowMode getMode() const = 0;
|
||||
|
||||
virtual void setTitle(const std::string& title) = 0;
|
||||
virtual void setIcon(const ImageData* image) = 0;
|
||||
|
||||
virtual void pushScissor(glm::vec4 area) = 0;
|
||||
|
||||
@ -468,6 +468,10 @@ public:
|
||||
return mode;
|
||||
}
|
||||
|
||||
void setTitle(const std::string& title) override {
|
||||
glfwSetWindowTitle(window, title.c_str());
|
||||
}
|
||||
|
||||
void setIcon(const ImageData* image) override {
|
||||
if (image == nullptr) {
|
||||
glfwSetWindowIcon(window, 0, nullptr);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user