Skip to content

Commit

Permalink
Merge branch 'MihailRis:main' into Fix-usage-vcpkg-for-windows-and-ad…
Browse files Browse the repository at this point in the history
…d-cmake-preset-for-vscode
  • Loading branch information
Ygrik2003 authored Dec 20, 2024
2 parents dd09e3f + cda34e3 commit 75f5a47
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 12 deletions.
6 changes: 3 additions & 3 deletions doc/en/audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Library **audio** contains available Audio API in Lua scripts.

```lua
audio.play_stream(
-- audio file location
-- audio file location (without entry point, but with extension included)
name: string,
-- audio source world position
x: number, y: number, z: number,
Expand All @@ -79,7 +79,7 @@ Plays streaming audio from the specified file at the specified world position. R

```lua
audio.play_stream_2d(
-- audio file location
-- audio file location (without entry point, but with extension included)
name: string,
-- audio gain (0.0 - 1.0)
volume: number
Expand Down Expand Up @@ -202,4 +202,4 @@ audio.count_speakers() -> integer

-- get current number of playing streams
audio.count_streams() -> integer
```
```
1 change: 1 addition & 0 deletions doc/en/world-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The main properties described in the configuration file:
- **biomes-bpd** - number of blocks per point of the biome selection parameter map. Default: 4.
- **heights-bpd** - number of blocks per point of the height map. Default: 4.
- **wide-structs-chunks-radius** - maximum radius for placing 'wide' structures, measured in chunks.
- **heightmap-inputs** - an array of parameter map numbers that will be passed by the inputs table to the height map generation function.

## Global variables

Expand Down
4 changes: 2 additions & 2 deletions doc/ru/audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

```lua
audio.play_stream(
-- путь к аудио-файлу
-- путь к аудио-файлу (без точки входа, но с указанием расширения)
name: string,
-- позиция источника аудио в мире
x: number, y: number, z: number,
Expand All @@ -80,7 +80,7 @@ audio.play_stream(

```lua
audio.play_stream_2d(
-- путь к аудио-файлу
-- путь к аудио-файлу (без точки входа, но с указанием расширения)
name: string,
-- громкость аудио (от 0.0 до 1.0)
volume: number
Expand Down
1 change: 1 addition & 0 deletions doc/ru/world-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- **biomes-bpd** - количество блоков на точку карты параметра выбора биомов. По-умолчанию: 4.
- **heights-bpd** - количество блоков на точку карты высот. По-умолчанию: 4.
- **wide-structs-chunks-radius** - масимальный радиус размещения 'широких' структур, измеряемый в чанках.
- **heightmap-inputs** - массив номеров карт параметров, которые будут переданы таблицей inputs в функцию генерации карты высот.

## Глобальные переменные

Expand Down
2 changes: 1 addition & 1 deletion res/scripts/stdmin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function table.deep_copy(t)
end
end

return copied
return setmetatable(copied, getmetatable(t))
end

function table.count_pairs(t)
Expand Down
8 changes: 3 additions & 5 deletions src/content/ContentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ void ContentLoader::loadBlock(
}

// block model
std::string modelTypeName;
std::string modelTypeName = to_string(def.model);
root.at("model").get(modelTypeName);
root.at("model-name").get(def.modelName);
if (auto model = BlockModel_from(modelTypeName)) {
if (*model == BlockModel::custom) {
if (*model == BlockModel::custom && def.customModelRaw == nullptr) {
if (root.has("model-primitives")) {
def.customModelRaw = root["model-primitives"];
} else if (def.modelName.empty()) {
Expand All @@ -246,7 +246,7 @@ void ContentLoader::loadBlock(
root.at("material").get(def.material);

// rotation profile
std::string profile = "none";
std::string profile = def.rotations.name;
root.at("rotation").get(profile);

def.rotatable = profile != "none";
Expand Down Expand Up @@ -285,8 +285,6 @@ void ContentLoader::loadBlock(
);
aabb.b += aabb.a;
def.hitboxes = {aabb};
} else {
def.hitboxes = {AABB()};
}

// block light emission [r, g, b] where r,g,b in range [0..15]
Expand Down
28 changes: 28 additions & 0 deletions src/frontend/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "window/Window.hpp"
#include "world/Level.hpp"
#include "world/World.hpp"
#include "debug/Logger.hpp"

#include <assert.h>
#include <memory>
Expand All @@ -56,6 +57,8 @@

using namespace gui;

static debug::Logger logger("hud");

bool Hud::showGeneratorMinimap = false;

// implemented in debug_panel.cpp
Expand Down Expand Up @@ -486,7 +489,32 @@ void Hud::openPermanent(UiDocument* doc) {
add(HudElement(hud_element_mode::permanent, doc, doc->getRoot(), false));
}

void Hud::dropExchangeSlot() {
auto slotView = std::dynamic_pointer_cast<SlotView>(
gui->get(SlotView::EXCHANGE_SLOT_NAME)
);
if (slotView == nullptr) {
return;
}
ItemStack& stack = slotView->getStack();

auto indices = frontend.getLevel().content->getIndices();
if (auto invView = std::dynamic_pointer_cast<InventoryView>(blockUI)) {
invView->getInventory()->move(stack, indices);
}
if (stack.isEmpty()) {
return;
}
player->getInventory()->move(stack, indices);
if (!stack.isEmpty()) {
logger.warning() << "discard item [" << stack.getItemId() << ":"
<< stack.getCount();
stack.clear();
}
}

void Hud::closeInventory() {
dropExchangeSlot();
gui->remove(SlotView::EXCHANGE_SLOT_NAME);
exchangeSlot = nullptr;
exchangeSlotInv = nullptr;
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/hud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class Hud : public util::ObjectsKeeper {
void updateHotbarControl();
void cleanup();

/// @brief Perform exchange slot removal when it's not empty.
void dropExchangeSlot();

void showExchangeSlot();
void updateWorldGenDebugVisualization();
public:
Expand Down
2 changes: 1 addition & 1 deletion src/voxels/Block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class Block {
bool translucent = false;

/// @brief Set of block physical hitboxes
std::vector<AABB> hitboxes;
std::vector<AABB> hitboxes {AABB()};

/// @brief Set of available block rotations (coord-systems)
BlockRotProfile rotations = BlockRotProfile::NONE;
Expand Down

0 comments on commit 75f5a47

Please sign in to comment.