All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mmb.content.wireworld.SelectBlock Maven / Gradle / Ivy

Go to download

Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world. THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<

There is a newer version: 0.6
Show newest version
/**
 * 
 */
package mmb.content.wireworld;

import javax.swing.JPanel;

import mmb.beans.BlockSetting;
import mmb.engine.block.BlockType;
import mmb.engine.item.ItemEntry;
import mmb.menu.world.window.WorldWindow;

import javax.swing.JLabel;
import javax.swing.BoxLayout;
import javax.swing.JButton;

import static mmb.engine.settings.GlobalSettings.$res;

import java.awt.Color;

/**
 * @author oskar
 *
 */
public class SelectBlock extends JPanel {
	private static final long serialVersionUID = -5267127312725839315L;
	
	private JLabel lblNewLabel;
	private JButton btnCancel;
	private JButton btnOK;
	private JButton btnRemove;
	
	private WorldWindow window;
	private JLabel lblType;
	public SelectBlock(BlockSetting setting, WorldWindow window) {
		this.window = window;
		BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS);
		setLayout(layout);
		
		lblNewLabel = new JLabel($res("wguim-selblock"));
		add(lblNewLabel);
		
		btnCancel = new JButton($res("cancel"));
		btnCancel.setBackground(Color.RED);
		btnCancel.addActionListener(e -> close());
		add(btnCancel);
		
		btnOK = new JButton($res("ok"));
		btnOK.setBackground(Color.GREEN);
		btnOK.addActionListener(e -> {
			ItemEntry item = window.getPlacer().getSelectedItem();
			if(item instanceof BlockType)
				setting.setBlockSetting((BlockType) item);
			close();
		});
		add(btnOK);
		
		btnRemove = new JButton($res("remove"));
		btnRemove.setBackground(Color.YELLOW);
		btnRemove.addActionListener(e ->{
			setting.setBlockSetting(null);
			close();
		});
		add(btnRemove);
		
		BlockType type = setting.blockSetting();
		lblType = new JLabel($res("wgui-nosel"));
		if(type != null) lblType.setText($res("wgui-curr")+" "+type.title());
		add(lblType);
	}

	private void close() {
		window.closeDialogWindow(this);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy