private static bool LoadGlobalData() { Program.Data.Load("data.xml"); FolderBrowserDialog browserDlg = new FolderBrowserDialog(); browserDlg.Description = "Please select the folder that contains Knytt Stories.exe."; Program.Path = Program.Data.GetElementsByTagName("path")[0].InnerText; if (Program.Path == "") { if (browserDlg.ShowDialog(Program.Editor) == DialogResult.OK) { Program.Path = browserDlg.SelectedPath; } else { return(false); } Program.Data.GetElementsByTagName("path")[0].InnerText = Program.Path; FileStream fout = File.Open("data.xml", FileMode.Truncate, FileAccess.Write); XmlWriter writer = XmlWriter.Create(fout); Program.Data.WriteContentTo(writer); writer.Close(); fout.Close(); } Program.ObjectsPath = Program.Path + @"\Data\Objects"; Program.WorldsPath = Program.Path + @"\Worlds"; string active = Program.Data.GetElementsByTagName("active")[0].InnerText; foreach (XmlElement el in Program.Data.GetElementsByTagName("profile")) { Profile p = new Profile(el); if (p.ID.Equals(active)) { Program.Banks = p.Load(); Program.ActiveProfile = p; } } if (Program.Banks == null) { return(false); } return(true); }
public ObjectBankList Load() { ObjectBankList bankList = new ObjectBankList(); /*foreach(string b in baseProfiles.Split(' ')) { * foreach(Profile p in Profile.Profiles) { * if(p.ID == b) bankList.Merge(p.Load()); * } * } * * ObjectBankList newList = new ObjectBankList();*/ foreach (BankDef def in banks) { List <Tuple <int, Bitmap> > objects = new List <Tuple <int, Bitmap> >(); for (int i = 0; i < def.Paths.Length; i++) { List <int> bounds = new List <int>(); string[] unparsed = def.Indices[i].Split(new char[] { ' ', '-' }); foreach (string s in unparsed) { bounds.Add(int.Parse(s)); } for (int r = 0; r < bounds.Count; r += 2) { for (int j = bounds[r]; j <= bounds[r + 1]; j++) { Bitmap b = Program.LoadBitmap(def.Paths[i] + @"\Object" + j + ".png"); b.MakeTransparent(Color.Magenta); objects.Add(Tuple.Create <int, Bitmap>(j, b)); } } } bankList.Add(new ObjectBank(def.Index, def.Name, objects)); } bankList.SortBanks(); //bankList.Merge(newList); return(bankList); }
public static void ChangeProfile(Profile p) { Program.Banks = p.Load(); Program.ActiveProfile = p; GC.Collect(); }