示例#1
0
        void ClickUpdate(object sender, RoutedEventArgs args)
        {
            SetStartButton(StartButtonSetting.Disabled);
            progressBar.Value = 0;
            lUpdate.Content   = LangStrings.Get("Update_Prepare");

            updateThread = new Thread(() =>
            {
                try
                {
                    current.DoUpdate(SetPercent,
                                     str =>
                    {
                        Dispatcher.Invoke(() => lUpdate.Content = str);
                    });

                    Dispatcher.Invoke(() =>
                    {
                        SetStartButton(StartButtonSetting.Start);
                    });
                }
                catch (Exception e)
                {
                    if (!(e is ThreadAbortException || e is TaskCanceledException))
                    {
                        ShowException(e);
                    }
                }
            });
            updateThread.Start();
        }
示例#2
0
        private string OnLanguageGetHook(string key, string sheet, string orig)
        {
#if DEBUG_CHARMS
            // There probably is a better way to do this, but for now take this
            #region Custom Charms
            if (key.StartsWith("CHARM_NAME_"))
            {
                int charmNum = int.Parse(key.Split('_')[2]);
                if (charmHelper.charmIDs.Contains(charmNum))
                {
                    return("CHARM NAME");
                }
            }
            if (key.StartsWith("CHARM_DESC_"))
            {
                int charmNum = int.Parse(key.Split('_')[2]);
                if (charmHelper.charmIDs.Contains(charmNum))
                {
                    return("CHARM DESC");
                }
            }
            #endregion
#endif
            if (LangStrings.ContainsKey(key, sheet))
            {
                return(LangStrings.Get(key, sheet));
            }
            return(orig);
        }
示例#3
0
        public void DoUpdate(Action <float> SetPercent, Action <string> SetStatus)
        {
            int bytesToLoad = 0;

            for (int i = 0; i < Packs.Count; i++)
            {
                bytesToLoad += Packs[i].PreUpdate();
            }

            int doneBytes = 0;

            int lastUpdate = int.MinValue;

            for (int i = 0; i < Packs.Count; i++)
            {
                Packs[i].DoUpdate(value =>
                {
                    doneBytes += value;
                    SetPercent((float)doneBytes / bytesToLoad);
                    int currentUpdate = doneBytes / 100000;
                    if (currentUpdate > lastUpdate)
                    {
                        SetStatus(string.Format("{0} ({1:0.0}MB / {2:0.0}MB)", LangStrings.Get("Update_Download"), currentUpdate / 10f, bytesToLoad / 1000000f));
                        lastUpdate = currentUpdate;
                    }
                });
            }

            SetStatus(LangStrings.Get("Update_Finished"));
        }
示例#4
0
        void SetStartButton(StartButtonSetting setting)
        {
            switch (setting)
            {
            case StartButtonSetting.Disabled:
                bStart.IsEnabled = false;
                bStart.Content   = LangStrings.Get("Project_Start");
                bStart.Click    -= ClickStart;
                bStart.Click    -= ClickUpdate;
                break;

            case StartButtonSetting.Update:
                bStart.IsEnabled = true;
                bStart.Content   = LangStrings.Get("Project_Update");
                bStart.Click    -= ClickStart;
                bStart.Click    += ClickUpdate;
                break;

            case StartButtonSetting.Start:
                bStart.IsEnabled = true;
                bStart.Content   = LangStrings.Get("Project_Start");
                bStart.Click    += ClickStart;
                bStart.Click    -= ClickUpdate;
                break;
            }
        }
示例#5
0
        void bAddServer_Click(object sender, RoutedEventArgs e)
        {
            var address = InputBox.Show(self, LangStrings.Get("List_Add_Long"));

            if (!string.IsNullOrWhiteSpace(address))
            {
                Configuration.AddServer(address);
            }
        }
示例#6
0
        public Lang_ES() : base(LocalizationManager.Language.ES)
        {
            LangStrings.Add(TextAlias.Mode_Title, "Modo Randomizador");
            LangStrings.Add(TextAlias.Mode_Description, "Randomiza los enemigos y objetos de una manera desafiante e inesperada.");

            LangStrings.Add(TextAlias.HCMode_Title, "Extremo Randomizador");
            LangStrings.Add(TextAlias.HCMode_Description, "Las mejoras están disponibles desde el principio, un mayor número de enemigos son aleatorios para plantear un desafío mortal.");

            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_Default, "Acabar con dos o más enemigos a la vez con Tempestad te devuelve la Concentración gastada al utilizar la habilidad.");
            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_HC, "Acabar con tres o más enemigos a la vez con Tempestad te devuelve la Concentración gastada al utilizar la habilidad.");
        }
