public override IList <ModelTreeNode> LoadTree(string path) { var directory = Path.GetDirectoryName(path); var folderTreeNode = new FolderTreeNode(); var shopPaths = Directory.EnumerateFiles(directory, "*.shop"); folderTreeNode.Text = directory; foreach (var filePath in shopPaths) { var json = File.ReadAllText(filePath); var item = JsonConvert.DeserializeObject <NpcShop>(json); item.Filename = Path.GetFileName(filePath); var node = new NpcShopTreeNode(item); folderTreeNode.Nodes.Add(node); } folderTreeNode.Expand(); return(new List <ModelTreeNode>() { folderTreeNode }); }
public override IList <ModelTreeNode> CreateTree() { var nodes = new List <ModelTreeNode>(1); var item = new NpcShop(); var node = new NpcShopTreeNode(item); nodes.Add(node); return(nodes); }
private List <ShopItem> getItemModels(NpcShopTreeNode root) { var result = new List <ShopItem>(); var itemNodes = root.ShopItemNodes.Nodes.Cast <ItemTreeNode>(); foreach (var itemNode in itemNodes) { var command = (ShopItem)itemNode.Model; command.RequiredItems.Clear(); var requiredItems = itemNode.RequiredItemsTreeNode.Nodes.Cast <RequiredItemTreeNode>() .Select(n => (RequiredItem)n.Model); command.RequiredItems.AddRange(requiredItems); result.Add(command); } return(result); }
public NpcShopTreeNode(NpcShopTreeNode other) { throw new NotImplementedException(); }