Exemplo n.º 1
0
 private void PatchForm_Load(object sender, EventArgs e)
 {
     tvPatch.Nodes.Clear();
     List<String> files = new List<String>(Directory.GetFiles("mge3", "*.mcp", SearchOption.AllDirectories));
     files.Add(patchSettings); // last of all
     foreach (String file in files) {
         INIFile mcpFile = new INIFile(file, new INIFile.INIVariableDef[] { INIFile.iniDefEmpty }, Encoding.Default);
         String[] sections = mcpFile.getSections();
         foreach (String Section in sections) {
             Patch patch = new Patch(mcpFile, Section);
             String[] parents = patch.Parent.Split(new String[] { Patch.SepInternal.ToString() }, StringSplitOptions.RemoveEmptyEntries);
             TreeNodeCollection nodes = tvPatch.Nodes;
             TreeNode[] exist;
             for (int i = 0; i < parents.Length; i++) {
                 exist = nodes.Find(parents[i].ToLower(), false);
                 if (exist.Length > 0) nodes = exist[0].Nodes;
                 else {
                     TreeNode node = nodes.Add(parents[i].ToLower(), parents[i]);
                     node.Checked = true;
                     nodes = node.Nodes;
                 }
             }
             exist = nodes.Find(Section.ToLower(), false);
             if (exist.Length > 0) {
                 Patch existing = (Patch)exist[0].Tag;
                 bool update = existing == null;
                 if (!update) {
                     if (patch.Version <= existing.Version) continue;
                     if (patch.Original == null && patch.Patched == null && patch.Attach == null) {
                         exist[0].Checked = existing.Checked = patch.Checked;
                         existing.Removed = patch.Removed || existing.Removed;
                         existing.Expanded = patch.Expanded;
                         continue;
                     }
                     update = true;
                 }
                 if (update) {
                     exist[0].Checked = patch.Checked;
                     exist[0].Tag = patch;
                     continue;
                 }
             } else {
                 TreeNode node = nodes.Add(Section.ToLower(), Section);
                 node.Tag = patch;
                 node.Checked = patch.Checked;
                 node.ToolTipText = "";
                 foreach(String language in Languages)
                     if (node.ToolTipText == "")
                         foreach(Unit description in patch.Description)
                             if (language == description.Name) { node.ToolTipText = description.Hex.Replace("\t", "\n"); break; }
             }
         }
     }
     RemoveEmptyNodes(tvPatch.Nodes);
     UpdateColour(tvPatch.Nodes, true);
     ExpandNodes(tvPatch.Nodes);
     tvPatch.Sort();
     loaded = true;
 }
Exemplo n.º 2
0
 private void bOpen_Click(object sender, EventArgs e)
 {
     RestoreButton();
     if (!SaveChanges(true)) return;
     if (openPatch.ShowDialog() != DialogResult.OK) return;
     INIFile mcpFile = new INIFile(openPatch.FileName, new INIFile.INIVariableDef[] { INIFile.iniDefEmpty }, Encoding.Default);
     String[] sections = mcpFile.getSections();
     if (sections.Length > 0) {
         selections.Sections.Clear();
         lbSections.Items.Clear();
     }
     foreach (String section in sections) {
         selections.Sections.Add(section, new Patch(mcpFile, section));
         lbSections.Items.Add(section);
     }
     propertyGrid.SelectedObject = null;
     currentState = 0;
     HistoryUpdate();
     savePatch.FileName = openPatch.FileName;
     DisableEditor();
 }