mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
adventure Editor rework
This commit is contained in:
@@ -6,7 +6,7 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class BiomeEdit extends JComponent {
|
||||
public class BiomeEdit extends FormPanel {
|
||||
BiomeData currentData;
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
JComponent center=new JComponent() { };
|
||||
center.setLayout(new GridLayout(14,2));
|
||||
FormPanel center=new FormPanel() { };
|
||||
|
||||
center.add(new JLabel("startPointX:")); center.add(startPointX);
|
||||
center.add(new JLabel("startPointY:")); center.add(startPointY);
|
||||
center.add(new JLabel("noiseWeight:")); center.add(noiseWeight);
|
||||
center.add(new JLabel("distWeight:")); center.add(distWeight);
|
||||
center.add(new JLabel("name:")); center.add(name);
|
||||
center.add(new JLabel("tilesetAtlas:")); center.add(tilesetAtlas);
|
||||
center.add(new JLabel("tilesetName:")); center.add(tilesetName);
|
||||
center.add(new JLabel("width:")); center.add(width);
|
||||
center.add(new JLabel("height:")); center.add(height);
|
||||
center.add(new JLabel("spriteNames:")); center.add(spriteNames);
|
||||
center.add(new JLabel("enemies:")); center.add(enemies);
|
||||
center.add(new JLabel("pointsOfInterest:")); center.add(pointsOfInterest);
|
||||
center.add(new JLabel("color:")); center.add(color);
|
||||
center.add(new JLabel("terrain/structures:"));center.add(new JLabel(""));
|
||||
BoxLayout layout=new BoxLayout(this, BoxLayout.Y_AXIS);
|
||||
setLayout(layout);
|
||||
add(center,BorderLayout.NORTH);
|
||||
add(terrain,BorderLayout.CENTER);
|
||||
add(structures,BorderLayout.SOUTH);
|
||||
center.add("startPointX:",startPointX);
|
||||
center.add("startPointY:",startPointY);
|
||||
center.add("noiseWeight:",noiseWeight);
|
||||
center.add("distWeight:",distWeight);
|
||||
center.add("name:",name);
|
||||
center.add("tilesetAtlas:",tilesetAtlas);
|
||||
center.add("tilesetName:",tilesetName);
|
||||
center.add("width:",width);
|
||||
center.add("height:",height);
|
||||
center.add("spriteNames:",spriteNames);
|
||||
center.add("enemies:",enemies);
|
||||
center.add("pointsOfInterest:",pointsOfInterest);
|
||||
center.add("color:",color);
|
||||
center.add("terrain/structures:",new JLabel(""));
|
||||
|
||||
add(center);
|
||||
add(terrain);
|
||||
add(structures);
|
||||
|
||||
name.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();
|
||||
}
|
||||
|
||||
private void updateTerrain() {
|
||||
protected void updateTerrain() {
|
||||
if(currentData==null||updating)
|
||||
return;
|
||||
currentData.startPointX = (Float) startPointX.getValue();
|
||||
@@ -80,15 +78,15 @@ public class BiomeEdit extends JComponent {
|
||||
currentData.distWeight = (Float)distWeight.getValue();
|
||||
currentData.name = name.getText();
|
||||
currentData.tilesetAtlas = tilesetAtlas.edit.getText();
|
||||
currentData.tilesetName = tilesetName.getName();
|
||||
currentData.tilesetName = tilesetName.getText();
|
||||
currentData.terrain = terrain.getBiomeTerrainData();
|
||||
currentData.structures = structures.getBiomeStructureData();
|
||||
currentData.width = (Float) width.getValue();
|
||||
currentData.height = (Float) height.getValue();
|
||||
currentData.color = color.getText();
|
||||
currentData.spriteNames = spriteNames.getList();
|
||||
currentData.enemies = Arrays.asList(enemies.getList());
|
||||
currentData.pointsOfInterest = Arrays.asList(pointsOfInterest.getList());
|
||||
currentData.enemies = enemies.getList();
|
||||
currentData.pointsOfInterest = pointsOfInterest.getList();
|
||||
}
|
||||
|
||||
public void setCurrentBiome(BiomeData data)
|
||||
|
||||
@@ -18,8 +18,12 @@ public class BiomeStructureDataMappingEditor extends JComponent {
|
||||
public void setCurrent(BiomeStructureData data) {
|
||||
this.data=data;
|
||||
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]);
|
||||
|
||||
list.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
public BiomeStructureData.BiomeStructureDataMapping[] getCurrent()
|
||||
@@ -115,7 +119,7 @@ public class BiomeStructureDataMappingEditor extends JComponent {
|
||||
model.remove(selected);
|
||||
}
|
||||
|
||||
private class BiomeStructureDataMappingEdit extends JComponent{
|
||||
private class BiomeStructureDataMappingEdit extends FormPanel{
|
||||
BiomeStructureData.BiomeStructureDataMapping currentData;
|
||||
|
||||
|
||||
@@ -127,11 +131,10 @@ public class BiomeStructureDataMappingEditor extends JComponent {
|
||||
public BiomeStructureDataMappingEdit()
|
||||
{
|
||||
|
||||
setLayout(new GridLayout(3,2));
|
||||
|
||||
add(new JLabel("name:")); add(name);
|
||||
add(new JLabel("color:")); add(color);
|
||||
add(new JLabel("collision:")); add(collision);
|
||||
add("name:",name);
|
||||
add("color:",color);
|
||||
add("collision:",collision);
|
||||
|
||||
name.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeStructureDataMappingEdit.this.update()));
|
||||
color.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeStructureDataMappingEdit.this.update()));
|
||||
|
||||
@@ -9,7 +9,7 @@ import javax.swing.event.ChangeListener;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class BiomeStructureEdit extends JComponent {
|
||||
public class BiomeStructureEdit extends FormPanel {
|
||||
private boolean updating=false;
|
||||
BiomeStructureData currentData;
|
||||
BiomeData currentBiomeData;
|
||||
@@ -28,24 +28,22 @@ public class BiomeStructureEdit extends JComponent {
|
||||
public BiomeStructureDataMappingEditor data=new BiomeStructureDataMappingEditor();
|
||||
public BiomeStructureEdit()
|
||||
{
|
||||
JComponent center=new JComponent() { };
|
||||
center.setLayout(new GridLayout(11,2));
|
||||
FormPanel center=new FormPanel();
|
||||
|
||||
center.add(new JLabel("structureAtlasPath:")); center.add(structureAtlasPath);
|
||||
center.add(new JLabel("x:")); center.add(x);
|
||||
center.add(new JLabel("y:")); center.add(y);
|
||||
center.add(new JLabel("width:")); center.add(width);
|
||||
center.add(new JLabel("height:")); center.add(height);
|
||||
center.add(new JLabel("N:")); center.add(N);
|
||||
center.add(new JLabel("sourcePath:")); center.add(sourcePath);
|
||||
center.add(new JLabel("periodicInput:")); center.add(periodicInput);
|
||||
center.add(new JLabel("ground:")); center.add(ground);
|
||||
center.add(new JLabel("symmetry:")); center.add(symmetry);
|
||||
center.add(new JLabel("periodicOutput:")); center.add(periodicOutput);
|
||||
BorderLayout layout=new BorderLayout();
|
||||
setLayout(layout);
|
||||
add(center,BorderLayout.CENTER);
|
||||
add(data,BorderLayout.SOUTH);
|
||||
center.add("structureAtlasPath:",structureAtlasPath);
|
||||
center.add("x:",x);
|
||||
center.add("y:",y);
|
||||
center.add("width:",width);
|
||||
center.add("height:",height);
|
||||
center.add("N:",N);
|
||||
center.add("sourcePath:",sourcePath);
|
||||
center.add("periodicInput:",periodicInput);
|
||||
center.add("ground:",ground);
|
||||
center.add("symmetry:",symmetry);
|
||||
center.add("periodicOutput:",periodicOutput);
|
||||
|
||||
add(center);
|
||||
add(data);
|
||||
|
||||
structureAtlasPath.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeStructureEdit.this.updateStructure()));
|
||||
|
||||
@@ -68,6 +66,7 @@ public class BiomeStructureEdit extends JComponent {
|
||||
setEnabled(currentData!=null);
|
||||
if(currentData==null)
|
||||
{
|
||||
data.setCurrent(null);
|
||||
return;
|
||||
}
|
||||
updating=true;
|
||||
@@ -85,6 +84,9 @@ public class BiomeStructureEdit extends JComponent {
|
||||
periodicOutput.setSelected(currentData.periodicOutput);
|
||||
|
||||
data.setCurrent(currentData);
|
||||
|
||||
|
||||
|
||||
updating=false;
|
||||
}
|
||||
public void updateStructure()
|
||||
|
||||
@@ -8,7 +8,7 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.*;
|
||||
|
||||
public class BiomeTerrainEdit extends JComponent {
|
||||
public class BiomeTerrainEdit extends FormPanel {
|
||||
SwingAtlasPreview preview=new SwingAtlasPreview(128);
|
||||
private boolean updating=false;
|
||||
BiomeTerrainData currentData;
|
||||
@@ -20,17 +20,13 @@ public class BiomeTerrainEdit extends JComponent {
|
||||
|
||||
public BiomeTerrainEdit()
|
||||
{
|
||||
JComponent center=new JComponent() { };
|
||||
center.setLayout(new GridLayout(4,2));
|
||||
FormPanel center=new FormPanel() { };
|
||||
|
||||
center.add(new JLabel("spriteName:")); center.add(spriteName);
|
||||
center.add(new JLabel("min:")); center.add(min);
|
||||
center.add(new JLabel("max:")); center.add(max);
|
||||
center.add(new JLabel("resolution:")); center.add(resolution);
|
||||
BorderLayout layout=new BorderLayout();
|
||||
setLayout(layout);
|
||||
add(preview,BorderLayout.WEST);
|
||||
add(center,BorderLayout.CENTER);
|
||||
center.add("spriteName:",spriteName);
|
||||
center.add("min:",min);
|
||||
center.add("max:",max);
|
||||
center.add("resolution:",resolution);
|
||||
add(center,preview);
|
||||
|
||||
spriteName.getDocument().addDocumentListener(new DocumentChangeListener(() -> BiomeTerrainEdit.this.updateTerrain()));
|
||||
|
||||
|
||||
@@ -25,16 +25,15 @@ public class EffectEditor extends JComponent {
|
||||
if(!isOpponentEffect)
|
||||
opponent=new EffectEditor(true);
|
||||
setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
|
||||
JPanel parameters=new JPanel();
|
||||
FormPanel parameters=new FormPanel();
|
||||
parameters.setBorder(BorderFactory.createTitledBorder("Effect"));
|
||||
parameters.setLayout(new GridLayout(7,2)) ;
|
||||
|
||||
parameters.add(new JLabel("Name:")); parameters.add(name);
|
||||
parameters.add(new JLabel("Start with extra cards:")); parameters.add(changeStartCards);
|
||||
parameters.add(new JLabel("Change life:")); parameters.add(lifeModifier);
|
||||
parameters.add(new JLabel("Movement speed:")); parameters.add(moveSpeed);
|
||||
parameters.add(new JLabel("Start battle with cards:")); parameters.add(startBattleWithCard);
|
||||
parameters.add(new JLabel("color view:")); parameters.add(colorView);
|
||||
parameters.add("Name:", name);
|
||||
parameters.add("Start with extra cards:", changeStartCards);
|
||||
parameters.add("Change life:", lifeModifier);
|
||||
parameters.add("Movement speed:", moveSpeed);
|
||||
parameters.add("Start battle with cards:", startBattleWithCard);
|
||||
parameters.add("color view:", colorView);
|
||||
add(parameters);
|
||||
if(!isOpponentEffect)
|
||||
{ add(new JLabel("Opponent:")); add(opponent);}
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.awt.*;
|
||||
/**
|
||||
* Editor class to edit configuration, maybe moved or removed
|
||||
*/
|
||||
public class EnemyEdit extends JComponent {
|
||||
public class EnemyEdit extends FormPanel {
|
||||
EnemyData currentData;
|
||||
JTextField nameField=new JTextField();
|
||||
JTextField colorField=new JTextField();
|
||||
@@ -26,23 +26,20 @@ public class EnemyEdit extends JComponent {
|
||||
public EnemyEdit()
|
||||
{
|
||||
|
||||
JComponent center=new JComponent() { };
|
||||
center.setLayout(new GridLayout(9,2));
|
||||
FormPanel center=new FormPanel() { };
|
||||
|
||||
center.add(new JLabel("Name:")); center.add(nameField);
|
||||
center.add(new JLabel("Life:")); center.add(lifeFiled);
|
||||
center.add(new JLabel("Spawn rate:")); center.add(spawnRate);
|
||||
center.add(new JLabel("Difficulty:")); center.add(difficulty);
|
||||
center.add(new JLabel("Speed:")); center.add(speed);
|
||||
center.add(new JLabel("Deck:")); center.add(deck);
|
||||
center.add(new JLabel("Sprite:")); center.add(atlas);
|
||||
center.add(new JLabel("Equipment:")); center.add(equipment);
|
||||
center.add(new JLabel("Colors:")); center.add(colorField);
|
||||
BorderLayout layout=new BorderLayout();
|
||||
setLayout(layout);
|
||||
add(center,BorderLayout.PAGE_START);
|
||||
add(rewards,BorderLayout.CENTER);
|
||||
add(preview,BorderLayout.LINE_START);
|
||||
center.add("Name:",nameField);
|
||||
center.add("Life:",lifeFiled);
|
||||
center.add("Spawn rate:",spawnRate);
|
||||
center.add("Difficulty:",difficulty);
|
||||
center.add("Speed:",speed);
|
||||
center.add("Deck:",deck);
|
||||
center.add("Sprite:",atlas);
|
||||
center.add("Equipment:",equipment);
|
||||
center.add("Colors:",colorField);
|
||||
add(center);
|
||||
add(rewards);
|
||||
add(preview);
|
||||
|
||||
equipment.getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy()));
|
||||
atlas.getEdit().getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy()));
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,20 +24,18 @@ public class ItemEdit extends JComponent {
|
||||
{
|
||||
|
||||
setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
|
||||
JPanel parameters=new JPanel();
|
||||
FormPanel parameters=new FormPanel();
|
||||
parameters.setBorder(BorderFactory.createTitledBorder("Parameter"));
|
||||
parameters.setLayout(new GridLayout(6,2)) ;
|
||||
|
||||
parameters.add(new JLabel("Name:")); parameters.add(nameField);
|
||||
parameters.add(new JLabel("equipmentSlot:")); parameters.add(equipmentSlot);
|
||||
parameters.add(new JLabel("description:")); parameters.add(description);
|
||||
parameters.add(new JLabel("iconName")); parameters.add(iconName);
|
||||
parameters.add(new JLabel("questItem")); parameters.add(questItem);
|
||||
parameters.add(new JLabel("cost")); parameters.add(cost);
|
||||
parameters.add("Name:",nameField);
|
||||
parameters.add("equipmentSlot:",equipmentSlot);
|
||||
parameters.add("description:",description);
|
||||
parameters.add("iconName",iconName);
|
||||
parameters.add("questItem",questItem);
|
||||
parameters.add("cost",cost);
|
||||
|
||||
add(parameters);
|
||||
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()));
|
||||
equipmentSlot.getDocument().addDocumentListener(new DocumentChangeListener(() -> ItemEdit.this.updateItem()));
|
||||
|
||||
@@ -25,20 +25,18 @@ public class PointOfInterestEdit extends JComponent {
|
||||
{
|
||||
|
||||
setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
|
||||
JPanel parameters=new JPanel();
|
||||
FormPanel parameters=new FormPanel();
|
||||
parameters.setBorder(BorderFactory.createTitledBorder("Parameter"));
|
||||
parameters.setLayout(new GridLayout(7,2)) ;
|
||||
|
||||
parameters.add(new JLabel("Name:")); parameters.add(name);
|
||||
parameters.add(new JLabel("Type:")); parameters.add(type);
|
||||
parameters.add(new JLabel("Count:")); parameters.add(count);
|
||||
parameters.add(new JLabel("Sprite atlas:")); parameters.add(spriteAtlas);
|
||||
parameters.add(new JLabel("Sprite:")); parameters.add(sprite);
|
||||
parameters.add(new JLabel("Map:")); parameters.add(map);
|
||||
parameters.add(new JLabel("Radius factor:")); parameters.add(radiusFactor);
|
||||
parameters.add("Name:",name);
|
||||
parameters.add("Type:",type);
|
||||
parameters.add("Count:",count);
|
||||
parameters.add("Sprite atlas:",spriteAtlas);
|
||||
parameters.add("Sprite:",sprite);
|
||||
parameters.add("Map:",map);
|
||||
parameters.add("Radius factor:",radiusFactor);
|
||||
|
||||
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()));
|
||||
type.getDocument().addDocumentListener(new DocumentChangeListener(() -> PointOfInterestEdit.this.updateItem()));
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Arrays;
|
||||
/**
|
||||
* Editor class to edit configuration, maybe moved or removed
|
||||
*/
|
||||
public class RewardEdit extends JComponent {
|
||||
public class RewardEdit extends FormPanel {
|
||||
RewardData currentData;
|
||||
|
||||
JComboBox typeField =new JComboBox(new String[] { "card", "gold", "life", "deckCard", "item"});
|
||||
@@ -36,24 +36,23 @@ public class RewardEdit extends JComponent {
|
||||
|
||||
public RewardEdit()
|
||||
{
|
||||
setLayout(new GridLayout(16,2));
|
||||
|
||||
add(new JLabel("Type:")); add(typeField);
|
||||
add(new JLabel("probability:")); add(probability);
|
||||
add(new JLabel("count:")); add(count);
|
||||
add(new JLabel("addMaxCount:")); add(addMaxCount);
|
||||
add(new JLabel("cardName:")); add(cardName);
|
||||
add(new JLabel("itemName:")); add(itemName);
|
||||
add(new JLabel("editions:")); add(editions);
|
||||
add(new JLabel("colors:")); add(colors);
|
||||
add(new JLabel("rarity:")); add(rarity);
|
||||
add(new JLabel("subTypes:")); add(subTypes);
|
||||
add(new JLabel("cardTypes:")); add(cardTypes);
|
||||
add(new JLabel("superTypes:")); add(superTypes);
|
||||
add(new JLabel("manaCosts:")); add(manaCosts);
|
||||
add(new JLabel("keyWords:")); add(keyWords);
|
||||
add(new JLabel("colorType:")); add(colorType);
|
||||
add(new JLabel("cardText:")); add(cardText);
|
||||
add("Type:",typeField);
|
||||
add("probability:",probability);
|
||||
add("count:",count);
|
||||
add("addMaxCount:",addMaxCount);
|
||||
add("cardName:",cardName);
|
||||
add("itemName:",itemName);
|
||||
add("editions:",editions);
|
||||
add("colors:",colors);
|
||||
add("rarity:",rarity);
|
||||
add("subTypes:",subTypes);
|
||||
add("cardTypes:",cardTypes);
|
||||
add("superTypes:",superTypes);
|
||||
add("manaCosts:",manaCosts);
|
||||
add("keyWords:",keyWords);
|
||||
add("colorType:",colorType);
|
||||
add("cardText:",cardText);
|
||||
|
||||
|
||||
typeField.addActionListener((e -> RewardEdit.this.updateReward()));
|
||||
|
||||
@@ -153,7 +153,10 @@ public class StructureEditor extends JComponent{
|
||||
currentData=data;
|
||||
model.clear();
|
||||
if(data==null||data.structures==null)
|
||||
{
|
||||
edit.setCurrentStructure(null,null);
|
||||
return;
|
||||
}
|
||||
for (int i=0;i<data.structures.length;i++) {
|
||||
model.add(i,data.structures[i]);
|
||||
}
|
||||
|
||||
@@ -92,31 +92,23 @@ public class WorldEditor extends JComponent {
|
||||
BorderLayout layout = new BorderLayout();
|
||||
setLayout(layout);
|
||||
add(tabs);
|
||||
JPanel worldPanel=new JPanel();
|
||||
JSplitPane biomeData=new JSplitPane();
|
||||
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);
|
||||
|
||||
|
||||
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);
|
||||
biomeData.setLeftComponent(list); biomeData.setRightComponent(pane);
|
||||
|
||||
@@ -126,6 +118,10 @@ public class WorldEditor extends JComponent {
|
||||
add(toolBar, BorderLayout.PAGE_START);
|
||||
JButton newButton=new JButton("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);
|
||||
|
||||
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()
|
||||
{
|
||||
currentData.width=width.intValue();
|
||||
@@ -175,11 +180,11 @@ public class WorldEditor extends JComponent {
|
||||
currentData.tileSize=tileSize.intValue();
|
||||
currentData.biomesSprites=biomesSprites.getText();
|
||||
currentData.maxRoadDistance=maxRoadDistance.floatValue();
|
||||
currentData.biomesNames= Arrays.asList(biomesNames.getList());
|
||||
currentData.biomesNames= (biomesNames.getList());
|
||||
|
||||
Json json = new Json(JsonWriter.OutputType.json);
|
||||
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()
|
||||
|
||||
@@ -28,8 +28,8 @@ public class BiomeData implements Serializable {
|
||||
public String color;
|
||||
public boolean invertHeight;
|
||||
public String[] spriteNames;
|
||||
public List<String> enemies;
|
||||
public List<String> pointsOfInterest;
|
||||
public String[] enemies;
|
||||
public String[] pointsOfInterest;
|
||||
public BiomeStructureData[] structures;
|
||||
|
||||
private ArrayList<EnemyData> enemyList;
|
||||
@@ -46,8 +46,13 @@ public class BiomeData implements Serializable {
|
||||
if (enemies == null)
|
||||
return enemyList;
|
||||
for (EnemyData data : new Array.ArrayIterator<>(WorldData.getAllEnemies())) {
|
||||
if (enemies.contains(data.name)) {
|
||||
for (String enemyName:enemies)
|
||||
{
|
||||
if(data.name.equals(enemyName))
|
||||
{
|
||||
enemyList.add(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,8 +66,13 @@ public class BiomeData implements Serializable {
|
||||
return pointOfInterestList;
|
||||
Array<PointOfInterestData> allTowns = PointOfInterestData.getAllPointOfInterest();
|
||||
for (PointOfInterestData data : new Array.ArrayIterator<>(allTowns)) {
|
||||
if (pointsOfInterest.contains(data.name)) {
|
||||
for (String poiName:pointsOfInterest)
|
||||
{
|
||||
if(data.name.equals(poiName))
|
||||
{
|
||||
pointOfInterestList.add(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class WorldData implements Serializable {
|
||||
public BiomeData roadTileset;
|
||||
public String biomesSprites;
|
||||
public float maxRoadDistance;
|
||||
public List<String> biomesNames;
|
||||
public String[] biomesNames;
|
||||
|
||||
|
||||
private BiomeSprites sprites;
|
||||
|
||||
@@ -1,52 +1,108 @@
|
||||
{
|
||||
"startPointX": 0.22,
|
||||
"startPointY": 0.43,
|
||||
"name": "green",
|
||||
"noiseWeight": 0.5,
|
||||
"distWeight": 1.5,
|
||||
"tilesetName":"Green",
|
||||
"tilesetAtlas":"world/tilesets/terrain.atlas",
|
||||
"terrain":[
|
||||
"startPointX": 0.22,
|
||||
"startPointY": 0.43,
|
||||
"noiseWeight": 0.5,
|
||||
"distWeight": 1.5,
|
||||
"name": "green",
|
||||
"tilesetAtlas": "world/tilesets/terrain.atlas",
|
||||
"tilesetName": "Green",
|
||||
"terrain": [
|
||||
{
|
||||
"spriteName":"Green_1",
|
||||
"min": 0,
|
||||
"spriteName": "Green_1",
|
||||
"max": 0.2,
|
||||
"resolution": 10
|
||||
},{
|
||||
"spriteName":"Green_2",
|
||||
},
|
||||
{
|
||||
"spriteName": "Green_2",
|
||||
"min": 0.8,
|
||||
"max": 1.0,
|
||||
"max": 1,
|
||||
"resolution": 10
|
||||
}
|
||||
],
|
||||
"structures":[
|
||||
{
|
||||
"sourcePath" : "world/tilesets/forestSource.png",
|
||||
"structureAtlasPath":"world/tilesets/structures.atlas",
|
||||
"mappingInfo":[
|
||||
{
|
||||
"name":"Forest",
|
||||
"color":"007000"
|
||||
}
|
||||
],
|
||||
"x": 0.5,
|
||||
"y": 0.5,
|
||||
"width": 0.3 ,
|
||||
"height": 0.3
|
||||
}
|
||||
],
|
||||
"width": 0.7,
|
||||
"height": 0.7,
|
||||
"color": "59a650",
|
||||
"spriteNames":[ "WoodTree","WoodTree2","Bush","Stump","Moss","Stone","Flower","Wood"] ,
|
||||
"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" ] ,
|
||||
"pointsOfInterest":[
|
||||
],
|
||||
"width": 0.7,
|
||||
"height": 0.7,
|
||||
"color": "59a650",
|
||||
"spriteNames": [
|
||||
"WoodTree",
|
||||
"WoodTree2",
|
||||
"Bush",
|
||||
"Stump",
|
||||
"Moss",
|
||||
"Stone",
|
||||
"Flower",
|
||||
"Wood"
|
||||
],
|
||||
"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"
|
||||
],
|
||||
"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"
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,16 +1,24 @@
|
||||
{
|
||||
"width": 700,
|
||||
"height": 700,
|
||||
"playerStartPosY": 0.495,
|
||||
"playerStartPosX": 0.5025,
|
||||
"playerStartPosY": 0.495,
|
||||
"noiseZoomBiome": 30,
|
||||
"tileSize": 16,
|
||||
"maxRoadDistance": 1000,
|
||||
"roadTileset":{
|
||||
"tilesetName":"Road",
|
||||
"tilesetAtlas":"world/tilesets/terrain.atlas",
|
||||
"roadTileset": {
|
||||
"tilesetAtlas": "world/tilesets/terrain.atlas",
|
||||
"tilesetName": "Road",
|
||||
"color": "ffffff"
|
||||
},
|
||||
"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"]
|
||||
"biomesSprites": "world/sprites/map_sprites.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"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user