public Parse(ConfigSettings settings) { datasets = new List <TabDataset>(settings.sections.Count); foreach (ConfigSection section in settings.sections) { TabDataset dataset = new TabDataset(section.sectionName, section.start, section.end, section.hidden); if (section.items.Count != 0) { dataset.recordMarker = section.items[0].serializedName; foreach (ConfigItem item in section.items) { dataset.factory.add(item); } } datasets.Add(dataset); } raceIDs = new Dictionary <string, int>(); raceNames = new Dictionary <int, string>(); addRace("Human", 0); addRace("Hiver", 1); addRace("Tarkas", 2); addRace("Liir", 3); addRace("_NPC", 4); addRace("Zuul", 5); addRace("Morrigi", 6); }
public bool parseSOTS(byte[] binaryData) { clear(); data = binaryData; int rangeStart = 0; int rangeEnd = 0; for (int i = 0; i < datasets.Count; ++i) { TabDataset table = datasets[i]; if (table.factory.index == 0) { continue; } rangeStart = findBStr(table.sectionBegin, 0); if (table.sectionEnd != "") { rangeEnd = findBStr(table.sectionEnd, rangeStart); } else { rangeEnd = data.Length; } parseDataRegion(table.recordMarker, i, rangeStart, rangeEnd); } hack_postParse(); data = null; return(true); }
private void parseDataRegion(string recordStartMarker, int datasetIndex, int rangeStart, int rangeEnd) { TabDataset dataset = datasets[datasetIndex]; while (true) { rangeStart = findBStr(recordStartMarker, rangeStart, rangeEnd); if (rangeStart == -1) { break; } int tooFar = findBStr(recordStartMarker, rangeStart + 1, rangeEnd); if (tooFar == -1) { tooFar = rangeEnd; } parseSingleRecord(dataset.attributes, dataset.factory, dataset.data, ref rangeStart, tooFar); } }
private void refreshData() { foreach (TabItem item in mainTabs.Items) { stopEdit((DataGrid)item.Content); //f*****g WPF } mainTabs.Items.Clear(); int index = 0; for (int i = 0; i < parser.datasets.Count; ++i) { TabDataset dataset = parser.datasets[i]; if (dataset.hidden) { continue; } TabItem tab = new TabItem(); tab.Header = dataset.name; dataset.index = index++; DataGrid grid = new DataGrid(); grid.AddHandler(UIElement.LostFocusEvent, (RoutedEventHandler)lostFocus); //enables single click edit grid.AddHandler(UIElement.GotFocusEvent, (RoutedEventHandler)gotFocus); //enables single click edit grid.AddHandler(UIElement.PreviewKeyDownEvent, (RoutedEventHandler)keyDown); //enables Enter to commit edit, edit cell below grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; grid.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; grid.AutoGenerateColumns = false; //grid.Name = dataset.name; for (int j = 0; j < dataset.factory.index; ++j) { Attribute att = dataset.attributes[j]; if (att.hidden) { continue; } DataGridTextColumn col = new DataGridTextColumn(); col.Header = att.friendlyName; col.IsReadOnly = !att.editable; if (att.type == typeof(float)) { col.Binding = new Binding("floats[" + att.index.ToString() + "]"); } else if (att.type == typeof(int) || att.type == typeof(short) || att.type == typeof(char)) { col.Binding = new Binding("ints[" + att.index.ToString() + "]"); } else if (att.type == typeof(string)) { col.Binding = new Binding("strings[" + att.index.ToString() + "]"); } grid.Columns.Add(col); } grid.ItemsSource = dataset.data; tab.Content = grid; mainTabs.Items.Add(tab); } }
public HackInfo(TabDataset ds, Attribute att) { dataset = ds; attribute = att; }