public static SoundMgr GetInstance() { if (instance == null) { instance = new SoundMgr(); instance.Load(); } return instance; }
private static void InternalLoadZone(string path) { LAST_SAVE = DateTime.UtcNow.Ticks; Loading.ShowLoading(); Polygon.Polygons.Clear(); var z = new Zone(); Program.ZONE = z; z.PATH = path; z.ZoneID = int.Parse(Path.GetFileName(path).Remove(0, 4)); Program.FORM.Text = "DAoC Zone Editor - " + z.ZoneID; { string p = string.Format("dat{0}.mpk", z.ZoneID.ToString("D3")); string pp = path + "\\" + p; Loading.Update("Loading " + p + "..."); z.LoadSectorDat(path); z.LoadHeightmap(path); z.LoadBoundings(path); #region zonejump.csv { Loading.Update(p + "... - Zonejumps"); Zonejump.Zonejumps.Clear(); var zonejumpcsv = string.Format("{0}\\zonejump.csv", pp); if (File.Exists(zonejumpcsv)) { var rs = new StreamReader(zonejumpcsv); while (!rs.EndOfStream) { string line = rs.ReadLine(); string[] s = line.Split(','); //ID, Name, X, Y, X2, Y2, Z1, Z2, JID var jp = new Zonejump(); jp.Name = s[1]; jp.ID = Parse(s[8]); jp.First = new Vector3(Parse(s[2]), Parse(s[3]), Parse(s[6])); jp.Second = new Vector3(Parse(s[4]), Parse(s[5]), Parse(s[7])); Zonejump.Zonejumps.Add(jp); } rs.Close(); } } #endregion #region lights.csv { Loading.Update(p + "... - Lights"); Light.Lights.Clear(); string f = string.Format("{0}\\lights.csv", pp); if (File.Exists(f)) { var rs = new StreamReader(f); while (!rs.EndOfStream) { string line = rs.ReadLine(); string[] s = line.Split(','); //46473, 54362, 2910, 3 //X, Y, Z, Intensity var l = new Light(); l.X = Parse(s[0]); l.Y = Parse(s[1]); int zz = Parse(s[2]); int x = Math.Min((int)Math.Round(l.X / 256f), 255); int y = Math.Min((int)Math.Round(l.Y / 256f), 255); l.Z = z.HeightMap[x, y]; l.ZOffset = zz - l.Z; int col = Parse(s[3]); l.Intensity = col / 10 + 1; l.Color = (LightColor)(col % 10); Light.Lights.Add(l); } rs.Close(); } } #endregion Loading.Update("Loading patchmaps ..."); Program.CONFIG.UsePatchmaps = true; #region texXXX.mpk { string px = string.Format("tex{0}.mpk", z.ZoneID.ToString("D3")); string ppx = path + "\\" + px; Loading.Update(px + "... - Terrain Texture"); //z.TextureSubZones = new Texture[8,8]; //Load all textures var Textures = new Image[8, 8]; foreach (string file in Directory.GetFiles(ppx, "*.bmp")) { string f = Path.GetFileName(file); int num1 = int.Parse(f.Substring(3, 2)); int num2 = int.Parse(f.Substring(6, 2)); //tex01-02.bmp Textures[num1, num2] = Image.FromFile(file); } //Merge var bmp = new Bitmap(2048, 2048); Graphics g = Graphics.FromImage(bmp); g.Clear(Color.Violet); for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { Image t = Textures[x, y]; if (t == null) { continue; } g.DrawImage(t, x * 256, y * 256, 256, 256); } } g.Save(); //bmp.RotateFlip(RotateFlipType.Rotate90FlipX); var ms = new MemoryStream(); bmp.Save(ms, ImageFormat.Bmp); ms.Capacity = (int)ms.Length; ms.Position = 0; Texture m = TextureLoader.FromStream(Program.FORM.renderControl1.DEVICE, ms); //Texture m = new Texture(Program.FORM.renderControl1.DEVICE, ms, Usage.None, Pool.SystemMemory); z.TextureMap = m; } #endregion var info = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone(); info.NumberDecimalSeparator = "."; Loading.Update("Loading Sounds.."); SoundMgr.Load(); #region nifs.csv lock (Objects.NIFs) { Objects.NIFs.Clear(); Loading.Update(p + "... - NIFs"); var rs = new StreamReader(string.Format("{0}\\nifs.csv", pp)); int index = 0; while (!rs.EndOfStream) { index++; string line = rs.ReadLine(); if (index <= 2) { continue; //header } string[] s = line.Split(','); var nif = new Objects.NIF(); nif.ID = Parse(s[0]); //1 = name string name = s[1]; int pos = name.IndexOf('|'); if (pos > 0) { nif.Group = name.Substring(pos + 1); } nif.FileName = s[2]; //3 = ambient //4 = merlin //5 = color nif.IsDoor = s[6] == "1"; //6 = animate nif.Collision = Parse(s[7]); //7 = collide //8 = ground //9 = minangle //10 = maxangle nif.MinScale = Parse(s[11]); nif.MaxScale = Parse(s[12]); nif.CollideRadius = Parse(s[13]); //13 = radius Objects.NIFs.Add(nif.ID, nif); if (nif.ID > Objects.NIFS_Max) { Objects.NIFS_Max = nif.ID; } } rs.Close(); } #endregion #region fixtures.csv lock (Objects.Fixtures) { Loading.Update(p + "... - Fixtures"); Objects.Fixture_Max = -1; Objects.Fixtures.Clear(); var rs = new StreamReader(string.Format("{0}\\fixtures.csv", pp)); int index = 0; while (!rs.EndOfStream) { index++; string line = rs.ReadLine(); if (index <= 2) { continue; //header } string[] s = line.Split(','); try { var fix = new Objects.Fixture(); fix.ID = Parse(s[0]); fix.NIF = Objects.NIFs[Parse(s[1])]; fix.Name = s[2]; fix.X = float.Parse(s[3], info); fix.Y = float.Parse(s[4], info); fix.Z = float.Parse(s[5], info); //6 = A (angle?) fix.Scale = Parse(s[7]); //8 = nif collide //9 = collide radius //10 = animate fix.OnGround = s[11] == "1"; //12 = flip //13 = cave //14 = uid if (s.Length > 15) { fix.Rotation = float.Parse(s[15], info); fix.AxisX = float.Parse(s[16], info); fix.AxisY = float.Parse(s[17], info); fix.AxisZ = float.Parse(s[18], info); } Objects.Fixtures.Add(fix); if (fix.ID > Objects.Fixture_Max) { Objects.Fixture_Max = fix.ID; } } catch (ArgumentOutOfRangeException) { } catch (IndexOutOfRangeException) { } } rs.Close(); } #endregion { int total = Objects.NIFs.Values.Count; int cur = 0; var array = new Objects.NIF[Objects.NIFs.Values.Count]; Objects.NIFs.Values.CopyTo(array, 0); for (int i = array.Length - 1; i >= 0; i--) { Objects.NIF n = array[i]; Loading.Update(p + "... - NIFs (" + (++cur) + "/" + total + "): " + n.FileName); n.LoadData(); //Application.DoEvents(); } } } LAST_SAVE = DateTime.UtcNow.Ticks; Loading.CloseLoading(); }