adventure Editor rework

This commit is contained in:
Grimm
2022-08-03 16:26:46 +02:00
parent 95fba3d0cb
commit aa9d15a908
16 changed files with 348 additions and 213 deletions

View File

@@ -6,7 +6,7 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.Arrays; import java.util.Arrays;
public class BiomeEdit extends JComponent { public class BiomeEdit extends FormPanel {
BiomeData currentData; BiomeData currentData;
public JSpinner startPointX= new JSpinner(new SpinnerNumberModel(0.0f, 0.f, 1f, 0.1f)); public JSpinner startPointX= new JSpinner(new SpinnerNumberModel(0.0f, 0.f, 1f, 0.1f));
@@ -30,28 +30,26 @@ public class BiomeEdit extends JComponent {
public BiomeEdit() public BiomeEdit()
{ {
JComponent center=new JComponent() { }; FormPanel center=new FormPanel() { };
center.setLayout(new GridLayout(14,2));
center.add(new JLabel("startPointX:")); center.add(startPointX); center.add("startPointX:",startPointX);
center.add(new JLabel("startPointY:")); center.add(startPointY); center.add("startPointY:",startPointY);
center.add(new JLabel("noiseWeight:")); center.add(noiseWeight); center.add("noiseWeight:",noiseWeight);
center.add(new JLabel("distWeight:")); center.add(distWeight); center.add("distWeight:",distWeight);
center.add(new JLabel("name:")); center.add(name); center.add("name:",name);
center.add(new JLabel("tilesetAtlas:")); center.add(tilesetAtlas); center.add("tilesetAtlas:",tilesetAtlas);
center.add(new JLabel("tilesetName:")); center.add(tilesetName); center.add("tilesetName:",tilesetName);
center.add(new JLabel("width:")); center.add(width); center.add("width:",width);
center.add(new JLabel("height:")); center.add(height); center.add("height:",height);
center.add(new JLabel("spriteNames:")); center.add(spriteNames); center.add("spriteNames:",spriteNames);
center.add(new JLabel("enemies:")); center.add(enemies); center.add("enemies:",enemies);
center.add(new JLabel("pointsOfInterest:")); center.add(pointsOfInterest); center.add("pointsOfInterest:",pointsOfInterest);
center.add(new JLabel("color:")); center.add(color); center.add("color:",color);
center.add(new JLabel("terrain/structures:"));center.add(new JLabel("")); center.add("terrain/structures:",new JLabel(""));
BoxLayout layout=new BoxLayout(this, BoxLayout.Y_AXIS);
setLayout(layout); add(center);
add(center,BorderLayout.NORTH); add(terrain);
add(terrain,BorderLayout.CENTER); add(structures);
add(structures,BorderLayout.SOUTH);
name.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeEdit.this.updateTerrain())); name.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeEdit.this.updateTerrain()));
tilesetName.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeEdit.this.updateTerrain())); tilesetName.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeEdit.this.updateTerrain()));
@@ -71,7 +69,7 @@ public class BiomeEdit extends JComponent {
refresh(); refresh();
} }
private void updateTerrain() { protected void updateTerrain() {
if(currentData==null||updating) if(currentData==null||updating)
return; return;
currentData.startPointX = (Float) startPointX.getValue(); currentData.startPointX = (Float) startPointX.getValue();
@@ -80,15 +78,15 @@ public class BiomeEdit extends JComponent {
currentData.distWeight = (Float)distWeight.getValue(); currentData.distWeight = (Float)distWeight.getValue();
currentData.name = name.getText(); currentData.name = name.getText();
currentData.tilesetAtlas = tilesetAtlas.edit.getText(); currentData.tilesetAtlas = tilesetAtlas.edit.getText();
currentData.tilesetName = tilesetName.getName(); currentData.tilesetName = tilesetName.getText();
currentData.terrain = terrain.getBiomeTerrainData(); currentData.terrain = terrain.getBiomeTerrainData();
currentData.structures = structures.getBiomeStructureData(); currentData.structures = structures.getBiomeStructureData();
currentData.width = (Float) width.getValue(); currentData.width = (Float) width.getValue();
currentData.height = (Float) height.getValue(); currentData.height = (Float) height.getValue();
currentData.color = color.getText(); currentData.color = color.getText();
currentData.spriteNames = spriteNames.getList(); currentData.spriteNames = spriteNames.getList();
currentData.enemies = Arrays.asList(enemies.getList()); currentData.enemies = enemies.getList();
currentData.pointsOfInterest = Arrays.asList(pointsOfInterest.getList()); currentData.pointsOfInterest = pointsOfInterest.getList();
} }
public void setCurrentBiome(BiomeData data) public void setCurrentBiome(BiomeData data)

View File

@@ -18,8 +18,12 @@ public class BiomeStructureDataMappingEditor extends JComponent {
public void setCurrent(BiomeStructureData data) { public void setCurrent(BiomeStructureData data) {
this.data=data; this.data=data;
model.clear(); model.clear();
for(int i=0;data.mappingInfo!=null&&i<data.mappingInfo.length;i++) if(data==null||data.mappingInfo==null)
return;
for(int i=0;i<data.mappingInfo.length;i++)
model.addElement(data.mappingInfo[i]); model.addElement(data.mappingInfo[i]);
list.setSelectedIndex(0);
} }
public BiomeStructureData.BiomeStructureDataMapping[] getCurrent() public BiomeStructureData.BiomeStructureDataMapping[] getCurrent()
@@ -115,7 +119,7 @@ public class BiomeStructureDataMappingEditor extends JComponent {
model.remove(selected); model.remove(selected);
} }
private class BiomeStructureDataMappingEdit extends JComponent{ private class BiomeStructureDataMappingEdit extends FormPanel{
BiomeStructureData.BiomeStructureDataMapping currentData; BiomeStructureData.BiomeStructureDataMapping currentData;
@@ -127,11 +131,10 @@ public class BiomeStructureDataMappingEditor extends JComponent {
public BiomeStructureDataMappingEdit() public BiomeStructureDataMappingEdit()
{ {
setLayout(new GridLayout(3,2));
add(new JLabel("name:")); add(name); add("name:",name);
add(new JLabel("color:")); add(color); add("color:",color);
add(new JLabel("collision:")); add(collision); add("collision:",collision);
name.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeStructureDataMappingEdit.this.update())); name.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeStructureDataMappingEdit.this.update()));
color.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeStructureDataMappingEdit.this.update())); color.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeStructureDataMappingEdit.this.update()));

