mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
implement a bit
This commit is contained in:
parent
2a4b8b0297
commit
927611c06b
3 changed files with 16 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue