public void LoadTranslations()
        {
            loader = new LocalizationLoader(Loc.Instance);

            loader.AddTranslation("SayHello", "en", "Hello");
            loader.AddTranslation("SayHello", "fr", "Bonjour");
        }
示例#2
0
        private void SplitSearchWindow_Load(object sender, EventArgs e)
        {
            ModSelectionHandler.ConfigureModFilter();

            _minLevel.KeyPress   += MinLevel_KeyPress;
            _minLevel.MouseWheel += MinLevel_MouseWheel;

            _maxLevel.KeyPress   += MinLevel_KeyPress;
            _maxLevel.MouseWheel += MaxLevel_MouseWheel;

            _itemQuality.Items.AddRange(UIHelper.QualityFilter.ToArray <object>());
            _itemQuality.SelectedIndex         = 0;
            _selectedItemQuality               = _itemQuality.SelectedItem as ComboBoxItemQuality;
            _itemQuality.SelectedIndexChanged += (s, ev) => { _selectedItemQuality = _itemQuality.SelectedItem as ComboBoxItemQuality; };
            _itemQuality.SelectedIndexChanged += BeginSearchOnAutoSearch;

            _slotFilter.Items.AddRange(UIHelper.SlotFilter.ToArray <object>());
            _slotFilter.SelectedIndex         = 0;
            _selectedSlot                     = _slotFilter.SelectedItem as ComboBoxItem;
            _slotFilter.SelectedIndexChanged += (s, ev) => { _selectedSlot = _slotFilter.SelectedItem as ComboBoxItem; };
            _slotFilter.SelectedIndexChanged += BeginSearchOnAutoSearch;

            FormClosing += SplitSearchWindow_FormClosing;

            _searchBox.TextChanged += SearchBox_TextChanged;

            _orderByLevel.CheckStateChanged += delegate { UpdateListViewDelayed(); };

            _flowPanelFilter.SizeChanged += FlowPanelFilter_Resize;
            _mainSplitter.SizeChanged    += FlowPanelFilter_Resize;

            LocalizationLoader.ApplyTooltipLanguage(toolTip1, Controls, RuntimeSettings.Language);
        }
示例#3
0
        public override void OnModLoad()
        {
            AutoRegisteredTranslations = new Dictionary <string, ModTranslation>();

            foreach (string culture in GetCultures())
            {
                foreach (string fileName in ExistingJsonFiles)
                {
                    string filePath = GetFilePath(culture, fileName);
                    if (!Mod.FileExists(filePath))
                    {
                        break;
                    }
                    using Stream stream = Mod.GetFileStream(filePath);
                    foreach ((string s, Dictionary <string, string> dictionary) in
                             JsonUtilities.DeserializeJsonFromStream <Dictionary <string, Dictionary <string, string> > >(stream))
                    {
                        foreach ((string key, string value) in dictionary)
                        {
                            GetOrCreateTranslation($"{s}.{key}").AddTranslation(culture, value);
                        }
                    }
                }
            }

            foreach (ModTranslation translation in AutoRegisteredTranslations.Values)
            {
                LocalizationLoader.AddTranslation(translation);
            }
        }