View File

@@ -9,7 +9,7 @@ import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
public class BiomeStructureEdit extends JComponent { public class BiomeStructureEdit extends FormPanel {
private boolean updating=false; private boolean updating=false;
BiomeStructureData currentData; BiomeStructureData currentData;
BiomeData currentBiomeData; BiomeData currentBiomeData;
@@ -28,24 +28,22 @@ public class BiomeStructureEdit extends JComponent {
public BiomeStructureDataMappingEditor data=new BiomeStructureDataMappingEditor(); public BiomeStructureDataMappingEditor data=new BiomeStructureDataMappingEditor();
public BiomeStructureEdit() public BiomeStructureEdit()
{ {
JComponent center=new JComponent() { }; FormPanel center=new FormPanel();
center.setLayout(new GridLayout(11,2));
center.add(new JLabel("structureAtlasPath:")); center.add(structureAtlasPath); center.add("structureAtlasPath:",structureAtlasPath);
center.add(new JLabel("x:")); center.add(x); center.add("x:",x);
center.add(new JLabel("y:")); center.add(y); center.add("y:",y);
center.add(new JLabel("width:")); center.add(width); center.add("width:",width);
center.add(new JLabel("height:")); center.add(height); center.add("height:",height);
center.add(new JLabel("N:")); center.add(N); center.add("N:",N);
center.add(new JLabel("sourcePath:")); center.add(sourcePath); center.add("sourcePath:",sourcePath);
center.add(new JLabel("periodicInput:")); center.add(periodicInput); center.add("periodicInput:",periodicInput);
center.add(new JLabel("ground:")); center.add(ground); center.add("ground:",ground);
center.add(new JLabel("symmetry:")); center.add(symmetry); center.add("symmetry:",symmetry);
center.add(new JLabel("periodicOutput:")); center.add(periodicOutput); center.add("periodicOutput:",periodicOutput);
BorderLayout layout=new BorderLayout();
setLayout(layout); add(center);
add(center,BorderLayout.CENTER); add(data);
add(data,BorderLayout.SOUTH);
structureAtlasPath.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeStructureEdit.this.updateStructure())); structureAtlasPath.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeStructureEdit.this.updateStructure()));
@@ -68,6 +66,7 @@ public class BiomeStructureEdit extends JComponent {
setEnabled(currentData!=null); setEnabled(currentData!=null);
if(currentData==null) if(currentData==null)
{ {
data.setCurrent(null);
return; return;
} }
updating=true; updating=true;
@@ -85,6 +84,9 @@ public class BiomeStructureEdit extends JComponent {
periodicOutput.setSelected(currentData.periodicOutput); periodicOutput.setSelected(currentData.periodicOutput);
data.setCurrent(currentData); data.setCurrent(currentData);
updating=false; updating=false;
} }
public void updateStructure() public void updateStructure()

View File

@@ -8,7 +8,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.*;
public class BiomeTerrainEdit extends JComponent { public class BiomeTerrainEdit extends FormPanel {
SwingAtlasPreview preview=new SwingAtlasPreview(128); SwingAtlasPreview preview=new SwingAtlasPreview(128);
private boolean updating=false; private boolean updating=false;
BiomeTerrainData currentData; BiomeTerrainData currentData;
@@ -20,17 +20,13 @@ public class BiomeTerrainEdit extends JComponent {
public BiomeTerrainEdit() public BiomeTerrainEdit()
{ {
JComponent center=new JComponent() { }; FormPanel center=new FormPanel() { };
center.setLayout(new GridLayout(4,2));
center.add(new JLabel("spriteName:")); center.add(spriteName); center.add("spriteName:",spriteName);
center.add(new JLabel("min:")); center.add(min); center.add("min:",min);
center.add(new JLabel("max:")); center.add(max); center.add("max:",max);
center.add(new JLabel("resolution:")); center.add(resolution); center.add("resolution:",resolution);
BorderLayout layout=new BorderLayout(); add(center,preview);
setLayout(layout);
add(preview,BorderLayout.WEST);
add(center,BorderLayout.CENTER);
spriteName.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeTerrainEdit.this.updateTerrain())); spriteName.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeTerrainEdit.this.updateTerrain()));

View File

@@ -25,16 +25,15 @@ public class EffectEditor extends JComponent {
if(!isOpponentEffect) if(!isOpponentEffect)
opponent=new EffectEditor(true); opponent=new EffectEditor(true);
setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
JPanel parameters=new JPanel(); FormPanel parameters=new FormPanel();
parameters.setBorder(BorderFactory.createTitledBorder("Effect")); parameters.setBorder(BorderFactory.createTitledBorder("Effect"));
parameters.setLayout(new GridLayout(7,2)) ;
parameters.add(new JLabel("Name:")); parameters.add(name); parameters.add("Name:", name);
parameters.add(new JLabel("Start with extra cards:")); parameters.add(changeStartCards); parameters.add("Start with extra cards:", changeStartCards);
parameters.add(new JLabel("Change life:")); parameters.add(lifeModifier); parameters.add("Change life:", lifeModifier);
parameters.add(new JLabel("Movement speed:")); parameters.add(moveSpeed); parameters.add("Movement speed:", moveSpeed);
parameters.add(new JLabel("Start battle with cards:")); parameters.add(startBattleWithCard); parameters.add("Start battle with cards:", startBattleWithCard);
parameters.add(new JLabel("color view:")); parameters.add(colorView); parameters.add("color view:", colorView);
add(parameters); add(parameters);
if(!isOpponentEffect) if(!isOpponentEffect)
{ add(new JLabel("Opponent:")); add(opponent);} { add(new JLabel("Opponent:")); add(opponent);}

View File

@@ -8,7 +8,7 @@ import java.awt.*;
/** /**
* Editor class to edit configuration, maybe moved or removed * Editor class to edit configuration, maybe moved or removed
*/ */
public class EnemyEdit extends JComponent { public class EnemyEdit extends FormPanel {
EnemyData currentData; EnemyData currentData;
JTextField nameField=new JTextField(); JTextField nameField=new JTextField();
JTextField colorField=new JTextField(); JTextField colorField=new JTextField();
@@ -26,23 +26,20 @@ public class EnemyEdit extends JComponent {
public EnemyEdit() public EnemyEdit()
{ {
JComponent center=new JComponent() { }; FormPanel center=new FormPanel() { };
center.setLayout(new GridLayout(9,2));
center.add(new JLabel("Name:")); center.add(nameField); center.add("Name:",nameField);
center.add(new JLabel("Life:")); center.add(lifeFiled); center.add("Life:",lifeFiled);
center.add(new JLabel("Spawn rate:")); center.add(spawnRate); center.add("Spawn rate:",spawnRate);
center.add(new JLabel("Difficulty:")); center.add(difficulty); center.add("Difficulty:",difficulty);
center.add(new JLabel("Speed:")); center.add(speed); center.add("Speed:",speed);
center.add(new JLabel("Deck:")); center.add(deck); center.add("Deck:",deck);
center.add(new JLabel("Sprite:")); center.add(atlas); center.add("Sprite:",atlas);
center.add(new JLabel("Equipment:")); center.add(equipment); center.add("Equipment:",equipment);
center.add(new JLabel("Colors:")); center.add(colorField); center.add("Colors:",colorField);
BorderLayout layout=new BorderLayout(); add(center);
setLayout(layout); add(rewards);
add(center,BorderLayout.PAGE_START); add(preview);
add(rewards,BorderLayout.CENTER);
add(preview,BorderLayout.LINE_START);
equipment.getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy())); equipment.getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy()));
atlas.getEdit().getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy())); atlas.getEdit().getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy()));

