Esempio n. 1
0
File: UO.cs Progetto: byterj/phoenix
        public static void AddObject(string name)
        {
            if (Helper.CheckName(ref name, false))
            {
                UO.Print("Select {0}:", name);

                Serial serial = UIManager.TargetObject();

                if (serial.IsValid)
                {
                    Aliases.SetObject(name, serial);
                }
                else
                {
                    ScriptErrorException.Throw("Invalid object serial.");
                }
            }
            else
            {
                ScriptErrorException.Throw("Invalid object name.");
            }
        }
Esempio n. 2
0
        internal static void Initialize()
        {
            if (initialized)
            {
                throw new InvalidProgramException();
            }
            initialized = true;

            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            AppDomain.CurrentDomain.AssemblyResolve    += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            Core.LoginComplete += new EventHandler(Core_LoginComplete);
            Core.Disconnected  += new EventHandler(Core_Disconnected);

            launchData = LaunchData.FromCmdLine(System.Environment.CommandLine);

            clientThreadId = Thread.CurrentThread.ManagedThreadId;

            SetInitEvent();
            InitLogging();

            // TODO: Set security

            try {
                culture = CultureInfo.GetCultureInfo(launchData.Culture);
            }
            catch (Exception e) {
                culture = CultureInfo.GetCultureInfo("en-US");
                ExceptionDialog.Show(e, "Error creating requested culture.");
            }

            Thread.CurrentThread.CurrentCulture   = culture;
            Thread.CurrentThread.CurrentUICulture = culture;

            System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = true;

            if (!clientKeys.Load())
            {
                ShowMessageBoxAsync("Unknown Client. Please use the same account and password you specified in launcher.", "Information");
            }
            spellList = new SpellList();

            Config.InternalSettings.Path = Path.Combine(launchData.PhoenixDir, SettingsFile);

            Config.Init();
            Config.Profile.ProfileChanged += new EventHandler(Profile_ProfileChanged);

            guiThread = new PhoenixGuiThread();

            // Run DataFiles.Load in different thread.
            Thread loadDataFilesThread = new Thread(new ParameterizedThreadStart(DataFiles.Load));

            loadDataFilesThread.Start(launchData.UltimaDir);

            Phoenix.Logging.JournalHandler.Init();
            Notepad.Init();
            Phoenix.Runtime.ReportViewer.Init();
            Journal.Init();
            WorldPacketHandler.Init();
            Aliases.Init();
            LoginInfo.Init();
            UIManager.Init();
            SpeechColorOverride.Init();
            Phoenix.Runtime.ClientMessageHandler.Init();
            Phoenix.Runtime.RuntimeCore.Hotkeys.Init();
            LatencyMeasurement.Init();

            // Create scripts and plugins dir if doesn't exists
            DirectoryInfo scriptsDir = new DirectoryInfo(Phoenix.Runtime.RuntimeCore.ScriptsDirectory);

            if (!scriptsDir.Exists)
            {
                scriptsDir.Create();
            }

            DirectoryInfo pluginsDir = new DirectoryInfo(Phoenix.Runtime.RuntimeCore.PluginsDirectory);

            if (!pluginsDir.Exists)
            {
                pluginsDir.Create();
            }

            Core.RegisterServerMessageCallback(0xA9, new MessageCallback(OnCharacterList), CallbackPriority.Highest);
            Core.RegisterServerMessageCallback(0x1B, new MessageCallback(OnLoginConfirmedPacket), CallbackPriority.Normal);
            Core.RegisterServerMessageCallback(0x55, new MessageCallback(OnLoginCompletePacket), CallbackPriority.Highest);

            loadDataFilesThread.Join();

            PlayerSkills.Init();

            Config.Profile.FpsLimit.Changed += new EventHandler(FrameLimit_Changed);

            Config.InternalSettings.Load();
            Config.Profile.LoadDefault();

            Phoenix.Runtime.RuntimeCore.RegisterPhoenix();
            Phoenix.Runtime.RuntimeCore.ReloadPlugins();
            Phoenix.Runtime.RuntimeCore.CompileScripts(true);

            Trace.WriteLine("Phoenix initialized.", DateTime.Now.ToString());
        }