示例#7
0
        public Lang_RU() : base(LocalizationManager.Language.RU)
        {
            LangStrings.Add(TextAlias.Mode_Title, "Режим Рандомизация");
            LangStrings.Add(TextAlias.Mode_Description, "Рандомизирует врагов и предметы сложным и неожиданным образом.");

            LangStrings.Add(TextAlias.HCMode_Title, "Жесткая Рандомизация");
            LangStrings.Add(TextAlias.HCMode_Description, "Модификации доступны с самого начала, большее количество врагов рандомизировано, чтобы бросить смертельный вызов.");

            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_Default, "При одновременном убийстве двух и более противников с помощью шквала потраченная на приём концентрация мгновенно восполняется.");
            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_HC, "При одновременном убийстве трех и более противников с помощью шквала потраченная на приём концентрация мгновенно восполняется.");
        }
示例#8
0
        public Lang_PL() : base(LocalizationManager.Language.PL)
        {
            LangStrings.Add(TextAlias.Mode_Title, "Tryb losowy");
            LangStrings.Add(TextAlias.Mode_Description, "Losuje przeciwników oraz obiekty w wymagającym i nieprzewidujący sposób.");

            LangStrings.Add(TextAlias.HCMode_Title, "Hardkorowy Randomizator");
            LangStrings.Add(TextAlias.HCMode_Description, "Ulepszenia są dostępne od samego początku, większa liczba wrogów jest losowana tak, aby stanowili śmiertelne wyzwanie.");

            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_Default, "Zabicie Burza co najmniej dwóch przeciwników naraz zapewnia natychmiastowe odzyskanie wykorzystanych na nia punktów Skupienia.");
            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_HC, "Zabicie Burza co najmniej trzech przeciwników naraz zapewnia natychmiastowe odzyskanie wykorzystanych na nia punktów Skupienia.");
        }
示例#9
0
        public Lang_FR() : base(LocalizationManager.Language.FR)
        {
            LangStrings.Add(TextAlias.Mode_Title, "Mode Aléatoire");
            LangStrings.Add(TextAlias.Mode_Description, "Rend les ennemis et les objets aléatoires pour un défi à la fois stimulant et surprenant.");

            LangStrings.Add(TextAlias.HCMode_Title, "Randomisateur Hardcore");
            LangStrings.Add(TextAlias.HCMode_Description, "Des améliorations sont disponibles dès le début, un plus grand nombre d'ennemis sont aléatoires pour poser un défi mortel.");

            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_Default, "Éliminer au moins deux ennemis d'un coup avec Tempête restitue instantanément la concentration consommée pour son utilisation.");
            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_HC, "Éliminer au moins trois ennemis d'un coup avec Tempête restitue instantanément la concentration consommée pour son utilisation.");
        }
示例#10
0
        public Lang_EN() : base(LocalizationManager.Language.EN)
        {
            LangStrings.Add(TextAlias.Mode_Title, "Randomizer Mode");
            LangStrings.Add(TextAlias.Mode_Description, "Randomizes enemies and objects in a challenging and unexpected way.");

            LangStrings.Add(TextAlias.HCMode_Title, "Hardcore Randomizer");
            LangStrings.Add(TextAlias.HCMode_Description, "Upgrades are available from the start, greater number of enemies are randomized to pose a deathly challenge.");

            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_Default, "Killing two or more enemies at once with Tempest instantly refunds Focus spent to use it.");
            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_HC, "Killing three or more enemies at once with Tempest instantly refunds Focus spent to use it.");
        }
示例#11
0
        public Lang_DE() : base(LocalizationManager.Language.DE)
        {
            LangStrings.Add(TextAlias.Mode_Title, "Zufalls Modus");
            LangStrings.Add(TextAlias.Mode_Description, "Platziert Gegenstände und Gegner in unerwarteten und herausfordernden orten.");

            LangStrings.Add(TextAlias.HCMode_Title, "Hardcore-Zufallsgenerator");
            LangStrings.Add(TextAlias.HCMode_Description, "Upgrades sind von Anfang an verfügbar, eine größere Anzahl von Gegnern wird zufällig ausgewählt und stellt eine tödliche Herausforderung dar.");

            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_Default, "Wenn zwei oder mehr Gegner mit Sturm getötet werden, wird der verbrauchte Fokus sofort zurückerstattet.");
            LangStrings.Add(TextAlias.Ability_Tempest_RefundDesc_HC, "Wenn drei oder mehr Gegner mit Sturm getötet werden, wird der verbrauchte Fokus sofort zurückerstattet.");
        }
