76 lines
1.8 KiB
Java
76 lines
1.8 KiB
Java
package xyz.thastertyn.UserInterface.Dialogs;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import com.googlecode.lanterna.gui2.Button;
|
|
import com.googlecode.lanterna.gui2.ComboBox;
|
|
import com.googlecode.lanterna.gui2.EmptySpace;
|
|
import com.googlecode.lanterna.gui2.GridLayout;
|
|
import com.googlecode.lanterna.gui2.LocalizedString;
|
|
import com.googlecode.lanterna.gui2.Panel;
|
|
import com.googlecode.lanterna.gui2.Window;
|
|
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
|
|
import com.googlecode.lanterna.gui2.dialogs.DialogWindow;
|
|
|
|
import xyz.thastertyn.Types.Options;
|
|
|
|
public class OptionsDialog extends DialogWindow {
|
|
|
|
public OptionsDialog(Options... options)
|
|
{
|
|
super("Choose from below");
|
|
|
|
Panel mainPanel = new Panel()
|
|
.setLayoutManager(new GridLayout(1)
|
|
.setLeftMarginSize(1)
|
|
.setRightMarginSize(1));
|
|
|
|
Panel optionPanel = new Panel().setLayoutManager(new GridLayout(3))
|
|
.addTo(mainPanel);
|
|
|
|
for(int i = 0; i < options.length; i++)
|
|
{
|
|
optionPanel.addComponent(new ComboBox<>(options[i].getOptions()));
|
|
|
|
if(i != options.length - 1)
|
|
{
|
|
optionPanel.addComponent(new EmptySpace());
|
|
}
|
|
}
|
|
|
|
new Panel()
|
|
.setLayoutManager(
|
|
new GridLayout(2).setHorizontalSpacing(1))
|
|
.addComponent(
|
|
new Button(LocalizedString.OK.toString(), this::onOK)
|
|
.setLayoutData(GridLayout.createLayoutData(
|
|
GridLayout.Alignment.CENTER,
|
|
GridLayout.Alignment.CENTER,
|
|
true,
|
|
false)))
|
|
.addComponent(
|
|
new Button(LocalizedString.Cancel.toString(), this::onCancel))
|
|
.addTo(mainPanel);
|
|
|
|
|
|
setHints(Arrays.asList(Window.Hint.CENTERED));
|
|
setComponent(mainPanel);
|
|
}
|
|
|
|
public void onOK()
|
|
{
|
|
close();
|
|
}
|
|
|
|
public void onCancel()
|
|
{
|
|
close();
|
|
}
|
|
|
|
@Override
|
|
public String showDialog(WindowBasedTextGUI textGUI) {
|
|
super.showDialog(textGUI);
|
|
return "";
|
|
}
|
|
}
|