示例#4
0
        public void AddToggle(String toggle, String name, int item, String color)
        {
            ModTranslation text = LocalizationLoader.CreateTranslation(toggle);

            text.SetDefault("[i:" + item + "] [c/" + color + ":" + name + "]");

            LocalizationLoader.AddTranslation(text);
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalizationSystem"/> class.
        /// </summary>
        /// <param name="defaultLocalization">The default localization.</param>
        /// <param name="loader">The loader.</param>
        public LocalizationSystem(string defaultLocalization, LocalizationLoader loader = null)
        {
            _locales            = new Dictionary <string, Localization>();
            DefaultLocalization = defaultLocalization;
            CurrentLocalization = defaultLocalization;
            LocalizationLoader  = loader;

            AddLanguage(defaultLocalization);
        }
示例#6
0
 private void ExportMode_Load(object sender, EventArgs e)
 {
     cbItemSelection.Items.Add("All items");
     cbItemSelection.Items.AddRange(_modSelection);
     cbItemSelection.SelectedIndex = 0;
     buttonExport.Enabled          = false;
     cbItemSelection.Visible       = false;
     LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
 }
示例#7
0
        private void StashTabPicker_Load(object sender, EventArgs e)
        {
            switch (Properties.Settings.Default.StashToDepositTo)
            {
            case 0:
                radioOutputSecondToLast.Checked = true;
                break;

            case 1:
                radioOutput1.Checked = true;
                break;

            case 2:
                radioOutput2.Checked = true;
                break;

            case 3:
                radioOutput3.Checked = true;
                break;

            case 4:
                radioOutput4.Checked = true;
                break;

            case 5:
                radioOutput5.Checked = true;
                break;
            }
            switch (Properties.Settings.Default.StashToLootFrom)
            {
            case 0:
                radioInputLast.Checked = true;
                break;

            case 1:
                radioInput1.Checked = true;
                break;

            case 2:
                radioInput2.Checked = true;
                break;

            case 3:
                radioInput3.Checked = true;
                break;

            case 4:
                radioInput4.Checked = true;
                break;

            case 5:
                radioInput5.Checked = true;
                break;
            }

            LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
        }
示例#8
0
        private void StashTabPicker_Load(object sender, EventArgs e)
        {
            // Calculate the height dynamically depending on how many stashes the user has
            Height            = Math.Min(800, Math.Max(357, 202 + 31 * _numStashTabs));
            gbMoveTo.Height   = Math.Max(248, 83 + 33 * _numStashTabs);
            gbLootFrom.Height = Math.Max(248, 83 + 33 * _numStashTabs);


            for (int i = 1; i <= Math.Max(5, _numStashTabs); i++)
            {
                int p = i; // Don't reference out scope (mutated)
                FirefoxRadioButton.CheckedChangedEventHandler callback = (o, args) => {
                    if (p <= _numStashTabs)
                    {
                        // Don't trust the "Firefox framework" to not trigger clicks on disabled buttons.
                        _settings.GetLocal().StashToDepositTo = p;
                    }
                };

                int y  = 32 + 33 * i;
                var cb = CreateCheckbox($"moveto_tab_{i}", $"iatag_ui_tab_{i}", $"Tab {i}", new Point(6, y), callback);

                cb.Checked     = _settings.GetLocal().StashToDepositTo == i;
                cb.Enabled     = i <= _numStashTabs;
                cb.EnabledCalc = i <= _numStashTabs;
                this.gbMoveTo.Controls.Add(cb);
                helpWhyAreTheseDisabled.Visible = _numStashTabs <= 4;
            }


            for (int i = 1; i <= Math.Max(5, _numStashTabs); i++)
            {
                int p = i; // Don't reference out scope (mutated)
                FirefoxRadioButton.CheckedChangedEventHandler callback = (o, args) => {
                    if (p <= _numStashTabs)
                    {
                        // Don't trust the "Firefox framework" to not trigger clicks on disabled buttons.
                        _settings.GetLocal().StashToLootFrom = p;
                    }
                };

                int y  = 32 + 33 * i;
                var cb = CreateCheckbox($"lootfrom_tab_{i}", $"iatag_ui_tab_{i}", $"Tab {i}", new Point(6, y), callback);
                cb.Checked     = _settings.GetLocal().StashToLootFrom == i;
                cb.Enabled     = i <= _numStashTabs;
                cb.EnabledCalc = i <= _numStashTabs;
                this.gbLootFrom.Controls.Add(cb);
            }



            radioOutputSecondToLast.Checked = _settings.GetLocal().StashToDepositTo == 0;
            radioInputLast.Checked          = _settings.GetLocal().StashToLootFrom == 0;

            LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
        }
示例#9
0
        public void LoadYaml()
        {
            loc = new Loc();

            loader = new LocalizationLoader(loc);

            loader.FileLanguageLoaders.Add(new YamlFileLoader());

            loader.AddDirectory(directory);
        }
示例#10
0
 /// <summary>
 /// Update the UI's language
 /// </summary>
 public void UpdateLanguage()
 {
     LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
     Text = GlobalSettings.Language.GetTag(Tag.ToString());
     if (tsStashStatus.Tag is string)
     {
         tsStashStatus.Text = GlobalSettings.Language.GetTag(tsStashStatus.Tag.ToString());
     }
     Refresh();
 }
示例#11
0
        private void ImportMode_Load(object sender, EventArgs e)
        {
            this.Dock = DockStyle.Fill;
            this.buttonImport.Enabled = false;
            cbItemSelection.Visible   = false;
            cbItemSelection.Enabled   = false;

            cbItemSelection.Items.AddRange(_modSelection);
            LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
        }
示例#12
0
 static GlobalSettings()
 {
     if (string.IsNullOrEmpty(Properties.Settings.Default.LocalizationFile) || !File.Exists(Properties.Settings.Default.LocalizationFile))
     {
         Language = new EnglishLanguage();
     }
     else
     {
         Language = new LocalizationLoader().LoadLanguage(Properties.Settings.Default.LocalizationFile);
     }
 }
示例#13
0
        /// <summary>
        ///     Creates or gets a translation from <see cref="AutoRegisteredTranslations"/>. If a translation is created, it will be added to <see cref="AutoRegisteredTranslations"/>.
        /// </summary>
        public ModTranslation GetOrCreateTranslation(string key)
        {
            if (AutoRegisteredTranslations.ContainsKey(key))
            {
                return(AutoRegisteredTranslations[key]);
            }

            ModTranslation translation = LocalizationLoader.CreateTranslation(Mod, key);

            AutoRegisteredTranslations.Add(key, translation);
            return(translation);
        }
示例#14
0
        private void LanguagePackPicker_Load(object sender, EventArgs e)
        {
            LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
            var loc = new LocalizationLoader();

            var n = 0;

            // Default language: English
            {
                var cb = new FirefoxRadioButton
                {
                    Location = new Point(10, 25 + n * 33),
                    Text     = "English (Official)",
                    Tag      = string.Empty,
                    Checked  = string.IsNullOrEmpty(_settings.GetLocal().LocalizationFile),
                    TabIndex = n,
                    TabStop  = true
                };

                groupBox1.Controls.Add(cb);
                _checkboxes.Add(cb);
                n++;
            }

            foreach (var path in _paths)
            {
                if (Directory.Exists(Path.Combine(path, "localization")))
                {
                    foreach (var file in Directory.EnumerateFiles(Path.Combine(path, "localization"), "*.zip"))
                    {
                        loc.CheckLanguage(file, out var author, out var language);

                        var cb = new FirefoxRadioButton
                        {
                            Location = new Point(10, 25 + n * 33),
                            Text     = RuntimeSettings.Language.GetTag("iatag_ui_language_by_author", language, author),
                            Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top,
                            Width    = groupBox1.Width - pictureBox1.Width,
                            Tag      = file,
                            Checked  = file == _settings.GetLocal().LocalizationFile,
                            TabIndex = n,
                            TabStop  = true
                        };

                        groupBox1.Controls.Add(cb);
                        _checkboxes.Add(cb);
                        n++;
                    }
                }
            }

            Height += n * 33;
        }
示例#15
0
        private void buttonSelect_Click(object sender, EventArgs e)
        {
            // find selected checkbox
            // if selected != Properties.Settings.Default.LocalizationFile
            var cb = _checkboxes.FirstOrDefault(m => m.Checked);

            if (cb != null)
            {
                var package = cb.Tag.ToString();
                if (package != Properties.Settings.Default.LocalizationFile)
                {
                    Properties.Settings.Default.LocalizationFile = package;
                    Properties.Settings.Default.Save();

                    if (!string.IsNullOrEmpty(Properties.Settings.Default.LocalizationFile))
                    {
                        var loader = new LocalizationLoader();
                        GlobalSettings.Language = loader.LoadLanguage(package, new EnglishLanguage(new Dictionary <string, string>()));

                        // TODO: Grab tags from loader and save to sql
                        _itemTagDao.Save(loader.GetItemTags(), new ProgressTracker());

                        UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(_playerItemDao);
                        x.ShowDialog();
                    }
                    // Load the GD one
                    else
                    {
                        // Override timestamp to force an update
                        GlobalSettings.InitializeLanguage(string.Empty, new Dictionary <string, string>()); // TODO: Not ideal, will need a restart

                        foreach (var location in _paths)
                        {
                            if (!string.IsNullOrEmpty(location) && Directory.Exists(location))
                            {
                                _parsingService.Update(location, string.Empty);
                                _parsingService.Execute();
                                break;
                            }
                            else
                            {
                                Logger.Warn("Could not find the Grim Dawn install location");
                            }
                        }

                        // Update item stats as well
                        UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(_playerItemDao);
                        x.ShowDialog();
                    }
                }
            }
            this.Close();
        }
示例#16
0
        private void LanguagePackPicker_Load(object sender, EventArgs e)
        {
            LocalizationLoader loc = new LocalizationLoader();

            int n = 0;

            // Default language: English
            {
                FirefoxRadioButton cb = new FirefoxRadioButton {
                    Location = new Point(10, 25 + n * 33),
                    Text     = "English (Official)",
                    Tag      = string.Empty,
                    Checked  = string.IsNullOrEmpty(Properties.Settings.Default.LocalizationFile)
                };

                cb.TabIndex = n;
                cb.TabStop  = true;
                groupBox1.Controls.Add(cb);
                _checkboxes.Add(cb);
                n++;
            }

            foreach (var path in _paths)
            {
                if (Directory.Exists(Path.Combine(path, "localization")))
                {
                    foreach (var file in Directory.EnumerateFiles(Path.Combine(path, "localization"), "*.zip"))
                    {
                        string author;
                        string language;
                        loc.CheckLanguage(file, out author, out language);

                        FirefoxRadioButton cb = new FirefoxRadioButton {
                            Location = new Point(10, 25 + n * 33),
                            Text     = string.Format("{0} by {1}", language, author),
                            Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top,
                            Width    = groupBox1.Width - pictureBox1.Width,
                            Tag      = file,
                            Checked  = file == Properties.Settings.Default.LocalizationFile
                        };

                        cb.TabIndex = n;
                        cb.TabStop  = true;
                        groupBox1.Controls.Add(cb);
                        _checkboxes.Add(cb);
                        n++;
                    }
                }
            }

            this.Height += n * 33;
        }
示例#17
0
        private void buttonSelect_Click(object sender, EventArgs e)
        {
            // find selected checkbox
            // if selected != Properties.Settings.Default.LocalizationFile
            var cb = Checkboxes.Where(m => m.Checked).FirstOrDefault();

            if (cb != null)
            {
                var package = cb.Tag.ToString();
                if (package != Properties.Settings.Default.LocalizationFile)
                {
                    Properties.Settings.Default.LocalizationFile = package;
                    Properties.Settings.Default.Save();

                    if (!string.IsNullOrEmpty(Properties.Settings.Default.LocalizationFile))
                    {
                        var loader = new LocalizationLoader();
                        GlobalSettings.Language = loader.LoadLanguage(package);

                        // TODO: Grab tags from loader and save to sql
                        databaseItemDao.Save(loader.GetItemTags());

                        UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(playerItemDao);
                        x.ShowDialog();
                    }
                    // Load the GD one
                    else
                    {
                        // Override timestamp to force an update
                        GlobalSettings.Language = new EnglishLanguage();

                        string location = GrimDawnDetector.GetGrimLocation();
                        if (!string.IsNullOrEmpty(location) && Directory.Exists(location))
                        {
                            ParsingDatabaseScreen parserUi = new ParsingDatabaseScreen(databaseSettingDao, this.parser, location, string.Empty, true, true);
                            parserUi.ShowDialog();
                        }
                        else
                        {
                            logger.Warn("Could not find the Grim Dawn install location");
                        }

                        // Update item stats as well
                        UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(playerItemDao);
                        x.ShowDialog();
                    }
                }
            }
            this.Close();
        }
示例#18
0
 public void LoadFile(
     string fileName,
     LocalizationLoader loader
     )
 {
     using (StreamReader reader = File.OpenText(fileName))
         ((JObject)JToken.ReadFrom((JsonReader) new JsonTextReader((TextReader)reader))).Properties().ToList <JProperty>().ForEach(
             (Action <JProperty>)(property => this.ParseSubElement(
                                      property,
                                      new Stack <string>(),
                                      loader,
                                      fileName
                                      ))
             );
 }
示例#19
0
        public LanguagePackPicker(
            IItemTagDao itemTagDao,
            IPlayerItemDao playerItemDao,
            IEnumerable <string> paths,
            ParsingService parsingService
            )
        {
            InitializeComponent();

            _paths          = paths;
            _parsingService = parsingService;
            _itemTagDao     = itemTagDao;
            _playerItemDao  = playerItemDao;

            LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
        }
示例#20
0
        private void OnlineBackupLogin_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Properties.Settings.Default.BackupLogin))
            {
                SetState(LoginState.WAITING_FOR_CONFIRM);
                StartWaitForVerifyBackgroundWorker();
            }
            else
            {
                SetState(LoginState.NEED_TO_LOGIN);
            }

            tbEmail.KeyDown += TbEmail_KeyDown;

            LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
        }
