add tpt.num_menus and tpt.menu_enabled functions
This commit is contained in:
parent
88097496af
commit
b75c8318e4
@ -1045,6 +1045,21 @@ std::vector<Menu*> GameController::GetMenuList()
|
||||
return gameModel->GetMenuList();
|
||||
}
|
||||
|
||||
int GameController::GetNumMenus(bool onlyEnabled)
|
||||
{
|
||||
int count = 0;
|
||||
if (onlyEnabled)
|
||||
{
|
||||
std::vector<Menu*> menuList = gameModel->GetMenuList();
|
||||
for (std::vector<Menu*>::iterator it = menuList.begin(), end = menuList.end(); it != end; ++it)
|
||||
if ((*it)->GetVisible())
|
||||
count++;
|
||||
}
|
||||
else
|
||||
count = gameModel->GetMenuList().size();
|
||||
return count;
|
||||
}
|
||||
|
||||
void GameController::RebuildFavoritesMenu()
|
||||
{
|
||||
gameModel->BuildFavoritesMenu();
|
||||
|
@ -103,6 +103,7 @@ public:
|
||||
void SetDebugFlags(unsigned int flags) { debugFlags = flags; }
|
||||
void SetActiveMenu(int menuID);
|
||||
std::vector<Menu*> GetMenuList();
|
||||
int GetNumMenus(bool onlyEnabled);
|
||||
void RebuildFavoritesMenu();
|
||||
Tool * GetActiveTool(int selection);
|
||||
void SetActiveTool(int toolSelection, Tool * tool);
|
||||
|
@ -248,15 +248,6 @@ void GameModel::BuildMenus()
|
||||
elementTools.clear();
|
||||
|
||||
//Create menus
|
||||
for (int i = 1; i < SC_TOOL; i++)
|
||||
{
|
||||
sim->msections[i].doshow = 0;
|
||||
}
|
||||
for (int i = 0; i < PT_NUM; i++)
|
||||
{
|
||||
if (sim->elements[i].Enabled && sim->elements[i].MenuVisible)
|
||||
sim->msections[sim->elements[i].MenuSection].doshow = 1;
|
||||
}
|
||||
for (int i = 0; i < SC_TOTAL; i++)
|
||||
{
|
||||
menuList.push_back(new Menu((const char)sim->msections[i].icon[0], sim->msections[i].name, sim->msections[i].doshow));
|
||||
|
@ -1800,6 +1800,30 @@ int luatpt_active_menu(lua_State* l)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luatpt_menu_enabled(lua_State* l)
|
||||
{
|
||||
int menusection = luaL_checkint(l, 1);
|
||||
if (menusection < 0 || menusection >= SC_TOTAL)
|
||||
return luaL_error(l, "Invalid menu");
|
||||
int acount = lua_gettop(l);
|
||||
if (acount == 1)
|
||||
{
|
||||
lua_pushboolean(l, luacon_sim->msections[menusection].doshow);
|
||||
return 1;
|
||||
}
|
||||
luaL_checktype(l, 2, LUA_TBOOLEAN);
|
||||
int enabled = lua_toboolean(l, 2);
|
||||
luacon_sim->msections[menusection].doshow = enabled;
|
||||
luacon_model->BuildMenus();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luatpt_num_menus(lua_State* l)
|
||||
{
|
||||
lua_pushinteger(l, luacon_controller->GetNumMenus(true));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int luatpt_decorations_enable(lua_State* l)
|
||||
{
|
||||
int acount = lua_gettop(l);
|
||||
|
@ -115,6 +115,8 @@ int luatpt_hud(lua_State* l);
|
||||
int luatpt_gravity(lua_State* l);
|
||||
int luatpt_airheat(lua_State* l);
|
||||
int luatpt_active_menu(lua_State* l);
|
||||
int luatpt_menu_enabled(lua_State* l);
|
||||
int luatpt_num_menus(lua_State* l);
|
||||
int luatpt_decorations_enable(lua_State* l);
|
||||
|
||||
int luatpt_heat(lua_State* l);
|
||||
|
@ -188,6 +188,8 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
||||
{"newtonian_gravity", &luatpt_gravity},
|
||||
{"ambient_heat", &luatpt_airheat},
|
||||
{"active_menu", &luatpt_active_menu},
|
||||
{"menu_enabled", &luatpt_menu_enabled},
|
||||
{"num_menus", &luatpt_num_menus},
|
||||
{"decorations_enable", &luatpt_decorations_enable},
|
||||
{"display_mode", &luatpt_cmode_set},
|
||||
{"throw_error", &luatpt_error},
|
||||
|
Reference in New Issue
Block a user