Search in sources :

Example 1 with ActionWidget

use of pneumaticCraft.common.remote.ActionWidget in project PneumaticCraft by MineMaarten.

the class GuiRemote method onGlobalVariableChange.

public void onGlobalVariableChange(String variable) {
    widgets.clear();
    initGui();
    for (ActionWidget actionWidget : remoteLayout.getActionWidgets()) {
        if (actionWidget instanceof ActionWidgetVariable) {
            ((ActionWidgetVariable) actionWidget).onVariableChange();
        }
    }
}
Also used : ActionWidget(pneumaticCraft.common.remote.ActionWidget) ActionWidgetVariable(pneumaticCraft.common.remote.ActionWidgetVariable)

Example 2 with ActionWidget

use of pneumaticCraft.common.remote.ActionWidget in project PneumaticCraft by MineMaarten.

the class GuiRemoteEditor method initGui.

@Override
public void initGui() {
    if (pastebinGui != null && pastebinGui.outputTag != null) {
        NBTTagCompound tag = remote.getTagCompound();
        if (tag == null) {
            tag = new NBTTagCompound();
            remote.setTagCompound(tag);
        }
        tag.setTag("actionWidgets", pastebinGui.outputTag.getTagList("main", 10));
    } else if (remoteLayout != null) {
        NBTTagCompound tag = remote.getTagCompound();
        if (tag == null) {
            tag = new NBTTagCompound();
            remote.setTagCompound(tag);
        }
        tag.setTag("actionWidgets", remoteLayout.toNBT(oldGuiLeft, oldGuiTop).getTagList("actionWidgets", 10));
    }
    if (invSearchGui != null && invSearchGui.getSearchStack() != null && invSearchGui.getSearchStack().getItem() == Itemss.remote) {
        if (ItemRemote.hasSameSecuritySettings(remote, invSearchGui.getSearchStack())) {
            remoteLayout = new RemoteLayout(invSearchGui.getSearchStack(), guiLeft, guiTop);
        } else {
            mc.thePlayer.addChatComponentMessage(new ChatComponentTranslation("gui.remote.differentSecuritySettings"));
        }
    }
    super.initGui();
    oldGuiLeft = guiLeft;
    oldGuiTop = guiTop;
    visibleSpawnWidgets.clear();
    visibleSpawnWidgets.add(new ActionWidgetCheckBox(new GuiCheckBox(-1, guiLeft + 200, guiTop + 10, 0xFF000000, I18n.format("remote.checkbox.name"))));
    visibleSpawnWidgets.add(new ActionWidgetLabel(new WidgetLabelVariable(guiLeft + 200, guiTop + 25, I18n.format("remote.label.name"))));
    visibleSpawnWidgets.add(new ActionWidgetButton(new GuiButtonSpecial(-1, guiLeft + 200, guiTop + 40, 50, 20, I18n.format("remote.button.name"))));
    visibleSpawnWidgets.add(new ActionWidgetDropdown(new WidgetComboBox(fontRendererObj, guiLeft + 200, guiTop + 70, 70, fontRendererObj.FONT_HEIGHT + 1).setFixedOptions()));
    for (ActionWidget actionWidget : visibleSpawnWidgets) {
        addWidget(actionWidget.getWidget());
    }
    GuiButtonSpecial importRemoteButton = new GuiButtonSpecial(0, guiLeft - 24, guiTop + 20, 20, 20, "");
    importRemoteButton.setTooltipText(I18n.format("gui.remote.button.importRemoteButton"));
    importRemoteButton.setRenderStacks(new ItemStack(Itemss.remote));
    buttonList.add(importRemoteButton);
    GuiButtonSpecial pastebinButton = new GuiButtonSpecial(1, guiLeft - 24, guiTop + 44, 20, 20, "");
    pastebinButton.setTooltipText(I18n.format("gui.remote.button.pastebinButton"));
    //pastebinButton.setRenderStacks(new ItemStack(Itemss.advancedPCB));
    pastebinButton.setRenderedIcon(Textures.GUI_PASTEBIN_ICON_LOCATION);
    buttonList.add(pastebinButton);
}
Also used : PacketUpdateRemoteLayout(pneumaticCraft.common.network.PacketUpdateRemoteLayout) RemoteLayout(pneumaticCraft.common.remote.RemoteLayout) ActionWidgetCheckBox(pneumaticCraft.common.remote.ActionWidgetCheckBox) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ActionWidgetDropdown(pneumaticCraft.common.remote.ActionWidgetDropdown) ActionWidgetButton(pneumaticCraft.common.remote.ActionWidgetButton) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ActionWidgetLabel(pneumaticCraft.common.remote.ActionWidgetLabel) GuiCheckBox(pneumaticCraft.client.gui.widget.GuiCheckBox) ActionWidget(pneumaticCraft.common.remote.ActionWidget) ItemStack(net.minecraft.item.ItemStack) WidgetLabelVariable(pneumaticCraft.common.remote.WidgetLabelVariable) WidgetComboBox(pneumaticCraft.client.gui.widget.WidgetComboBox)