示例#21
0
        public void LoadTags(
            List <string> tagfiles,
            string localizationFile,
            ProgressTracker tracker
            )
        {
            int numFiles = tagfiles.Count - tagfiles.Where(string.IsNullOrEmpty).Count() + (string.IsNullOrEmpty(localizationFile) ? 0 : 1);

            tracker.MaxValue = numFiles;

            // Load tags in a prioritized order
            foreach (var tagfile in tagfiles)
            {
                if (File.Exists(tagfile))
                {
                    Logger.Debug($"Loading tags from {tagfile}");
                    LoadTags(tagfile);
                }
                else
                {
                    Logger.Debug($"Ignoring non-existing tagfile {tagfile}");
                }

                tracker.Increment();
            }

            // User override for some tags
            var localizationLoader = new LocalizationLoader();

            if (!string.IsNullOrEmpty(localizationFile) && localizationLoader.Load(localizationFile))
            {
                Logger.Debug($"Loading tags from {localizationFile}");

                var tags = localizationLoader.GetItemTags();
                foreach (var tag in tags)
                {
                    _tagAccumulator.Add(tag.Tag, tag.Name);
                }

                Logger.Debug($"Loaded {tags.Count} tags from {localizationFile}");
                tracker.Increment();
            }

            tracker.MaxProgress();
        }
