use of gregtech.api.items.gui.PlayerInventoryHolder in project GregTech by GregTechCEu.
the class ClipboardBehavior method createMTEUI.
public ModularUI createMTEUI(PlayerInventoryHolder holder, EntityPlayer entityPlayer) {
// So that people don't click on any text fields
initNBT(holder.getCurrentItem());
ModularUI.Builder builder = ModularUI.builder(GuiTextures.CLIPBOARD_PAPER_BACKGROUND, 170, 238);
builder.image(18, 8, 130, 14, GuiTextures.CLIPBOARD_TEXT_BOX);
builder.widget(new SimpleTextWidget(20, 10, "", TEXT_COLOR, () -> getTitle(holder), true).setCenter(false));
for (int i = 0; i < 8; i++) {
int finalI = i;
builder.widget(new ImageCycleButtonWidget(6, 37 + 20 * i, 15, 15, GuiTextures.CLIPBOARD_BUTTON, 4, () -> getButtonState(holder, finalI), (x) -> setButton(holder, finalI, x)));
builder.image(22, 38 + 20 * i, 140, 12, GuiTextures.CLIPBOARD_TEXT_BOX);
builder.widget(new SimpleTextWidget(24, 40 + 20 * i, "", TEXT_COLOR, () -> getString(holder, finalI), true).setCenter(false));
}
builder.widget(new ClickButtonWidget(30, 200, 16, 16, "", (x) -> incrPageNum(holder, x.isShiftClick ? -10 : -1)).setButtonTexture(GuiTextures.BUTTON_LEFT).setShouldClientCallback(true));
builder.widget(new ClickButtonWidget(124, 200, 16, 16, "", (x) -> incrPageNum(holder, x.isShiftClick ? 10 : 1)).setButtonTexture(GuiTextures.BUTTON_RIGHT).setShouldClientCallback(true));
builder.widget(new SimpleTextWidget(85, 208, "", TEXT_COLOR, () -> (getPageNum(holder) + 1) + " / " + MAX_PAGES, true));
builder.shouldColor(false);
return builder.build(holder, entityPlayer);
}
use of gregtech.api.items.gui.PlayerInventoryHolder in project GregTech by GregTechCEu.
the class ClipboardBehavior method createUI.
@Override
public ModularUI createUI(PlayerInventoryHolder holder, EntityPlayer entityPlayer) {
ModularUI.Builder builder = ModularUI.builder(GuiTextures.CLIPBOARD_BACKGROUND, 186, 263);
initNBT(holder.getCurrentItem());
List<TextFieldWidget2> textFields = new ArrayList<>();
builder.image(28, 28, 130, 12, GuiTextures.CLIPBOARD_TEXT_BOX);
textFields.add(new TextFieldWidget2(30, 30, 126, 9, () -> getTitle(holder), val -> setTitle(holder, val)).setMaxLength(25).setCentered(true).setTextColor(TEXT_COLOR));
for (int i = 0; i < 8; i++) {
int finalI = i;
builder.widget(new ImageCycleButtonWidget(14, 55 + 22 * i, 15, 15, GuiTextures.CLIPBOARD_BUTTON, 4, () -> getButtonState(holder, finalI), (x) -> setButton(holder, finalI, x)));
builder.image(32, 58 + 22 * i, 140, 12, GuiTextures.CLIPBOARD_TEXT_BOX);
textFields.add(new TextFieldWidget2(34, 60 + 22 * i, 136, 9, () -> getString(holder, finalI), val -> setString(holder, finalI, val)).setMaxLength(23).setTextColor(TEXT_COLOR));
}
for (TextFieldWidget2 textField : textFields) {
builder.widget(textField.setOnFocus(textField2 -> textFields.forEach(textField3 -> {
if (textField3 != textField2) {
textField3.unFocus();
}
})));
}
builder.widget(new ClickButtonWidget(38, 231, 16, 16, "", (x) -> incrPageNum(holder, x.isShiftClick ? -10 : -1)).setButtonTexture(GuiTextures.BUTTON_LEFT).setShouldClientCallback(true));
builder.widget(new ClickButtonWidget(132, 231, 16, 16, "", (x) -> incrPageNum(holder, x.isShiftClick ? 10 : 1)).setButtonTexture(GuiTextures.BUTTON_RIGHT).setShouldClientCallback(true));
builder.widget(new SimpleTextWidget(93, 240, "", TEXT_COLOR, () -> (getPageNum(holder) + 1) + " / " + MAX_PAGES, true));
builder.shouldColor(false);
return builder.build(holder, entityPlayer);
}
use of gregtech.api.items.gui.PlayerInventoryHolder in project GregTech by GregTechCEu.
the class MetaTileEntityClipboard method createUI.
@Override
public ModularUI createUI(EntityPlayer entityPlayer) {
if (getClipboard().isItemEqual(CLIPBOARD.getStackForm())) {
List<IItemBehaviour> behaviours = ((MetaItem<?>) getClipboard().getItem()).getBehaviours(getClipboard());
Optional<IItemBehaviour> clipboardBehaviour = behaviours.stream().filter((x) -> x instanceof ClipboardBehavior).findFirst();
if (!clipboardBehaviour.isPresent())
return null;
if (clipboardBehaviour.get() instanceof ClipboardBehavior) {
// We can't have this actually set the player's hand
PlayerInventoryHolder holder = new PlayerInventoryHolder(new GregFakePlayer(entityPlayer.world), EnumHand.MAIN_HAND);
holder.setCustomValidityCheck(this::isValid).setCurrentItem(this.getClipboard());
if (entityPlayer instanceof GregFakePlayer) {
// This is how to tell if this is being called in-world or not
return ((ClipboardBehavior) clipboardBehaviour.get()).createMTEUI(holder, entityPlayer);
} else {
return ((ClipboardBehavior) clipboardBehaviour.get()).createUI(holder, entityPlayer);
}
}
}
return null;
}
use of gregtech.api.items.gui.PlayerInventoryHolder in project GregTech by GregTechCEu.
the class IntCircuitBehaviour method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack heldItem = player.getHeldItem(hand);
if (!world.isRemote) {
PlayerInventoryHolder holder = new PlayerInventoryHolder(player, hand);
holder.openUI();
}
return ActionResult.newResult(EnumActionResult.SUCCESS, heldItem);
}
use of gregtech.api.items.gui.PlayerInventoryHolder in project GregTech by GregTechCE.
the class IntCircuitBehaviour method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack heldItem = player.getHeldItem(hand);
if (!world.isRemote) {
PlayerInventoryHolder holder = new PlayerInventoryHolder(player, hand);
holder.openUI();
}
return ActionResult.newResult(EnumActionResult.SUCCESS, heldItem);
}
Aggregations