示例#12
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();
                self = this;
                serverGrid.Visibility = projectGrid.Visibility = settingsGrid.Visibility = Visibility.Hidden;

                Configuration.Init();

                cbLanguage.SelectedIndex = LangStrings.LanguageIndex;
                foreach (var t in LangStrings.GetNames())
                {
                    cbLanguage.Items.Add(t);
                }

                lSpy.Content    = "zSpy-Level: " + Configuration.zSpyLevel;
                spySlider.Value = Configuration.zSpyLevel;

                lvServerList.ItemsSource = Configuration.Servers;
                string path = Configuration.GothicPath;
                if (string.IsNullOrWhiteSpace(path))
                {
                    // check for steam installation
                    const string RegKey   = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 39510";
                    const string RegValue = @"InstallLocation";
                    tbPath.Text = (string)Microsoft.Win32.Registry.GetValue(RegKey, RegValue, null);
                    ShowSettings();
                }
                else
                {
                    tbPath.Text = path;
                    if (!Configuration.CheckGothicPath(path))
                    {
                        ShowSettings();
                    }
                    else
                    {
                        ShowServerList();
                        if (Configuration.ActiveProject != null)
                        {
                            TryOpenProjectPage(Configuration.ActiveProject, Configuration.ActiveProject.Password, true);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("{0}: {1}\r\n{2}", e.Source, e.Message, e.StackTrace), e.GetType().ToString(), MessageBoxButton.OK);
                Application.Current.Shutdown();
            }
        }
示例#13
0
        void bPathChange_Click(object sender, RoutedEventArgs e)
        {
            using (var dlg = new System.Windows.Forms.FolderBrowserDialog())
            {
                dlg.ShowNewFolderButton = false;
                dlg.SelectedPath        = Directory.Exists(tbPath.Text) ? tbPath.Text : Directory.GetCurrentDirectory();
                dlg.Description         = LangStrings.Get("Config_Search_Long");

                if (dlg.ShowDialog(MainWindow.Self.GetIWin32Window()) == System.Windows.Forms.DialogResult.OK)
                {
                    tbPath.Text = dlg.SelectedPath;
                }
            }
        }
示例#14
0
        public void Read(Stream stream, string path, Action <UpdateUIEnum> UpdateUI, Action <float> SetPercent, Action <string> SetStatus)
        {
            Packs.Clear();

            using (DeflateStream ds = new DeflateStream(stream, CompressionMode.Decompress))
            {
                byte[] buf = new byte[4];
                stream.Read(buf, 0, 4);
                int fileSize = BitConverter.ToInt32(buf, 0) - 4;

                using (PacketStream header = new PacketStream(ds, fileSize, value => SetPercent(0.4f * value)))
                {
                    SetStatus(LangStrings.Get("Update_Website"));
                    this.Website = header.ReadStringShort();
                    UpdateUI(UpdateUIEnum.Website);

                    SetStatus(LangStrings.Get("Update_Text"));
                    this.InfoText = header.ReadStringLong();
                    UpdateUI(UpdateUIEnum.InfoText);

                    SetStatus(LangStrings.Get("Update_Background"));
                    int len = header.ReadInt();
                    ImageData = header.ReadBytes(len);
                    UpdateUI(UpdateUIEnum.Image);

                    int count      = header.ReadByte();
                    int checkBytes = 0;
                    for (int i = 0; i < count; i++)
                    {
                        SetStatus(string.Format("{0} ({1}/{2})...", LangStrings.Get("Update_Data"), i + 1, count));
                        DataPack pack = new DataPack();
                        checkBytes += pack.Read(header, path);
                        Packs.Add(pack);
                    }

                    int doneBytes = 0;
                    for (int i = 0; i < count; i++)
                    {
                        SetStatus(string.Format("{0} ({1}/{2})...", LangStrings.Get("Update_Check"), i + 1, count));
                        Packs[i].EndCheck(value =>
                        {
                            doneBytes += value;
                            SetPercent(0.4f + 0.6f * doneBytes / checkBytes);
                        });
                    }

                    SetPercent(1);
                }
            }
        }
示例#15
0
 void UpdateLanguage()
 {
     bConnect.Content      = LangStrings.Get("List_Connect");
     bRefresh.Content      = LangStrings.Get("List_Refresh");
     bAddServer.Content    = LangStrings.Get("List_Add");
     bRemoveServer.Content = LangStrings.Get("List_Remove");
     ((GridView)lvServerList.View).Columns[2].Header = LangStrings.Get("List_Players");
     bBack1.Content          = LangStrings.Get("Project_Back");
     bWebsite.Content        = LangStrings.Get("Project_Website");
     lSettings.Content       = LangStrings.Get("Config_Settings");
     bSettingsAccept.Content = LangStrings.Get("Input_Accept");
     lLanguage.Content       = LangStrings.Get("Config_Language");
     lPath.Content           = LangStrings.Get("Config_InstallPath");
     bPathChange.Content     = LangStrings.Get("Config_ChangePath");
 }