示例#22
0
        public static void InitializeLanguage(string localizationFile, Dictionary <string, string> dbTags)
        {
            var english = new EnglishLanguage(dbTags);

            if (string.IsNullOrEmpty(localizationFile))
            {
                Language = english;
            }
            else if (!File.Exists(localizationFile))
            {
                Language = english;
                Logger.Warn($"Could not locate {localizationFile}, defaulting to English.");
            }
            else
            {
                Language = new LocalizationLoader().LoadLanguage(Properties.Settings.Default.LocalizationFile, english);
            }
        }
示例#23
0
    private void ParseSubElement(
        JProperty property,
        Stack <string> textId,
        LocalizationLoader loader,
        string fileName
        )
    {
        var valueType = property.Value.Type;

        switch (valueType)
        {
        case JTokenType.Object:
            textId.Push(property.Name);
            ((JObject)property.Value).Properties().ToList <JProperty>().ForEach(
                (Action <JProperty>)(subProperty => this.ParseSubElement(
                                         subProperty,
                                         textId,
                                         loader,
                                         fileName
                                         ))
                );
            textId.Pop();
            break;

        case JTokenType.Array:
        case JTokenType.String:
            var value = property.Value.ToString();
            if (valueType == JTokenType.Array)
            {
                value = property.Value.ToObject <string[]>().ToDelimitedString("");
            }

            loader.AddTranslation(
                textId: this.LabelPathRootPrefix + string.Join(this.LabelPathSeparator, textId.Reverse <string>()) + this.LabelPathSuffix,
                languageId: property.Name,
                value: value,
                source: fileName
                );
            break;

        default:
            throw new FormatException("Invalid format in Json language file for property [" + property.Name + "]");
        }
    }
