improved door & doorto handling
This commit is contained in:
parent
39306b66f9
commit
7fb1ea5d34
@ -205,10 +205,12 @@ public class DetailedCellInfo extends JPanel {
|
|||||||
info += getFieldInfo("map name", true);
|
info += getFieldInfo("map name", true);
|
||||||
}
|
}
|
||||||
else if (type.equals("DOOR")) {
|
else if (type.equals("DOOR")) {
|
||||||
|
info = getDoorInfo(type);
|
||||||
info += getTrueFalseInfo("vertical", "horizontal");
|
info += getTrueFalseInfo("vertical", "horizontal");
|
||||||
info += getFieldInfo("dialog", false);
|
info += getFieldInfo("dialog", false);
|
||||||
}
|
}
|
||||||
else if (type.equals("DOORTO")) {
|
else if (type.equals("DOORTO")) {
|
||||||
|
info = getDoorInfo(type);
|
||||||
info += getLockedInfo();
|
info += getLockedInfo();
|
||||||
info += getTrueFalseInfo("vertical", "horizontal");
|
info += getTrueFalseInfo("vertical", "horizontal");
|
||||||
info += getFieldInfo("dialog", false);
|
info += getFieldInfo("dialog", false);
|
||||||
@ -224,7 +226,6 @@ public class DetailedCellInfo extends JPanel {
|
|||||||
info += getTrueFalseInfo("chest", "item");
|
info += getTrueFalseInfo("chest", "item");
|
||||||
}
|
}
|
||||||
editor.hideError();
|
editor.hideError();
|
||||||
System.out.println(info);
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,6 +329,17 @@ public class DetailedCellInfo extends JPanel {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDoorInfo(String type) {
|
||||||
|
String info = "";
|
||||||
|
if (j == 0 || editor.getCellArray()[i][j+1].split(",")[0].equals(type)) {
|
||||||
|
info = type.toLowerCase();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
info = type;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
private String getLockedInfo() {
|
private String getLockedInfo() {
|
||||||
String info = "";
|
String info = "";
|
||||||
for (JTextField field : textFields) {
|
for (JTextField field : textFields) {
|
||||||
@ -340,6 +352,7 @@ public class DetailedCellInfo extends JPanel {
|
|||||||
|
|
||||||
private void setInfo() {
|
private void setInfo() {
|
||||||
String[] info = editor.getCellArray()[i][j].split(",");
|
String[] info = editor.getCellArray()[i][j].split(",");
|
||||||
|
System.out.println(editor.getCellArray()[i][j]);
|
||||||
String type = info[0];
|
String type = info[0];
|
||||||
if (type.equals("BLOCK") || type.equals("block")) {
|
if (type.equals("BLOCK") || type.equals("block")) {
|
||||||
setTrueFalseInfo(type);
|
setTrueFalseInfo(type);
|
||||||
@ -359,11 +372,11 @@ public class DetailedCellInfo extends JPanel {
|
|||||||
setDirectionInfo(info[2]);
|
setDirectionInfo(info[2]);
|
||||||
setFieldInfo("map name", info[3]);
|
setFieldInfo("map name", info[3]);
|
||||||
}
|
}
|
||||||
else if (type.equals("DOOR")) {
|
else if (type.equals("DOOR") || type.equals("door")) {
|
||||||
setTrueFalseInfo(info[1]);
|
setTrueFalseInfo(info[1]);
|
||||||
if (info.length > 2) setFieldInfo("dialog", info[2]);
|
if (info.length > 2) setFieldInfo("dialog", info[2]);
|
||||||
}
|
}
|
||||||
else if (type.equals("DOORTO")) {
|
else if (type.equals("DOORTO") || type.equals("doorto")) {
|
||||||
if (info[1].equals("locked")) {
|
if (info[1].equals("locked")) {
|
||||||
setTrueFalseInfo(info[2]);
|
setTrueFalseInfo(info[2]);
|
||||||
setFieldInfo("dialog", info[3]);
|
setFieldInfo("dialog", info[3]);
|
||||||
|
|||||||
@ -60,7 +60,8 @@ public class EditorSaveManager {
|
|||||||
for (int i = 0; i < editor.getMapWidth(); i++) {
|
for (int i = 0; i < editor.getMapWidth(); i++) {
|
||||||
for (int j = 0; j < editor.getMapHeight(); j++) {
|
for (int j = 0; j < editor.getMapHeight(); j++) {
|
||||||
if (j != 0) info += " ";
|
if (j != 0) info += " ";
|
||||||
info += set[i][j];
|
if (set[j][i].split(",")[0].contains("door")) info += "EMPTY";
|
||||||
|
else info += set[j][i];
|
||||||
}
|
}
|
||||||
if (i != editor.getMapWidth() -1) info += System.lineSeparator();
|
if (i != editor.getMapWidth() -1) info += System.lineSeparator();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -222,7 +222,8 @@ public class InfoManager {
|
|||||||
saveInfo.addActionListener(e -> {
|
saveInfo.addActionListener(e -> {
|
||||||
String value = detailedCellInfo.getCellInfo(String.valueOf(cellType.getSelectedItem()));
|
String value = detailedCellInfo.getCellInfo(String.valueOf(cellType.getSelectedItem()));
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
editor.getCellArray()[x][y] = value;
|
if (value.contains("DOOR") || value.contains("door")) saveDoor(value, x, y);
|
||||||
|
else editor.getCellArray()[x][y] = value;
|
||||||
editor.getMapLayers().repaintCellSet();
|
editor.getMapLayers().repaintCellSet();
|
||||||
info.removeAll();
|
info.removeAll();
|
||||||
info.revalidate();
|
info.revalidate();
|
||||||
@ -242,4 +243,21 @@ public class InfoManager {
|
|||||||
info.add(openCellMap);
|
info.add(openCellMap);
|
||||||
info.add(saveInfo);
|
info.add(saveInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveDoor(String value, int x, int y) {
|
||||||
|
System.out.println(value + y);
|
||||||
|
if (value.split(",")[0].contains("DOOR") && y == 0) {
|
||||||
|
value = value.substring(0, value.indexOf(",")).toLowerCase() + value.substring(value.indexOf(","));
|
||||||
|
}
|
||||||
|
if (value.split(",")[0].contains("DOOR")) {
|
||||||
|
editor.getCellArray()[x][y] = value;
|
||||||
|
value = value.substring(0, value.indexOf(",")).toLowerCase() + value.substring(value.indexOf(","));
|
||||||
|
editor.getCellArray()[x][y-1] = value;
|
||||||
|
}
|
||||||
|
else if (value.split(",")[0].contains("door")) {
|
||||||
|
editor.getCellArray()[x][y] = value;
|
||||||
|
value = value.substring(0, value.indexOf(",")).toUpperCase() + value.substring(value.indexOf(","));
|
||||||
|
editor.getCellArray()[x][y+1] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -169,11 +169,12 @@ public class MapLayersManager {
|
|||||||
private void setCellIcon(JLabel cell, int i, int j) {
|
private void setCellIcon(JLabel cell, int i, int j) {
|
||||||
String value;
|
String value;
|
||||||
String[] info = editor.getCellArray()[i][j].split(",");
|
String[] info = editor.getCellArray()[i][j].split(",");
|
||||||
if (info[0].equals(info[0].toLowerCase())) {
|
if (info[0].toUpperCase().equals("DOOR") || info[0].toUpperCase().equals("DOORTO")) {
|
||||||
|
setDoorImage(cell, info);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (info[0].toUpperCase().equals("DOOR") || info[0].toUpperCase().equals("DOORTO")) {
|
if (info[0].equals(info[0].toLowerCase())) {
|
||||||
value = "DOOR/DOORTO";
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
value = info[0].toUpperCase();
|
value = info[0].toUpperCase();
|
||||||
@ -212,6 +213,49 @@ public class MapLayersManager {
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDoorImage(JLabel cell, String[] info) {
|
||||||
|
if (editor.getCellMap().get("DOOR/DOORTO") == 0) {
|
||||||
|
cell.setIcon(new ImageIcon(imagesOfTiles.get(editor.getCellMap().get("DOOR/DOORTO")).getScaledInstance(50, 50, Image.SCALE_DEFAULT)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (info[0].equals("DOOR") || info[0].equals("door")) {
|
||||||
|
if (info[1].equals("true")) {
|
||||||
|
if (info[0].equals("door")) {
|
||||||
|
cell.setIcon(new ImageIcon(imagesOfTiles.get(editor.getCellMap().get("DOOR/DOORTO") - 1).getScaledInstance(50, 50, Image.SCALE_DEFAULT)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cell.setIcon(new ImageIcon(imagesOfTiles.get(editor.getCellMap().get("DOOR/DOORTO")).getScaledInstance(50, 50, Image.SCALE_DEFAULT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (info[1].equals("false")) {
|
||||||
|
if (info[0].equals("door")) {
|
||||||
|
cell.setIcon(new ImageIcon(imagesOfTiles.get(editor.getCellMap().get("DOOR/DOORTO") + 3).getScaledInstance(50, 50, Image.SCALE_DEFAULT)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cell.setIcon(new ImageIcon(imagesOfTiles.get(editor.getCellMap().get("DOOR/DOORTO") + 4).getScaledInstance(50, 50, Image.SCALE_DEFAULT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (info[0].equals("DOORTO") || info[0].equals("doorto")) {
|
||||||
|
if (info[1].equals("true") || info[2].equals("true")) {
|
||||||
|
if (info[0].equals("doorto")) {
|
||||||
|
cell.setIcon(new ImageIcon(imagesOfTiles.get(editor.getCellMap().get("DOOR/DOORTO") - 1).getScaledInstance(50, 50, Image.SCALE_DEFAULT)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cell.setIcon(new ImageIcon(imagesOfTiles.get(editor.getCellMap().get("DOOR/DOORTO")).getScaledInstance(50, 50, Image.SCALE_DEFAULT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (info[1].equals("false") || info[2].equals("false")) {
|
||||||
|
if (info[0].equals("doorto")) {
|
||||||
|
cell.setIcon(new ImageIcon(imagesOfTiles.get(editor.getCellMap().get("DOOR/DOORTO") + 3).getScaledInstance(50, 50, Image.SCALE_DEFAULT)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cell.setIcon(new ImageIcon(imagesOfTiles.get(editor.getCellMap().get("DOOR/DOORTO") + 4).getScaledInstance(50, 50, Image.SCALE_DEFAULT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public JLayeredPane getMapLayers() {
|
public JLayeredPane getMapLayers() {
|
||||||
return mapLayers;
|
return mapLayers;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user