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 shareFunc,
slotcallback rightClick
)
: index(index),
) : index(index),
position(position),
background(background),
itemSource(itemSource),
@@ -47,22 +46,13 @@ InventoryBuilder::InventoryBuilder() {
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(
int cols, int count,
glm::vec2 pos,
int padding,
bool addpanel,
SlotLayout slotLayout)
{
SlotLayout slotLayout
) {
const int slotSize = InventoryView::SLOT_SIZE;
const int interval = InventoryView::SLOT_INTERVAL;
@@ -88,8 +78,9 @@ void InventoryBuilder::addGrid(
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
if (row * cols + col >= count)
if (row * cols + col >= count) {
break;
}
glm::vec2 position (
col * (slotSize + interval) + padding,
row * (slotSize + interval) + padding
@@ -122,14 +113,13 @@ void SlotView::draw(const GfxContext* pctx, Assets* assets) {
if (bound == nullptr)
return;
const int slotSize = InventoryView::SLOT_SIZE;
ItemStack& stack = *bound;
glm::vec2 pos = calcPos();
int slotSize = InventoryView::SLOT_SIZE;
glm::vec4 tint(1.0f);
glm::vec2 pos = calcPos();
glm::vec4 color = getColor();
if (hover || highlighted) {
tint *= 1.333f;
color = glm::vec4(1, 1, 1, 0.2f);
+12 -2
View File
@@ -48,13 +48,15 @@ struct SlotLayout {
slotcallback rightClick;
int padding = 0;
SlotLayout(int index,
SlotLayout(
int index,
glm::vec2 position,
bool background,
bool itemSource,
slotcallback updateFunc,
slotcallback shareFunc,
slotcallback rightClick);
slotcallback rightClick
);
};
class SlotView : public gui::UINode {
@@ -135,6 +137,14 @@ class InventoryBuilder {
public:
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(
int cols, int count,
glm::vec2 pos,
+18 -18
View File
@@ -7,56 +7,56 @@
#include "typedefs.h"
struct DisplaySettings {
/* Is window in full screen mode */
/// @brief Is window in full screen mode
bool fullscreen = false;
/* Window width (pixels) */
/// @brief Window width (pixels)
int width = 1280;
/* Window height (pixels) */
/// @brief Window height (pixels)
int height = 720;
/* Anti-aliasing samples */
/// @brief Anti-aliasing samples
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;
/* Window title */
/// @brief Window title */
std::string title = "VoxelEngine-Cpp v" +
std::to_string(ENGINE_VERSION_MAJOR) + "." +
std::to_string(ENGINE_VERSION_MINOR);
};
struct ChunksSettings {
/* Max milliseconds that engine uses for chunks loading only */
/// @brief Max milliseconds that engine uses for chunks loading only
uint loadSpeed = 4;
/* Radius of chunks loading zone (chunk is unit) */
/// @brief Radius of chunks loading zone (chunk is unit)
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;
};
struct CameraSettings {
/* Camera dynamic field of view effects */
/// @brief Camera dynamic field of view effects
bool fovEvents = true;
/* Camera movement shake */
/// @brief Camera movement shake
bool shaking = true;
/* Camera field of view */
/// @brief Camera field of view
float fov = 90.0f;
/* Camera sensitivity */
/// @brief Camera sensitivity
float sensitivity = 2.0f;
};
struct GraphicsSettings {
/* 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 */
/// @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
float fogCurve = 1.6f;
float gamma = 1.0f;
/* Enable blocks backlight to prevent complete darkness */
/// @brief Enable blocks backlight to prevent complete darkness
bool backlight = true;
/* Enable chunks frustum culling */
/// @brief Enable chunks frustum culling */
bool frustumCulling = true;
int skyboxResolution = 64 + 32;
};
struct DebugSettings {
/* Turns off chunks saving/loading */
/// @brief Turns off chunks saving/loading
bool generatorTestMode = false;
bool showChunkBorders = false;
bool doWriteLights = true;
+1 -1
View File
@@ -75,7 +75,7 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
return chunk;
}
// some magic code
// reduce nesting on next modification
void ChunksStorage::getVoxels(VoxelsVolume* volume, bool backlight) const {
const Content* content = level->content;
auto indices = content->getIndices();