示例#24
0
        public void LoadTags(
            string tagfileVanilla,
            string tagfileExpansion1,
            string tagfileMod,
            string localizationFile,
            ProgressTracker tracker
            )
        {
            var files    = new[] { tagfileVanilla, tagfileExpansion1, tagfileMod };
            int numFiles = files.Length - files.Where(string.IsNullOrEmpty).Count() + (string.IsNullOrEmpty(localizationFile) ? 0 : 1);

            tracker.MaxValue = numFiles;

            // Load tags in a prioritized order
            foreach (var tagfile in files)
            {
                if (File.Exists(tagfile))
                {
                    LoadTags(tagfile);
                }

                tracker.Increment();
            }

            // User override for some tags
            var localizationLoader = new LocalizationLoader();

            if (!string.IsNullOrEmpty(localizationFile) && localizationLoader.Load(localizationFile))
            {
                Logger.Debug($"Loading tags from {localizationFile}");

                var tags = localizationLoader.GetItemTags();
                foreach (var tag in tags)
                {
                    _tagAccumulator.Add(tag.Tag, tag.Name);
                }

                Logger.Debug($"Loaded {tags.Count} tags from {localizationFile}");
                tracker.Increment();
            }

            tracker.MaxProgress();
        }
示例#25
0
        private void DonateNagScreen_Load(object sender, EventArgs e)
        {
            if (CanNag)
            {
                _aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

                _aTimer.Interval = 50;
                _aTimer.Enabled  = true;

                DateTime dt = DateTime.Now.AddDays(28 + new Random().Next(0, 5));
                _settings.GetLocal().LastNagTimestamp = dt.Ticks;

                LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
            }
            else
            {
                _nagDelay = -1;
                this.Close();
            }
        }
