Exemplo n.º 1
0
        public static void DisableSystem(string system)
        {
            if (m_RegSystems.ContainsKey(system))
            {
                Type t = ScriptCompiler.FindTypeByFullName(system);
                if (t != null)
                {
                    if (!Directory.Exists("ACC Backups"))
                    {
                        Directory.CreateDirectory("ACC Backups");
                    }

                    ACCSystem sys = (ACCSystem)Activator.CreateInstance(t);
                    if (sys != null)
                    {
                        sys.StartSave("ACC Backups/");
                        sys.Disable();
                    }
                    m_RegSystems[system] = false;
                }
            }
            else
            {
                Console.WriteLine("Invalid System - {0} - Cannot disable.", system);
            }
        }
Exemplo n.º 2
0
        public static void Save(WorldSaveEventArgs args)
        {
            if (!Directory.Exists("Saves/ACC"))
            {
                Directory.CreateDirectory("Saves/ACC");
            }

            string   filename  = "acc.sav";
            string   path      = @"Saves/ACC/";
            string   pathNfile = path + filename;
            DateTime start     = DateTime.Now;

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("----------");
            Console.WriteLine("Saving ACC...");

            try
            {
                using (FileStream m_FileStream = new FileStream(pathNfile, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    BinaryFileWriter writer = new BinaryFileWriter(m_FileStream, true);

                    writer.Write((int)m_RegSystems.Count);
                    foreach (KeyValuePair <string, bool> kvp in m_RegSystems)
                    {
                        Type t = ScriptCompiler.FindTypeByFullName(kvp.Key);
                        if (t != null)
                        {
                            writer.Write(kvp.Key);
                            writer.Write(kvp.Value);

                            if (kvp.Value)
                            {
                                ACCSystem system = (ACCSystem)Activator.CreateInstance(t);
                                if (system != null)
                                {
                                    system.StartSave(path);
                                }
                            }
                        }
                    }

                    writer.Close();
                    m_FileStream.Close();
                }

                Console.WriteLine("Done in {0:F1} seconds.", (DateTime.Now - start).TotalSeconds);
                Console.WriteLine("----------");
                Console.WriteLine();
            }
            catch (Exception err)
            {
                Console.WriteLine("Failed. Exception: " + err);
            }
        }
Exemplo n.º 3
0
        public static void RegisterSystem(string system)
        {
            if (m_RegSystems.ContainsKey(system))
            {
                return;
            }

            Type t = Type.GetType(system);

            if (t == null)
            {
                Console.WriteLine("Invalid System String: " + system);
                return;
            }

            ACCSystem sys = (ACCSystem)Activator.CreateInstance(t);

            if (sys != null)
            {
                m_RegSystems.Add(system, true);
                Console.WriteLine("ACC Registered: " + system);
            }
        }
Exemplo n.º 4
0
		public ACCGump( Mobile from, string system, object[] subParams ) : base( 0, 0 )
		{
			if( from.AccessLevel != AccessLevel.Administrator )
				return;

			m_List = new ArrayList();
			m_Page = -1;
			m_SubP = subParams;

			foreach( DictionaryEntry de in ACC.RegisteredSystems )
			{
				if( String.Equals( system, (string)de.Key ) )
					m_Page = m_List.Count;
				m_List.Add( (string)de.Key );
			}

			Closable   = true;
			Disposable = true;
			Dragable   = true;
			Resizable  = false;

			AddPage(0);

			AddBackground( 0,   0, 630, 360,  5120 ); //Top BG
			AddBackground( 0, 360, 630, 113,  5120 ); //Bottom BG
			AddImageTiled( 0, 446, 620,  50, 10452 ); //Bottom

			if( m_Page == -1 )
			{
				AddHtml( 175, 40, 375,  30, "<basefont size=7 color=#33CC33><center>A_Li_N - Completely Custom</center></basefont>", false, false );
				AddHtml( 175, 80, 420, 265, "<basefont size=4 color=white>Thanks for choosing to test A_Li_N - Completely Custom.  With this gump, you will be able to control every aspect of my systems that are changable in-game.  Currently, there are only a couple test bases that I have made to do minimal testing.  If you have any questions, concerns, requests, bugs or anything else having to do with my systems, please email me at anAliengmail.com with the topic of 'ACC'.  Enjoy!</basefont>", false, false );
			}

			for( int i = 0; i < m_List.Count; i++ )
			{
				Type t = Type.GetType( (string)m_List[i] );
				if( t == null )
					continue;

				ACCSystem sys = (ACCSystem)Activator.CreateInstance( t );
				if( sys == null )
					continue;

				AddButton( (i<3?35:(i<6?225:415)), (i%3==0?372:(i%3==1?397:422)), 1122, 1124, i+1, GumpButtonType.Reply, 0 );
				AddHtml( (i<3?35:(i<6?225:415)), (i%3==0?370:(i%3==1?395:420)), 184, 20, String.Format( "<basefont color=white><center>{0}</center></basefont>", sys.Name() ), false, false );

				if( i == m_Page )
					m_Syst = sys;
			}

			if( m_Syst != null )
			{
				AddButton( 560, 0, 1417, 1417, 10, GumpButtonType.Reply, 0 );
				if( m_Syst.Enabled )
					AddLabel( 592, 45, 66, "On" );
				else
					AddLabel( 588, 45, 36, "Off" );

//				AddButton( 15, 340, 22153, 22155, 11, GumpButtonType.Reply, 0 ); //Help
			}

			AddImage(   0,   0,  9002); //Border
			AddImage( 580, 350, 10410); //Dragon

			if( m_Syst != null )
			{
				AddPage(1);
				m_Syst.Gump( from, this, m_SubP );
			}
		}
Exemplo n.º 5
0
        public ACCGump(Mobile from, string system, object[] subParams) : base(0, 0)
        {
            if (from.AccessLevel != AccessLevel.Administrator)
            {
                return;
            }

            m_List = new ArrayList();
            m_Page = -1;
            m_SubP = subParams;

            foreach (DictionaryEntry de in ACC.RegisteredSystems)
            {
                if (String.Equals(system, (string)de.Key))
                {
                    m_Page = m_List.Count;
                }
                m_List.Add((string)de.Key);
            }

            Closable   = true;
            Disposable = true;
            Dragable   = true;
            Resizable  = false;

            AddPage(0);

            AddBackground(0, 0, 630, 360, 5120);                  //Top BG
            AddBackground(0, 360, 630, 113, 5120);                //Bottom BG
            AddImageTiled(0, 446, 620, 50, 10452);                //Bottom

            if (m_Page == -1)
            {
                AddHtml(175, 40, 375, 30, "<basefont size=7 color=#33CC33><center>A_Li_N - Completely Custom</center></basefont>", false, false);
                AddHtml(175, 80, 420, 265, "<basefont size=4 color=white>Thanks for choosing to test A_Li_N - Completely Custom.  With this gump, you will be able to control every aspect of my systems that are changable in-game.  Currently, there are only a couple test bases that I have made to do minimal testing.  If you have any questions, concerns, requests, bugs or anything else having to do with my systems, please email me at anAliengmail.com with the topic of 'ACC'.  Enjoy!</basefont>", false, false);
            }

            for (int i = 0; i < m_List.Count; i++)
            {
                Type t = Type.GetType((string)m_List[i]);
                if (t == null)
                {
                    continue;
                }

                ACCSystem sys = (ACCSystem)Activator.CreateInstance(t);
                if (sys == null)
                {
                    continue;
                }

                AddButton((i < 3?35:(i < 6?225:415)), (i % 3 == 0?372:(i % 3 == 1?397:422)), 1122, 1124, i + 1, GumpButtonType.Reply, 0);
                AddHtml((i < 3?35:(i < 6?225:415)), (i % 3 == 0?370:(i % 3 == 1?395:420)), 184, 20, String.Format("<basefont color=white><center>{0}</center></basefont>", sys.Name()), false, false);

                if (i == m_Page)
                {
                    m_Syst = sys;
                }
            }

            if (m_Syst != null)
            {
                AddButton(560, 0, 1417, 1417, 10, GumpButtonType.Reply, 0);
                if (m_Syst.Enabled)
                {
                    AddLabel(592, 45, 66, "On");
                }
                else
                {
                    AddLabel(588, 45, 36, "Off");
                }

//				AddButton( 15, 340, 22153, 22155, 11, GumpButtonType.Reply, 0 ); //Help
            }

            AddImage(0, 0, 9002);                   //Border
            AddImage(580, 350, 10410);              //Dragon

            if (m_Syst != null)
            {
                AddPage(1);
                m_Syst.Gump(from, this, m_SubP);
            }
        }
Exemplo n.º 6
0
        public static void Load()
        {
            if (!Directory.Exists("Saves/ACC"))
            {
                return;
            }

            string   filename  = "acc.sav";
            string   path      = @"Saves/ACC/";
            string   pathNfile = path + filename;
            DateTime start     = DateTime.Now;

            Console.WriteLine();
            Console.WriteLine("----------");
            Console.WriteLine("Loading ACC...");

            try
            {
                using (FileStream m_FileStream = new FileStream(pathNfile, FileMode.Open, FileAccess.Read))
                {
                    BinaryReader     m_BinaryReader = new BinaryReader(m_FileStream);
                    BinaryFileReader reader         = new BinaryFileReader(m_BinaryReader);

                    if (m_RegSystems == null)
                    {
                        m_RegSystems = new Dictionary <string, bool>();
                    }

                    int Count = reader.ReadInt();
                    for (int i = 0; i < Count; i++)
                    {
                        string system  = reader.ReadString();
                        Type   t       = ScriptCompiler.FindTypeByFullName(system);
                        bool   enabled = reader.ReadBool();

                        if (t != null)
                        {
                            m_RegSystems[system] = enabled;

                            if (m_RegSystems[system])
                            {
                                ACCSystem sys = (ACCSystem)Activator.CreateInstance(t);
                                if (sys != null)
                                {
                                    sys.StartLoad(path);
                                }
                            }
                        }
                    }

                    reader.Close();
                    m_FileStream.Close();
                }

                Console.WriteLine("Done in {0:F1} seconds.", (DateTime.Now - start).TotalSeconds);
                Console.WriteLine("----------");
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed. Exception: " + e);
            }
        }