Example 3 with ActionWidget

use of pneumaticCraft.common.remote.ActionWidget in project PneumaticCraft by MineMaarten.

the class GuiRemoteEditor method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y) {
    bindGuiTexture();
    Gui.func_146110_a(guiLeft, guiTop, 0, 0, xSize, ySize, 320, 256);
    super.drawGuiContainerBackgroundLayer(partialTicks, x, y);
    x += guiLeft;
    y += guiTop;
    boolean isLeftClicking = Mouse.isButtonDown(0);
    boolean isMiddleClicking = Mouse.isButtonDown(2);
    if (draggingWidget != null) {
        draggingWidget.setWidgetPos(x - dragMouseStartX + dragWidgetStartX - guiLeft, y - dragMouseStartY + dragWidgetStartY - guiTop);
    }
    if (isLeftClicking && !wasClicking) {
        for (ActionWidget widget : visibleSpawnWidgets) {
            Rectangle bounds = widget.getWidget().getBounds();
            if (x >= bounds.x + guiLeft && y >= bounds.y + guiTop && x <= bounds.x + guiLeft + bounds.width && y <= bounds.y + guiTop + bounds.height) {
                draggingWidget = widget.copy();
                remoteLayout.addWidget(draggingWidget);
                addWidget(draggingWidget.getWidget());
                dragMouseStartX = x - guiLeft;
                dragMouseStartY = y - guiTop;
                dragWidgetStartX = bounds.x;
                dragWidgetStartY = bounds.y;
                break;
            }
        }
        if (draggingWidget == null) {
            for (ActionWidget widget : remoteLayout.getActionWidgets()) {
                Rectangle bounds = widget.getWidget().getBounds();
                if (x >= bounds.x + guiLeft && y >= bounds.y + guiTop && x <= bounds.x + guiLeft + bounds.width && y <= bounds.y + guiTop + bounds.height) {
                    draggingWidget = widget;
                    dragMouseStartX = x - guiLeft;
                    dragMouseStartY = y - guiTop;
                    dragWidgetStartX = bounds.x;
                    dragWidgetStartY = bounds.y;
                    break;
                }
            }
        }
    } else if (isMiddleClicking && !wasClicking) {
        for (ActionWidget widget : remoteLayout.getActionWidgets()) {
            Rectangle bounds = widget.getWidget().getBounds();
            if (x >= bounds.x + guiLeft && y >= bounds.y + guiTop && x <= bounds.x + guiLeft + bounds.width && y <= bounds.y + guiTop + bounds.height) {
                draggingWidget = widget.copy();
                remoteLayout.addWidget(draggingWidget);
                addWidget(draggingWidget.getWidget());
                dragMouseStartX = 0;
                dragMouseStartY = 0;
                dragWidgetStartX = bounds.x - (x - guiLeft);
                dragWidgetStartY = bounds.y - (y - guiTop);
                break;
            }
        }
    }
    if (!isLeftClicking && !isMiddleClicking && draggingWidget != null) {
        if (isOutsideProgrammingArea(draggingWidget)) {
            remoteLayout.getActionWidgets().remove(draggingWidget);
            removeWidget(draggingWidget.getWidget());
        }
        draggingWidget = null;
    }
    wasClicking = isLeftClicking || isMiddleClicking;
}
Also used : Rectangle(java.awt.Rectangle) ActionWidget(pneumaticCraft.common.remote.ActionWidget)

Aggregations

ActionWidget (pneumaticCraft.common.remote.ActionWidget)3 Rectangle (java.awt.Rectangle)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1 GuiCheckBox (pneumaticCraft.client.gui.widget.GuiCheckBox)1 WidgetComboBox (pneumaticCraft.client.gui.widget.WidgetComboBox)1 PacketUpdateRemoteLayout (pneumaticCraft.common.network.PacketUpdateRemoteLayout)1 ActionWidgetButton (pneumaticCraft.common.remote.ActionWidgetButton)1 ActionWidgetCheckBox (pneumaticCraft.common.remote.ActionWidgetCheckBox)1 ActionWidgetDropdown (pneumaticCraft.common.remote.ActionWidgetDropdown)1 ActionWidgetLabel (pneumaticCraft.common.remote.ActionWidgetLabel)1 ActionWidgetVariable (pneumaticCraft.common.remote.ActionWidgetVariable)1 RemoteLayout (pneumaticCraft.common.remote.RemoteLayout)1 WidgetLabelVariable (pneumaticCraft.common.remote.WidgetLabelVariable)1