示例#26
0
        private void DonateNagScreen_Load(object sender, EventArgs e)
        {
            if (CanNag)
            {
                _aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

                _aTimer.Interval = 50;
                _aTimer.Enabled  = true;

                DateTime dt = DateTime.Now.AddDays(28 + new Random().Next(0, 5));
                _settings.GetLocal().LastNagTimestamp = dt.Ticks;

                var tags = new [] { "iatag_ui_nagscreen1_button", "iatag_ui_nagscreen2_button", "iatag_ui_nagscreen3_button", "iatag_ui_nagscreen4_button", "iatag_ui_nagscreen5_button" };
                buttonNoThanks.Tag = tags[new Random().Next(tags.Length)];
                LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
            }
            else
            {
                _nagDelay = -1;
                this.Close();
            }
        }
示例#27
0
        public EntitiesManager Create(string assetsPath, string distPath)
        {
            var localizationsLoader = new LocalizationLoader();
            var localizations       = localizationsLoader.LoadFromAssets(assetsPath);
            var localizationWriter  = new LocalizationWriter();
            var heroItemLoader      = new HeroItemLoader(localizations);
            var heroItemWriter      = new HeroItemWriter();
            var heroItemManager     = new HeroItemManager(assetsPath, distPath, localizations, heroItemLoader, heroItemWriter, localizationWriter);
            var skillLoader         = new SkillLoader(localizations);
            var skillWriter         = new SkillWriter();
            var skillManager        = new SkillManager(assetsPath, distPath, localizations, skillLoader, skillWriter, localizationWriter);

            var shipLoader  = new ShipLoader(localizations);
            var shipWriter  = new ShipWriter();
            var shipManager = new ShipManager(assetsPath, distPath, localizations, shipLoader, shipWriter, localizationWriter);

            var localizationProvider = new LocalizationProvider(localizations);
            var heroWriter           = new HeroWriter();
            var heroLoader           = new HeroLoader(localizations, localizationProvider);
            var heroManager          = new HeroManager(assetsPath, distPath, localizations, heroLoader, heroWriter, localizationWriter);

            return(new EntitiesManager(heroItemManager, skillManager, shipManager, heroManager));
        }
示例#28
0
        public void LoadTranslations()
        {
            loader = new LocalizationLoader(Loc.Instance);
            JsonFileLoader jsonFileLoader = new JsonFileLoader();

            loader.FileLanguageLoaders.Add(jsonFileLoader);

            loader.AddTranslation("SayHello", "en", "Hello");
            loader.AddTranslation("SayHello", "fr", "Bonjour");

            File.WriteAllText(localizationFileName, GetEmbeddedResource("LocFileTest.loc.json"), Encoding.UTF8);
            File.WriteAllText(structuredTransFileName, GetEmbeddedResource("StructuredTrans.loc.json"), Encoding.UTF8);

            Thread.Sleep(1000);

            loader.AddFile(localizationFileName);
            loader.AddFile(structuredTransFileName);
            jsonFileLoader.LabelPathRootPrefix = "/";
            jsonFileLoader.LabelPathSeparator  = "/";
            jsonFileLoader.LabelPathSuffix     = ":";
            loader.AddFile(structuredTransFileName);

            Loc.Instance.Translators.Add(new InMemoryTranslator());
        }
示例#29
0
 public void LocalizeModule()
 {
     LocalizationLoader.LoadItemsInModule(this);
 }