View File

@@ -0,0 +1,63 @@
package forge.adventure.editor;
import javax.swing.*;
import java.awt.*;
public class FormPanel extends JPanel {
int row=0;
static final int MAXIMUM_LINES=300;
public FormPanel()
{
setLayout(new GridBagLayout()) ;
GridBagConstraints constraint=new GridBagConstraints();
constraint.weightx = 1.0;
constraint.weighty = 1.0;
constraint.gridy=MAXIMUM_LINES;
constraint.gridx=0;
constraint.gridwidth=2;
add(Box.createVerticalGlue(),constraint);
row++;
}
public void add(JComponent name,JComponent element)
{
GridBagConstraints constraint=new GridBagConstraints();
constraint.ipadx = 5;
constraint.ipady = 5;
constraint.weightx = 1.0;
constraint.weighty = 0.0;
constraint.gridy=row;
constraint.gridx=0;
constraint.anchor=GridBagConstraints.NORTHWEST;
add(name,constraint);
constraint.gridy=row;
constraint.gridx=1;
constraint.fill=GridBagConstraints.HORIZONTAL;
constraint.anchor=GridBagConstraints.NORTHEAST;
add(element,constraint);
row++;
}
public void add(String name,JComponent element)
{
add(new JLabel(name),element);
}
public void add(JComponent element)
{
GridBagConstraints constraint=new GridBagConstraints();
constraint.ipadx = 5;
constraint.ipady = 5;
constraint.weightx = 1.0;
constraint.weighty = 0.0;
constraint.gridy=row;
constraint.gridx=0;
constraint.gridwidth=2;
constraint.fill=GridBagConstraints.HORIZONTAL;
constraint.anchor=GridBagConstraints.NORTHEAST;
add(element,constraint);
row++;
}
}

