/*
Minetest
Copyright (C) 2013 sapier
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "lua_api/l_mainmenu.h"
#include "lua_api/l_internal.h"
#include "common/c_content.h"
#include "cpp_api/s_async.h"
#include "guiEngine.h"
#include "guiMainMenu.h"
#include "guiKeyChangeMenu.h"
#include "guiFileSelectMenu.h"
#include "subgame.h"
#include "version.h"
#include "porting.h"
#include "filesys.h"
#include "convert_json.h"
#include "serverlist.h"
#include "emerge.h"
#include "sound.h"
#include "settings.h"
#include "log.h"
#include "EDriverTypes.h"
#include <IFileArchive.h>
#include <IFileSystem.h>
/******************************************************************************/
std::string ModApiMainMenu::getTextData(lua_State *L, std::string name)
{
lua_getglobal(L, "gamedata");
lua_getfield(L, -1, name.c_str());
if(lua_isnil(L, -1))
return "";
return luaL_checkstring(L, -1);
}
/******************************************************************************/
int ModApiMainMenu::getIntegerData(lua_State *L, std::string name,bool& valid)
{
lua_getglobal(L, "gamedata");
lua_getfield(L, -1, name.c_str());
if(lua_isnil(L, -1)) {
valid = false;
return -1;
}
valid = true;
return luaL_checkinteger(L, -1);
}
/******************************************************************************/
int ModApiMainMenu::getBoolData(lua_State *L, std::string name,bool& valid)
{
lua_getglobal(L, "gamedata");
lua_getfield(L, -1, name.c_str());
if(lua_isnil(L, -1)) {
valid = false;
return false;
}
valid = true;
return lua_toboolean(L, -1);
}
/******************************************************************************/
int ModApiMainMenu::l_update_formspec(lua_State *L)
{
GUIEngine* engine = getGuiEngine(L);
sanity_check(engine != NULL);
if (engine->m_startgame)
return 0;
//read formspec
std::string formspec(luaL_checkstring(L, 1));
if (engine->m_formspecgui != 0) {
engine->m_formspecgui->setForm(formspec);
}
return 0;
}
|