panel = Panel.create(player); //creates the Dialog (DIALOG: Panel)
if(panel.getDialogType() == DialogType.PAGE) { //currently the Panel's default type is DialogType.PAGE
panel.setDialogLayout(DialogLayout.FORM); //sets the layout
panel.getLeftButton().setText("BACK"); //sets the text of the left button
panel.getRightButton().setText("NEXT"); //sets the text of the left button
Input input = Input.create(panel.getContent(), panel.getLayout().getSlot(panel.getContent(), 2, 2), "email"); //creates the email input
input.attachLabel("Enter an E-Mail"); //adds an label to this input
input.setInputTypes(InputType.EMAIL); //sets that an matcher checks for an email address
input.toggleRequired(true); //toggles this input as required
Input input2 = Input.create(panel.getContent(), panel.getLayout().getSlot(panel.getContent(), 1, 2), "name");
input2.attachLabel("Enter a Name");
input2.setInputTypes(InputType.TEXT); //all text / chars are allowed (default setting)
input2.toggleRequired(true);
Input input3 = Input.create(panel.getContent(), panel.getLayout().getSlot(panel.getContent(), 3, 2), "password");
input3.attachLabel("Enter a Password");
input3.setInputTypes(InputType.PASSWORD); //sets as an password (TODO: Hide it!)
input3.toggleRequired(true);
Page page1 = Page.create(); //creates the first page
page1.getComponents().add(input); //add the component to this page
page1.getComponents().add(input2);
page1.getComponents().add(input3);
Input input4 = Input.create(panel.getContent(), panel.getLayout().getSlot(panel.getContent(), 1, 2), "description");
input4.attachLabel("Enter a Description");
input4.setInputTypes(InputType.TEXT);
input4.toggleRequired(false); //input is not required (default)
Bar playerTextdrawBar = Bar.create( //creates a bar (not shown in this video)
panel.getContent(),
panel.getLayout().getSlot(panel.getContent(), 2, 3),
10, 10,
0, 100,
new Color(150, 0, 0, 255),
new Color(0, 150, 0, 255),
new BarInterface() { //enables a barInterface
@Override
public void onProcess(Content content, Bar bar) { //on every bar update (200ms)
double process = (double) Shoebill.get().getSampObjectManager().getPlayerTextdraws(content.getDialog().getPlayer()).size() / 360.0;
if (bar.getProcess() != process || bar.getLabel() == null) {
bar.setProcess(process); //set bar process / progress
Label label = bar.attachLabel("PlayerTextdraws~n~(" + Shoebill.get().getSampObjectManager().getPlayerTextdraws(content.getDialog().getPlayer()).size() + " / 360)"); //attach the label
label.show(); //show the label (only the bar is auto showed (soon fixed))
}
}
},
"playerTextdrawBar"
);
Bar fpsBar = Bar.create(
panel.getContent(),
panel.getLayout().getSlot(panel.getContent(), 2, 1),
10, 10,
0, 100,
new Color(150, 0, 0, 255),
new Color(0, 150, 0, 255),
new BarInterface() {
@Override
public void onProcess(Content content, Bar bar) {
double process = (double) content.getDialog().getPlayer().getPing() / 50.0;
if (bar.getProcess() != process || bar.getLabel() == null) {
bar.setProcess(process);
String text = "Ping~n~(" + content.getDialog().getPlayer().getPing() + " / 50)";
Label label = bar.attachLabel(text);
label.show();
}
}
},
"pingBar"
);
Bar packetLossBar = Bar.create(
panel.getContent(),
panel.getLayout().getSlot(panel.getContent(), 3, 2),
10, 10,
0, 100,
new Color(150, 0, 0, 255),
new Color(0, 150, 0, 255),
new BarInterface() {
@Override
public void onProcess(Content content, Bar bar) {
double process = (double) content.getDialog().getPlayer().getPacketLossPercent();
if (bar.getProcess() != process || bar.getLabel() == null) {
bar.setProcess(process);
String text = "PacketLoss: " + content.getDialog().getPlayer().getPacketLossPercent();
Label label = bar.attachLabel(text);
label.show();
}
}
},
"packetLossBar"
);
Page page2 = Page.create();
page2.getComponents().add(input4);
page2.getComponents().add(playerTextdrawBar);
page2.getComponents().add(fpsBar);
page2.getComponents().add(packetLossBar);
Page page3 = Page.create(new PageInterface() {
@Override
public void onReach(Content content, Page page) {
Text text = Text.create(content, content.getContentBackground().getPosition(), "text");
String string = "Email: " + content.getComponentData("email").getString(); //get the data of the component with the name "email"
string += "~n~Name: " + content.getComponentData("name").getString();
string += "~n~Password: " + content.getComponentData("password").getString();
string += "~n~Description: " + content.getComponentData("description").getString();
text.setText(string);
text.attachLabel("Some infos");
page.getComponents().add(text);
Bar quadBar = Bar.create(
content,
content.getDialog().getLayout().getSlot(content, 2, 2),
10, 30,
10, 30,
new Color(150, 0, 0, 255),
new Color(0, 150, 0, 255),
new BarInterface() {
@Override
public void onProcess(Content content, Bar bar) {
double process = (double) (new Random().nextInt(101)-1) / 100.0;
if (bar.getProcess() != process) {
bar.setProcess(process);
}
}
},
"quadBar"
);
page.getComponents().add(quadBar);
content.getDialog().getPlayer().sendMessage("Width: " + Calculation.getBoxWidth(text.getPlayerTextdraws().get(0)));
//TODO only delete items which was created HERE with page.clear()
}
@Override
public void onLeave(Content content, Page page) {
page.clear(); //clears the completely page from components
}
});
panel.getContent().addPage(page1);
panel.getContent().addPage(page2);
panel.getContent().addPage(page3);
panel.getContent().setCurrentPage(page1);
Alles anzeigen