View File

@@ -24,20 +24,18 @@ public class ItemEdit extends JComponent {
{ {
setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
JPanel parameters=new JPanel(); FormPanel parameters=new FormPanel();
parameters.setBorder(BorderFactory.createTitledBorder("Parameter")); parameters.setBorder(BorderFactory.createTitledBorder("Parameter"));
parameters.setLayout(new GridLayout(6,2)) ;
parameters.add(new JLabel("Name:")); parameters.add(nameField); parameters.add("Name:",nameField);
parameters.add(new JLabel("equipmentSlot:")); parameters.add(equipmentSlot); parameters.add("equipmentSlot:",equipmentSlot);
parameters.add(new JLabel("description:")); parameters.add(description); parameters.add("description:",description);
parameters.add(new JLabel("iconName")); parameters.add(iconName); parameters.add("iconName",iconName);
parameters.add(new JLabel("questItem")); parameters.add(questItem); parameters.add("questItem",questItem);
parameters.add(new JLabel("cost")); parameters.add(cost); parameters.add("cost",cost);
add(parameters); add(parameters);
add(effect); add(effect);
add(new Box.Filler(new Dimension(0,0),new Dimension(0,Integer.MAX_VALUE),new Dimension(0,Integer.MAX_VALUE)));
nameField.getDocument().addDocumentListener(new DocumentChangeListener(() -> ItemEdit.this.updateItem())); nameField.getDocument().addDocumentListener(new DocumentChangeListener(() -> ItemEdit.this.updateItem()));
equipmentSlot.getDocument().addDocumentListener(new DocumentChangeListener(() -> ItemEdit.this.updateItem())); equipmentSlot.getDocument().addDocumentListener(new DocumentChangeListener(() -> ItemEdit.this.updateItem()));

View File

@@ -25,20 +25,18 @@ public class PointOfInterestEdit extends JComponent {
{ {
setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
JPanel parameters=new JPanel(); FormPanel parameters=new FormPanel();
parameters.setBorder(BorderFactory.createTitledBorder("Parameter")); parameters.setBorder(BorderFactory.createTitledBorder("Parameter"));
parameters.setLayout(new GridLayout(7,2)) ;
parameters.add(new JLabel("Name:")); parameters.add(name); parameters.add("Name:",name);
parameters.add(new JLabel("Type:")); parameters.add(type); parameters.add("Type:",type);
parameters.add(new JLabel("Count:")); parameters.add(count); parameters.add("Count:",count);
parameters.add(new JLabel("Sprite atlas:")); parameters.add(spriteAtlas); parameters.add("Sprite atlas:",spriteAtlas);
parameters.add(new JLabel("Sprite:")); parameters.add(sprite); parameters.add("Sprite:",sprite);
parameters.add(new JLabel("Map:")); parameters.add(map); parameters.add("Map:",map);
parameters.add(new JLabel("Radius factor:")); parameters.add(radiusFactor); parameters.add("Radius factor:",radiusFactor);
add(parameters); add(parameters);
add(new Box.Filler(new Dimension(0,0),new Dimension(0,Integer.MAX_VALUE),new Dimension(0,Integer.MAX_VALUE)));
name.getDocument().addDocumentListener(new DocumentChangeListener(() -> PointOfInterestEdit.this.updateItem())); name.getDocument().addDocumentListener(new DocumentChangeListener(() -> PointOfInterestEdit.this.updateItem()));
type.getDocument().addDocumentListener(new DocumentChangeListener(() -> PointOfInterestEdit.this.updateItem())); type.getDocument().addDocumentListener(new DocumentChangeListener(() -> PointOfInterestEdit.this.updateItem()));

View File

@@ -13,7 +13,7 @@ import java.util.Arrays;
/** /**
* Editor class to edit configuration, maybe moved or removed * Editor class to edit configuration, maybe moved or removed
*/ */
public class RewardEdit extends JComponent { public class RewardEdit extends FormPanel {
RewardData currentData; RewardData currentData;
JComboBox typeField =new JComboBox(new String[] { "card", "gold", "life", "deckCard", "item"}); JComboBox typeField =new JComboBox(new String[] { "card", "gold", "life", "deckCard", "item"});
@@ -36,24 +36,23 @@ public class RewardEdit extends JComponent {
public RewardEdit() public RewardEdit()
{ {
setLayout(new GridLayout(16,2));
add(new JLabel("Type:")); add(typeField); add("Type:",typeField);
add(new JLabel("probability:")); add(probability); add("probability:",probability);
add(new JLabel("count:")); add(count); add("count:",count);
add(new JLabel("addMaxCount:")); add(addMaxCount); add("addMaxCount:",addMaxCount);
add(new JLabel("cardName:")); add(cardName); add("cardName:",cardName);
add(new JLabel("itemName:")); add(itemName); add("itemName:",itemName);
add(new JLabel("editions:")); add(editions); add("editions:",editions);
add(new JLabel("colors:")); add(colors); add("colors:",colors);
add(new JLabel("rarity:")); add(rarity); add("rarity:",rarity);
add(new JLabel("subTypes:")); add(subTypes); add("subTypes:",subTypes);
add(new JLabel("cardTypes:")); add(cardTypes); add("cardTypes:",cardTypes);
add(new JLabel("superTypes:")); add(superTypes); add("superTypes:",superTypes);
add(new JLabel("manaCosts:")); add(manaCosts); add("manaCosts:",manaCosts);
add(new JLabel("keyWords:")); add(keyWords); add("keyWords:",keyWords);
add(new JLabel("colorType:")); add(colorType); add("colorType:",colorType);
add(new JLabel("cardText:")); add(cardText); add("cardText:",cardText);
typeField.addActionListener((e -> RewardEdit.this.updateReward())); typeField.addActionListener((e -> RewardEdit.this.updateReward()));

View File

@@ -153,7 +153,10 @@ public class StructureEditor extends JComponent{
currentData=data; currentData=data;
model.clear(); model.clear();
if(data==null||data.structures==null) if(data==null||data.structures==null)
{
edit.setCurrentStructure(null,null);
return; return;
}
for (int i=0;i<data.structures.length;i++) { for (int i=0;i<data.structures.length;i++) {
model.add(i,data.structures[i]); model.add(i,data.structures[i]);
} }

View File

@@ -92,31 +92,23 @@ public class WorldEditor extends JComponent {
BorderLayout layout = new BorderLayout(); BorderLayout layout = new BorderLayout();
setLayout(layout); setLayout(layout);
add(tabs); add(tabs);
JPanel worldPanel=new JPanel();
JSplitPane biomeData=new JSplitPane(); JSplitPane biomeData=new JSplitPane();
tabs.addTab("BiomeData", biomeData); tabs.addTab("BiomeData", biomeData);
FormPanel worldPanel=new FormPanel();
worldPanel.add("width:",width);
worldPanel.add("height:",height);
worldPanel.add("playerStartPosX:",playerStartPosX);
worldPanel.add("playerStartPosY:",playerStartPosY);
worldPanel.add("noiseZoomBiome:",noiseZoomBiome);
worldPanel.add("tileSize:",tileSize);
worldPanel.add("biomesSprites:",biomesSprites);
worldPanel.add("maxRoadDistance:",maxRoadDistance);
worldPanel.add("biomesNames:",biomesNames);
tabs.addTab("WorldData", worldPanel); tabs.addTab("WorldData", worldPanel);
JPanel worldData=new JPanel();
worldData.setLayout(new GridLayout(9,2)) ;
worldData.add(new JLabel("width:")); worldData.add(width);
worldData.add(new JLabel("height:")); worldData.add(height);
worldData.add(new JLabel("playerStartPosX:")); worldData.add(playerStartPosX);
worldData.add(new JLabel("playerStartPosY:")); worldData.add(playerStartPosY);
worldData.add(new JLabel("noiseZoomBiome:")); worldData.add(noiseZoomBiome);
worldData.add(new JLabel("tileSize:")); worldData.add(tileSize);
worldData.add(new JLabel("biomesSprites:")); worldData.add(biomesSprites);
worldData.add(new JLabel("maxRoadDistance:")); worldData.add(maxRoadDistance);
worldData.add(new JLabel("biomesNames:")); worldData.add(biomesNames);
worldPanel.setLayout(new BoxLayout(worldPanel,BoxLayout.Y_AXIS));
worldPanel.add(worldData);
worldPanel.add(new Box.Filler(new Dimension(0,0),new Dimension(0,Integer.MAX_VALUE),new Dimension(0,Integer.MAX_VALUE)));
JScrollPane pane = new JScrollPane(edit); JScrollPane pane = new JScrollPane(edit);
biomeData.setLeftComponent(list); biomeData.setRightComponent(pane); biomeData.setLeftComponent(list); biomeData.setRightComponent(pane);
@@ -126,6 +118,10 @@ public class WorldEditor extends JComponent {
add(toolBar, BorderLayout.PAGE_START); add(toolBar, BorderLayout.PAGE_START);
JButton newButton=new JButton("save"); JButton newButton=new JButton("save");
newButton.addActionListener(e -> WorldEditor.this.save()); newButton.addActionListener(e -> WorldEditor.this.save());
toolBar.add(newButton);
newButton=new JButton("save selected biome");
newButton.addActionListener(e -> WorldEditor.this.saveBiome());
toolBar.add(newButton); toolBar.add(newButton);
newButton=new JButton("load"); newButton=new JButton("load");
@@ -165,6 +161,15 @@ public class WorldEditor extends JComponent {
} }
} }
void saveBiome()
{
edit.updateTerrain();
Json json = new Json(JsonWriter.OutputType.json);
FileHandle handle = Config.instance().getFile(currentData.biomesNames[list.getSelectedIndex()]);
handle.writeString(json.prettyPrint(json.toJson(edit.currentData, BiomeData.class)),false);
}
void save() void save()
{ {
currentData.width=width.intValue(); currentData.width=width.intValue();
@@ -175,11 +180,11 @@ public class WorldEditor extends JComponent {
currentData.tileSize=tileSize.intValue(); currentData.tileSize=tileSize.intValue();
currentData.biomesSprites=biomesSprites.getText(); currentData.biomesSprites=biomesSprites.getText();
currentData.maxRoadDistance=maxRoadDistance.floatValue(); currentData.maxRoadDistance=maxRoadDistance.floatValue();
currentData.biomesNames= Arrays.asList(biomesNames.getList()); currentData.biomesNames= (biomesNames.getList());
Json json = new Json(JsonWriter.OutputType.json); Json json = new Json(JsonWriter.OutputType.json);
FileHandle handle = Config.instance().getFile(Paths.WORLD); FileHandle handle = Config.instance().getFile(Paths.WORLD);
handle.writeString(json.prettyPrint(json.toJson(currentData,Array.class, WorldData.class)),false); handle.writeString(json.prettyPrint(json.toJson(currentData, WorldData.class)),false);
} }
void load() void load()

View File

@@ -28,8 +28,8 @@ public class BiomeData implements Serializable {
public String color; public String color;
public boolean invertHeight; public boolean invertHeight;
public String[] spriteNames; public String[] spriteNames;
public List<String> enemies; public String[] enemies;
public List<String> pointsOfInterest; public String[] pointsOfInterest;
public BiomeStructureData[] structures; public BiomeStructureData[] structures;
private ArrayList<EnemyData> enemyList; private ArrayList<EnemyData> enemyList;
@@ -46,8 +46,13 @@ public class BiomeData implements Serializable {
if (enemies == null) if (enemies == null)
return enemyList; return enemyList;
for (EnemyData data : new Array.ArrayIterator<>(WorldData.getAllEnemies())) { for (EnemyData data : new Array.ArrayIterator<>(WorldData.getAllEnemies())) {
if (enemies.contains(data.name)) { for (String enemyName:enemies)
enemyList.add(data); {
if(data.name.equals(enemyName))
{
enemyList.add(data);
break;
}
} }
} }
} }
@@ -61,8 +66,13 @@ public class BiomeData implements Serializable {
return pointOfInterestList; return pointOfInterestList;
Array<PointOfInterestData> allTowns = PointOfInterestData.getAllPointOfInterest(); Array<PointOfInterestData> allTowns = PointOfInterestData.getAllPointOfInterest();
for (PointOfInterestData data : new Array.ArrayIterator<>(allTowns)) { for (PointOfInterestData data : new Array.ArrayIterator<>(allTowns)) {
if (pointsOfInterest.contains(data.name)) { for (String poiName:pointsOfInterest)
pointOfInterestList.add(data); {
if(data.name.equals(poiName))
{
pointOfInterestList.add(data);
break;
}
} }
} }
} }

View File

@@ -27,7 +27,7 @@ public class WorldData implements Serializable {
public BiomeData roadTileset; public BiomeData roadTileset;
public String biomesSprites; public String biomesSprites;
public float maxRoadDistance; public float maxRoadDistance;
public List<String> biomesNames; public String[] biomesNames;
private BiomeSprites sprites; private BiomeSprites sprites;

View File

@@ -1,52 +1,108 @@
{ {
"startPointX": 0.22, "startPointX": 0.22,
"startPointY": 0.43, "startPointY": 0.43,
"name": "green", "noiseWeight": 0.5,
"noiseWeight": 0.5, "distWeight": 1.5,
"distWeight": 1.5, "name": "green",
"tilesetName":"Green", "tilesetAtlas": "world/tilesets/terrain.atlas",
"tilesetAtlas":"world/tilesets/terrain.atlas", "tilesetName": "Green",
"terrain":[ "terrain": [
{ {
"spriteName":"Green_1", "spriteName": "Green_1",
"min": 0, "max": 0.2,
"max": 0.2, "resolution": 10
"resolution": 10 },
},{ {
"spriteName":"Green_2", "spriteName": "Green_2",
"min": 0.8, "min": 0.8,
"max": 1.0, "max": 1,
"resolution": 10 "resolution": 10
} }
], ],
"structures":[ "width": 0.7,
{ "height": 0.7,
"sourcePath" : "world/tilesets/forestSource.png", "color": "59a650",
"structureAtlasPath":"world/tilesets/structures.atlas", "spriteNames": [
"mappingInfo":[ "WoodTree",
{ "WoodTree2",
"name":"Forest", "Bush",
"color":"007000" "Stump",
} "Moss",
], "Stone",
"x": 0.5, "Flower",
"y": 0.5, "Wood"
"width": 0.3 , ],
"height": 0.3 "enemies": [
} "Ape",
], "Bear",
"width": 0.7, "Centaur",
"height": 0.7, "Centaur Warrior",
"color": "59a650", "Dino",
"spriteNames":[ "WoodTree","WoodTree2","Bush","Stump","Moss","Stone","Flower","Wood"] , "Eldraine Faerie",
"enemies":[ "Ape","Bear","Centaur","Centaur Warrior","Dino","Eldraine Faerie","Elf","Elf warrior","Elk","Faerie","Giant Spider","Gorgon","Gorgon 2","Green Beast","Green Wiz1","Green Wiz2","Green Wiz3","High Elf","Hydra","Satyr","Snake","Spider","Treefolk","Treefolk Guardian","Viper","Werewolf","Wurm" ] , "Elf",
"pointsOfInterest":[ "Elf warrior",
"Green Castle", "Elk",
"Forest Town", "Faerie",
"ElfTown", "Giant Spider",
"WurmPond", "Gorgon",
"Grove", "Grove1", "Grove2", "Grove3", "Grove4", "Grove5", "Grove6", "Grove7", "Grove8", "Gorgon 2",
"CatLairG", "CatLairG1", "CatLairG2", "Green Beast",
"CaveG", "CaveG1", "CaveG2", "CaveG3", "CaveG4", "CaveG5", "CaveG6", "CaveG8", "CaveG9", "CaveGB" "Green Wiz1",
] "Green Wiz2",
"Green Wiz3",
"High Elf",
"Hydra",
"Satyr",
"Snake",
"Spider",
"Treefolk",
"Treefolk Guardian",
"Viper",
"Werewolf",
"Wurm"
],
"pointsOfInterest": [
"Green Castle",
"Forest Town",
"ElfTown",
"WurmPond",
"Grove",
"Grove1",
"Grove2",
"Grove3",
"Grove4",
"Grove5",
"Grove6",
"Grove7",
"Grove8",
"CatLairG",
"CatLairG1",
"CatLairG2",
"CaveG",
"CaveG1",
"CaveG2",
"CaveG3",
"CaveG4",
"CaveG5",
"CaveG6",
"CaveG8",
"CaveG9",
"CaveGB"
],
"structures": [
{
"x": 0.5,
"y": 0.5,
"structureAtlasPath": "world/tilesets/structures.atlas",
"sourcePath": "world/tilesets/forestSource.png",
"height": 0.3,
"width": 0.3,
"mappingInfo": [
{
"name": "Forest",
"color": "007000"
}
]
}
]
} }

View File

@@ -1,16 +1,24 @@
{ {
"width": 700, "width": 700,
"height": 700, "height": 700,
"playerStartPosY": 0.495,
"playerStartPosX": 0.5025, "playerStartPosX": 0.5025,
"noiseZoomBiome": 30, "playerStartPosY": 0.495,
"tileSize": 16, "noiseZoomBiome": 30,
"maxRoadDistance": 1000, "tileSize": 16,
"roadTileset":{ "roadTileset": {
"tilesetName":"Road", "tilesetAtlas": "world/tilesets/terrain.atlas",
"tilesetAtlas":"world/tilesets/terrain.atlas", "tilesetName": "Road",
"color": "ffffff" "color": "ffffff"
}, },
"biomesSprites":"world/sprites/map_sprites.json", "biomesSprites": "world/sprites/map_sprites.json",
"biomesNames": [ "world/base.json","world/waste.json","world/white.json","world/blue.json","world/black.json","world/red.json","world/green.json"] "maxRoadDistance": 1000,
"biomesNames": [
"world/base.json",
"world/waste.json",
"world/white.json",
"world/blue.json",
"world/black.json",
"world/red.json",
"world/green.json"
]
} }