size limit on list
This commit is contained in:
parent
8d711734da
commit
3674d63d0c
@ -77,10 +77,9 @@ public class ConfigFile {
|
|||||||
|
|
||||||
public static void addObjectToCommList(JSONObject jsonObject) {
|
public static void addObjectToCommList(JSONObject jsonObject) {
|
||||||
ArrayList<JSONObject> commListCopy = MacroButtons.getMasterCommList();
|
ArrayList<JSONObject> commListCopy = MacroButtons.getMasterCommList();
|
||||||
if (commListCopy.size() <= 20) {
|
|
||||||
commListCopy.add(jsonObject);
|
commListCopy.add(jsonObject);
|
||||||
MacroButtons.setMasterCommList(commListCopy);
|
MacroButtons.setMasterCommList(commListCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ public class ButtonGUI extends LightweightGuiDescription {
|
|||||||
private void addCommandSection(WGridPanel root) {
|
private void addCommandSection(WGridPanel root) {
|
||||||
// Add text field for command NAME entry
|
// Add text field for command NAME entry
|
||||||
WTextField nameTextField = new WTextField();
|
WTextField nameTextField = new WTextField();
|
||||||
|
nameTextField.setMaxLength(10);
|
||||||
nameTextField.setSuggestion("Name");
|
nameTextField.setSuggestion("Name");
|
||||||
root.add(nameTextField, 0, 12, 6, 1);
|
root.add(nameTextField, 0, 12, 6, 1);
|
||||||
|
|
||||||
@ -57,6 +58,7 @@ public class ButtonGUI extends LightweightGuiDescription {
|
|||||||
// Only add the button if there are contents in both
|
// Only add the button if there are contents in both
|
||||||
if (!name.getText().equals("") && !command.getText().equals("")) {
|
if (!name.getText().equals("") && !command.getText().equals("")) {
|
||||||
|
|
||||||
|
if (!isListTooLong()) {
|
||||||
String commandString = command.getText();
|
String commandString = command.getText();
|
||||||
WButton button = new WButton(new TranslatableText(name.getText()));
|
WButton button = new WButton(new TranslatableText(name.getText()));
|
||||||
button.setOnClick(() -> {
|
button.setOnClick(() -> {
|
||||||
@ -74,6 +76,7 @@ public class ButtonGUI extends LightweightGuiDescription {
|
|||||||
ConfigFile.appendToFile(newJsonObject);
|
ConfigFile.appendToFile(newJsonObject);
|
||||||
|
|
||||||
adjustBounds();
|
adjustBounds();
|
||||||
|
}
|
||||||
|
|
||||||
name.setText("");
|
name.setText("");
|
||||||
command.setText("");
|
command.setText("");
|
||||||
@ -127,6 +130,10 @@ public class ButtonGUI extends LightweightGuiDescription {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isListTooLong() {
|
||||||
|
return MacroButtons.getMasterCommList().size() > 19;
|
||||||
|
}
|
||||||
|
|
||||||
// Change background panel color to transparent black
|
// Change background panel color to transparent black
|
||||||
@Override
|
@Override
|
||||||
public void addPainters() {
|
public void addPainters() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user