int top = 10;
int left = 10;
int right = left + labelWidth + 10;
int labelHeight = 20;
recordButton = new GenericButton();
recordButton.setGeometry(width - 160, top - 3, 150, labelHeight);
getScreen().attachWidget("Spoutcraft", recordButton);
updateRecordButton();
titleLabel = new GenericLabel("Name:");
titleLabel.setGeometry(left, top + 3, labelWidth, labelHeight);
getScreen().attachWidget("Spoutcraft", titleLabel);
commandName = new GenericTextField();
commandName.setGeometry(right, top - 1, (int) (width - right - recordButton.getWidth() - 20), 16);
commandName.setText(item.getTitle());
commandName.setMaximumCharacters(0);
commandName.setPlaceholder("Enter a name here");
getScreen().attachWidget("Spoutcraft", commandName);
top += 23;
commandLabel = new GenericLabel("Command:");
commandLabel.setGeometry(left, top + 3, labelWidth, labelHeight);
getScreen().attachWidget("Spoutcraft", commandLabel);
commandText = new GenericTextField();
commandText.setGeometry(right, top - 1, width - right - 10, 16);
commandText.setMaximumCharacters(0);
commandText.setPlaceholder("Enter new command here, then click \"Add Command\"");
getScreen().attachWidget("Spoutcraft", commandText);
top += 23;
delayLabel = new GenericLabel("Delay (ms)");
delayLabel.setGeometry(left, top + 3, labelWidth, labelHeight);
getScreen().attachWidget("Spoutcraft", delayLabel);
delayText = new GenericTextField();
delayText.setGeometry(right, top - 1, width - right - 10, 16);
delayText.setText(item.getDelay() + "");
delayText.setTextProcessor(new GenericTextProcessor() {
protected boolean insert(char c) {
if (c >= '0' && c <= '9') {
return super.insert(c);
}
return false;
};
@Override
protected boolean insert(String s) {
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (!(c >= '0' && c <= '9')) {
return false;
}
}
return super.insert(s);
}
});
getScreen().attachWidget("Spoutcraft", delayText);
top += 23;
slot = new GuiCommandsSlot(this);
slot.setGeometry(0, top, width, this.height - top - 30);
getScreen().attachWidget("Spoutcraft", slot);
doneButton = new GenericButton("Done");
doneButton.setHeight(20).setWidth(50);
doneButton.setX(10).setY(height - 25);
getScreen().attachWidget("Spoutcraft", doneButton);
addButton = new GenericButton("Add Command");
addButton.setHeight(20).setWidth(100);
addButton.setX(70).setY(height - 25);
getScreen().attachWidget("Spoutcraft", addButton);
editButton = new GenericButton("Edit Command");
editButton.setHeight(20).setWidth(100);
editButton.setX(180).setY(height - 25);
getScreen().attachWidget("Spoutcraft", editButton);
removeButton = new GenericButton("Remove Command");
removeButton.setHeight(20).setWidth(100);
removeButton.setX(290).setY(height - 25);
getScreen().attachWidget("Spoutcraft", removeButton);
updateButtons();