mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
add 'taking' and 'placing' xml properties to slot and slots-grid
This commit is contained in:
parent
4e25362f9b
commit
69df0eba1b
3 changed files with 22 additions and 4 deletions
|
|
@ -209,7 +209,7 @@ bool SlotView::isHighlighted() const {
|
|||
}
|
||||
|
||||
void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) {
|
||||
if (Events::pressed(keycode::LEFT_SHIFT)) {
|
||||
if (layout.taking && Events::pressed(keycode::LEFT_SHIFT)) {
|
||||
if (layout.shareFunc) {
|
||||
layout.shareFunc(layout.index, stack);
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (!layout.itemSource && stack.accepts(grabbed)) {
|
||||
if (!layout.itemSource && stack.accepts(grabbed) && layout.placing) {
|
||||
stack.move(grabbed, content->getIndices());
|
||||
} else {
|
||||
if (layout.itemSource) {
|
||||
|
|
@ -227,7 +227,11 @@ void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) {
|
|||
} else {
|
||||
grabbed.clear();
|
||||
}
|
||||
} else {
|
||||
} else if (grabbed.isEmpty()) {
|
||||
if (layout.taking) {
|
||||
std::swap(grabbed, stack);
|
||||
}
|
||||
} else if (layout.taking && layout.placing) {
|
||||
std::swap(grabbed, stack);
|
||||
}
|
||||
}
|
||||
|
|
@ -244,7 +248,7 @@ void SlotView::performRightClick(ItemStack& stack, ItemStack& grabbed) {
|
|||
if (layout.itemSource)
|
||||
return;
|
||||
if (grabbed.isEmpty()) {
|
||||
if (!stack.isEmpty()) {
|
||||
if (!stack.isEmpty() && layout.taking) {
|
||||
grabbed.set(stack);
|
||||
int halfremain = stack.getCount() / 2;
|
||||
grabbed.setCount(stack.getCount() - halfremain);
|
||||
|
|
@ -253,6 +257,9 @@ void SlotView::performRightClick(ItemStack& stack, ItemStack& grabbed) {
|
|||
return;
|
||||
}
|
||||
auto& stackDef = content->getIndices()->items.require(stack.getItemId());
|
||||
if (!layout.placing) {
|
||||
return;
|
||||
}
|
||||
if (stack.isEmpty()) {
|
||||
stack.set(grabbed);
|
||||
stack.setCount(1);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ namespace gui {
|
|||
slotcallback rightClick;
|
||||
int padding = 0;
|
||||
|
||||
bool taking = true;
|
||||
bool placing = true;
|
||||
|
||||
SlotLayout(
|
||||
int index,
|
||||
glm::vec2 position,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue