private void updateScanButton() { if (tileEntity.isScanning()) { scanButton.setText("Stop"); progressBar.setValue(tileEntity.getProgress()); } else { scanButton.setText("Scan"); progressBar.setValue(0); } }
@Override protected void drawGuiContainerBackgroundLayer(float v, int i, int i2) { updateStorageList(); updateContentsList(); updateScanButton(); drawWindow(); int currentRF = tileEntity.getCurrentRF(); energyBar.setValue(currentRF); tileEntity.requestRfFromServer(RFToolsMessages.INSTANCE); }
@Override public void initGui() { super.initGui(); int maxEnergyStored = tileEntity.getMaxEnergyStored(ForgeDirection.DOWN); energyBar = new EnergyBar(mc, this) .setFilledRectThickness(1) .setVertical() .setDesiredWidth(8) .setDesiredHeight(84) .setMaxValue(maxEnergyStored) .setShowText(false); energyBar.setValue(tileEntity.getCurrentRF()); storageList = createStyledList() .addSelectionEvent( new DefaultSelectionEvent() { @Override public void select(Widget parent, int index) { itemList.removeChildren(); tileEntity.clearShowingItems(); getInventoryOnServer(); } @Override public void doubleClick(Widget parent, int index) { hilightSelectedContainer(index); } }); Slider storageListSlider = new Slider(mc, this).setDesiredWidth(10).setVertical().setScrollable(storageList); Panel topPanel = new Panel(mc, this) .setLayout(new HorizontalLayout().setSpacing(1).setHorizontalMargin(1)) .setDesiredHeight(90) .addChild(energyBar) .addChild(storageList) .addChild(storageListSlider); itemList = createStyledList(); Slider itemListSlider = new Slider(mc, this).setDesiredWidth(10).setVertical().setScrollable(itemList); Panel midPanel = new Panel(mc, this) .setLayout(new HorizontalLayout().setSpacing(1).setHorizontalMargin(1)) .addChild(itemList) .addChild(itemListSlider); scanButton = new Button(mc, this) .setText("Scan") .setDesiredWidth(50) .setDesiredHeight(14) .addButtonEvent( new ButtonEvent() { @Override public void buttonClicked(Widget parent) { startStopScan(); } }) .setTooltips("Start/stop a scan of", "all storage units", "in radius"); progressBar = new EnergyBar(mc, this) .setShowText(false) .setColor1(0xFF777777) .setColor2(0xFF555555) .setHorizontal() .setMaxValue(100) .setDesiredWidth(30) .setValue(0); radiusLabel = new ScrollableLabel(mc, this) .addValueEvent( new ValueEvent() { @Override public void valueChanged(Widget parent, int newValue) { changeRadius(newValue); } }) .setRealMinimum(1) .setRealMaximum(20) .setDesiredWidth(30); radiusLabel.setRealValue(tileEntity.getRadius()); TextField textField = new TextField(mc, this) .addTextEvent( new TextEvent() { @Override public void textChanged(Widget parent, String newText) { storageList.clearHilightedRows(); fromServer_coordinates.clear(); startSearch(newText); } }); Panel searchPanel = new Panel(mc, this) .setLayout(new HorizontalLayout()) .setDesiredHeight(18) .addChild(new Label(mc, this).setText("Search:")) .addChild(textField); Slider radiusSlider = new Slider(mc, this) .setHorizontal() .setTooltips("Radius of scan") .setScrollable(radiusLabel); Panel scanPanel = new Panel(mc, this) .setLayout(new HorizontalLayout()) .setDesiredHeight(18) .addChild(scanButton) .addChild(progressBar) .addChild(radiusSlider) .addChild(radiusLabel); Widget toplevel = new Panel(mc, this) .setFilledRectThickness(2) .setLayout(new VerticalLayout().setSpacing(1).setVerticalMargin(3)) .addChild(topPanel) .addChild(midPanel) .addChild(searchPanel) .addChild(scanPanel); toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize)); window = new Window(this, toplevel); Keyboard.enableRepeatEvents(true); tileEntity.requestRfFromServer(RFToolsMessages.INSTANCE); }