Search in sources :

Example 1 with MessageWirelessNewFreq

use of com.bluepowermod.network.message.MessageWirelessNewFreq in project BluePower by Qmunity.

the class GuiGateWireless method actionPerformed.

@Override
public void actionPerformed(IGuiWidget widget) {
    super.actionPerformed(widget);
    if (widget == filterAccessLevel) {
        if (filterAccessLevel.value == 3 && !Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) {
            filterAccessLevel.value++;
        }
        if (selected != null && !selected.equals(gate.getFrequency())) {
            frequencyName.setText("");
            filter = "";
        }
        selected = null;
    }
    if (widget == modeSelector)
        sendToServer(0, modeSelector.value);
    if (widget == addFrequency)
        BPNetworkHandler.INSTANCE.sendToServer(new MessageWirelessNewFreq(gate, acc, frequencyName.getText().trim(), gate.isBundled()));
    if (widget == saveFrequency) {
        BPNetworkHandler.INSTANCE.sendToServer(new MessageWirelessSaveFreq(selected, acc, frequencyName.getText().trim()));
        filter = "";
    }
    if (widget == removeFrequency) {
        if (gate.getFrequency() != null && (selected == null || selected.equals(gate.getFrequency()))) {
            sendToServer(1, 0);
        } else if (selected != null) {
            BPNetworkHandler.INSTANCE.sendToServer(new MessageWirelessRemoveFreq(selected));
            selected = null;
        }
    }
    if (widget == accessLevel) {
        acc = Accessibility.values()[accessLevel.value];
    }
}
Also used : MessageWirelessRemoveFreq(com.bluepowermod.network.message.MessageWirelessRemoveFreq) MessageWirelessNewFreq(com.bluepowermod.network.message.MessageWirelessNewFreq) MessageWirelessSaveFreq(com.bluepowermod.network.message.MessageWirelessSaveFreq)

Example 2 with MessageWirelessNewFreq

use of com.bluepowermod.network.message.MessageWirelessNewFreq in project BluePower by Qmunity.

the class GuiGateWireless method mouseClicked.

@Override
protected void mouseClicked(int x, int y, int button) {
    super.mouseClicked(x, y, button);
    frequencyName.mouseClicked(x, y, button);
    if (x > frequencyName.xPosition && x < frequencyName.xPosition + frequencyName.width && y > frequencyName.yPosition && y < frequencyName.yPosition + frequencyName.height && button == 1) {
        frequencyName.setText("");
        if (selected == null)
            filter = "";
    }
    List<Frequency> frequencies = getFrequencies();
    if (x > guiLeft + 88 && x <= guiLeft + 88 + 133 - (frequencies.size() > 12 ? 11 : 0)) {
        for (int i = 0; i < Math.min(frequencies.size(), 12); i++) {
            Frequency f = frequencies.get(i + scrolled);
            if (f.isBundled() == gate.isBundled()) {
                int yPos = guiTop + 22 + 10 + 2 + (i * 12);
                if (y > yPos && y < yPos + 11) {
                    if (button == 0) {
                        if (f.equals(selected)) {
                            BPNetworkHandler.INSTANCE.sendToServer(new MessageWirelessNewFreq(gate, f.getAccessibility(), f.getFrequencyName(), f.isBundled()));
                        } else {
                            selected = f;
                            frequencyName.setText(f.getFrequencyName());
                            accessLevel.value = (acc = f.getAccessibility()).ordinal();
                        }
                    } else if (button == 1) {
                        selected = null;
                        frequencyName.setText(filter);
                    }
                    return;
                }
            }
        }
    }
}
Also used : Frequency(com.bluepowermod.part.gate.wireless.Frequency) IFrequency(com.bluepowermod.api.wireless.IFrequency) MessageWirelessNewFreq(com.bluepowermod.network.message.MessageWirelessNewFreq)

Aggregations

MessageWirelessNewFreq (com.bluepowermod.network.message.MessageWirelessNewFreq)2 IFrequency (com.bluepowermod.api.wireless.IFrequency)1 MessageWirelessRemoveFreq (com.bluepowermod.network.message.MessageWirelessRemoveFreq)1 MessageWirelessSaveFreq (com.bluepowermod.network.message.MessageWirelessSaveFreq)1 Frequency (com.bluepowermod.part.gate.wireless.Frequency)1