mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
Merge branch 'main' into animation
This commit is contained in:
commit
d20e9fcb40
18 changed files with 242 additions and 124 deletions
|
|
@ -47,9 +47,10 @@ void AssetsLoader::add(
|
|||
AssetType tag,
|
||||
const std::string& filename,
|
||||
const std::string& alias,
|
||||
std::shared_ptr<AssetCfg> settings
|
||||
std::shared_ptr<AssetCfg> settings,
|
||||
bool overwrite
|
||||
) {
|
||||
if (enqueued.find({tag, alias}) != enqueued.end()){
|
||||
if (!overwrite && enqueued.find({tag, alias}) != enqueued.end()){
|
||||
return;
|
||||
}
|
||||
entries.push(aloader_entry {tag, filename, alias, std::move(settings)});
|
||||
|
|
@ -154,11 +155,12 @@ void AssetsLoader::processPreload(
|
|||
std::string defFolder = assets_def_folder(tag);
|
||||
std::string path = defFolder + "/" + name;
|
||||
if (map == nullptr) {
|
||||
add(tag, path, name);
|
||||
add(tag, path, name, nullptr, true);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AssetCfg> config = nullptr;
|
||||
map.at("path").get(path);
|
||||
logger.debug() << "processing preload " << util::quote(name) << " path: " << util::quote(path);
|
||||
switch (tag) {
|
||||
case AssetType::SOUND: {
|
||||
bool keepPCM = false;
|
||||
|
|
@ -196,7 +198,7 @@ void AssetsLoader::processPreload(
|
|||
default:
|
||||
break;
|
||||
}
|
||||
add(tag, path, name, std::move(config));
|
||||
add(tag, path, name, std::move(config), true);
|
||||
}
|
||||
|
||||
void AssetsLoader::processPreloadList(AssetType tag, const dv::value& list) {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@ public:
|
|||
AssetType tag,
|
||||
const std::string& filename,
|
||||
const std::string& alias,
|
||||
std::shared_ptr<AssetCfg> settings = nullptr
|
||||
std::shared_ptr<AssetCfg> settings = nullptr,
|
||||
bool overwrite = false
|
||||
);
|
||||
|
||||
bool hasNext() const;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "debug/Logger.hpp"
|
||||
#include "alutil.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
#include "../MemoryPCMStream.hpp"
|
||||
|
||||
static debug::Logger logger("al-audio");
|
||||
|
|
@ -99,6 +100,8 @@ ALInputDevice::ALInputDevice(
|
|||
|
||||
if (deviceName) {
|
||||
deviceSpecifier = std::string(deviceName);
|
||||
logger.info() << "created input device with specifier "
|
||||
<< util::quote(deviceSpecifier);
|
||||
} else {
|
||||
logger.warning() << "could not retrieve input device specifier";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,12 +211,15 @@ void audio::initialize(
|
|||
return;
|
||||
}
|
||||
if (enabled) {
|
||||
logger.info() << "recording enabled; input device is "
|
||||
<< settings.inputDevice.get();
|
||||
const auto& targetDevice = settings.inputDevice.get();
|
||||
logger.info() << "recording enabled; target input device is "
|
||||
<< (targetDevice.empty() ? "not specified"
|
||||
: targetDevice);
|
||||
::input_device = backend->openInputDevice(
|
||||
settings.inputDevice.get(), 44100, 1, 16
|
||||
);
|
||||
if (::input_device != nullptr) {
|
||||
logger.error() << "could not create input device";
|
||||
::input_device->startCapture();
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -78,9 +78,10 @@ void Panel::refresh() {
|
|||
glm::vec2 size = getSize();
|
||||
if (orientation == Orientation::VERTICAL) {
|
||||
float maxw = size.x;
|
||||
for (auto& node : nodes) {
|
||||
for (size_t i = 0; i < nodes.size(); i++) {
|
||||
const auto& node = nodes[i];
|
||||
const glm::vec4 margin = node->getMargin();
|
||||
y += margin.y;
|
||||
y += margin.y + (i > 0 ? interval : 0);
|
||||
|
||||
float ex = x + margin.x;
|
||||
node->setPos(glm::vec2(ex, y));
|
||||
|
|
@ -94,16 +95,17 @@ void Panel::refresh() {
|
|||
}
|
||||
node->refresh();
|
||||
glm::vec2 nodeSize = node->getSize();
|
||||
y += nodeSize.y + margin.w + interval;
|
||||
y += nodeSize.y + margin.w;
|
||||
maxw = fmax(maxw, ex + nodeSize.x + margin.z + padding.z);
|
||||
}
|
||||
actualLengthX = size.x;
|
||||
actualLengthY = y + padding.w;
|
||||
} else {
|
||||
float maxh = size.y;
|
||||
for (auto& node : nodes) {
|
||||
for (size_t i = 0; i < nodes.size(); i++) {
|
||||
const auto& node = nodes[i];
|
||||
const glm::vec4 margin = node->getMargin();
|
||||
x += margin.x;
|
||||
x += margin.x + (i > 0 ? interval : 0);
|
||||
|
||||
float ey = y + margin.y;
|
||||
node->setPos(glm::vec2(x, ey));
|
||||
|
|
@ -117,7 +119,7 @@ void Panel::refresh() {
|
|||
}
|
||||
node->refresh();
|
||||
glm::vec2 nodesize = node->getSize();
|
||||
x += nodesize.x + margin.z + interval;
|
||||
x += nodesize.x + margin.z;
|
||||
maxh = fmax(maxh, ey + nodesize.y + margin.w + padding.w);
|
||||
}
|
||||
actualLengthY = size.y;
|
||||
|
|
|
|||
|
|
@ -92,6 +92,17 @@ static int l_reconfig_packs(lua::State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/// @brief Get current content packs configuration
|
||||
static int l_get_content(lua::State* L) {
|
||||
const auto& configuration = content_control->getContentPacks();
|
||||
lua::createtable(L, configuration.size(), 0);
|
||||
for (int i = 0; i < configuration.size(); i++) {
|
||||
lua::pushlstring(L, configuration[i].id);
|
||||
lua::rawseti(L, i + 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// @brief Get content sources list
|
||||
static int l_get_content_sources(lua::State* L) {
|
||||
const auto& sources = engine->getContentControl().getContentSources();
|
||||
|
|
@ -453,6 +464,7 @@ const luaL_Reg applib[] = {
|
|||
{"load_content", lua::wrap<l_load_content>},
|
||||
{"reset_content", lua::wrap<l_reset_content>},
|
||||
{"reconfig_packs", lua::wrap<l_reconfig_packs>},
|
||||
{"get_content", lua::wrap<l_get_content>},
|
||||
{"get_content_sources", lua::wrap<l_get_content_sources>},
|
||||
{"set_content_sources", lua::wrap<l_set_content_sources>},
|
||||
{"reset_content_sources", lua::wrap<l_reset_content_sources>},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "engine/Engine.hpp"
|
||||
#include "api_lua.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
using namespace scripting;
|
||||
|
|
@ -20,11 +21,18 @@ static int l_utc_time(lua::State* L) {
|
|||
return lua::pushnumber(L, std::time(nullptr));
|
||||
}
|
||||
|
||||
static int l_precise_utc_time(lua::State* L) {
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
return lua::pushnumber(
|
||||
L, std::chrono::duration<double>(now.time_since_epoch()).count()
|
||||
);
|
||||
}
|
||||
|
||||
static int l_local_time(lua::State* L) {
|
||||
std::time_t t = std::time(nullptr);
|
||||
|
||||
std::tm gmt_tm{};
|
||||
std::tm local_tm{};
|
||||
std::tm gmt_tm {};
|
||||
std::tm local_tm {};
|
||||
|
||||
#if defined(USE_MSVC_TIME_SAFE)
|
||||
gmtime_s(&gmt_tm, &t);
|
||||
|
|
@ -44,8 +52,8 @@ static int l_local_time(lua::State* L) {
|
|||
static int l_utc_offset(lua::State* L) {
|
||||
std::time_t t = std::time(nullptr);
|
||||
|
||||
std::tm gmt_tm{};
|
||||
std::tm local_tm{};
|
||||
std::tm gmt_tm {};
|
||||
std::tm local_tm {};
|
||||
|
||||
#if defined(USE_MSVC_TIME_SAFE)
|
||||
gmtime_s(&gmt_tm, &t);
|
||||
|
|
@ -74,6 +82,7 @@ const luaL_Reg timelib[] = {
|
|||
{"uptime", lua::wrap<l_uptime>},
|
||||
{"delta", lua::wrap<l_delta>},
|
||||
{"utc_time", lua::wrap<l_utc_time>},
|
||||
{"precise_utc_time", lua::wrap<l_precise_utc_time>},
|
||||
{"utc_offset", lua::wrap<l_utc_offset>},
|
||||
{"local_time", lua::wrap<l_local_time>},
|
||||
{"precise_time", lua::wrap<l_precise_time>},
|
||||
|
|
|
|||
|
|
@ -74,6 +74,11 @@ static void create_libs(State* L, StateType stateType) {
|
|||
getglobal(L, "__vc_app");
|
||||
setregistry(L, "app");
|
||||
|
||||
createtable(L, 0, 0);
|
||||
pushvalue(L, -1);
|
||||
setglobal(L, "__vc_internals");
|
||||
setregistry(L, "internals");
|
||||
|
||||
if (stateType == StateType::SCRIPT) {
|
||||
getregistry(L, "app");
|
||||
setglobal(L, "app");
|
||||
|
|
|
|||
|
|
@ -288,7 +288,23 @@ void scripting::on_content_load(Content* content) {
|
|||
lua::setfield(L, "properties");
|
||||
lua::pop(L);
|
||||
}
|
||||
load_script("post_content.lua", true);
|
||||
|
||||
lua::getregistry(L, "app");
|
||||
lua::setglobal(L, "__vc_app");
|
||||
lua::getregistry(L, "internals");
|
||||
lua::setglobal(L, "__vc_internals");
|
||||
try {
|
||||
load_script("post_content.lua", true);
|
||||
} catch (const std::exception&) {
|
||||
lua::pushnil(L);
|
||||
lua::setglobal(L, "__vc_app");
|
||||
throw;
|
||||
}
|
||||
lua::pushnil(L);
|
||||
lua::setglobal(L, "__vc_app");
|
||||
lua::pushnil(L);
|
||||
lua::setglobal(L, "__vc_internals");
|
||||
|
||||
load_script("stdcmd.lua", true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ struct AudioSettings {
|
|||
NumberSetting volumeAmbient {1.0f, 0.0f, 1.0f, setting_format::percent};
|
||||
NumberSetting volumeMusic {1.0f, 0.0f, 1.0f, setting_format::percent};
|
||||
|
||||
StringSetting inputDevice {"auto"};
|
||||
StringSetting inputDevice {""};
|
||||
|
||||
FlagSetting acousticEffects {true};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue