mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
Merge pull request #765 from MihailRis/new-project-permissions
New projects permissions
This commit is contained in:
commit
f6cb2f4065
8 changed files with 35 additions and 10 deletions
|
|
@ -18,8 +18,8 @@ function update_setting(x, id, name, postfix)
|
|||
-- updating label
|
||||
document[id..".L"].text = string.format(
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
core.str_setting(id),
|
||||
gui.str(name, "settings"),
|
||||
core.str_setting(id),
|
||||
postfix
|
||||
)
|
||||
end
|
||||
|
|
@ -67,5 +67,8 @@ function on_open()
|
|||
table.insert(devices, {value=name, text=name})
|
||||
end
|
||||
selectbox.options = devices
|
||||
selectbox.value = audio.__get_input_info().device_specifier
|
||||
local info = audio.__get_input_info()
|
||||
if info then
|
||||
selectbox.value = info.device_specifier
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,5 +2,6 @@
|
|||
name = "default"
|
||||
base_packs = ["base"]
|
||||
permissions = [
|
||||
"network"
|
||||
"network",
|
||||
"record-audio"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ namespace {
|
|||
std::vector<std::unique_ptr<Channel>> channels;
|
||||
util::ObjectsKeeper objects_keeper {};
|
||||
std::unique_ptr<InputDevice> input_device = nullptr;
|
||||
static bool input_enabled = false;
|
||||
}
|
||||
|
||||
Channel::Channel(std::string name) : name(std::move(name)) {
|
||||
|
|
@ -152,7 +153,9 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
void audio::initialize(bool enabled, AudioSettings& settings) {
|
||||
void audio::initialize(
|
||||
bool enabled, bool inputEnabled, AudioSettings& settings
|
||||
) {
|
||||
enabled = enabled && settings.enabled.get();
|
||||
if (enabled) {
|
||||
logger.info() << "initializing ALAudio backend";
|
||||
|
|
@ -182,7 +185,10 @@ void audio::initialize(bool enabled, AudioSettings& settings) {
|
|||
}, true));
|
||||
}
|
||||
|
||||
::input_device = backend->openInputDevice("", 44100, 1, 16);
|
||||
if (inputEnabled) {
|
||||
::input_device = backend->openInputDevice("", 44100, 1, 16);
|
||||
::input_enabled = true;
|
||||
}
|
||||
if (::input_device) {
|
||||
::input_device->startCapture();
|
||||
}
|
||||
|
|
@ -270,6 +276,10 @@ std::vector<std::string> audio::get_output_devices_names() {
|
|||
|
||||
void audio::set_input_device(const std::string& deviceName) {
|
||||
logger.info() << "setting input device to " << deviceName;
|
||||
if (!::input_enabled) {
|
||||
logger.warning() << "unable to set input device due to project permissions";
|
||||
return;
|
||||
}
|
||||
if (deviceName == audio::DEVICE_NONE) {
|
||||
if (::input_device) {
|
||||
::input_device->stopCapture();
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ namespace audio {
|
|||
|
||||
/// @brief Initialize audio system or use no audio mode
|
||||
/// @param enabled try to initialize actual audio
|
||||
void initialize(bool enabled, AudioSettings& settings);
|
||||
void initialize(bool enabled, bool inputEnabled, AudioSettings& settings);
|
||||
|
||||
/// @brief Load audio file info and PCM data
|
||||
/// @param file audio file
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ static network::Server& create_tcp_server(
|
|||
}
|
||||
u64id_t serverId = network->openTcpServer(
|
||||
port,
|
||||
[&network, &dbgServer](u64id_t sid, u64id_t id) {
|
||||
[network, &dbgServer](u64id_t sid, u64id_t id) {
|
||||
auto& connection = dynamic_cast<network::ReadableConnection&>(
|
||||
*network->getConnection(id, true)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,10 @@ namespace scripting {
|
|||
}
|
||||
|
||||
struct Permissions {
|
||||
static inline std::string WRITE_TO_USER = "write-to-user";
|
||||
static inline std::string DEBUGGING = "debugging";
|
||||
static inline std::string NETWORK = "network";
|
||||
static inline std::string RECORD_AUDIO = "record-audio";
|
||||
static inline std::string WRITE_TO_USER = "write-to-user";
|
||||
|
||||
std::set<std::string> permissions;
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,11 @@ void Engine::initialize(CoreParameters coreParameters) {
|
|||
if (!params.headless) {
|
||||
initializeClient();
|
||||
}
|
||||
audio::initialize(!params.headless, settings.audio);
|
||||
audio::initialize(
|
||||
!params.headless,
|
||||
project->permissions.has(Permissions::RECORD_AUDIO),
|
||||
settings.audio
|
||||
);
|
||||
|
||||
if (settings.ui.language.get() == "auto") {
|
||||
settings.ui.language.set(
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "content/ContentControl.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
#include "engine/EnginePaths.hpp"
|
||||
#include "devtools/Project.hpp"
|
||||
#include "network/Network.hpp"
|
||||
#include "util/platform.hpp"
|
||||
#include "window/Window.hpp"
|
||||
|
|
@ -13,6 +14,10 @@
|
|||
using namespace scripting;
|
||||
|
||||
static int l_start_debug_instance(lua::State* L) {
|
||||
if (!engine->getProject().permissions.has(Permissions::DEBUGGING)) {
|
||||
throw std::runtime_error("project has no debugging permission");
|
||||
}
|
||||
|
||||
int port = lua::tointeger(L, 1);
|
||||
if (port == 0) {
|
||||
auto network = engine->getNetwork();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue