public static void Main(string[] args) { // Create algorithm setup. var algorithmZoom1 = new RuntimeLayer(new AlgorithmZoom2D()); var algorithmZoom2 = new RuntimeLayer(new AlgorithmZoom2D()); var algorithmZoom3 = new RuntimeLayer(new AlgorithmZoom2D()); var algorithmZoom4 = new RuntimeLayer(new AlgorithmZoom2D()); var algorithmInitialLand = new RuntimeLayer(new AlgorithmInitialBool()); algorithmZoom4.SetInput(0, algorithmInitialLand); algorithmZoom3.SetInput(0, algorithmZoom4); algorithmZoom2.SetInput(0, algorithmZoom3); algorithmZoom1.SetInput(0, algorithmZoom2); StorageLayer[] storage = null; Console.WriteLine("Storing..."); using (var writer = new StreamWriter("WorldConfig.xml", false)) StorageAccess.SaveStorage( new StorageLayer[] { StorageAccess.FromRuntime(algorithmZoom1) }, writer); Console.WriteLine("Loading..."); using (var reader = new StreamReader("WorldConfig.xml")) storage = StorageAccess.LoadStorage(reader); foreach (var l in storage) { Console.WriteLine(l.Algorithm.GetType().FullName); } }
private void c_LoadConfigurationButton_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog() { Filter = "XML Files|*.xml", CheckFileExists = true, CheckPathExists = true }; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { StorageLayer[] layers; try { // Load from file. using (var stream = new StreamReader(openFileDialog.FileName)) layers = StorageAccess.LoadStorage(stream); if (layers == null) { MessageBox.Show(this, "Unable to load configuration file.", "Configuration invalid.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception ex) { MessageBox.Show(this, "Unable to load configuration file.", "Configuration invalid.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Reset state. this.c_FlowInterfaceControl.Elements.Clear(); this.c_FlowInterfaceControl.Invalidate(); this.m_LastSavePath = openFileDialog.FileName; this.c_SaveConfigurationButton.Enabled = true; // Create algorithm flow elements. this.c_FlowInterfaceControl.Elements.AddRange( layers.Where(v => v != null) .Select(v => new AlgorithmFlowElement(this.c_FlowInterfaceControl, v) { X = v.EditorX, Y = v.EditorY }) ); /*foreach (var el in layers) * { * el.SetDeserializationData(this.c_FlowInterfaceControl); * this.c_FlowInterfaceControl.Elements.Add(el); * } * foreach (FlowElement el in config) * this.c_FlowInterfaceControl.PushForReprocessing(el); * this.c_FlowInterfaceControl.Invalidate();*/ } }
private static RuntimeLayer CreateLayerFromConfig(string path, GenerationRequest request) { // Use StorageAccess to load reference to world generation. StorageLayer[] layers; using (var reader = new StreamReader(path)) layers = StorageAccess.LoadStorage(reader); foreach (var layer in layers) { if ((layer.Algorithm is AlgorithmResult) && (layer.Algorithm as AlgorithmResult).Name == request.LayerName && ((layer.Algorithm as AlgorithmResult).ShowInMakeMeAWorld || (layer.Algorithm as AlgorithmResult).PermitInMakeMeAWorld)) { return(StorageAccess.ToRuntime(layer)); } } return(null); }
static ChunkProvider() { // Use StorageAccess to load reference to world generation. StorageLayer[] layers; using (var reader = new StreamReader(WORLD_CONFIG_FILE)) layers = StorageAccess.LoadStorage(reader); foreach (var layer in layers) { if (layer.Algorithm is AlgorithmResult) { if ((layer.Algorithm as AlgorithmResult).DefaultForGame) { m_ResultLayer = StorageAccess.ToRuntime(layer); break; } } } }
private static string GetDefaultAvailableLayer(string path) { // Use StorageAccess to load reference to world generation. StorageLayer[] layers; using (var reader = new StreamReader(path)) layers = StorageAccess.LoadStorage(reader); foreach (var layer in layers) { if (layer.Algorithm is AlgorithmResult) { if ((layer.Algorithm as AlgorithmResult).DefaultForMakeMeAWorld) { return((layer.Algorithm.Is2DOnly ? "2D," : "3D,") + (layer.Algorithm as AlgorithmResult).Name); } } } return(null); }
private static List <string> GetListOfAvailableLayers(string path) { var result = new List <string>(); // Use StorageAccess to load reference to world generation. StorageLayer[] layers; using (var reader = new StreamReader(path)) layers = StorageAccess.LoadStorage(reader); foreach (var layer in layers) { if (layer.Algorithm is AlgorithmResult) { if ((layer.Algorithm as AlgorithmResult).ShowInMakeMeAWorld) { result.Add( (layer.Algorithm.Is2DOnly ? "2D," : "3D,") + (layer.Algorithm as AlgorithmResult).Name); } } } return(result); }