config saving, structure saving
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
48c5a3bcf3
commit
c18a7a0d8a
@ -1865,6 +1865,8 @@ Invert rotation calculation for fab cursor
|
|||||||
BlockFab io work
|
BlockFab io work
|
||||||
File dialog support
|
File dialog support
|
||||||
Editor structure tab uses file dialog to save fabs
|
Editor structure tab uses file dialog to save fabs
|
||||||
|
Config saving
|
||||||
|
Structure data saving
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import electrosphere.data.units.UnitDefinitionFile;
|
|||||||
import electrosphere.data.units.UnitLoader;
|
import electrosphere.data.units.UnitLoader;
|
||||||
import electrosphere.data.voxel.VoxelData;
|
import electrosphere.data.voxel.VoxelData;
|
||||||
import electrosphere.data.voxel.sampler.SamplerFile;
|
import electrosphere.data.voxel.sampler.SamplerFile;
|
||||||
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.net.config.NetConfig;
|
import electrosphere.net.config.NetConfig;
|
||||||
import electrosphere.server.macro.race.RaceMap;
|
import electrosphere.server.macro.race.RaceMap;
|
||||||
import electrosphere.server.macro.symbolism.SymbolMap;
|
import electrosphere.server.macro.symbolism.SymbolMap;
|
||||||
@ -155,6 +156,15 @@ public class Config {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves all edits made to the config
|
||||||
|
* @param config The config
|
||||||
|
*/
|
||||||
|
public static void save(Config config){
|
||||||
|
LoggerInterface.loggerFileIO.WARNING("Warning! Creatures, items, objects, voxels, blocks are all unsupported currently!");
|
||||||
|
config.structureData.save();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a child entity defintion file
|
* Reads a child entity defintion file
|
||||||
* @param filename The filename
|
* @param filename The filename
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
package electrosphere.data.struct;
|
package electrosphere.data.struct;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
@ -19,6 +21,11 @@ public class StructureDataLoader {
|
|||||||
*/
|
*/
|
||||||
Map<String,StructureData> idTypeMap = new HashMap<String,StructureData>();
|
Map<String,StructureData> idTypeMap = new HashMap<String,StructureData>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of java file object -> structure data file at that path
|
||||||
|
*/
|
||||||
|
Map<File,StructureDataFile> fileMap = new HashMap<File,StructureDataFile>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds structure data to the loader
|
* Adds structure data to the loader
|
||||||
* @param name The id of the structure
|
* @param name The id of the structure
|
||||||
@ -55,12 +62,14 @@ public class StructureDataLoader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a child structure defintion file
|
* Reads a child structure defintion file
|
||||||
|
* @param loader The loader that is loading all the files
|
||||||
* @param filename The filename
|
* @param filename The filename
|
||||||
* @return The list of structure in the file
|
* @return The list of structure in the file
|
||||||
*/
|
*/
|
||||||
static List<StructureData> recursiveReadStructureLoader(String filename){
|
static List<StructureData> recursiveReadStructureLoader(StructureDataLoader loader, String filename){
|
||||||
List<StructureData> typeList = new LinkedList<StructureData>();
|
List<StructureData> typeList = new LinkedList<StructureData>();
|
||||||
StructureDataFile loaderFile = FileUtils.loadObjectFromAssetPath(filename, StructureDataFile.class);
|
StructureDataFile loaderFile = FileUtils.loadObjectFromAssetPath(filename, StructureDataFile.class);
|
||||||
|
loader.fileMap.put(FileUtils.getAssetFile(filename),loaderFile);
|
||||||
//push the types from this file
|
//push the types from this file
|
||||||
for(StructureData type : loaderFile.getData()){
|
for(StructureData type : loaderFile.getData()){
|
||||||
typeList.add(type);
|
typeList.add(type);
|
||||||
@ -68,7 +77,7 @@ public class StructureDataLoader {
|
|||||||
//push types from any other files
|
//push types from any other files
|
||||||
if(loaderFile.getFiles() != null){
|
if(loaderFile.getFiles() != null){
|
||||||
for(String filepath : loaderFile.getFiles()){
|
for(String filepath : loaderFile.getFiles()){
|
||||||
List<StructureData> parsedTypeList = StructureDataLoader.recursiveReadStructureLoader(filepath);
|
List<StructureData> parsedTypeList = StructureDataLoader.recursiveReadStructureLoader(loader, filepath);
|
||||||
for(StructureData type : parsedTypeList){
|
for(StructureData type : parsedTypeList){
|
||||||
typeList.add(type);
|
typeList.add(type);
|
||||||
}
|
}
|
||||||
@ -84,11 +93,20 @@ public class StructureDataLoader {
|
|||||||
*/
|
*/
|
||||||
public static StructureDataLoader loadStructureFiles(String initialPath) {
|
public static StructureDataLoader loadStructureFiles(String initialPath) {
|
||||||
StructureDataLoader rVal = new StructureDataLoader();
|
StructureDataLoader rVal = new StructureDataLoader();
|
||||||
List<StructureData> typeList = StructureDataLoader.recursiveReadStructureLoader(initialPath);
|
List<StructureData> typeList = StructureDataLoader.recursiveReadStructureLoader(rVal, initialPath);
|
||||||
for(StructureData type : typeList){
|
for(StructureData type : typeList){
|
||||||
rVal.putType(type.getId(), type);
|
rVal.putType(type.getId(), type);
|
||||||
}
|
}
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the updated state of the loader
|
||||||
|
*/
|
||||||
|
public void save(){
|
||||||
|
for(Entry<File,StructureDataFile> pair : this.fileMap.entrySet()){
|
||||||
|
FileUtils.serializeObjectToFilePath(pair.getKey(), pair.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user