void AddBlock(string blockName, int templateIndex) { Template.Block templateBlock = Helper.Template.Data.Files[Data.TemplateIndex].Blocks.Values[templateIndex]; //add options to new block EditorINIBlock editorBlock = new EditorINIBlock(blockName, templateIndex); for (int i = 0; i < templateBlock.Options.Count; ++i) { Template.Option option = templateBlock.Options[i]; editorBlock.Options.Add(new EditorINIOption(option.Name, i)); if (templateBlock.Identifier != null && templateBlock.Identifier.Equals(editorBlock.Options[editorBlock.Options.Count - 1].Name, StringComparison.OrdinalIgnoreCase)) { editorBlock.MainOptionIndex = editorBlock.Options.Count - 1; editorBlock.Options[editorBlock.Options.Count - 1].Values.Add(new EditorINIEntry(blockName)); } } //add actual block AddBlocks(new List <TableBlock> { new TableBlock(GetNewBlockId(), Data.MaxId++, editorBlock, Data.TemplateIndex) }); }
public PropertyBlock(EditorINIBlock block, Template.Block templateBlock) { foreach (EditorINIOption option in block.Options) { List.Add(new PropertyOption(option.Values, templateBlock.Options[option.TemplateIndex], option.ChildTemplateIndex != -1)); } // show comments List.Add(new PropertyOption("comments", block.Comments)); }
string GetTitle(EditorINIBlock block) { if (block.Options.Count > block.MainOptionIndex) { if (block.Options[block.MainOptionIndex].Values.Count > 0) { return(block.Options[block.MainOptionIndex].Values[0].Value.ToString()); } } return(block.Name); }
public static ArchetypeInfo GetModelPreviewInfo(EditorINIBlock block) { foreach (EditorINIOption option in block.Options) { if (option.Values.Count > 0) { switch (option.Name.ToLowerInvariant()) { case "da_archetype": return(new ArchetypeInfo { Type = ContentType.ModelPreview, ModelPath = option.Values[0].Value.ToString() }); } } } return(null); }
public TableBlock(int id, EditorINIBlock block, int templateIndex) { ID = id; ObjectType = ContentType.None; //name of block if (block.MainOptionIndex > -1 && block.Options.Count >= block.MainOptionIndex + 1) { if (block.Options[block.MainOptionIndex].Values.Count > 0) { Name = block.Options[block.MainOptionIndex].Values[0].Value.ToString(); } else { Name = block.Name; } } else { //if (Helper.Template.Data.Files[Data.TemplateIndex].Blocks[block.TemplateIndex].Multiple) // blockName = blockName + i.ToString(); //else Name = block.Name; //todo: different block name if they are all the same } //name of group if (Helper.Template.Data.Files[templateIndex].Blocks[block.TemplateIndex].Multiple) { Group = block.Name; } else { Group = "General"; } Block = block; }
public TableBlock(int index, int id, EditorINIBlock block, int templateIndex) { Index = index; Id = id; //name of block if (block.MainOptionIndex > -1 && block.Options.Count >= block.MainOptionIndex + 1) { if (block.Options[block.MainOptionIndex].Values.Count > 0) { Name = block.Options[block.MainOptionIndex].Values[0].Value.ToString(); } else { Name = block.Name; } } else { //if (Helper.Template.Data.Files[Data.TemplateIndex].Blocks[block.TemplateIndex].Multiple) // blockName = blockName + i.ToString(); //else Name = block.Name; //todo: different block name if they are all the same } //name of group if (Helper.Template.Data.Files[templateIndex].Blocks.Values[block.TemplateIndex].Multiple) { Group = block.Name; } else { Group = Strings.FileDefaultCategory; } Block = block; }
public static KeyValuePair <string, ArchetypeInfo> GetArchetypeInfo(EditorINIBlock block) { if (block.Name.Equals("solar", StringComparison.OrdinalIgnoreCase)) { ContentType type = ContentType.None; string name = null; double radius = 0d; string cmpFile = null; foreach (EditorINIOption option in block.Options) { if (option.Values.Count > 0) { switch (option.Name.ToLowerInvariant()) { case "nickname": name = option.Values[0].Value.ToString(); break; case "solar_radius": radius = Parser.ParseDouble(option.Values[0].Value.ToString(), 1); break; case "type": type = ParseContentType(option.Values[0].Value.ToString()); break; case "da_archetype": cmpFile = option.Values[0].Value.ToString(); break; } } } if (name != null) { if (type == ContentType.Planet || type == ContentType.Sun) { //save radius only for planets and suns if (radius != 0.0) { return(new KeyValuePair <string, ArchetypeInfo>(name, new ArchetypeInfo { Type = type, Radius = radius })); } } else if (type != ContentType.None && cmpFile != null) { //save model path only for supported objects (not planets and suns) return(new KeyValuePair <string, ArchetypeInfo>(name, new ArchetypeInfo { Type = type, ModelPath = cmpFile })); } } } return(new KeyValuePair <string, ArchetypeInfo>(null, null)); }