示例#30
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "UI";
            }

            ExceptionReporter.EnableLogUnhandledOnThread();
            SizeChanged += OnMinimizeWindow;

            _stashManager = new StashManager(_playerItemDao, _databaseItemStatDao, SetFeedback, ListviewUpdateTrigger);
            _stashFileMonitor.OnStashModified += (_, __) => {
                StashEventArg args = __ as StashEventArg;
                if (_stashManager != null && _stashManager.TryLootStashFile(args?.Filename))
                {
                    // STOP TIMER
                    _stashFileMonitor.CancelQueuedNotify();
                } // TODO: This logic should be changed to 're queue' but only trigger once, if its slow it triggers multiple times.
            };

            if (!_stashFileMonitor.StartMonitorStashfile(GlobalPaths.SavePath))
            {
                MessageBox.Show("Ooops!\nIt seems you are synchronizing your saves to steam cloud..\nThis tool is unfortunately not compatible.\n");
                Process.Start("http://www.grimdawn.com/forums/showthread.php?t=20752");

                if (!Debugger.IsAttached)
                {
                    Close();
                }
            }

            // Chicken and the egg..
            SearchController searchController = new SearchController(
                _databaseItemDao,
                _playerItemDao,
                _databaseItemStatDao,
                _itemSkillDao,
                _buddyItemDao,
                _stashManager,
                _augmentationItemRepo
                );

            _cefBrowserHandler.InitializeChromium(searchController.JsBind, Browser_IsBrowserInitializedChanged);
            searchController.Browser             = _cefBrowserHandler;
            searchController.JsBind.OnClipboard += SetItemsClipboard;

            // Load the grim database
            string gdPath = GrimDawnDetector.GetGrimLocation();

            if (!string.IsNullOrEmpty(gdPath))
            {
            }
            else
            {
                Logger.Warn("Could not find the Grim Dawn install location");
                statusLabel.Text = "Could not find the Grim Dawn install location";

                var timer = new System.Windows.Forms.Timer();
                timer.Tick    += TimerTickLookForGrimDawn;
                timer.Interval = 10000;
                timer.Start();
            }

            // Load recipes
            foreach (string file in GlobalPaths.FormulasFiles)
            {
                if (!string.IsNullOrEmpty(file))
                {
                    bool isHardcore = file.EndsWith("gsh");
                    Logger.InfoFormat("Reading recipes at \"{0}\", IsHardcore={1}", file, isHardcore);
                    _recipeParser.UpdateFormulas(file, isHardcore);
                }
            }

            var addAndShow = UIHelper.AddAndShow;

            // Create the tab contents
            _buddySettingsWindow = new BuddySettings(delegate(bool b) { BuddySyncEnabled = b; },
                                                     _buddyItemDao,
                                                     _buddySubscriptionDao
                                                     );

            addAndShow(_buddySettingsWindow, buddyPanel);

            _authAuthService = new AzureAuthService(_cefBrowserHandler, new AuthenticationProvider());
            var backupSettings = new BackupSettings(_playerItemDao, _authAuthService);

            addAndShow(backupSettings, backupPanel);
            addAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, _playerItemDao, _parsingService), modsPanel);
            addAndShow(new HelpTab(), panelHelp);
            addAndShow(new LoggingWindow(), panelLogging);
            var backupService = new BackupService(_authAuthService, _playerItemDao, _azurePartitionDao, () => Settings.Default.UsingDualComputer);

            _backupServiceWorker            = new BackupServiceWorker(backupService);
            backupService.OnUploadComplete += (o, args) => _searchWindow.UpdateListView();
            searchController.OnSearch      += (o, args) => backupService.OnSearch();

            _searchWindow = new SplitSearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, _playerItemDao, searchController, _itemTagDao);
            addAndShow(_searchWindow, searchPanel);
            _stashManager.StashUpdated += (_, __) => {
                _searchWindow.UpdateListView();
            };

            addAndShow(
                new SettingsWindow(
                    _cefBrowserHandler,
                    _itemTagDao,
                    _tooltipHelper,
                    ListviewUpdateTrigger,
                    _databaseSettingDao,
                    _playerItemDao,
                    _arzParser,
                    _searchWindow.ModSelectionHandler.GetAvailableModSelection(),
                    _stashManager,
                    _parsingService
                    ),
                settingsPanel);

            new StashTabPicker(_stashManager.NumStashTabs).SaveStashSettingsToRegistry();

