public static List <SignEntry> LoadConfig(String path) { List <SignEntry> list = new List <SignEntry>(); string cfg = Path.Combine(Core.BaseDirectory, path); if (File.Exists(cfg)) { using (StreamReader ip = new StreamReader(cfg)) { string line; while ((line = ip.ReadLine()) != null) { string[] split = line.Split(' '); SignEntry e = new SignEntry( line.Substring(split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1), new Point3D(Utility.ToInt32(split[2]), Utility.ToInt32(split[3]), Utility.ToInt32(split[4])), Utility.ToInt32(split[1]), Utility.ToInt32(split[0])); list.Add(e); } } } return(list); }
protected override void OnTarget(Mobile from, object o) { if (!(o is Sign)) { return; } Sign target = (Sign)o; int targetMap = SignEntry.GetIdForMap(target.Map); SignEntry toRemove = null; List <SignEntry> signs = SignEntry.LoadConfig("Data/signs.cfg"); foreach (SignEntry sign in signs) { if (sign.m_Map == targetMap || sign.m_Map == 0 && (targetMap == 1 || targetMap == 2)) { if (sign.m_Location.CompareTo(target.Location) == 0) { RemoveSign(target); toRemove = sign; } } } if (toRemove != null) { signs.Remove(toRemove); SignEntry.WriteConfig(signs, "Data/signs.cfg"); } else { from.SendMessage("An entry for that sign was not found."); } }
public static void Parse(Mobile from) { string cfg = Path.Combine(Core.BaseDirectory, "Data/signs.cfg"); if (File.Exists(cfg)) { from.SendMessage("Generating signs, please wait."); using (StreamReader ip = new StreamReader(cfg)) { string line; while ((line = ip.ReadLine()) != null) { string[] split = line.Split(' '); SignEntry e = new SignEntry( line.Substring(split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1), new Point3D(Utility.ToInt32(split[2]), Utility.ToInt32(split[3]), Utility.ToInt32(split[4])), Utility.ToInt32(split[1]), Utility.ToInt32(split[0])); Add_Static(e.m_ItemID, e.m_Location, Map.Felucca, e.m_Text); } } from.SendMessage("Sign generating complete."); } else { from.SendMessage("{0} not found!", cfg); } }
public static void Parse( Mobile from ) { string cfg = Path.Combine( Core.BaseDirectory, "Data/signs.cfg" ); if ( File.Exists( cfg ) ) { ArrayList list = new ArrayList(); from.SendMessage( "Generating signs, please wait." ); using ( StreamReader ip = new StreamReader( cfg ) ) { string line; while ( (line = ip.ReadLine()) != null ) { string[] split = line.Split( ' ' ); SignEntry e = new SignEntry( line.Substring( split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1 ), new Point3D( Utility.ToInt32( split[2] ), Utility.ToInt32( split[3] ), Utility.ToInt32( split[4] ) ), Utility.ToInt32( split[1] ), Utility.ToInt32( split[0] ) ); list.Add( e ); } } Map[] brit = new Map[]{ Map.Felucca, Map.Trammel }; Map[] fel = new Map[]{ Map.Felucca }; Map[] tram = new Map[]{ Map.Trammel }; Map[] ilsh = new Map[]{ Map.Ilshenar }; Map[] malas = new Map[]{ Map.Malas }; Map[] tokuno = new Map[]{ Map.Tokuno }; for ( int i = 0; i < list.Count; ++i ) { SignEntry e = (SignEntry)list[i]; Map[] maps = null; switch ( e.m_Map ) { case 0: maps = brit; break; // Trammel and Felucca case 1: maps = fel; break; // Felucca case 2: maps = tram; break; // Trammel case 3: maps = ilsh; break; // Ilshenar case 4: maps = malas; break; // Malas case 5: maps = tokuno; break; // Tokuno Islands } for ( int j = 0; maps != null && j < maps.Length; ++j ) Add_Static( e.m_ItemID, e.m_Location, maps[j], e.m_Text ); } from.SendMessage( "Sign generating complete." ); } else { from.SendMessage( "{0} not found!", cfg ); } }
public static void Parse(Mobile from) { string cfg = Path.Combine(Core.BaseDirectory, "Data/signs.cfg"); if (File.Exists(cfg)) { List <SignEntry> list = new List <SignEntry>(); from.SendMessage("Generating signs, please wait."); using (StreamReader ip = new StreamReader(cfg)) { string line; while ((line = ip.ReadLine()) != null) { string[] split = line.Split(' '); SignEntry e = new SignEntry( line.Substring(split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1), new Point3D(Utility.ToInt32(split[2]), Utility.ToInt32(split[3]), Utility.ToInt32(split[4])), Utility.ToInt32(split[1]), Utility.ToInt32(split[0])); list.Add(e); } } Map[] brit = new Map[] { Map.Felucca }; Map[] fel = new Map[] { Map.Felucca }; for (int i = 0; i < list.Count; ++i) { SignEntry e = list[i]; Map[] maps = null; switch (e.m_Map) { case 0: maps = brit; break; // Felucca case 1: maps = fel; break; // Felucca } for (int j = 0; maps != null && j < maps.Length; ++j) { Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text); } } from.SendMessage("Sign generating complete."); } else { from.SendMessage("{0} not found!", cfg); } }
public static void Parse(Mobile from) { from.SendMessage("Generating signs, please wait."); List <SignEntry> list = SignEntry.LoadConfig("Data/signs.cfg"); Map[] brit = new Map[] { Map.Felucca, Map.Trammel }; Map[] fel = new Map[] { Map.Felucca }; Map[] tram = new Map[] { Map.Trammel }; Map[] ilsh = new Map[] { Map.Ilshenar }; Map[] malas = new Map[] { Map.Malas }; Map[] tokuno = new Map[] { Map.Tokuno }; for (int i = 0; i < list.Count; ++i) { SignEntry e = list[i]; Map[] maps = null; switch (e.m_Map) { case 0: maps = brit; break; // Trammel and Felucca case 1: maps = fel; break; // Felucca case 2: maps = tram; break; // Trammel case 3: maps = ilsh; break; // Ilshenar case 4: maps = malas; break; // Malas case 5: maps = tokuno; break; // Tokuno Islands } for (int j = 0; maps != null && j < maps.Length; ++j) { Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text); } } from.SendMessage("Sign generating complete."); }
public static void Parse( Mobile from ) { string cfg = Path.Combine( Core.BaseDirectory, "Data/signs.cfg" ); if ( File.Exists( cfg ) ) { List<SignEntry> list = new List<SignEntry>(); from.SendMessage( "Generating signs, please wait." ); using ( StreamReader ip = new StreamReader( cfg ) ) { string line; while ( (line = ip.ReadLine()) != null ) { string[] split = line.Split( ' ' ); SignEntry e = new SignEntry( line.Substring( split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1 ), new Point3D( Utility.ToInt32( split[2] ), Utility.ToInt32( split[3] ), Utility.ToInt32( split[4] ) ), Utility.ToInt32( split[1] ), Utility.ToInt32( split[0] ) ); list.Add( e ); } } Map[] brit = new Map[]{ Map.Felucca }; Map[] fel = new Map[]{ Map.Felucca }; for ( int i = 0; i < list.Count; ++i ) { SignEntry e = list[i]; Map[] maps = null; switch ( e.m_Map ) { case 0: maps = brit; break; // Felucca case 1: maps = fel; break; // Felucca } for ( int j = 0; maps != null && j < maps.Length; ++j ) Add_Static( e.m_ItemID, e.m_Location, maps[j], e.m_Text ); } from.SendMessage( "Sign generating complete." ); } else { from.SendMessage( "{0} not found!", cfg ); } }
public void DoSave() { List <SignEntry> signs = SignEntry.LoadConfig("Data/signs.cfg"); foreach (SignEntry sign in signs) { if (sign.m_Map == TargetMap && sign.m_Location.CompareTo(m_Sign.Location) == 0) { m_From.SendMessage("A sign is already configured for this location."); return; } } signs.Add(new SignEntry(m_Sign.Name, m_Sign.Location, m_Sign.ItemID, TargetMap)); SignEntry.WriteConfig(signs, "Data/signs.cfg"); }
protected override void OnTarget(Mobile from, object o) { if (!(o is Sign)) { return; } m_Sign = (Sign)o; m_From = from; TargetMap = SignEntry.GetIdForMap(m_Sign.Map); if (m_Sign.Map == Map.Felucca || m_Sign.Map == Map.Trammel) { from.SendGump(new BritGump(this)); } else { DoSave(); } }
public static void Parse(Mobile from) { string cfg = Path.Combine(Core.BaseDirectory, "Data/signs.cfg"); if (File.Exists(cfg)) { List <SignEntry> list = new List <SignEntry>(); from.SendMessage("Deleting signs, please wait."); using (StreamReader ip = new StreamReader(cfg)) { string line; while ((line = ip.ReadLine()) != null) { string[] split = line.Split(' '); SignEntry e = new SignEntry(new Point3D(Utility.ToInt32(split[2]), Utility.ToInt32(split[3]), Utility.ToInt32(split[4])), Utility.ToInt32(split[1]), Utility.ToInt32(split[0])); list.Add(e); } } Map[] brit = { Map.Felucca, Map.Trammel }; Map[] fel = { Map.Felucca }; Map[] tram = { Map.Trammel }; Map[] ilsh = { Map.Ilshenar }; Map[] malas = { Map.Malas }; Map[] tokuno = { Map.Tokuno }; for (int i = 0; i < list.Count; ++i) { SignEntry e = list[i]; Map[] maps = null; switch (e.m_Map) { case 0: maps = brit; break; // Trammel and Felucca case 1: maps = fel; break; // Felucca case 2: maps = tram; break; // Trammel case 3: maps = ilsh; break; // Ilshenar case 4: maps = malas; break; // Malas case 5: maps = tokuno; break; // Tokuno Islands } for (int j = 0; maps != null && j < maps.Length; ++j) { Delete_Static(e.m_ItemID, e.m_Location, maps[j]); } } from.SendMessage("Sign deleting complete."); } else { from.SendMessage("{0} not found!", cfg); } }
public static void Parse( Mobile from, string filename, bool AddOrDel ) { string ThisFile; if ( filename == null || filename == "" ) { ThisFile = "Signs.cfg"; } else { ThisFile = "Signs" + filename.ToUpper() + ".cfg"; } List<string> line = new List<string>( Lib.ListOfLines( "Data/Nerun's Distro/Signs", ThisFile ) ); if ( line.Count > 1 ) // File Exists { List<SignEntry> list = new List<SignEntry>(); if ( AddOrDel == true ) { from.SendMessage( "Removing signs, please wait." ); } else { from.SendMessage( "Generating signs, please wait." ); } for ( int i = 0; i < line.Count; ++i ) { string lineA = Convert.ToString( line[i] ); if ( !lineA.StartsWith("#") && Lib.IsNumber( Convert.ToString( lineA[0] ) ) && lineA != null && lineA != "" && lineA != " " ) // If not comment or blank Line { string[] split = lineA.Split( ' ' ); SignEntry e = new SignEntry( lineA.Substring( split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1 ), new Point3D( Utility.ToInt32( split[2] ), Utility.ToInt32( split[3] ), Utility.ToInt32( split[4] ) ), Utility.ToInt32( split[1] ), Utility.ToInt32( split[0] ) ); list.Add( e ); } } Map[] brit = new Map[]{ Map.Felucca, Map.Trammel }; Map[] fel = new Map[]{ Map.Felucca }; Map[] tram = new Map[]{ Map.Trammel }; Map[] ilsh = new Map[]{ Map.Ilshenar }; Map[] malas = new Map[]{ Map.Malas }; Map[] tokuno = new Map[]{ Map.Tokuno }; for ( int i = 0; i < list.Count; ++i ) { SignEntry e = list[i]; Map[] maps = null; switch ( e.m_Map ) { case 0: maps = brit; break; // Trammel and Felucca case 1: maps = fel; break; // Felucca case 2: maps = tram; break; // Trammel case 3: maps = ilsh; break; // Ilshenar case 4: maps = malas; break; // Malas case 5: maps = tokuno; break; // Tokuno Islands } for ( int j = 0; maps != null && j < maps.Length; ++j ) { if ( AddOrDel == true ) { Del_Static( e.m_ItemID, e.m_Location, maps[j] ); } else { Add_Static( e.m_ItemID, e.m_Location, maps[j], e.m_Text ); m_AddCount++; } } } if ( AddOrDel == true ) { from.SendMessage( "{0} signs removed.", m_DelCount ); } else { from.SendMessage( "{0} signs created.", m_AddCount ); } m_AddCount = 0; m_DelCount = 0; } else { from.SendMessage( "{0} not found!", line[0] ); // line[0] = path + file name } }
public static void Parse(Mobile from, string filename, bool AddOrDel) { string ThisFile; if (filename == null || filename == "") { ThisFile = "Signs.cfg"; } else { ThisFile = "Signs" + filename.ToUpper() + ".cfg"; } List <string> line = new List <string>(Lib.ListOfLines("Data/Nerun's Distro/Signs", ThisFile)); if (line.Count > 1) // File Exists { List <SignEntry> list = new List <SignEntry>(); if (AddOrDel == true) { from.SendMessage("Removing signs, please wait."); } else { from.SendMessage("Generating signs, please wait."); } for (int i = 0; i < line.Count; ++i) { string lineA = Convert.ToString(line[i]); if (!lineA.StartsWith("#") && Lib.IsNumber(Convert.ToString(lineA[0])) && lineA != null && lineA != "" && lineA != " ") // If not comment or blank Line { string[] split = lineA.Split(' '); SignEntry e = new SignEntry(lineA.Substring(split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1), new Point3D(Utility.ToInt32(split[2]), Utility.ToInt32(split[3]), Utility.ToInt32(split[4])), Utility.ToInt32(split[1]), Utility.ToInt32(split[0])); list.Add(e); } } Map[] brit = new Map[] { Map.Felucca, Map.Trammel }; Map[] fel = new Map[] { Map.Felucca }; Map[] tram = new Map[] { Map.Trammel }; Map[] ilsh = new Map[] { Map.Ilshenar }; Map[] malas = new Map[] { Map.Malas }; Map[] tokuno = new Map[] { Map.Tokuno }; for (int i = 0; i < list.Count; ++i) { SignEntry e = list[i]; Map[] maps = null; switch (e.m_Map) { case 0: maps = brit; break; // Trammel and Felucca case 1: maps = fel; break; // Felucca case 2: maps = tram; break; // Trammel case 3: maps = ilsh; break; // Ilshenar case 4: maps = malas; break; // Malas case 5: maps = tokuno; break; // Tokuno Islands } for (int j = 0; maps != null && j < maps.Length; ++j) { if (AddOrDel == true) { Del_Static(e.m_ItemID, e.m_Location, maps[j]); } else { Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text); m_AddCount++; } } } if (AddOrDel == true) { from.SendMessage("{0} signs removed.", m_DelCount); } else { from.SendMessage("{0} signs created.", m_AddCount); } m_AddCount = 0; m_DelCount = 0; } else { from.SendMessage("{0} not found!", line[0]); // line[0] = path + file name } }
public static void Parse(Mobile from) { var cfg = Path.Combine(Core.BaseDirectory, "Data/signs.cfg"); if (File.Exists(cfg)) { var list = new List <SignEntry>(); from.SendMessage("Generating signs, please wait."); using (var ip = new StreamReader(cfg)) { string line; while ((line = ip.ReadLine()) != null) { var split = line.Split(' '); var e = new SignEntry( line.Substring( split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1 ), new Point3D(Utility.ToInt32(split[2]), Utility.ToInt32(split[3]), Utility.ToInt32(split[4])), Utility.ToInt32(split[1]), Utility.ToInt32(split[0]) ); list.Add(e); } } Map[] brit = { Map.Felucca, Map.Trammel }; Map[] fel = { Map.Felucca }; Map[] tram = { Map.Trammel }; Map[] ilsh = { Map.Ilshenar }; Map[] malas = { Map.Malas }; Map[] tokuno = { Map.Tokuno }; for (var i = 0; i < list.Count; ++i) { var e = list[i]; var maps = e.m_Map switch { 0 => brit, 1 => fel, 2 => tram, 3 => ilsh, 4 => malas, 5 => tokuno, _ => null }; for (var j = 0; maps?.Length > j; ++j) { Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text); } } from.SendMessage("Sign generating complete."); } else { from.SendMessage("{0} not found!", cfg); } }
private void GenerateSigns_Callback() { string cfg = Path.Combine(Server.Core.BaseDirectory, "Data/signs.cfg"); if (File.Exists(cfg)) { ArrayList list = new ArrayList(); using (StreamReader ip = new StreamReader(cfg)) { string line; while ((line = ip.ReadLine()) != null) { string[] split = line.Split(' '); SignEntry e = new SignEntry( line.Substring(split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1), new Point3D(Utility.ToInt32(split[2]), Utility.ToInt32(split[3]), Utility.ToInt32(split[4])), Utility.ToInt32(split[1]), Utility.ToInt32(split[0])); list.Add(e); } } Map[] brit = new Map[] { Map.Felucca, Map.Trammel }; Map[] fel = new Map[] { Map.Felucca }; Map[] tram = new Map[] { Map.Trammel }; Map[] ilsh = new Map[] { Map.Ilshenar }; Map[] malas = new Map[] { Map.Malas }; Map[] tokuno = new Map[] { Map.Tokuno }; for (int i = 0; i < list.Count; ++i) { SignEntry e = (SignEntry)list[i]; Map[] maps = null; switch (e.m_Map) { case 0: maps = brit; break; // Trammel and Felucca case 1: maps = fel; break; // Felucca case 2: maps = tram; break; // Trammel case 3: maps = ilsh; break; // Ilshenar case 4: maps = malas; break; // Malas case 5: maps = tokuno; break; // Tokuno Islands } for (int j = 0; maps != null && j < maps.Length; ++j) { SignParser.Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text); } } MessageBox.Show(Core.MainForm, "Signs successfully generated", "Success"); } else { MessageBox.Show(Core.MainForm, string.Format("{0} not found!", cfg), "Error"); } }
private void GenerateSigns_Callback() { string cfg = Path.Combine( Server.Core.BaseDirectory, "Data/signs.cfg" ); if ( File.Exists( cfg ) ) { ArrayList list = new ArrayList(); using ( StreamReader ip = new StreamReader( cfg ) ) { string line; while ( (line = ip.ReadLine()) != null ) { string[] split = line.Split( ' ' ); SignEntry e = new SignEntry( line.Substring( split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1 ), new Point3D( Utility.ToInt32( split[2] ), Utility.ToInt32( split[3] ), Utility.ToInt32( split[4] ) ), Utility.ToInt32( split[1] ), Utility.ToInt32( split[0] ) ); list.Add( e ); } } Map[] brit = new Map[]{ Map.Felucca, Map.Trammel }; Map[] fel = new Map[]{ Map.Felucca }; Map[] tram = new Map[]{ Map.Trammel }; Map[] ilsh = new Map[]{ Map.Ilshenar }; Map[] malas = new Map[]{ Map.Malas }; Map[] tokuno = new Map[]{ Map.Tokuno }; for ( int i = 0; i < list.Count; ++i ) { SignEntry e = (SignEntry)list[i]; Map[] maps = null; switch ( e.m_Map ) { case 0: maps = brit; break; // Trammel and Felucca case 1: maps = fel; break; // Felucca case 2: maps = tram; break; // Trammel case 3: maps = ilsh; break; // Ilshenar case 4: maps = malas; break; // Malas case 5: maps = tokuno; break; // Tokuno Islands } for ( int j = 0; maps != null && j < maps.Length; ++j ) SignParser.Add_Static( e.m_ItemID, e.m_Location, maps[j], e.m_Text ); } MessageBox.Show(Core.MainForm, "Signs successfully generated", "Success"); } else { MessageBox.Show(Core.MainForm, string.Format("{0} not found!", cfg) ,"Error"); } }
public static List<SignEntry> LoadConfig(String path) { List<SignEntry> list = new List<SignEntry>(); string cfg = Path.Combine(Core.BaseDirectory, path); if (File.Exists(cfg)) { using (StreamReader ip = new StreamReader(cfg)) { string line; while ((line = ip.ReadLine()) != null) { string[] split = line.Split(' '); SignEntry e = new SignEntry( line.Substring(split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 + split[3].Length + 1 + split[4].Length + 1), new Point3D(Utility.ToInt32(split[2]), Utility.ToInt32(split[3]), Utility.ToInt32(split[4])), Utility.ToInt32(split[1]), Utility.ToInt32(split[0])); list.Add(e); } } } return list; }