Ejemplo n.º 1
0
        private void dataBrowse_Click(object sender, System.EventArgs e)
        {
            FolderBrowserDialog folder = new FolderBrowserDialog();

            folder.Description = "Select a UO Data Directory...";

            if (m_DataDir != null)
            {
                folder.SelectedPath = m_DataDir;
            }

            folder.ShowNewFolderButton = false;
            if (folder.ShowDialog() == DialogResult.OK)
            {
                dataDir.Text = m_DataDir = folder.SelectedPath;
                Config.SetAppSetting("UODataDir", dataDir.Text);

                IsValidClientAndDataDir();

                if (!dataDir.Text.Equals(Path.GetDirectoryName(uoClient.Text)))
                {
                    MessageBox.Show(Language.GetString(LocString.ClientDataMismatch), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Ejemplo n.º 2
0
        private void makeDef_Click(object sender, System.EventArgs e)
        {
            Config.SetAppSetting("PatchEncy", patchEncy.Checked ? "1" : "0");
            Config.SetAppSetting("ServerEnc", useEnc.Checked ? "1" : "0");

            MessageBox.Show(this, Language.GetString(LocString.SaveOK), "Done", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Ejemplo n.º 3
0
        private void okay_Click(object sender, System.EventArgs e)
        {
            m_PatchEncy = patchEncy.Checked;

            m_Launch     = ClientLaunch.TwoD;
            m_ClientPath = uoClient.Text;

            ServerEntry se = null;

            if (serverList.SelectedItem != null)
            {
                if (serverList.SelectedItem is Custom_SE)
                {
                    int port = ((Custom_SE)serverList.SelectedItem).Port;

                    string addr = ((Custom_SE)serverList.SelectedItem).RealAddress;

                    if (addr == "login.ultimaonline.com")
                    {
                        ClientCommunication.ServerEncrypted = true;
                    }

                    if (port == 0)
                    {
                        port = 2593; // runuo default
                    }
                    se = new ServerEntry(addr, port);
                }
            }
            else
            {
                try
                {
                    string[] portAddress = serverList.Text.Split(',');
                    se = new ServerEntry(portAddress[0], Int32.Parse(portAddress[1]));
                }
                catch
                {
                    MessageBox.Show("O padrão que tem que ser seguido é 127.0.0.1,2593", "Erro ao digitar o endereço e porta",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }

            if (se != null && se.Address != null)
            {
                Config.SetAppSetting("LastServer", se.Address);
                Config.SetAppSetting("LastPort", se.Port.ToString());

                Config.SetAppSetting("LastServerId", serverList.SelectedIndex.ToString());
            }

            SaveData();
            this.Close();
        }
Ejemplo n.º 4
0
        private void patchEncy_CheckedChanged(object sender, System.EventArgs e)
        {
            if (!patchEncy.Checked)
            {
                if (MessageBox.Show(this, Language.GetString(LocString.NoPatchWarning),
                                    Language.GetString(LocString.Confirm), MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                    DialogResult.No)
                {
                    patchEncy.Checked = true;
                }
            }

            Config.SetAppSetting("ClientEncrypted", patchEncy.Checked ? "1" : "0");
        }
Ejemplo n.º 5
0
        private void browse_Click(object sender, System.EventArgs e)
        {
            if (openFile.ShowDialog(this) == DialogResult.OK)
            {
                PathElipsis pe = new PathElipsis(openFile.FileName);

                uoClient.Text = pe.GetPath();

                dataDir.Text = m_DataDir = Path.GetDirectoryName(uoClient.Text);

                Config.SetAppSetting("UODataDir", dataDir.Text);
                Config.SetAppSetting("UOClient", uoClient.Text);

                IsValidClientAndDataDir();
            }
        }
Ejemplo n.º 6
0
        private void langSel_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            string lang = langSel.SelectedItem as string;

            if (lang != null && lang != Language.Current)
            {
                if (!Language.Load(lang))
                {
                    MessageBox.Show("There was an error loading that language.", "Language Load Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    langSel.SelectedItem = Language.Current;
                }
                else
                {
                    Config.SetAppSetting("DefaultLanguage", Language.Current);
                    Language.LoadControlNames(this);
                }
            }
        }
Ejemplo n.º 7
0
        private void okay_Click(object sender, System.EventArgs e)
        {
            Config.SetAppSetting("PatchEncy", patchEncy.Checked ? "1" : "0");

            m_PatchEncy = patchEncy.Checked;

            m_Launch     = ClientLaunch.TwoD;
            m_ClientPath = uoClient.Text;

            ServerEntry se = null;

            if (serverList.SelectedItem != null)
            {
                if (serverList.SelectedItem is Custom_SE)
                {
                    int port = ((Custom_SE)serverList.SelectedItem).Port;

                    string addr = ((Custom_SE)serverList.SelectedItem).RealAddress;

                    if (addr == "login.ultimaonline.com")
                    {
                        Assistant.Client.Instance.ServerEncrypted = true;
                    }

                    if (port == 0)
                    {
                        port = 2593; // runuo default
                    }
                    se = new ServerEntry(addr, port);
                }
            }

            if (se != null && se.Address != null)
            {
                Config.SetAppSetting("LastServer", se.Address);
                Config.SetAppSetting("LastPort", se.Port.ToString());

                Config.SetAppSetting("LastServerId", serverList.SelectedIndex.ToString());
            }

            SaveData();
            this.Close();
        }
Ejemplo n.º 8
0
        private void dataBrowse_Click(object sender, System.EventArgs e)
        {
            FolderBrowserDialog folder = new FolderBrowserDialog();

            folder.Description = "Select a UO Data Directory...";

            if (m_DataDir != null)
            {
                folder.SelectedPath = m_DataDir;
            }

            folder.ShowNewFolderButton = false;
            if (folder.ShowDialog() == DialogResult.OK)
            {
                dataDir.Text = m_DataDir = folder.SelectedPath;
                Config.SetAppSetting("UODataDir", dataDir.Text);

                IsValidClientAndDataDir();
            }
        }
Ejemplo n.º 9
0
        private void okay_Click(object sender, System.EventArgs e)
        {
            m_ClientPath = uoClient.Text;

            ServerEntry se = null;

            if (serverList.SelectedItem != null)
            {
                if (serverList.SelectedItem is Custom_SE)
                {
                    int port = ((Custom_SE)serverList.SelectedItem).Port;

                    string addr = ((Custom_SE)serverList.SelectedItem).RealAddress;

                    if (addr == "login.ultimaonline.com")
                    {
                        Config.SetAppSetting("ServerEncrypted", "1");
                    }

                    if (port == 0)
                    {
                        port = 2593; // runuo default
                    }
                    se = new ServerEntry(addr, port);
                }
            }

            if (se != null && se.Address != null)
            {
                Config.SetAppSetting("LastServer", se.Address);
                Config.SetAppSetting("LastPort", se.Port.ToString());

                Config.SetAppSetting("LastServerId", serverList.SelectedIndex.ToString());
            }

            SaveData();
            this.Close();
        }
Ejemplo n.º 10
0
        private void SaveData()
        {
            for (int i = 0; i < serverList.Items.Count; i++)
            {
                for (int j = i + 1; j < serverList.Items.Count; j++)
                {
                    ServerEntry si = (ServerEntry)serverList.Items[i];
                    ServerEntry sj = (ServerEntry)serverList.Items[j];
                    if (si.Address == sj.Address && si.Port == sj.Port)
                    {
                        serverList.Items.RemoveAt(j);
                    }
                }
            }

            int num = 1;

            for (int i = 0; i < serverList.Items.Count; i++)
            {
                ServerEntry se = (ServerEntry)serverList.Items[i];
                if (se is Custom_SE || se is LoginCFG_SE)
                {
                    continue;
                }

                if (se.Address != "")
                {
                    Config.SetAppSetting($"Server{num}", se.Address);
                    Config.SetAppSetting($"Port{num}", se.Port.ToString());
                    num++;
                }
            }

            Config.SetAppSetting("UOClient", uoClient.Text);
            Config.SetAppSetting("UODataDir", dataDir.Text);
            m_DataDir = dataDir.Text;
        }
Ejemplo n.º 11
0
 private void showAtStart_CheckedChanged(object sender, System.EventArgs e)
 {
     Config.SetAppSetting("ShowWelcome", (showAtStart.Checked ? 1 : 0).ToString());
 }
Ejemplo n.º 12
0
        private void WelcomeForm_Load(object sender, System.EventArgs e)
        {
            Language.LoadControlNames(this);

            this.BringToFront();

            langSel.Items.AddRange(Language.GetPackNames());
            langSel.SelectedItem = Language.Current;

            showAtStart.Checked = Config.GetAppSetting <int>("ShowWelcome") == 1;

            uoClient.Text = Config.GetAppSetting <string>("UOClient");
            dataDir.Text  = Config.GetAppSetting <string>("UODataDir");

            IsValidClientAndDataDir();

            patchEncy.Checked = Config.GetAppSetting <int>("PatchEncy") != 0;

            LoginCFG_SE lse = new LoginCFG_SE();
            Custom_SE   cse;

            serverList.BeginUpdate();

            AddUORServers();

            // Load any custom servers they might have added
            NameValueCollection servers =
                (NameValueCollection)ConfigurationManager.GetSection("Servers");

            foreach (string server in servers.AllKeys)
            {
                string[] serverHostAndPort = servers[server].Split(',');
                string   serverHost        = serverHostAndPort[0];
                string   serverPort        = serverHostAndPort[1];

                serverList.Items.Add(new Custom_SE(server, serverHost, Convert.ToInt32(serverPort)));
            }

            serverList.EndUpdate();
            serverList.Refresh();

            // Set it to the last used one, or just set it to default UOR Prod
            try
            {
                serverList.SelectedIndex = Config.GetAppSetting <int>("LastServerId");
            }
            catch
            {
                serverList.SelectedIndex = 0;
            }

            WindowState = FormWindowState.Normal;
            this.BringToFront();
            this.TopMost = true;

            _ShowTimer          = new System.Windows.Forms.Timer();
            _ShowTimer.Interval = 250;
            _ShowTimer.Enabled  = true;
            _ShowTimer.Tick    += new EventHandler(timer_Tick);


            if (Config.GetAppSetting <bool>("ImportProfilesAndMacros"))
            {
                string appDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Razor");

                if (Directory.Exists(appDataDir))
                {
                    if (MessageBox.Show(Language.GetString(LocString.ImportFromPrevious), "Import Razor Profiles and Macros",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Config.ImportProfilesMacros(appDataDir);

                        MessageBox.Show("Import complete", "Import Razor Profiles and Macros", MessageBoxButtons.OK);
                    }
                }

                Config.SetAppSetting("ImportProfilesAndMacros", "false");
            }
        }
Ejemplo n.º 13
0
        public static void Main(string[] Args)
        {
            Client.Init(true);
            Application.EnableVisualStyles();
            m_Running = true;
            Thread.CurrentThread.Name = "Razor Main Thread";

#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Directory.SetCurrentDirectory(Config.GetInstallDirectory());
#endif

            try
            {
                Engine.ShardList = Config.GetAppSetting <string>("ShardList");
            }
            catch
            {
            }

            bool         patch       = Config.GetAppSetting <int>("PatchEncy") != 0;
            bool         showWelcome = Config.GetAppSetting <int>("ShowWelcome") != 0;
            ClientLaunch launch      = ClientLaunch.TwoD;

            int    attPID = -1;
            string dataDir;

            Client.Instance.ClientEncrypted = false;

            Client.Instance.ServerEncrypted = false;

            Config.SetAppSetting("PatchEncy", "1");

            patch = true;

            dataDir = null;

            bool advCmdLine = false;

            for (int i = 0; i < Args.Length; i++)
            {
                string arg = Args[i].ToLower();
                if (arg == "--nopatch")
                {
                    patch = false;
                }
                else if (arg == "--clientenc")
                {
                    Client.Instance.ClientEncrypted = true;
                    advCmdLine = true;
                    patch      = false;
                }
                else if (arg == "--serverenc")
                {
                    Client.Instance.ServerEncrypted = true;
                    advCmdLine = true;
                }
                else if (arg == "--welcome")
                {
                    showWelcome = true;
                }
                else if (arg == "--nowelcome")
                {
                    showWelcome = false;
                }
                else if (arg == "--pid" && i + 1 < Args.Length)
                {
                    i++;
                    patch  = false;
                    attPID = Utility.ToInt32(Args[i], 0);
                }
                else if (arg.Substring(0, 5) == "--pid" && arg.Length > 5) //support for uog 1.8 (damn you fixit)
                {
                    patch  = false;
                    attPID = Utility.ToInt32(arg.Substring(5), 0);
                }
                else if (arg == "--uodata" && i + 1 < Args.Length)
                {
                    i++;
                    dataDir = Args[i];
                }
                else if (arg == "--server" && i + 1 < Args.Length)
                {
                    i++;
                    string[] split = Args[i].Split(',', ':', ';', ' ');
                    if (split.Length >= 2)
                    {
                        Config.SetAppSetting("LastServer", split[0]);
                        Config.SetAppSetting("LastPort", split[1]);

                        showWelcome = false;
                    }
                }
                else if (arg == "--debug")
                {
                    ScavengerAgent.Debug  = true;
                    DragDropManager.Debug = true;
                }
            }

            if (attPID > 0 && !advCmdLine)
            {
                Client.Instance.ServerEncrypted = false;
                Client.Instance.ClientEncrypted = false;
            }

            if (!Language.Load("ENU"))
            {
                SplashScreen.End();
                MessageBox.Show(
                    "Fatal Error: Unable to load required file Language/Razor_lang.enu\nRazor cannot continue.",
                    "No Language Pack", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            string defLang = Config.GetAppSetting <string>("DefaultLanguage");
            if (defLang != null && !Language.Load(defLang))
            {
                MessageBox.Show(
                    String.Format(
                        "WARNING: Razor was unable to load the file Language/Razor_lang.{0}\nENU will be used instead.",
                        defLang), "Language Load Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            string clientPath = "";

            // welcome only needed when not loaded by a launcher (ie uogateway)
            if (attPID == -1)
            {
                if (!showWelcome)
                {
                    int cli = Config.GetAppSetting <int>("DefClient");
                    if (cli < 0 || cli > 1)
                    {
                        launch     = ClientLaunch.Custom;
                        clientPath = Config.GetAppSetting <string>($"Client{cli - 1}");
                        if (string.IsNullOrEmpty(clientPath))
                        {
                            showWelcome = true;
                        }
                    }
                    else
                    {
                        launch = (ClientLaunch)cli;
                    }
                }

                if (showWelcome)
                {
                    SplashScreen.End();

                    WelcomeForm welcome = new WelcomeForm();
                    m_ActiveWnd = welcome;
                    if (welcome.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                    patch   = welcome.PatchEncryption;
                    launch  = welcome.Client;
                    dataDir = welcome.DataDirectory;
                    if (launch == ClientLaunch.Custom)
                    {
                        clientPath = welcome.ClientPath;
                    }

                    SplashScreen.Start();
                    m_ActiveWnd = SplashScreen.Instance;
                }
            }

            if (dataDir != null && Directory.Exists(dataDir))
            {
                Ultima.Files.SetMulPath(dataDir);
            }

            Language.LoadCliLoc();

            SplashScreen.Message = LocString.Initializing;

            //m_TimerThread = new Thread( new ThreadStart( Timer.TimerThread.TimerMain ) );
            //m_TimerThread.Name = "Razor Timers";

            Initialize(typeof(Assistant.Engine).Assembly); //Assembly.GetExecutingAssembly()

            SplashScreen.Message = LocString.LoadingLastProfile;
            Config.LoadCharList();
            if (!Config.LoadLastProfile())
            {
                MessageBox.Show(
                    "The selected profile could not be loaded, using default instead.", "Profile Load Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (attPID == -1)
            {
                Client.Instance.SetConnectionInfo(IPAddress.None, -1);

                Client.Loader_Error result = Client.Loader_Error.UNKNOWN_ERROR;

                SplashScreen.Message = LocString.LoadingClient;

                if (launch == ClientLaunch.TwoD)
                {
                    clientPath = Ultima.Files.GetFilePath("client.exe");
                }
                else if (launch == ClientLaunch.ThirdDawn)
                {
                    clientPath = Ultima.Files.GetFilePath("uotd.exe");
                }

                if (!advCmdLine)
                {
                    Client.Instance.ClientEncrypted = patch;
                }

                if (clientPath != null && File.Exists(clientPath))
                {
                    result = Client.Instance.LaunchClient(clientPath);
                }

                if (result != Client.Loader_Error.SUCCESS)
                {
                    if (clientPath == null && File.Exists(clientPath))
                    {
                        MessageBox.Show(SplashScreen.Instance,
                                        String.Format("Unable to find the client specified.\n{0}: \"{1}\"", launch.ToString(),
                                                      clientPath != null ? clientPath : "-null-"), "Could Not Start Client",
                                        MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                    else
                    {
                        MessageBox.Show(SplashScreen.Instance,
                                        String.Format("Unable to launch the client specified. (Error: {2})\n{0}: \"{1}\"",
                                                      launch.ToString(), clientPath != null ? clientPath : "-null-", result),
                                        "Could Not Start Client", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                    SplashScreen.End();
                    return;
                }

                string addr = Config.GetAppSetting <string>("LastServer");
                int    port = Config.GetAppSetting <int>("LastPort");

                // if these are null then the registry entry does not exist (old razor version)
                IPAddress ip = Resolve(addr);
                if (ip == IPAddress.None || port == 0)
                {
                    MessageBox.Show(SplashScreen.Instance, Language.GetString(LocString.BadServerAddr),
                                    "Bad Server Address", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    SplashScreen.End();
                    return;
                }

                Client.Instance.SetConnectionInfo(ip, port);
            }
            else
            {
                string error  = "Error attaching to the UO client.";
                bool   result = false;
                try
                {
                    result = Client.Instance.Attach(attPID);
                }
                catch (Exception e)
                {
                    result = false;
                    error  = e.Message;
                }

                if (!result)
                {
                    MessageBox.Show(SplashScreen.Instance,
                                    String.Format("{1}\nThe specified PID '{0}' may be invalid.", attPID, error), "Attach Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    SplashScreen.End();
                    return;
                }

                Client.Instance.SetConnectionInfo(IPAddress.Any, 0);
            }



            if (Utility.Random(4) != 0)
            {
                SplashScreen.Message = LocString.WaitingForClient;
            }
            else
            {
                SplashScreen.Message = LocString.RememberDonate;
            }

            m_MainWnd = new MainForm();
            Application.Run(m_MainWnd);

            m_Running = false;

            Client.Instance.Close();
            Counter.Save();
            Macros.MacroManager.Save();
            Config.Save();
        }