#if !DEBUG
            ThreadPool.QueueUserWorkItem(m => ExceptionReporter.ReportUsage());
            CheckForUpdates();
#endif

            int min  = 1000 * 60;
            int hour = 60 * min;
            _timerReportUsage = new Timer();
            _timerReportUsage.Start();
            _timerReportUsage.Elapsed += (a1, a2) => {
                if (Thread.CurrentThread.Name == null)
                {
                    Thread.CurrentThread.Name = "ReportUsageThread";
                }
                ReportUsage();
            };
            _timerReportUsage.Interval  = 12 * hour;
            _timerReportUsage.AutoReset = true;
            _timerReportUsage.Start();

            Shown += (_, __) => { StartInjector(); };

            //settingsController.Data.budd
            BuddySyncEnabled = (bool)Settings.Default.BuddySyncEnabled;

            // Start the backup task
            _backupBackgroundTask = new BackgroundTask(new FileBackup(_playerItemDao));

            LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
            EasterEgg.Activate(this);

            // Initialize the "stash packer" used to find item positions for transferring items ingame while the stash is open
            {
                _dynamicPacker.Initialize(8, 16);

                var transferFiles = GlobalPaths.TransferFiles;
                if (transferFiles.Count > 0)
                {
                    var file  = transferFiles.MaxBy(m => m.LastAccess);
                    var stash = StashManager.GetStash(file.Filename);
                    if (stash != null)
                    {
                        _dynamicPacker.Initialize(stash.Width, stash.Height);
                        if (stash.Tabs.Count >= 3)
                        {
                            foreach (var item in stash.Tabs[2].Items)
                            {
                                byte[] bx = BitConverter.GetBytes(item.XOffset);
                                uint   x  = (uint)BitConverter.ToSingle(bx, 0);

                                byte[] by = BitConverter.GetBytes(item.YOffset);
                                uint   y  = (uint)BitConverter.ToSingle(by, 0);

                                _dynamicPacker.Insert(item.BaseRecord, item.Seed, x, y);
                            }
                        }
                    }
                }
            }

            _messageProcessors.Add(new ItemPositionFinder(_dynamicPacker));
            _messageProcessors.Add(new PlayerPositionTracker());
            _messageProcessors.Add(new StashStatusHandler());
            _messageProcessors.Add(new ItemReceivedProcessor(_searchWindow, _stashFileMonitor, _playerItemDao));
            _messageProcessors.Add(new ItemInjectCallbackProcessor(_searchWindow.UpdateListViewDelayed, _playerItemDao));
            _messageProcessors.Add(new ItemSpawnedProcessor());
            _messageProcessors.Add(new CloudDetectorProcessor(SetFeedback));
            _messageProcessors.Add(new GenericErrorHandler());
            //messageProcessors.Add(new LogMessageProcessor());
#if DEBUG
            //messageProcessors.Add(new DebugMessageProcessor());
#endif

            GlobalSettings.StashStatusChanged += GlobalSettings_StashStatusChanged;

            _transferController = new ItemTransferController(
                _cefBrowserHandler,
                SetFeedback,
                SetTooltipAtmouse,
                _settingsController,
                _searchWindow,
                _dynamicPacker,
                _playerItemDao,
                _stashManager,
                new ItemStatService(_databaseItemStatDao, _itemSkillDao)
                );
            Application.AddMessageFilter(new MousewheelMessageFilter());


            var titleTag = GlobalSettings.Language.GetTag("iatag_ui_itemassistant");
            if (!string.IsNullOrEmpty(titleTag))
            {
                this.Text += $" - {titleTag}";
            }


            // Popup login diag
            if (_authAuthService.CheckAuthentication() == AzureAuthService.AccessStatus.Unauthorized)
            {
                var t = new System.Windows.Forms.Timer {
                    Interval = 100
                };
                t.Tick += (o, args) => {
                    if (_cefBrowserHandler.BrowserControl.IsBrowserInitialized)
                    {
                        _authAuthService.Authenticate();
                        t.Stop();
                    }
                };
                t.Start();
            }


            _cefBrowserHandler.TransferSingleRequested += TransferSingleItem;
            _cefBrowserHandler.TransferAllRequested    += TransferAllItems;
            new WindowSizeManager(this);
        }