mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 15:01: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
|
-- updating label
|
||||||
document[id..".L"].text = string.format(
|
document[id..".L"].text = string.format(
|
||||||
"%s: %s%s",
|
"%s: %s%s",
|
||||||
gui.str(name, "settings"),
|
gui.str(name, "settings"),
|
||||||
core.str_setting(id),
|
core.str_setting(id),
|
||||||
postfix
|
postfix
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
@ -67,5 +67,8 @@ function on_open()
|
||||||
table.insert(devices, {value=name, text=name})
|
table.insert(devices, {value=name, text=name})
|
||||||
end
|
end
|
||||||
selectbox.options = devices
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,6 @@
|
||||||
name = "default"
|
name = "default"
|
||||||
base_packs = ["base"]
|
base_packs = ["base"]
|
||||||
permissions = [
|
permissions = [
|
||||||
"network"
|
"network",
|
||||||
|
"record-audio"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ namespace {
|
||||||
std::vector<std::unique_ptr<Channel>> channels;
|
std::vector<std::unique_ptr<Channel>> channels;
|
||||||
util::ObjectsKeeper objects_keeper {};
|
util::ObjectsKeeper objects_keeper {};
|
||||||
std::unique_ptr<InputDevice> input_device = nullptr;
|
std::unique_ptr<InputDevice> input_device = nullptr;
|
||||||
|
static bool input_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel::Channel(std::string name) : name(std::move(name)) {
|
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();
|
enabled = enabled && settings.enabled.get();
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
logger.info() << "initializing ALAudio backend";
|
logger.info() << "initializing ALAudio backend";
|
||||||
|
|
@ -182,7 +185,10 @@ void audio::initialize(bool enabled, AudioSettings& settings) {
|
||||||
}, true));
|
}, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
::input_device = backend->openInputDevice("", 44100, 1, 16);
|
if (inputEnabled) {
|
||||||
|
::input_device = backend->openInputDevice("", 44100, 1, 16);
|
||||||
|
::input_enabled = true;
|
||||||
|
}
|
||||||
if (::input_device) {
|
if (::input_device) {
|
||||||
::input_device->startCapture();
|
::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) {
|
void audio::set_input_device(const std::string& deviceName) {
|
||||||
logger.info() << "setting input device to " << 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 (deviceName == audio::DEVICE_NONE) {
|
||||||
if (::input_device) {
|
if (::input_device) {
|
||||||
::input_device->stopCapture();
|
::input_device->stopCapture();
|
||||||
|
|
|
||||||
|
|
@ -402,7 +402,7 @@ namespace audio {
|
||||||
|
|
||||||
/// @brief Initialize audio system or use no audio mode
|
/// @brief Initialize audio system or use no audio mode
|
||||||
/// @param enabled try to initialize actual audio
|
/// @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
|
/// @brief Load audio file info and PCM data
|
||||||
/// @param file audio file
|
/// @param file audio file
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ static network::Server& create_tcp_server(
|
||||||
}
|
}
|
||||||
u64id_t serverId = network->openTcpServer(
|
u64id_t serverId = network->openTcpServer(
|
||||||
port,
|
port,
|
||||||
[&network, &dbgServer](u64id_t sid, u64id_t id) {
|
[network, &dbgServer](u64id_t sid, u64id_t id) {
|
||||||
auto& connection = dynamic_cast<network::ReadableConnection&>(
|
auto& connection = dynamic_cast<network::ReadableConnection&>(
|
||||||
*network->getConnection(id, true)
|
*network->getConnection(id, true)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,10 @@ namespace scripting {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Permissions {
|
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 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;
|
std::set<std::string> permissions;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,11 @@ void Engine::initialize(CoreParameters coreParameters) {
|
||||||
if (!params.headless) {
|
if (!params.headless) {
|
||||||
initializeClient();
|
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") {
|
if (settings.ui.language.get() == "auto") {
|
||||||
settings.ui.language.set(
|
settings.ui.language.set(
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "content/ContentControl.hpp"
|
#include "content/ContentControl.hpp"
|
||||||
#include "engine/Engine.hpp"
|
#include "engine/Engine.hpp"
|
||||||
#include "engine/EnginePaths.hpp"
|
#include "engine/EnginePaths.hpp"
|
||||||
|
#include "devtools/Project.hpp"
|
||||||
#include "network/Network.hpp"
|
#include "network/Network.hpp"
|
||||||
#include "util/platform.hpp"
|
#include "util/platform.hpp"
|
||||||
#include "window/Window.hpp"
|
#include "window/Window.hpp"
|
||||||
|
|
@ -13,6 +14,10 @@
|
||||||
using namespace scripting;
|
using namespace scripting;
|
||||||
|
|
||||||
static int l_start_debug_instance(lua::State* L) {
|
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);
|
int port = lua::tointeger(L, 1);
|
||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
auto network = engine->getNetwork();
|
auto network = engine->getNetwork();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue