2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
2013-08-11 04:09:45 +02:00
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2013-08-11 04:09:45 +02:00
|
|
|
|
|
|
|
#include "cpp_api/s_base.h"
|
|
|
|
#include "cpp_api/s_mainmenu.h"
|
2024-11-03 16:53:01 +01:00
|
|
|
#include "cpp_api/s_security.h"
|
2014-04-15 13:41:07 -04:00
|
|
|
#include "cpp_api/s_async.h"
|
2013-08-11 04:09:45 +02:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Scripting <-> Main Menu Interface */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
class MainMenuScripting
|
|
|
|
: virtual public ScriptApiBase,
|
2024-11-03 16:53:01 +01:00
|
|
|
public ScriptApiMainMenu,
|
|
|
|
public ScriptApiSecurity
|
2013-08-11 04:09:45 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MainMenuScripting(GUIEngine* guiengine);
|
|
|
|
|
2014-04-15 13:41:07 -04:00
|
|
|
// Global step handler to pass back async events
|
2014-04-15 15:10:30 -04:00
|
|
|
void step();
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2014-04-15 13:41:07 -04:00
|
|
|
// Pass async events from engine to async threads
|
2021-08-28 12:15:12 +02:00
|
|
|
u32 queueAsync(std::string &&serialized_func,
|
|
|
|
std::string &&serialized_param);
|
|
|
|
|
2024-11-03 16:53:01 +01:00
|
|
|
// Is the main menu allowed writeable access to this path?
|
|
|
|
static bool mayModifyPath(const std::string &path);
|
|
|
|
|
|
|
|
// (public implementation so it can be used from AsyncEngine)
|
|
|
|
static bool checkPathAccess(const std::string &abs_path, bool write_required,
|
|
|
|
bool *write_allowed);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool checkPathInternal(const std::string &abs_path, bool write_required,
|
|
|
|
bool *write_allowed) override {
|
|
|
|
return checkPathAccess(abs_path, write_required, write_allowed);
|
|
|
|
}
|
|
|
|
|
2013-08-11 04:09:45 +02:00
|
|
|
private:
|
2014-04-15 15:10:30 -04:00
|
|
|
void initializeModApi(lua_State *L, int top);
|
2014-12-12 14:49:19 -05:00
|
|
|
static void registerLuaClasses(lua_State *L, int top);
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2014-04-15 15:10:30 -04:00
|
|
|
AsyncEngine asyncEngine;
|
2013-08-11 04:09:45 +02:00
|
|
|
};
|