示例#16
0
        void ShowPasswordPage(ServerListItem item, bool wrongPW = false)
        {
            var pw = ShowInputBox(LangStrings.Get(wrongPW ? "Password_Wrong" : "Password_Needed"));

            if (pw == null)
            {
                return;
            }

            byte[] hash;
            using (MD5 md5 = new MD5CryptoServiceProvider())
            {
                hash = md5.ComputeHash(Encoding.Unicode.GetBytes(pw));
            }

            TryOpenProjectPage(item, hash);
        }
示例#17
0
        public static void Init()
        {
            const string LanguageFile = "launcher.languages";

            if (!File.Exists(LanguageFile))
            {
                using (var s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("GUCLauncher.Resources." + LanguageFile))
                    using (var fs = new FileStream(LanguageFile, FileMode.Create, FileAccess.Write, FileShare.None))
                    {
                        s.CopyTo(fs);
                    }
            }

            LangStrings.LoadFile(LanguageFile);

            Load();
        }
示例#18
0
        void CheckForUpdates(object arg)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(dlLink))
                {
                    Dispatcher.Invoke(() =>
                    {
                        lUpdate.Content = LangStrings.Get("Update_Disabled");
                        SetStartButton(StartButtonSetting.Start);
                        progressBar.Value = 100;
                    });
                    return;
                }

                Dispatcher.Invoke(() => lUpdate.Content = LangStrings.Get("Update_Connecting"));
                // load the information file
                float percent = 0;
                using (var response = Download.GetResponse(dlLink, value =>
                {
                    percent = value * 0.70f;
                    SetPercent(percent);
                }))
                {
                    Stream stream;
                    if (response != null && (stream = response.GetResponseStream()) != null)
                    {
                        Dispatcher.Invoke(() => lUpdate.Content = LangStrings.Get("Update_Infos"));
                        current = new InfoPack();
                        current.Read(stream, Configuration.ActiveProject.GetFolder(), UpdateUI,
                                     value =>
                        {
                            SetPercent(value * (1 - percent) + percent);
                        },
                                     str =>
                        {
                            Dispatcher.Invoke(() => lUpdate.Content = str);
                        });

                        Dispatcher.Invoke(() =>
                        {
                            if (current.NeedsUpdate())
                            {
                                SetStartButton(StartButtonSetting.Update);
                                lUpdate.Content = LangStrings.Get("Update_Needed");
                            }
                            else
                            {
                                SetStartButton(StartButtonSetting.Start);
                                lUpdate.Content = LangStrings.Get("Update_Finished");
                            }
                        });
                    }
                    else
                    {
                        Dispatcher.Invoke(() =>
                        {
                            lUpdate.Content   = LangStrings.Get("Update_Failed");
                            progressBar.Value = 100;
                        });
                    }
                }
            }
            catch (Exception e)
            {
                if (!(e is ThreadAbortException || e is TaskCanceledException))
                {
                    ShowException(e);
                }
            }
        }
示例#19
0
        void TryOpenProjectPage(ServerListItem item, byte[] password, bool initload = false)
        {
            if (item.HasPW && password == null)
            {
                if (initload)
                {
                    return;
                }

                ShowPasswordPage(item);
                return;
            }

            TcpClient client   = new TcpClient();
            int       waitTime = initload ? 400 : 1000;

            if (client.ConnectAsync(item.IP, item.Port).Wait(waitTime))
            {
                var    stream = client.GetStream();
                byte[] buf    = new byte[byte.MaxValue];
                buf[0] = 1;

                if (password != null)
                {
                    Array.Copy(password, 0, buf, 1, 16);
                }

                if (stream.WriteAsync(buf, 0, 17).Wait(waitTime))
                {
                    if (stream.ReadAsync(buf, 0, 1).Wait(waitTime))
                    {
                        if (buf[0] == 0)
                        {
                            // wrong password
                            client.Close();
                            ShowPasswordPage(item, true);
                            return;
                        }
                        else if (stream.ReadAsync(buf, 0, 1).Wait(waitTime))
                        {
                            // correct password!
                            item.Password = password;
                            Configuration.Save();

                            int byteLen = buf[0];
                            if (stream.ReadAsync(buf, 0, byteLen).Wait(waitTime))
                            {
                                dlLink = Encoding.UTF8.GetString(buf, 0, byteLen);
                                client.Close();
                                ShowProjectPage(item);
                                return;
                            }
                        }
                    }
                }
            }
            client.Close();

            //Could not connect
            if (!initload)
            {
                ShowInfoBox(LangStrings.Get("Connection_Failed"));
            }
        }