use of com.bluepowermod.part.gate.wireless.Frequency in project BluePower by Qmunity.
the class GuiGateWireless method renderGUI.
@Override
protected void renderGUI(int x, int y, float partialTick) {
super.renderGUI(x, y, partialTick);
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
// Enable/disable components depending on our needs
{
String txt = frequencyName.getText();
removeFrequency.enabled = (gate.getFrequency() != null && (gate.getFrequency().getOwner().equals(player.getGameProfile().getId()) || player.capabilities.isCreativeMode)) || (selected != null && (selected.getOwner().equals(player.getGameProfile().getId()) || player.capabilities.isCreativeMode));
accessLevel.enabled = selected != null || (txt.trim().length() > 0 && checkNoMatches());
saveFrequency.enabled = selected != null && (acc != selected.getAccessibility() || (txt.trim().length() > 0 && !txt.trim().equals(selected.getFrequencyName())));
addFrequency.enabled = selected == null && txt.trim().length() > 0 && checkNoMatches();
}
// Render title
drawCenteredString(fontRendererObj, I18n.format("bluepower.gui.wireless"), guiLeft + (xSize / 2), guiTop + 8, 0xEFEFEF);
// Filter
{
drawCenteredString(fontRendererObj, "Filter", guiLeft + 45, guiTop + 22 + 3, 0xEFEFEF);
String accessLevelLabel = filterAccessLevel.value == 0 ? "bluepower.accessability.public" : (filterAccessLevel.value == 1 ? "bluepower.accessability.shared" : (filterAccessLevel.value == 2 ? "bluepower.accessability.private" : (filterAccessLevel.value == 3 ? "bluepower.gui.admin" : "bluepower.gui.none")));
drawString(fontRendererObj, I18n.format(accessLevelLabel), guiLeft + 12 + 14 + 3, guiTop + 35 + 3, filterAccessLevel.enabled ? 0xEFEFEF : 0x565656);
}
// Label for the access level
String accessLevelLabel = accessLevel.value == 0 ? "bluepower.accessability.public" : (accessLevel.value == 1 ? "bluepower.accessability.shared" : "bluepower.accessability.private");
drawString(fontRendererObj, I18n.format(accessLevelLabel), guiLeft + 10 + 14 + 3, guiTop + ySize - 24 + 3, accessLevel.enabled ? 0xEFEFEF : 0x565656);
// Label for the mode
String modeLabel = modeSelector.value == 0 ? "bluepower.mode.sendreceive" : (modeSelector.value == 1 ? "bluepower.mode.send" : "bluepower.mode.receive");
drawString(fontRendererObj, I18n.format(modeLabel), guiLeft + 10 + 14 + 3, guiTop + 57 + 3, 0xEFEFEF);
// Render the textbox
frequencyName.drawTextBox();
// Get all frequencies and sort them
List<Frequency> frequencies = getFrequencies();
// Render the list
for (int i = 0; i < Math.min(frequencies.size(), 12); i++) {
Frequency f = frequencies.get(i + scrolled);
int yPos = guiTop + 22 + 10 + 2 + (i * 12);
int color = f.equals(gate.getFrequency()) ? 0x00CCCC : (f.equals(selected) ? 0x888888 : ((x > guiLeft + 88 && x <= guiLeft + 88 + 133 - (frequencies.size() > 12 ? 11 : 0) && y > yPos && y <= yPos + 11 && f.isBundled() == gate.isBundled()) ? 0xAAAAAA : 0x333333));
int textColor = f.equals(gate.getFrequency()) ? 0x333333 : (f.isBundled() != gate.isBundled() ? 0x999999 : 0xFFFFFF);
drawRect(guiLeft + 88, yPos, guiLeft + 88 + 133 - (frequencies.size() > 12 ? 11 : 0), yPos + 11, (0xFF << 24) + color);
String format = f.isBundled() != gate.isBundled() ? EnumChatFormatting.STRIKETHROUGH.toString() : "";
String txt = format + f.getFrequencyName() + ((filterAccessLevel.value == 3 || filterAccessLevel.value == 4) ? " [" + StringUtils.capitalize(f.getAccessibility().name().toLowerCase()) + "]" : "");
fontRendererObj.drawString(txt, guiLeft + 88 + 2 + 12 + 2, yPos + 2, textColor, !f.equals(gate.getFrequency()));
ItemStack item = PartManager.getPartInfo("wire.bluestone" + (f.isBundled() ? ".bundled" : "")).getStack();
GL11.glPushMatrix();
{
if (f.isBundled() != gate.isBundled())
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glTranslated(guiLeft + 88 + 1, yPos - 2, 0);
GL11.glScaled(0.75, 0.75, 0.75);
ForgeHooksClient.renderInventoryItem(RenderBlocks.getInstance(), Minecraft.getMinecraft().renderEngine, item, true, 1, 1, 1);
if (f.isBundled() != gate.isBundled())
GL11.glDisable(GL11.GL_LIGHTING);
}
GL11.glPopMatrix();
}
if (frequencies.size() > 12) {
drawRect(guiLeft + 88 + 133 - 10, guiTop + 22 + 10 + 2, guiLeft + 88 + 133, guiTop + 22 + 10 + 1 + (12 * 12), 0xFF565656);
}
for (int i = 0; i < Math.min(frequencies.size(), 12); i++) {
Frequency f = frequencies.get(i + scrolled);
int yPos = guiTop + 22 + 10 + 2 + (i * 12);
if (x > guiLeft + 88 && x <= guiLeft + 88 + 133 - (frequencies.size() > 12 ? 11 : 0) && y > yPos && y <= yPos + 11 && f.isBundled() == gate.isBundled()) {
func_146283_a(Arrays.asList("Frequency: " + f.getFrequencyName(), EnumChatFormatting.GRAY + "Accessibility: " + StringUtils.capitalize(f.getAccessibility().name().toLowerCase()), EnumChatFormatting.GRAY + "Owner: " + f.getOwnerName(), "Devices: " + f.getDevices()), x, y);
}
}
}
use of com.bluepowermod.part.gate.wireless.Frequency in project BluePower by Qmunity.
the class GuiGateWireless method getFrequencies.
private List<Frequency> getFrequencies() {
List<Frequency> frequencies = new ArrayList<Frequency>();
for (IFrequency f : WirelessManager.CLIENT_INSTANCE.getFrequencies()) {
if (f.getAccessibility().ordinal() == filterAccessLevel.value || filterAccessLevel.value == 3 || filterAccessLevel.value == 4)
if (f.getFrequencyName().toLowerCase().contains(filter.toLowerCase()))
frequencies.add((Frequency) f);
}
Collections.sort(frequencies, new FrequencySorter(this));
return frequencies;
}
use of com.bluepowermod.part.gate.wireless.Frequency in project BluePower by Qmunity.
the class MessageWirelessFrequencySync method handleClientSide.
@Override
public void handleClientSide(EntityPlayer player) {
WirelessManager m = WirelessManager.CLIENT_INSTANCE;
m.unloadFrequencies();
for (Frequency f : frequencies) m.registerFrequency(f);
}
use of com.bluepowermod.part.gate.wireless.Frequency in project BluePower by Qmunity.
the class MessageWirelessRemoveFreq method read.
@Override
public void read(DataInput buffer) throws IOException {
freq = new Frequency();
freq.readFromBuffer(buffer);
}
use of com.bluepowermod.part.gate.wireless.Frequency 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;
}
}
}
}
}
Aggregations