indentation fix + minor refactor

This commit is contained in:
MihailRis
2024-03-12 23:07:24 +03:00
parent 5c3b61265a
commit a82a77ba2d
5 changed files with 132 additions and 132 deletions
+9 -19
View File
@@ -34,8 +34,7 @@ SlotLayout::SlotLayout(
slotcallback updateFunc, slotcallback updateFunc,
slotcallback shareFunc, slotcallback shareFunc,
slotcallback rightClick slotcallback rightClick
) ) : index(index),
: index(index),
position(position), position(position),
background(background), background(background),
itemSource(itemSource), itemSource(itemSource),
@@ -47,22 +46,13 @@ InventoryBuilder::InventoryBuilder() {
view = std::make_shared<InventoryView>(); view = std::make_shared<InventoryView>();
} }
/** Add slots grid to inventory view
* @param cols grid columns
* @param count total number of grid slots
* @param pos position of the first slot of the grid
* @param padding additional space around the grid
* @param addpanel automatically create panel behind the grid
* with size including padding
* @param slotLayout slot settings (index and position are ignored)
*/
void InventoryBuilder::addGrid( void InventoryBuilder::addGrid(
int cols, int count, int cols, int count,
glm::vec2 pos, glm::vec2 pos,
int padding, int padding,
bool addpanel, bool addpanel,
SlotLayout slotLayout) SlotLayout slotLayout
{ ) {
const int slotSize = InventoryView::SLOT_SIZE; const int slotSize = InventoryView::SLOT_SIZE;
const int interval = InventoryView::SLOT_INTERVAL; const int interval = InventoryView::SLOT_INTERVAL;
@@ -88,8 +78,9 @@ void InventoryBuilder::addGrid(
for (int row = 0; row < rows; row++) { for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) { for (int col = 0; col < cols; col++) {
if (row * cols + col >= count) if (row * cols + col >= count) {
break; break;
}
glm::vec2 position ( glm::vec2 position (
col * (slotSize + interval) + padding, col * (slotSize + interval) + padding,
row * (slotSize + interval) + padding row * (slotSize + interval) + padding
@@ -122,14 +113,13 @@ void SlotView::draw(const GfxContext* pctx, Assets* assets) {
if (bound == nullptr) if (bound == nullptr)
return; return;
const int slotSize = InventoryView::SLOT_SIZE;
ItemStack& stack = *bound; ItemStack& stack = *bound;
glm::vec2 pos = calcPos();
int slotSize = InventoryView::SLOT_SIZE;
glm::vec4 tint(1.0f); glm::vec4 tint(1.0f);
glm::vec2 pos = calcPos();
glm::vec4 color = getColor(); glm::vec4 color = getColor();
if (hover || highlighted) { if (hover || highlighted) {
tint *= 1.333f; tint *= 1.333f;
color = glm::vec4(1, 1, 1, 0.2f); color = glm::vec4(1, 1, 1, 0.2f);
+12 -2
View File
@@ -48,13 +48,15 @@ struct SlotLayout {
slotcallback rightClick; slotcallback rightClick;
int padding = 0; int padding = 0;
SlotLayout(int index, SlotLayout(
int index,
glm::vec2 position, glm::vec2 position,
bool background, bool background,
bool itemSource, bool itemSource,
slotcallback updateFunc, slotcallback updateFunc,
slotcallback shareFunc, slotcallback shareFunc,
slotcallback rightClick); slotcallback rightClick
);
}; };
class SlotView : public gui::UINode { class SlotView : public gui::UINode {
@@ -135,6 +137,14 @@ class InventoryBuilder {
public: public:
InventoryBuilder(); InventoryBuilder();
/// @brief Add slots grid to inventory view
/// @param cols grid columns
/// @param count total number of grid slots
/// @param pos position of the first slot of the grid
/// @param padding additional space around the grid
/// @param addpanel automatically create panel behind the grid
/// with size including padding
/// @param slotLayout slot settings (index and position are ignored)
void addGrid( void addGrid(
int cols, int count, int cols, int count,
glm::vec2 pos, glm::vec2 pos,
+18 -18
View File
@@ -7,56 +7,56 @@
#include "typedefs.h" #include "typedefs.h"
struct DisplaySettings { struct DisplaySettings {
/* Is window in full screen mode */ /// @brief Is window in full screen mode
bool fullscreen = false; bool fullscreen = false;
/* Window width (pixels) */ /// @brief Window width (pixels)
int width = 1280; int width = 1280;
/* Window height (pixels) */ /// @brief Window height (pixels)
int height = 720; int height = 720;
/* Anti-aliasing samples */ /// @brief Anti-aliasing samples
int samples = 0; int samples = 0;
/* GLFW swap interval value, 0 - unlimited fps, 1 - vsync*/ /// @brief GLFW swap interval value, 0 - unlimited fps, 1 - vsync
int swapInterval = 1; int swapInterval = 1;
/* Window title */ /// @brief Window title */
std::string title = "VoxelEngine-Cpp v" + std::string title = "VoxelEngine-Cpp v" +
std::to_string(ENGINE_VERSION_MAJOR) + "." + std::to_string(ENGINE_VERSION_MAJOR) + "." +
std::to_string(ENGINE_VERSION_MINOR); std::to_string(ENGINE_VERSION_MINOR);
}; };
struct ChunksSettings { struct ChunksSettings {
/* Max milliseconds that engine uses for chunks loading only */ /// @brief Max milliseconds that engine uses for chunks loading only
uint loadSpeed = 4; uint loadSpeed = 4;
/* Radius of chunks loading zone (chunk is unit) */ /// @brief Radius of chunks loading zone (chunk is unit)
uint loadDistance = 22; uint loadDistance = 22;
/* Buffer zone where chunks are not unloading (chunk is unit)*/ /// @brief Buffer zone where chunks are not unloading (chunk is unit)
uint padding = 2; uint padding = 2;
}; };
struct CameraSettings { struct CameraSettings {
/* Camera dynamic field of view effects */ /// @brief Camera dynamic field of view effects
bool fovEvents = true; bool fovEvents = true;
/* Camera movement shake */ /// @brief Camera movement shake
bool shaking = true; bool shaking = true;
/* Camera field of view */ /// @brief Camera field of view
float fov = 90.0f; float fov = 90.0f;
/* Camera sensitivity */ /// @brief Camera sensitivity
float sensitivity = 2.0f; float sensitivity = 2.0f;
}; };
struct GraphicsSettings { struct GraphicsSettings {
/* Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance. /// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance.
Use values in range [1.0 - 2.0] where 1.0 is linear, 2.0 is quadratic */ /// Use values in range [1.0 - 2.0] where 1.0 is linear, 2.0 is quadratic
float fogCurve = 1.6f; float fogCurve = 1.6f;
float gamma = 1.0f; float gamma = 1.0f;
/* Enable blocks backlight to prevent complete darkness */ /// @brief Enable blocks backlight to prevent complete darkness
bool backlight = true; bool backlight = true;
/* Enable chunks frustum culling */ /// @brief Enable chunks frustum culling */
bool frustumCulling = true; bool frustumCulling = true;
int skyboxResolution = 64 + 32; int skyboxResolution = 64 + 32;
}; };
struct DebugSettings { struct DebugSettings {
/* Turns off chunks saving/loading */ /// @brief Turns off chunks saving/loading
bool generatorTestMode = false; bool generatorTestMode = false;
bool showChunkBorders = false; bool showChunkBorders = false;
bool doWriteLights = true; bool doWriteLights = true;
+1 -1
View File
@@ -75,7 +75,7 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
return chunk; return chunk;
} }
// some magic code // reduce nesting on next modification
void ChunksStorage::getVoxels(VoxelsVolume* volume, bool backlight) const { void ChunksStorage::getVoxels(VoxelsVolume* volume, bool backlight) const {
const Content* content = level->content; const Content* content = level->content;
auto indices = content->getIndices(); auto indices = content->getIndices();