private void SaveEditor_Shown(object sender, EventArgs e)
 {
     SuspendUpdate.Suspend(this);
     UpdateInfo();
     SuspendUpdate.Resume(this);
     txtFilter.Text = currentFilter;
     txtFilter_TextChanged(this, null);
 }
        private void txtFilter_TextChanged(object sender, EventArgs e)
        {
            SuspendUpdate.Suspend(this);
            currentFilter = txtFilter.Text;
            string[] filters = null;
            if (!string.IsNullOrEmpty(currentFilter))
            {
                filters = currentFilter.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            }

            treeObjects.SuspendLayout();
            treeObjects.Nodes.Clear();

            for (int i = 0; i < allNodes.Count; i++)
            {
                TreeNode node = allNodes[i];
                TreeNode copy = new TreeNode(node.Text);

                bool addedParent = false;
                if (filters != null && filters.Length > 0)
                {
                    for (int k = 0; k < filters.Length; k++)
                    {
                        if (node.Text.IndexOf(filters[k], StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            addedParent = true;
                            break;
                        }
                    }
                }

                bool addedChild = false;
                for (int j = 0; j < node.Nodes.Count; j++)
                {
                    TreeNode child = node.Nodes[j];

                    bool shouldAdd = addedParent || filters == null || filters.Length == 0;
                    if (!shouldAdd)
                    {
                        for (int k = 0; k < filters.Length; k++)
                        {
                            if (child.Text.IndexOf(filters[k], StringComparison.OrdinalIgnoreCase) >= 0)
                            {
                                shouldAdd = true;
                                break;
                            }
                        }
                    }

                    if (shouldAdd)
                    {
                        addedChild = true;
                        copy.Nodes.Add(child);
                    }
                }

                if (addedChild || addedParent)
                {
                    treeObjects.Nodes.Add(copy);
                }
            }

            treeObjects.ExpandAll();
            treeObjects.ResumeLayout(true);
            treeObjects.SelectedNode = treeObjects.Nodes[0];
            SuspendUpdate.Resume(this);
        }
Beispiel #3
0
        private void GetAllSaves()
        {
            try {
                Assembly asm = Assembly.GetExecutingAssembly();

                string        savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Ori and the Blind Forest DE\");
                List <string> files    = new List <string>(Directory.GetFiles(savePath, "*.sav", SearchOption.TopDirectoryOnly));
                files.Sort(delegate(string file1, string file2) {
                    int f1 = 0;
                    int.TryParse(Path.GetFileNameWithoutExtension(file1).Substring(8), out f1);
                    int f2 = 0;
                    int.TryParse(Path.GetFileNameWithoutExtension(file2).Substring(8), out f2);
                    return(f1 > f2 ? 1 : f1 < f2 ? -1 : 0);
                });

                bool shouldSuspend = this.Visible;
                if (shouldSuspend)
                {
                    SuspendUpdate.Suspend(this);
                }

                flowLayout.SuspendLayout();

                foreach (Control c in flowLayout.Controls)
                {
                    FlowLayoutPanel panel = c as FlowLayoutPanel;
                    if (panel != null)
                    {
                        foreach (Control pc in panel.Controls)
                        {
                            PictureBox pb = pc as PictureBox;
                            if (pb != null)
                            {
                                pb.Click -= SaveImage_Click;
                            }
                            pc.Dispose();
                        }
                        panel.Controls.Clear();
                    }
                }

                flowLayout.Controls.Clear();

                int count = 0;
                for (int i = 0; i < files.Count; i++)
                {
                    string name = Path.GetFileNameWithoutExtension(files[i]);

                    if (name.IndexOf("bkup", StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        continue;
                    }

                    count++;
                    SaveGameData save = new SaveGameData();
                    try {
                        save.Load(files[i]);
                    } catch { continue; }

                    SceneData data         = save.Master[MasterAssets.SeinLevel];
                    int       currentLevel = (data?.GetInt((int)LevelInfo.CurrentLevel)).GetValueOrDefault(0);
                    int       currentXP    = (data?.GetInt((int)LevelInfo.Experience)).GetValueOrDefault(0);
                    int       currentAP    = (data?.GetInt((int)LevelInfo.AbilityPoints)).GetValueOrDefault(0);

                    PictureBox saveImage = new PictureBox();
                    saveImage.Name    = "image" + name;
                    saveImage.Size    = new Size(70, 64);
                    saveImage.Cursor  = Cursors.Hand;
                    saveImage.TabStop = false;
                    saveImage.Click  += SaveImage_Click;
                    saveImage.Tag     = save;

                    Stream file = asm.GetManifestResourceStream("LiveSplit.OriDE.Images." + save.AreaName + ".png");
                    if (file != null)
                    {
                        saveImage.Image = Image.FromStream(file);
                    }

                    Label saveLabel = new Label();
                    saveLabel.Name      = "label" + name;
                    saveLabel.Anchor    = AnchorStyles.Left | AnchorStyles.Right;
                    saveLabel.Size      = new Size(110, 64);
                    saveLabel.TextAlign = ContentAlignment.MiddleCenter;
                    saveLabel.BackColor = Color.Transparent;
                    saveLabel.Text      = name + "\n" +
                                          save.Health + "/" + save.MaxHealth + " HP " + save.Energy + "/" + save.MaxEnergy + " EN\n" +
                                          "Lvl" + currentLevel + " " + currentXP + " XP " + currentAP + " AP\n" +
                                          (save.Hours > 0 ? save.Hours + ":" : "") + save.Minutes.ToString(save.Hours > 0 ? "00" : "0") + ":" + save.Seconds.ToString("00") + " " + save.Completion + "%";

                    FlowLayoutPanel saveLayout = new FlowLayoutPanel();
                    saveLayout.SuspendLayout();
                    saveLayout.AutoSize = true;
                    saveLayout.Controls.Add(saveImage);
                    saveLayout.Controls.Add(saveLabel);
                    saveLayout.FlowDirection = FlowDirection.LeftToRight;
                    saveLayout.Name          = "layout" + name;
                    saveLayout.BackColor     = Color.Transparent;

                    flowLayout.Controls.Add(saveLayout);
                }

                foreach (Control c in flowLayout.Controls)
                {
                    FlowLayoutPanel panel = c as FlowLayoutPanel;
                    if (panel != null)
                    {
                        panel.ResumeLayout(true);
                    }
                }

                flowLayout.ResumeLayout(true);

                int sqSize = (int)Math.Ceiling(Math.Sqrt(count));
                if (count > sqSize * (sqSize - 1))
                {
                    this.ClientSize = new Size(sqSize * 200, sqSize * 78);
                }
                else
                {
                    this.ClientSize = new Size((sqSize - 1) * 200, sqSize * 78);
                }
                if (shouldSuspend)
                {
                    SuspendUpdate.Resume(this);
                }
            } catch { }
        }