mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
move open_folder, open_url from core to app
This commit is contained in:
parent
e794aa864d
commit
13d13e89cf
6 changed files with 35 additions and 35 deletions
|
|
@ -15,7 +15,7 @@
|
||||||
<textbox id='search_textbox' multiline='false' size='440,25' sub-consumer='function(x) refresh_search() end'></textbox>
|
<textbox id='search_textbox' multiline='false' size='440,25' sub-consumer='function(x) refresh_search() end'></textbox>
|
||||||
</panel>
|
</panel>
|
||||||
|
|
||||||
<image onclick='core.open_folder("user:content")' interactive='true' src='gui/folder_icon'
|
<image onclick='app.open_folder("user:content")' interactive='true' src='gui/folder_icon'
|
||||||
size='32' margin='0,0,18,66' gravity='bottom-right'
|
size='32' margin='0,0,18,66' gravity='bottom-right'
|
||||||
color='#FFFFFF50' hover-color='#FFFFFF10'/>
|
color='#FFFFFF50' hover-color='#FFFFFF10'/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<textbox id='search_textbox' multiline='false' size='440,25' sub-consumer='function(x) refresh_search() end'></textbox>
|
<textbox id='search_textbox' multiline='false' size='440,25' sub-consumer='function(x) refresh_search() end'></textbox>
|
||||||
</panel>
|
</panel>
|
||||||
|
|
||||||
<image onclick='core.open_folder("user:content")' interactive='true' src='gui/folder_icon'
|
<image onclick='app.open_folder("user:content")' interactive='true' src='gui/folder_icon'
|
||||||
size='32' margin='0,0,10,15' gravity='bottom-right'
|
size='32' margin='0,0,10,15' gravity='bottom-right'
|
||||||
color='#FFFFFF50' hover-color='#FFFFFF10'/>
|
color='#FFFFFF50' hover-color='#FFFFFF10'/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<panel margin='6' gravity='bottom-left' size='250' color='0' interval='1'>
|
<panel margin='6' gravity='bottom-left' size='250' color='0' interval='1'>
|
||||||
<button onclick='menu.page="languages"' id='langs_btn'>-</button>
|
<button onclick='menu.page="languages"' id='langs_btn'>-</button>
|
||||||
<button onclick='core.open_folder("user:")'>@Open data folder</button>
|
<button onclick='app.open_folder("user:")'>@Open data folder</button>
|
||||||
<button id='s_rst' onclick='sections:set("reset")'>@Reset settings</button>
|
<button id='s_rst' onclick='sections:set("reset")'>@Reset settings</button>
|
||||||
<button onclick='menu:back()'>@Back</button>
|
<button onclick='menu:back()'>@Back</button>
|
||||||
</panel>
|
</panel>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@
|
||||||
|
|
||||||
<panel id='worlds' size='390,1' padding='5' color='#FFFFFF11' max-length='400'>
|
<panel id='worlds' size='390,1' padding='5' color='#FFFFFF11' max-length='400'>
|
||||||
</panel>
|
</panel>
|
||||||
<button pos='485,525' size='500,40' onclick='core.open_folder("user:worlds")'>@Open worlds folder</button>
|
<button pos='485,525' size='500,40' onclick='app.open_folder("user:worlds")'>@Open worlds folder</button>
|
||||||
<button onclick='menu:back()'>@Back</button>
|
<button onclick='menu:back()'>@Back</button>
|
||||||
</panel>
|
</panel>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,12 @@
|
||||||
#include "devtools/Project.hpp"
|
#include "devtools/Project.hpp"
|
||||||
#include "network/Network.hpp"
|
#include "network/Network.hpp"
|
||||||
#include "util/platform.hpp"
|
#include "util/platform.hpp"
|
||||||
|
#include "util/stringutil.hpp"
|
||||||
#include "window/Window.hpp"
|
#include "window/Window.hpp"
|
||||||
|
#include "frontend/locale.hpp"
|
||||||
|
#include "graphics/ui/GUI.hpp"
|
||||||
|
#include "graphics/ui/gui_util.hpp"
|
||||||
|
#include "graphics/ui/elements/Menu.hpp"
|
||||||
|
|
||||||
using namespace scripting;
|
using namespace scripting;
|
||||||
|
|
||||||
|
|
@ -102,6 +107,29 @@ static int l_set_title(lua::State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_open_folder(lua::State* L) {
|
||||||
|
platform::open_folder(io::resolve(lua::require_string(L, 1)));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int l_open_url(lua::State* L) {
|
||||||
|
auto url = lua::require_string(L, 1);
|
||||||
|
|
||||||
|
std::wstring msg = langs::get(L"Are you sure you want to open the link:") +
|
||||||
|
L"\n" + util::str2wstr_utf8(url) +
|
||||||
|
std::wstring(L"?");
|
||||||
|
|
||||||
|
auto menu = engine->getGUI().getMenu();
|
||||||
|
|
||||||
|
guiutil::confirm(*engine, msg, [url, menu]() {
|
||||||
|
platform::open_url(url);
|
||||||
|
if (!menu->back()) {
|
||||||
|
menu->reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg applib[] = {
|
const luaL_Reg applib[] = {
|
||||||
{"start_debug_instance", lua::wrap<l_start_debug_instance>},
|
{"start_debug_instance", lua::wrap<l_start_debug_instance>},
|
||||||
{"focus", lua::wrap<l_focus>},
|
{"focus", lua::wrap<l_focus>},
|
||||||
|
|
@ -110,6 +138,8 @@ const luaL_Reg applib[] = {
|
||||||
{"set_content_sources", lua::wrap<l_set_content_sources>},
|
{"set_content_sources", lua::wrap<l_set_content_sources>},
|
||||||
{"reset_content_sources", lua::wrap<l_reset_content_sources>},
|
{"reset_content_sources", lua::wrap<l_reset_content_sources>},
|
||||||
{"set_title", lua::wrap<l_set_title>},
|
{"set_title", lua::wrap<l_set_title>},
|
||||||
|
{"open_folder", lua::wrap<l_open_folder>},
|
||||||
|
{"open_url", lua::wrap<l_open_url>},
|
||||||
// for other functions see libcore.cpp and stdlib.lua
|
// for other functions see libcore.cpp and stdlib.lua
|
||||||
{nullptr, nullptr}
|
{nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,6 @@
|
||||||
#include "util/platform.hpp"
|
#include "util/platform.hpp"
|
||||||
#include "world/Level.hpp"
|
#include "world/Level.hpp"
|
||||||
#include "world/generator/WorldGenerator.hpp"
|
#include "world/generator/WorldGenerator.hpp"
|
||||||
#include "util/platform.hpp"
|
|
||||||
#include "frontend/locale.hpp"
|
|
||||||
#include "graphics/ui/gui_util.hpp"
|
|
||||||
#include "graphics/ui/GUI.hpp"
|
|
||||||
#include "graphics/ui/elements/Menu.hpp"
|
|
||||||
#include "window/Window.hpp"
|
#include "window/Window.hpp"
|
||||||
|
|
||||||
using namespace scripting;
|
using namespace scripting;
|
||||||
|
|
@ -240,29 +235,6 @@ static int l_get_setting_info(lua::State* L) {
|
||||||
throw std::runtime_error("unsupported setting type");
|
throw std::runtime_error("unsupported setting type");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_open_folder(lua::State* L) {
|
|
||||||
platform::open_folder(io::resolve(lua::require_string(L, 1)));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int l_open_url(lua::State* L) {
|
|
||||||
auto url = lua::require_string(L, 1);
|
|
||||||
|
|
||||||
std::wstring msg = langs::get(L"Are you sure you want to open the link:") +
|
|
||||||
L"\n" + util::str2wstr_utf8(url) +
|
|
||||||
std::wstring(L"?");
|
|
||||||
|
|
||||||
auto menu = engine->getGUI().getMenu();
|
|
||||||
|
|
||||||
guiutil::confirm(*engine, msg, [url, menu]() {
|
|
||||||
platform::open_url(url);
|
|
||||||
if (!menu->back()) {
|
|
||||||
menu->reset();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Quit the game
|
/// @brief Quit the game
|
||||||
static int l_quit(lua::State*) {
|
static int l_quit(lua::State*) {
|
||||||
engine->quit();
|
engine->quit();
|
||||||
|
|
@ -317,8 +289,6 @@ const luaL_Reg corelib[] = {
|
||||||
{"set_setting", lua::wrap<l_set_setting>},
|
{"set_setting", lua::wrap<l_set_setting>},
|
||||||
{"str_setting", lua::wrap<l_str_setting>},
|
{"str_setting", lua::wrap<l_str_setting>},
|
||||||
{"get_setting_info", lua::wrap<l_get_setting_info>},
|
{"get_setting_info", lua::wrap<l_get_setting_info>},
|
||||||
{"open_folder", lua::wrap<l_open_folder>},
|
|
||||||
{"open_url", lua::wrap<l_open_url>},
|
|
||||||
{"quit", lua::wrap<l_quit>},
|
{"quit", lua::wrap<l_quit>},
|
||||||
{"capture_output", lua::wrap<l_capture_output>},
|
{"capture_output", lua::wrap<l_capture_output>},
|
||||||
{nullptr, nullptr}
|
{nullptr, nullptr}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue