aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-06-26 20:11:17 +0200
committerGitHub <noreply@github.com>2017-06-26 20:11:17 +0200
commitb3a36f7378ea0f299cfa36c81de42e00adb7292d (patch)
tree23d056b575ff0dba8cc759cc00f732099a1f3bce /src/script/lua_api
parenta8650e785df3f12efa5f8cd3c6a695fb9e22a598 (diff)
downloadminetest-b3a36f7378ea0f299cfa36c81de42e00adb7292d.tar.gz
minetest-b3a36f7378ea0f299cfa36c81de42e00adb7292d.tar.bz2
minetest-b3a36f7378ea0f299cfa36c81de42e00adb7292d.zip
Isolate irrlicht references and use a singleton (#6041)
* Add Device3D class which will contain IrrlichtDevice interface move getSupportedVideoDrivers to Device3D Add Device3D singleton & use it in various places Rename Device3D to Rendering engine & add helper functions to various device pointers More singleton work RenderingEngine owns draw_load_screen move draw functions to RenderingEngine Reduce IrrlichtDevice exposure and guienvironment RenderingEngine: Expose get_timer_time() to remove device from guiEngine Make irrlichtdevice & scene manager less exposed * Code style fixes * Move porting::getVideoDriverName, getVideoDriverFriendlyName, getDisplayDensity, getDisplaySize to RenderingEngine Fix XORG_USED macro -> RenderingEngine + create_engine_device from RenderingEngine constructor directly * enum paralax => enum parallax
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_mainmenu.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 3ed2ba0e0..7c86525f6 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -33,10 +33,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serverlist.h"
#include "mapgen.h"
#include "settings.h"
-#include "EDriverTypes.h"
#include <IFileArchive.h>
#include <IFileSystem.h>
+#include "client/renderingengine.h"
/******************************************************************************/
@@ -628,8 +628,7 @@ int ModApiMainMenu::l_show_keys_menu(lua_State *L)
GUIEngine* engine = getGuiEngine(L);
sanity_check(engine != NULL);
- GUIKeyChangeMenu *kmenu
- = new GUIKeyChangeMenu( engine->m_device->getGUIEnvironment(),
+ GUIKeyChangeMenu *kmenu = new GUIKeyChangeMenu(RenderingEngine::get_gui_env(),
engine->m_parent,
-1,
engine->m_menumanager);
@@ -832,9 +831,6 @@ int ModApiMainMenu::l_copy_dir(lua_State *L)
/******************************************************************************/
int ModApiMainMenu::l_extract_zip(lua_State *L)
{
- GUIEngine* engine = getGuiEngine(L);
- sanity_check(engine);
-
const char *zipfile = luaL_checkstring(L, 1);
const char *destination = luaL_checkstring(L, 2);
@@ -843,7 +839,7 @@ int ModApiMainMenu::l_extract_zip(lua_State *L)
if (ModApiMainMenu::isMinetestPath(absolute_destination)) {
fs::CreateAllDirs(absolute_destination);
- io::IFileSystem* fs = engine->m_device->getFileSystem();
+ io::IFileSystem *fs = RenderingEngine::get_filesystem();
if (!fs->addFileArchive(zipfile,true,false,io::EFAT_ZIP)) {
lua_pushboolean(L,false);
@@ -960,7 +956,7 @@ int ModApiMainMenu::l_show_path_select_dialog(lua_State *L)
bool is_file_select = lua_toboolean(L, 3);
GUIFileSelectMenu* fileOpenMenu =
- new GUIFileSelectMenu(engine->m_device->getGUIEnvironment(),
+ new GUIFileSelectMenu(RenderingEngine::get_gui_env(),
engine->m_parent,
-1,
engine->m_menumanager,
@@ -997,13 +993,12 @@ int ModApiMainMenu::l_download_file(lua_State *L)
/******************************************************************************/
int ModApiMainMenu::l_get_video_drivers(lua_State *L)
{
- std::vector<irr::video::E_DRIVER_TYPE> drivers
- = porting::getSupportedVideoDrivers();
+ std::vector<irr::video::E_DRIVER_TYPE> drivers = RenderingEngine::getSupportedVideoDrivers();
lua_newtable(L);
for (u32 i = 0; i != drivers.size(); i++) {
- const char *name = porting::getVideoDriverName(drivers[i]);
- const char *fname = porting::getVideoDriverFriendlyName(drivers[i]);
+ const char *name = RenderingEngine::getVideoDriverName(drivers[i]);
+ const char *fname = RenderingEngine::getVideoDriverFriendlyName(drivers[i]);
lua_newtable(L);
lua_pushstring(L, name);
@@ -1021,7 +1016,7 @@ int ModApiMainMenu::l_get_video_drivers(lua_State *L)
int ModApiMainMenu::l_get_video_modes(lua_State *L)
{
std::vector<core::vector3d<u32> > videomodes
- = porting::getSupportedVideoModes();
+ = RenderingEngine::getSupportedVideoModes();
lua_newtable(L);
for (u32 i = 0; i != videomodes.size(); i++) {
@@ -1054,23 +1049,24 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L)
lua_newtable(L);
int top = lua_gettop(L);
lua_pushstring(L,"density");
- lua_pushnumber(L,porting::getDisplayDensity());
+ lua_pushnumber(L,RenderingEngine::getDisplayDensity());
lua_settable(L, top);
lua_pushstring(L,"display_width");
- lua_pushnumber(L,porting::getDisplaySize().X);
+ lua_pushnumber(L,RenderingEngine::getDisplaySize().X);
lua_settable(L, top);
lua_pushstring(L,"display_height");
- lua_pushnumber(L,porting::getDisplaySize().Y);
+ lua_pushnumber(L,RenderingEngine::getDisplaySize().Y);
lua_settable(L, top);
+ const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
lua_pushstring(L,"window_width");
- lua_pushnumber(L,porting::getWindowSize().X);
+ lua_pushnumber(L, window_size.X);
lua_settable(L, top);
lua_pushstring(L,"window_height");
- lua_pushnumber(L,porting::getWindowSize().Y);
+ lua_pushnumber(L, window_size.Y);
lua_settable(L, top);
return 1;
}