implement a bit

This commit is contained in:
neveix 2026-08-13 22:16:21 +05:00
parent 2a4b8b0297
commit 927611c06b
3 changed files with 16 additions and 0 deletions

View file

@ -1,5 +1,7 @@
#include "InventoryView.hpp"
#include <iostream>
#include <glm/glm.hpp>
#include <utility>
@ -368,6 +370,7 @@ void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) {
return;
}
std::cout << "perform left click" << std::endl;
if (!layout.itemSource && stack.accepts(grabbed) && layout.placing) {
action = InteractionAction::PUT;
stack.move(grabbed, *content->getIndices());
@ -375,6 +378,10 @@ void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) {
if (layout.itemSource) {
if (grabbed.isEmpty()) {
action = InteractionAction::TAKE;
if (input.pressed(Keycode::LEFT_SHIFT)) {
stack.maximizeCount(*content->getIndices());
std::cout << "maximized grabbed item" << std::endl;
}
grabbed.set(stack);
} else {
action = InteractionAction::PUT;

View file

@ -48,6 +48,14 @@ void ItemStack::setCount(itemcount_t count) {
}
}
void ItemStack::maximizeCount(const ContentIndices& indices) {
auto& def = indices.items.require(getItemId());
this->count = def.stackSize;
if (count == 0) {
clear();
}
}
void ItemStack::setField(std::string_view name, dv::value value) {
if (fields == nullptr) {
if (value == nullptr) {

View file

@ -18,6 +18,7 @@ public:
void set(const ItemStack& item);
void set(ItemStack&& item);
void setCount(itemcount_t count);
void maximizeCount(const ContentIndices& indices);
/// @brief Set a field in the item stack data.
void setField(std::string_view name, dv::value value);