World can be imported from JSON
At least for assets.
This commit is contained in:
parent
53bc93a15c
commit
e516770fca
@ -1,4 +1,4 @@
|
||||
#Wed, 05 Dec 2018 18:41:22 +0100
|
||||
#Wed, 05 Dec 2018 19:04:38 +0100
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.processors.list=
|
||||
|
@ -218,12 +218,12 @@ public class AssetEditorPanel extends javax.swing.JPanel {
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@Export
|
||||
public String getDeecimals() {
|
||||
@Export("decimals")
|
||||
public String getDecimals() {
|
||||
return decimalsField.getValue().toString();
|
||||
}
|
||||
|
||||
@Import
|
||||
@Import("decimals")
|
||||
public void setDecimals(String d) {
|
||||
decimalsField.setValue(Integer.parseInt(d));
|
||||
}
|
||||
@ -277,6 +277,8 @@ public class AssetEditorPanel extends javax.swing.JPanel {
|
||||
public boolean save(WorldAdm worldadm ){
|
||||
JSONObject jo = Json.get(this);
|
||||
|
||||
System.out.printf("ASSETGETTER: %s\n",jo.toString(5));
|
||||
|
||||
if (jo.getString(World.JKEYS.ASSET_SYMBOL).length()==0){
|
||||
javax.swing.JOptionPane.showMessageDialog(this, "Symbol must not be empty.",
|
||||
"Error",
|
||||
|
@ -178,10 +178,15 @@ public class AssetListDialog extends EscDialog {
|
||||
AssetEditorDialog.runDialog(this, worldadm, o, null);
|
||||
assetListPanel.reload();
|
||||
|
||||
|
||||
|
||||
}//GEN-LAST:event_newButtonActionPerformed
|
||||
|
||||
private void doneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doneButtonActionPerformed
|
||||
dispose();
|
||||
|
||||
JSONObject o = worldadm.world.getJson();
|
||||
Globals.prefs.put("world", o.toString());
|
||||
}//GEN-LAST:event_doneButtonActionPerformed
|
||||
|
||||
private void doEdit() {
|
||||
|
@ -91,8 +91,9 @@ public class SeSimApplication extends javax.swing.JFrame {
|
||||
// Globals.setLookAndFeel("Metal");
|
||||
initComponents();
|
||||
|
||||
|
||||
worldadm = new WorldAdm();
|
||||
JSONObject cfg;
|
||||
cfg = new JSONObject(Globals.prefs.get("world","{}"));
|
||||
worldadm = new WorldAdm(cfg);
|
||||
|
||||
|
||||
|
||||
|
@ -90,6 +90,9 @@ public class World implements GetJson {
|
||||
private void putJson(JSONObject cfg){
|
||||
// Read assets
|
||||
JSONArray jassets = cfg.optJSONArray(World.JKEYS.ASSETS);
|
||||
if (jassets==null){
|
||||
jassets=new JSONArray();
|
||||
}
|
||||
for (int i=0; i<jassets.length();i++) {
|
||||
JSONObject o = jassets.optJSONObject(i);
|
||||
AbstractAsset a;
|
||||
@ -117,8 +120,9 @@ public class World implements GetJson {
|
||||
}
|
||||
|
||||
private long masterkey;
|
||||
public World(long masterkey){
|
||||
public World(JSONObject cfg, long masterkey){
|
||||
this.masterkey=masterkey;
|
||||
putJson(cfg);
|
||||
}
|
||||
|
||||
private AbstractAsset createAsset_p(JSONObject cfg) throws SeSimException {
|
||||
|
@ -25,6 +25,8 @@
|
||||
*/
|
||||
package opensesim.world;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tohe
|
||||
@ -32,9 +34,9 @@ package opensesim.world;
|
||||
public class WorldAdm {
|
||||
public World world;
|
||||
public long masterKey;
|
||||
public WorldAdm(){
|
||||
public WorldAdm(JSONObject cfg){
|
||||
masterKey = 123456;
|
||||
world = new World(masterKey);
|
||||
world = new World(cfg,masterKey);
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
|
Loading…
Reference in New Issue
Block a user