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) {
|
||||
ArrayList<JSONObject> commListCopy = MacroButtons.getMasterCommList();
|
||||
if (commListCopy.size() <= 20) {
|
||||
commListCopy.add(jsonObject);
|
||||
MacroButtons.setMasterCommList(commListCopy);
|
||||
}
|
||||
|
||||
commListCopy.add(jsonObject);
|
||||
MacroButtons.setMasterCommList(commListCopy);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public class ButtonGUI extends LightweightGuiDescription {
|
||||
private void addCommandSection(WGridPanel root) {
|
||||
// Add text field for command NAME entry
|
||||
WTextField nameTextField = new WTextField();
|
||||
nameTextField.setMaxLength(10);
|
||||
nameTextField.setSuggestion("Name");
|
||||
root.add(nameTextField, 0, 12, 6, 1);
|
||||
|
||||
@ -57,23 +58,25 @@ public class ButtonGUI extends LightweightGuiDescription {
|
||||
// Only add the button if there are contents in both
|
||||
if (!name.getText().equals("") && !command.getText().equals("")) {
|
||||
|
||||
String commandString = command.getText();
|
||||
WButton button = new WButton(new TranslatableText(name.getText()));
|
||||
button.setOnClick(() -> {
|
||||
MacroButtons.runCommand(commandString);
|
||||
});
|
||||
root.add(button, xValue, yValue, 4, 1);
|
||||
if (!isListTooLong()) {
|
||||
String commandString = command.getText();
|
||||
WButton button = new WButton(new TranslatableText(name.getText()));
|
||||
button.setOnClick(() -> {
|
||||
MacroButtons.runCommand(commandString);
|
||||
});
|
||||
root.add(button, xValue, yValue, 4, 1);
|
||||
|
||||
// Create a new Json object & append to masterCommList
|
||||
JSONObject newJsonObject = new JSONObject();
|
||||
newJsonObject.put("name", name.getText());
|
||||
newJsonObject.put("command", command.getText());
|
||||
// Create a new Json object & append to masterCommList
|
||||
JSONObject newJsonObject = new JSONObject();
|
||||
newJsonObject.put("name", name.getText());
|
||||
newJsonObject.put("command", command.getText());
|
||||
|
||||
// append the buttons to masterList for future loading
|
||||
ConfigFile.addObjectToCommList(newJsonObject);
|
||||
ConfigFile.appendToFile(newJsonObject);
|
||||
// append the buttons to masterList for future loading
|
||||
ConfigFile.addObjectToCommList(newJsonObject);
|
||||
ConfigFile.appendToFile(newJsonObject);
|
||||
|
||||
adjustBounds();
|
||||
adjustBounds();
|
||||
}
|
||||
|
||||
name.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
|
||||
@Override
|
||||
public void addPainters() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user