public MainWindow(NPCList list) { MoveBothWindows = true; InitializeComponent(); PopulateRoomComboBox(); npcList = list; PopulateNPCComboBox(); PopulateAnimationsComboBox(); }
private void LoadNPCList() { XmlSerializer serializer = new XmlSerializer(typeof(NPCList)); using (FileStream fileStream = new FileStream(RMFiles.NPCLIST, FileMode.Open)) { npcList = (NPCList)serializer.Deserialize(fileStream); } npcList.setNPCIndexes(); }
private bool LoadSOBJL(NPCList npcList, string sobjlToLoad, ObservableCollection <NPC> usingNPCs, string roomID) { // If there is no NPC List to load, setup a default list and return if (!File.Exists(sobjlToLoad)) { var defaultNPCs = npcList.NPCs.Where(x => x.DefaultRooms.Contains(roomID)); foreach (NPC defaultNPC in defaultNPCs) { usingNPCs.Add(defaultNPC); } return(false); } using (BinaryReader reader = new BinaryReader(File.Open(sobjlToLoad, FileMode.Open))) { reader.BaseStream.Position = RMOffsets.SOBJL_COUNT; uint npcCount = reader.ReadUInt32(); for (int i = 0; i < npcCount; i++) { reader.BaseStream.Position = RMOffsets.SOBJL_NPC_START + RMOffsets.SOBJL_NPC_FILE + (i * RMOffsets.SOBJL_NPC_SIZE); int npcIndex = int.Parse(new string(reader.ReadChars(3))); //usingNPCs.Add(npcList.NPCs[npcIndex - 1]); // Needs optimization, too lazy to look up the proper way bool found = false; for (int j = 0; j < npcList.NPCs.Count; j++) { if (npcList.NPCs[j].Index == npcIndex) { usingNPCs.Add(npcList.NPCs[j]); found = true; } } if (found == false) { MessageBox.Show($"Couldn't parse index {npcIndex}", "Parsing error", MessageBoxButton.OK, MessageBoxImage.Error); } } } return(true); }
public EditRoomsWindow(NPCList npcList) { InitializeComponent(); MoveBothWindows = true; usingLivingNPCs = new ObservableCollection <NPC>(); usingPrivateNPCs = new ObservableCollection <NPC>(); usingSuiteNPCs = new ObservableCollection <NPC>(); usingResearchBaseNPCs = new ObservableCollection <NPC>(); usingSelianaSuiteNPCs = new ObservableCollection <NPC>(); usingSelianaPubNPCs = new ObservableCollection <NPC>(); usingSelianaNPCs = new ObservableCollection <NPC>(); usingAsteraNPCs = new ObservableCollection <NPC>(); NPCs_Available_Living.ItemsSource = npcList.NPCs.Where(x => !x.Warning.Equals("Ignore")); NPCs_Available_Private.ItemsSource = npcList.NPCs.Where(x => !x.Warning.Equals("Ignore")); NPCs_Available_Suite.ItemsSource = npcList.NPCs.Where(x => !x.Warning.Equals("Ignore")); NPCs_Available_ResearchBase.ItemsSource = npcList.NPCs.Where(x => !x.Warning.Equals("Ignore")); NPCs_Available_SelianaSuite.ItemsSource = npcList.NPCs.Where(x => !x.Warning.Equals("Ignore")); NPCs_Available_SelianaPub.ItemsSource = npcList.NPCs.Where(x => !x.Warning.Equals("Ignore")); NPCs_Available_Seliana.ItemsSource = npcList.NPCs.Where(x => !x.Warning.Equals("Ignore")); NPCs_Available_Astera.ItemsSource = npcList.NPCs.Where(x => !x.Warning.Equals("Ignore")); NPCs_Using_Living.ItemsSource = usingLivingNPCs; NPCs_Using_Private.ItemsSource = usingPrivateNPCs; NPCs_Using_Suite.ItemsSource = usingSuiteNPCs; NPCs_Using_ResearchBase.ItemsSource = usingResearchBaseNPCs; NPCs_Using_SelianaSuite.ItemsSource = usingSelianaSuiteNPCs; NPCs_Using_SelianaPub.ItemsSource = usingSelianaPubNPCs; NPCs_Using_Seliana.ItemsSource = usingSelianaNPCs; NPCs_Using_Astera.ItemsSource = usingAsteraNPCs; NPCs_Using_Living.Items.SortDescriptions.Add(new SortDescription("Index", ListSortDirection.Ascending)); NPCs_Using_Private.Items.SortDescriptions.Add(new SortDescription("Index", ListSortDirection.Ascending)); NPCs_Using_Suite.Items.SortDescriptions.Add(new SortDescription("Index", ListSortDirection.Ascending)); NPCs_Using_ResearchBase.Items.SortDescriptions.Add(new SortDescription("Index", ListSortDirection.Ascending)); NPCs_Using_SelianaSuite.Items.SortDescriptions.Add(new SortDescription("Index", ListSortDirection.Ascending)); NPCs_Using_SelianaPub.Items.SortDescriptions.Add(new SortDescription("Index", ListSortDirection.Ascending)); NPCs_Using_Seliana.Items.SortDescriptions.Add(new SortDescription("Index", ListSortDirection.Ascending)); NPCs_Using_Astera.Items.SortDescriptions.Add(new SortDescription("Index", ListSortDirection.Ascending)); if (LoadSOBJL(npcList, LIVING_QUARTERS.SOBJPaths[0], usingLivingNPCs, "501")) { Button_Delete_Living.IsEnabled = true; } if (LoadSOBJL(npcList, PRIVATE_QUARTERS.SOBJPaths[0], usingPrivateNPCs, "502")) { Button_Delete_Private.IsEnabled = true; } if (LoadSOBJL(npcList, PRIVATE_SUITE.SOBJPaths[0], usingSuiteNPCs, "503")) { Button_Delete_Suite.IsEnabled = true; } if (LoadSOBJL(npcList, RESEARCH_BASE.SOBJPaths[1], usingResearchBaseNPCs, "303")) { Button_Delete_ResearchBase.IsEnabled = true; } if (LoadSOBJL(npcList, SELIANA_SUITE.SOBJPaths[0], usingSelianaSuiteNPCs, "506")) { Button_Delete_SelianaSuite.IsEnabled = true; } if (LoadSOBJL(npcList, SELIANA_PUB.SOBJPaths[0], usingSelianaPubNPCs, "306")) { Button_Delete_SelianaPub.IsEnabled = true; } if (LoadSOBJL(npcList, SELIANA.SOBJPaths[0], usingSelianaNPCs, "305")) { Button_Delete_Seliana.IsEnabled = true; } if (LoadSOBJL(npcList, ASTERA.SOBJPaths[0], usingAsteraNPCs, "301")) { Button_Delete_Astera.IsEnabled = true; } selectedRoom = LIVING_QUARTERS; selectedList = usingLivingNPCs; }