finished cell info menu
This commit is contained in:
parent
481ebf5e5b
commit
39306b66f9
@ -6,12 +6,14 @@ import java.util.LinkedList;
|
||||
public class DetailedCellInfo extends JPanel {
|
||||
|
||||
private LinkedList<JRadioButton> radioButtons;
|
||||
private LinkedList<JTextField> textFields;
|
||||
private LevelEditor editor;
|
||||
private int i;
|
||||
private int j;
|
||||
|
||||
public DetailedCellInfo(LevelEditor editor, int i, int j) {
|
||||
this.radioButtons = new LinkedList<>();
|
||||
this.textFields = new LinkedList<>();
|
||||
this.editor = editor;
|
||||
this.i = i;
|
||||
this.j = j;
|
||||
@ -20,26 +22,57 @@ public class DetailedCellInfo extends JPanel {
|
||||
public void displayDetailedCellInfo(String type) {
|
||||
removeAll();
|
||||
setVisible(false);
|
||||
radioButtons.clear();
|
||||
textFields.clear();
|
||||
if (type.equals("BLOCK")) {
|
||||
visibleInfo();
|
||||
trueFalseInfo("Visible", "visible", "hidden", 0);
|
||||
upperLowerInfo();
|
||||
}
|
||||
setRadioButtons();
|
||||
else if (type.equals("INTER")) {
|
||||
trueFalseInfo("Visible", "visible", "hidden", 0);
|
||||
fieldInfo("Dialog Name", "dialog", 100);
|
||||
}
|
||||
else if (type.equals("TRIGGER")) {
|
||||
trueFalseInfo("Active", "active", "inactive", 0);
|
||||
fieldInfo("Dialog Name", "dialog", 100);
|
||||
}
|
||||
else if (type.equals("MOVETO")) {
|
||||
trueFalseInfo("Visible", "visible", "hidden", 0);
|
||||
fieldInfo("Target Map Name", "map name", 100);
|
||||
fieldInfo("Target Door Id", "door id", 200);
|
||||
directionInfo(300);
|
||||
}
|
||||
else if (type.equals("DOOR")) {
|
||||
trueFalseInfo("Vertical", "vertical", "horizontal", 0);
|
||||
fieldInfo("Dialog Name", "dialog", 100);
|
||||
}
|
||||
else if (type.equals("DOORTO")) {
|
||||
trueFalseInfo("Vertical", "vertical", "horizontal", 0);
|
||||
fieldInfo("Dialog Name", "dialog", 100);
|
||||
fieldInfo("Target Map Name", "map name", 200);
|
||||
fieldInfo("Target Door Id", "door id", 300);
|
||||
directionInfo(400);
|
||||
}
|
||||
else if (type.equals("CHEST")) {
|
||||
trueFalseInfo("Shown as Chest", "chest", "item", 0);
|
||||
fieldInfo("Inventory Name", "inventory", 100);
|
||||
}
|
||||
setInfo();
|
||||
}
|
||||
|
||||
private void visibleInfo() {
|
||||
JLabel label = new JLabel("<html><div style='text-align: center; width: 260'>Is Visible</div></html>");
|
||||
label.setBounds(0, 0, 260, 20);
|
||||
private void trueFalseInfo(String title, String trueLabel, String falseLabel, int offset) {
|
||||
JLabel label = new JLabel("<html><div style='text-align: center; width: 260'>Is " + title + "</div></html>");
|
||||
label.setBounds(0, offset, 260, 20);
|
||||
|
||||
JRadioButton yes = new JRadioButton("Yes");
|
||||
yes.setBounds(75, 30, 70, 20);
|
||||
yes.setBounds(75, offset + 30, 70, 20);
|
||||
yes.setSelected(true);
|
||||
yes.setName("visible");
|
||||
yes.setName(trueLabel);
|
||||
radioButtons.add(yes);
|
||||
|
||||
JRadioButton no = new JRadioButton("No");
|
||||
no.setBounds(150, 30, 70, 20);
|
||||
no.setName("hidden");
|
||||
no.setBounds(150, offset + 30, 70, 20);
|
||||
no.setName(falseLabel);
|
||||
radioButtons.add(no);
|
||||
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
@ -54,25 +87,39 @@ public class DetailedCellInfo extends JPanel {
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void fieldInfo(String title, String fieldName, int offset) {
|
||||
JLabel label = new JLabel("<html><div style='text-align: center; width: 260'>" + title + "</div></html>");
|
||||
label.setBounds(0, offset, 260, 20);
|
||||
|
||||
JTextField field = new JTextField();
|
||||
field.setBounds(80, offset + 30, 100, 20);
|
||||
field.setName(fieldName);
|
||||
|
||||
textFields.add(field);
|
||||
|
||||
add(label);
|
||||
add(field);
|
||||
|
||||
repaint();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void upperLowerInfo() {
|
||||
JLabel label = new JLabel("<html><div style='text-align: center; width: 260'>Half Block</div></html>");
|
||||
label.setBounds(0, 100, 260, 20);
|
||||
|
||||
JRadioButton up = new JRadioButton("Upper");
|
||||
up.setBounds(0, 130, 70, 20);
|
||||
up.setName("up");
|
||||
add(up);
|
||||
up.setName("upper");
|
||||
|
||||
JRadioButton low = new JRadioButton("Lower");
|
||||
low.setBounds(100, 130, 70, 20);
|
||||
low.setName("low");
|
||||
add(low);
|
||||
low.setName("lower");
|
||||
|
||||
JRadioButton none = new JRadioButton("None");
|
||||
none.setBounds(200, 130, 70, 20);
|
||||
none.setSelected(true);
|
||||
none.setName("full");
|
||||
add(none);
|
||||
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(up);
|
||||
@ -91,42 +138,326 @@ public class DetailedCellInfo extends JPanel {
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void directionInfo(int offset) {
|
||||
JLabel label = new JLabel("<html><div style='text-align: center; width: 260'>Direction Out</div></html>");
|
||||
label.setBounds(0, offset, 260, 20);
|
||||
|
||||
JRadioButton up = new JRadioButton("Up");
|
||||
up.setBounds(110, offset + 30, 70, 20);
|
||||
up.setSelected(true);
|
||||
up.setName("up");
|
||||
|
||||
JRadioButton down = new JRadioButton("Down");
|
||||
down.setBounds(110, offset + 90, 70, 20);
|
||||
down.setName("down");
|
||||
|
||||
JRadioButton left = new JRadioButton("Left");
|
||||
left.setBounds(75, offset + 60, 70, 20);
|
||||
left.setName("left");
|
||||
|
||||
JRadioButton right = new JRadioButton("Right");
|
||||
right.setBounds(150, offset + 60, 70, 20);
|
||||
right.setName("right");
|
||||
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(up);
|
||||
group.add(down);
|
||||
group.add(left);
|
||||
group.add(right);
|
||||
|
||||
radioButtons.add(up);
|
||||
radioButtons.add(down);
|
||||
radioButtons.add(left);
|
||||
radioButtons.add(right);
|
||||
|
||||
add(label);
|
||||
add(up);
|
||||
add(down);
|
||||
add(left);
|
||||
add(right);
|
||||
|
||||
repaint();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public String getCellInfo(String type) {
|
||||
String info = type;
|
||||
if (type.equals("BLOCK")) {
|
||||
info = getVisibleInfo(type);
|
||||
if (info.equals(type)) info += getUpperLowerInfo();
|
||||
}
|
||||
else if (type.equals("INTER")) {
|
||||
info = getVisibleInfo(type);
|
||||
if (getFieldInfo("dialog", true) == null) return null;
|
||||
info += getFieldInfo("dialog", true);
|
||||
}
|
||||
else if (type.equals("TRIGGER")) {
|
||||
if (getFieldInfo("dialog", true) == null) return null;
|
||||
info += getFieldInfo("dialog", true);
|
||||
info += getTrueFalseInfo("active", "inactive");
|
||||
}
|
||||
else if (type.equals("MOVETO")) {
|
||||
info = getVisibleInfo(type);
|
||||
if (getFieldIntegerInfo("door id") == null) return null;
|
||||
info += getFieldIntegerInfo("door id");
|
||||
info += getDirectionInfo();
|
||||
if (getFieldInfo("map name", true) == null) return null;
|
||||
info += getFieldInfo("map name", true);
|
||||
}
|
||||
else if (type.equals("DOOR")) {
|
||||
info += getTrueFalseInfo("vertical", "horizontal");
|
||||
info += getFieldInfo("dialog", false);
|
||||
}
|
||||
else if (type.equals("DOORTO")) {
|
||||
info += getLockedInfo();
|
||||
info += getTrueFalseInfo("vertical", "horizontal");
|
||||
info += getFieldInfo("dialog", false);
|
||||
if (getFieldIntegerInfo("door id") == null) return null;
|
||||
info += getFieldIntegerInfo("door id");
|
||||
info += getDirectionInfo();
|
||||
if (getFieldInfo("map name", true) == null) return null;
|
||||
info += getFieldInfo("map name", true);
|
||||
}
|
||||
else if (type.equals("CHEST")) {
|
||||
if (getFieldInfo("inventory", true) == null) return null;
|
||||
info += getFieldInfo("inventory", true);
|
||||
info += getTrueFalseInfo("chest", "item");
|
||||
}
|
||||
editor.hideError();
|
||||
System.out.println(info);
|
||||
return info;
|
||||
}
|
||||
|
||||
private String getVisibleInfo(String type) {
|
||||
String info = "";
|
||||
for (JRadioButton button : radioButtons) {
|
||||
if (button.getName().equals("visible") && button.isSelected()) {
|
||||
info = type.toUpperCase();
|
||||
break;
|
||||
}
|
||||
else if (button.getName().equals("hidden") && button.isSelected()) {
|
||||
info = type.toLowerCase();
|
||||
break;
|
||||
}
|
||||
else if (button.getName().equals("up") && button.isSelected()) {
|
||||
info += ",u";
|
||||
}
|
||||
else if (button.getName().equals("low") && button.isSelected()) {
|
||||
return info;
|
||||
}
|
||||
|
||||
private String getUpperLowerInfo() {
|
||||
String info = "";
|
||||
for (JRadioButton button : radioButtons) {
|
||||
if (button.getName().equals("upper") && button.isSelected()) {
|
||||
info += ",u";
|
||||
break;
|
||||
}
|
||||
else if (button.getName().equals("lower") && button.isSelected()) {
|
||||
info += ",d";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private void setRadioButtons() {
|
||||
private String getFieldInfo(String fieldName, boolean isRequired) {
|
||||
String info = "";
|
||||
for (JTextField field : textFields) {
|
||||
if (field.getName().equals(fieldName)) {
|
||||
if (isRequired && field.getText().trim().length() == 0) {
|
||||
editor.displayError("The " + field.getName() + " field cannot stay empty.");
|
||||
return null;
|
||||
}
|
||||
if(field.getText().trim().length() != 0) {
|
||||
info += "," + field.getText().trim();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private String getFieldIntegerInfo(String fieldName) {
|
||||
String info = "";
|
||||
for (JTextField field : textFields) {
|
||||
if (field.getName().equals(fieldName)) {
|
||||
try {
|
||||
info += "," + Integer.parseInt(field.getText().trim());
|
||||
} catch (NumberFormatException ex) {
|
||||
editor.displayError("The " + field.getName() + " field must be an Integer.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private String getTrueFalseInfo(String trueLabel, String falseLabel) {
|
||||
String info = "";
|
||||
for (JRadioButton button : radioButtons) {
|
||||
if (button.getName().equals(trueLabel) && button.isSelected()) {
|
||||
info += ",true";
|
||||
break;
|
||||
}
|
||||
if (button.getName().equals(falseLabel) && button.isSelected()) {
|
||||
info += ",false";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private String getDirectionInfo() {
|
||||
String info = "";
|
||||
for (JRadioButton button : radioButtons) {
|
||||
if (button.getName().equals("up") && button.isSelected()) {
|
||||
info += ",1";
|
||||
break;
|
||||
}
|
||||
else if (button.getName().equals("down") && button.isSelected()) {
|
||||
info += ",3";
|
||||
break;
|
||||
}
|
||||
else if (button.getName().equals("left") && button.isSelected()) {
|
||||
info += ",4";
|
||||
break;
|
||||
}
|
||||
else if (button.getName().equals("right") && button.isSelected()) {
|
||||
info += ",2";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private String getLockedInfo() {
|
||||
String info = "";
|
||||
for (JTextField field : textFields) {
|
||||
if (field.getName().equals("dialog") && field.getText().trim().length() != 0) {
|
||||
info += ",locked";
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private void setInfo() {
|
||||
String[] info = editor.getCellArray()[i][j].split(",");
|
||||
if (info[0].equals(info[0].toLowerCase())) {
|
||||
String type = info[0];
|
||||
if (type.equals("BLOCK") || type.equals("block")) {
|
||||
setTrueFalseInfo(type);
|
||||
if (info.length > 1) setUpperLowerInfo(info[1]);
|
||||
}
|
||||
else if (type.equals("INTER") || type.equals("inter")) {
|
||||
setTrueFalseInfo(type);
|
||||
setFieldInfo("dialog", info[1]);
|
||||
}
|
||||
else if (type.equals("TRIGGER")) {
|
||||
setFieldInfo("dialog", info[1]);
|
||||
if (info.length > 2) setTrueFalseInfo(info[2]);
|
||||
}
|
||||
else if (type.equals("MOVETO") || type.equals("moveto")) {
|
||||
setTrueFalseInfo(type);
|
||||
setFieldInfo("door id", info[1]);
|
||||
setDirectionInfo(info[2]);
|
||||
setFieldInfo("map name", info[3]);
|
||||
}
|
||||
else if (type.equals("DOOR")) {
|
||||
setTrueFalseInfo(info[1]);
|
||||
if (info.length > 2) setFieldInfo("dialog", info[2]);
|
||||
}
|
||||
else if (type.equals("DOORTO")) {
|
||||
if (info[1].equals("locked")) {
|
||||
setTrueFalseInfo(info[2]);
|
||||
setFieldInfo("dialog", info[3]);
|
||||
setFieldInfo("door id", info[4]);
|
||||
setDirectionInfo(info[5]);
|
||||
setFieldInfo("map name", info[6]);
|
||||
}
|
||||
else {
|
||||
setTrueFalseInfo(info[1]);
|
||||
setFieldInfo("door id", info[2]);
|
||||
setDirectionInfo(info[3]);
|
||||
setFieldInfo("map name", info[4]);
|
||||
}
|
||||
}
|
||||
else if (type.equals("CHEST")) {
|
||||
setFieldInfo("inventory", info[1]);
|
||||
if (info.length > 2) setTrueFalseInfo(info[2]);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTrueFalseInfo(String value) {
|
||||
if (value.equals("false")) {
|
||||
for (JRadioButton btn : radioButtons) {
|
||||
if (btn.getName().equals("hidden")) btn.setSelected(true);
|
||||
if (btn.getName().equals("inactive")) {
|
||||
btn.setSelected(true);
|
||||
return;
|
||||
}
|
||||
else if (btn.getName().equals("horizontal")) {
|
||||
btn.setSelected(true);
|
||||
return;
|
||||
}
|
||||
else if (btn.getName().equals("item")) {
|
||||
btn.setSelected(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (info.length > 1) {
|
||||
if (info[1].equals("u")) {
|
||||
}
|
||||
else if (value.equals(value.toLowerCase())) {
|
||||
for (JRadioButton btn : radioButtons) {
|
||||
if (btn.getName().equals("up")) btn.setSelected(true);
|
||||
if (btn.getName().equals("hidden")) {
|
||||
btn.setSelected(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpperLowerInfo(String value) {
|
||||
String name = "";
|
||||
switch (value) {
|
||||
case "u":
|
||||
name = "upper";
|
||||
break;
|
||||
case "d":
|
||||
name = "lower";
|
||||
break;
|
||||
}
|
||||
} else if (info[1].equals("d")) {
|
||||
for (JRadioButton btn : radioButtons) {
|
||||
if (btn.getName().equals("low")) btn.setSelected(true);
|
||||
}
|
||||
if (btn.getName().equals(name)) {
|
||||
btn.setSelected(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setFieldInfo(String fieldName, String value) {
|
||||
for (JTextField field : textFields) {
|
||||
if (field.getName().equals(fieldName)) {
|
||||
field.setText(value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setDirectionInfo(String value) {
|
||||
String name = "";
|
||||
switch (value) {
|
||||
case "1":
|
||||
name = "up";
|
||||
break;
|
||||
case "2":
|
||||
name = "right";
|
||||
break;
|
||||
case "3":
|
||||
name = "down";
|
||||
break;
|
||||
case "4":
|
||||
name = "left";
|
||||
break;
|
||||
}
|
||||
for (JRadioButton btn : radioButtons) {
|
||||
if (btn.getName().equals(name)) {
|
||||
btn.setSelected(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public class InfoManager {
|
||||
info.setLayout(null);
|
||||
|
||||
detailedCellInfo = new DetailedCellInfo(editor, x, y);
|
||||
detailedCellInfo.setBounds(20, 270, 260, 280);
|
||||
detailedCellInfo.setBounds(20, 270, 260, 520);
|
||||
detailedCellInfo.setLayout(null);
|
||||
detailedCellInfo.setVisible(false);
|
||||
|
||||
@ -206,7 +206,7 @@ public class InfoManager {
|
||||
@Override public void mouseExited(MouseEvent e) {}
|
||||
});
|
||||
|
||||
openCellMap.setBounds(30, 580, 200, 30);
|
||||
openCellMap.setBounds(30, 600, 200, 30);
|
||||
openCellMap.addActionListener(e -> {
|
||||
info.removeAll();
|
||||
info.revalidate();
|
||||
@ -218,9 +218,11 @@ public class InfoManager {
|
||||
new CellSetConfig(editor, scrollInfo).displayCellSetConfig();
|
||||
});
|
||||
|
||||
saveInfo.setBounds(50, 630, 150, 30);
|
||||
saveInfo.setBounds(50, 650, 150, 30);
|
||||
saveInfo.addActionListener(e -> {
|
||||
editor.getCellArray()[x][y] = detailedCellInfo.getCellInfo(String.valueOf(cellType.getSelectedItem()));
|
||||
String value = detailedCellInfo.getCellInfo(String.valueOf(cellType.getSelectedItem()));
|
||||
if (value == null) return;
|
||||
editor.getCellArray()[x][y] = value;
|
||||
editor.getMapLayers().repaintCellSet();
|
||||
info.removeAll();
|
||||
info.revalidate();
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
<map>
|
||||
<mapName>tutorial</mapName>
|
||||
<events>
|
||||
<trigger>
|
||||
<x>11</x>
|
||||
<y>6</y>
|
||||
<active>false</active>
|
||||
</trigger>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>openspace</mapName>
|
||||
<events>
|
||||
<trigger>
|
||||
<x>6</x>
|
||||
<y>4</y>
|
||||
<active>true</active>
|
||||
</trigger>
|
||||
<trigger>
|
||||
<x>14</x>
|
||||
<y>16</y>
|
||||
<active>false</active>
|
||||
</trigger>
|
||||
<chest>
|
||||
<x>15</x>
|
||||
<y>7</y>
|
||||
<active>true</active>
|
||||
</chest>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>office</mapName>
|
||||
<events>
|
||||
<trigger>
|
||||
<x>4</x>
|
||||
<y>2</y>
|
||||
<active>false</active>
|
||||
</trigger>
|
||||
<chest>
|
||||
<x>1</x>
|
||||
<y>9</y>
|
||||
<active>true</active>
|
||||
</chest>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>boss</mapName>
|
||||
<events>
|
||||
<trigger>
|
||||
<x>4</x>
|
||||
<y>18</y>
|
||||
<active>true</active>
|
||||
</trigger>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>treasure</mapName>
|
||||
<events>
|
||||
<trigger>
|
||||
<x>6</x>
|
||||
<y>1</y>
|
||||
<active>true</active>
|
||||
</trigger>
|
||||
</events>
|
||||
</map>
|
||||
@ -0,0 +1,6 @@
|
||||
<location>
|
||||
<map>openspace</map>
|
||||
<x>8</x>
|
||||
<y>16</y>
|
||||
<direction>3</direction>
|
||||
</location>
|
||||
@ -0,0 +1 @@
|
||||
TODO: Village
|
||||
Loading…
x
Reference in New Issue
Block a user