public ImportMode(GDTransferFile[] modSelection, IPlayerItemDao playerItemDao, TransferStashService sm) { InitializeComponent(); this._modSelection = modSelection; this._playerItemDao = playerItemDao; this._sm = sm; }
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) { // No idea which of these are triggering on rare occasions, perhaps Deactivate, sizechanged or filterWindow. FormClosing -= MainWindow_FormClosing; SizeChanged -= OnMinimizeWindow; _stashFileMonitor?.Dispose(); _stashFileMonitor = null; _transferStashService = null; _backupBackgroundTask?.Dispose(); _usageStatisticsReporter.Dispose(); _automaticUpdateChecker.Dispose(); _tooltipHelper?.Dispose(); _buddyBackgroundThread?.Dispose(); _buddyBackgroundThread = null; panelHelp.Controls.Clear(); _injector?.Dispose(); _injector = null; _backupServiceWorker?.Dispose(); _backupServiceWorker = null; _window?.Dispose(); _window = null; IterAndCloseForms(Controls); }
public List <PlayerItem> EmptyStash(string filename) { Logger.InfoFormat("Looting {0}", filename); var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename)); var items = new List <Item>(); var stash = new Stash(); if (stash.Read(pCrypto)) { var isHardcore = GlobalPaths.IsHardcore(filename); foreach (var tab in stash.Tabs) { // Grab the items and clear the tab items.AddRange(Classify(tab).Remaining); tab.Items.Clear(); } _stashWriter.SafelyWriteStash(filename, stash); // TODO: Ideally we should check if it worked. Logger.InfoFormat("Looted {0} items from stash", items.Count); return(items.Select(m => TransferStashService.Map(m, stash.ModLabel, isHardcore)).ToList()); } Logger.Error("Could not load stash file."); Logger.Error("An update from the developer is most likely required."); return(new List <PlayerItem>()); }
private ClassifiedItems Classify(StashTab tab) { var stacked = tab.Items.Where(item => item.StackCount > 1 || _cache.StackableRecords.Contains(item.BaseRecord) || _cache.SpecialRecords.Contains(item.BaseRecord) // Special "single seed" items. ).ToList(); var unknownItems = tab.Items.Where(item => !_cache.AllRecords.Contains(item.BaseRecord)).ToList(); var duplicates = tab.Items .SkipWhile(item => stacked.Contains(item)) .SkipWhile(item => unknownItems.Contains(item)) .Where(item => _playerItemDao.Exists(TransferStashService.Map(item, null, false))) // We don't care about mod/hardcore for dupe checking. .ToList(); var remaining = tab.Items .SkipWhile(item => duplicates.Contains(item)) .SkipWhile(item => stacked.Contains(item)) .SkipWhile(item => unknownItems.Contains(item)) .ToList(); return(new ClassifiedItems { Stacked = stacked, Duplicates = duplicates, Unknown = unknownItems, Remaining = remaining }); }
public SettingsWindow( CefBrowserHandler cefBrowserHandler, TooltipHelper tooltipHelper, Action itemViewUpdateTrigger, IPlayerItemDao playerItemDao, GDTransferFile[] modFilter, TransferStashService transferStashService, LanguagePackPicker languagePackPicker, SettingsService settings, GrimDawnDetector grimDawnDetector) { InitializeComponent(); _controller = new SettingsController(settings); this._cefBrowserHandler = cefBrowserHandler; this._tooltipHelper = tooltipHelper; this._itemViewUpdateTrigger = itemViewUpdateTrigger; this._playerItemDao = playerItemDao; this._modFilter = modFilter; this._transferStashService = transferStashService; _languagePackPicker = languagePackPicker; _settings = settings; _grimDawnDetector = grimDawnDetector; _controller.BindCheckbox(cbMinimizeToTray); _controller.BindCheckbox(cbMergeDuplicates); _controller.BindCheckbox(cbTransferAnyMod); _controller.BindCheckbox(cbSecureTransfers); _controller.BindCheckbox(cbShowRecipesAsItems); _controller.BindCheckbox(cbAutoUpdateModSettings); _controller.BindCheckbox(cbDisplaySkills); _controller.LoadDefaults(); }
public ImportExportContainer(GDTransferFile[] modFilter, IPlayerItemDao playerItemDao, TransferStashService sm) { InitializeComponent(); this.modFilter = modFilter; this.playerItemDao = playerItemDao; this.sm = sm; }
public TransferStashService2(IPlayerItemDao playerItemDao, TransferStashServiceCache cache, TransferStashService transferStashService, SafeTransferStashWriter stashWriter, SettingsService settings) { _playerItemDao = playerItemDao; _cache = cache; _transferStashService = transferStashService; _stashWriter = stashWriter; _settings = settings; }
public TransferStashService2(IPlayerItemDao playerItemDao, TransferStashServiceCache cache, TransferStashService transferStashService, SafeTransferStashWriter stashWriter, SettingsService settings, IHelpService helpService, IReplicaItemDao replicaItemDao) { _playerItemDao = playerItemDao; _cache = cache; _transferStashService = transferStashService; _stashWriter = stashWriter; _settings = settings; _helpService = helpService; this._replicaItemDao = replicaItemDao; }
public CsvParsingService(IPlayerItemDao playerItemDao, IReplicaItemDao replicaItemDao, UserFeedbackService userFeedbackService, TransferStashServiceCache cache, ItemTransferController itemTransferController, TransferStashService transferStashService, SettingsService settings) { _playerItemDao = playerItemDao; _replicaItemDao = replicaItemDao; _userFeedbackService = userFeedbackService; _cache = cache; _itemTransferController = itemTransferController; _transferStashService = transferStashService; _settings = settings; }
public void Add(Item item) { // Dupe-check list bool stacked = item.StackCount > 1 || _cache.StackableRecords.Contains(item.BaseRecord) || _cache.SpecialRecords.Contains(item.BaseRecord); // Special "single seed" items. if (stacked) { Stacked.Add(item); All.Add(item); return; } // TODO: Detect slith rings etc // We don't have this record at all, unknown to IA. Probably need to parse DB. bool unknownItem = !_cache.AllRecords.Contains(item.BaseRecord); if (unknownItem) { if (item.BaseRecord.StartsWith("records/storyelements/rewards/")) { Quest.Add(item); } else { Unknown.Add(item); } All.Add(item); return; } // We already have this item.. if (All.Any(m => m.Equals(item))) { Duplicates.Add(item); All.Add(item); return; } // We already have this item.. if (_playerItemDao.Exists(TransferStashService.Map(item, null, false))) { Duplicates.Add(item); All.Add(item); return; } Remaining.Add(item); All.Add(item); }
public ImportExportModePicker( GDTransferFile[] modFilter, IPlayerItemDao playerItemDao, Control.ControlCollection parentContainer, TransferStashService sm, Action onClose ) { InitializeComponent(); this.modFilter = modFilter; this.playerItemDao = playerItemDao; this.parentContainer = parentContainer; this.sm = sm; this.onClose = onClose; }
public SearchController( IDatabaseItemDao databaseItemDao, IPlayerItemDao playerItemDao, IDatabaseItemStatDao databaseItemStatDao, IItemSkillDao itemSkillDao, IBuddyItemDao buddyItemDao, TransferStashService transferStashService, AugmentationItemRepo augmentationItemRepo ) { _dbItemDao = databaseItemDao; _playerItemDao = playerItemDao; _itemStatService = new ItemStatService(databaseItemStatDao, itemSkillDao); _itemPaginatorService = new ItemPaginatorService(TakeSize); _recipeService = new RecipeService(databaseItemDao); _costCalculationService = new CostCalculationService(playerItemDao, transferStashService); _buddyItemDao = buddyItemDao; _transferStashService = transferStashService; _augmentationItemRepo = augmentationItemRepo; // Just make sure it writes .css/.html files before displaying anything to the browser // ItemHtmlWriter.ToJsonSerializeable(new List <PlayerHeldItem>()); // TODO: is this not a NOOP? JsBind.OnRequestItems += JsBind_OnRequestItems; // Return the ingredients for a given recipe JsBind.OnRequestRecipeIngredients += (sender, args) => { var recipeArgument = args as RequestRecipeArgument; var ingredients = _recipeService.GetRecipeIngredients(recipeArgument?.RecipeRecord); _costCalculationService.Populate(ingredients); _costCalculationService.SetMod(_previousMod); _previousCallback = recipeArgument?.Callback; _previousRecipe = recipeArgument?.RecipeRecord; Browser.SetRecipeIngredients(JsBind.Serialize(ingredients)); }; // Update the recipe when the stash has changed transferStashService.StashUpdated += StashManagerOnStashUpdated; // Return the list of recipes JsBind.OnRequestRecipeList += (sender, args) => { var recipes = _recipeService.GetRecipeList(); Browser.SetRecipes(JsBind.Serialize(recipes)); }; }
private bool StoreItemsToDatabase(ICollection <Item> items, string mod, bool isHardcore) { // Convert the items var playerItems = items.Select(item => TransferStashService.Map(item, mod, isHardcore)).ToList(); try { _playerItemDao.Save(playerItems); } catch (Exception ex) { Logger.Warn(ex.Message); Logger.Warn(ex.StackTrace); ExceptionReporter.ReportException(ex, "StoreItems"); return(false); } return(true); }
public bool TransferToOpenStash(PlayerItem pi) { List <byte> buffer = ItemInjectCallbackProcessor.Serialize(pi); var stashTab = Properties.Settings.Default.StashToDepositTo; if (stashTab == 0) { // Find real tab.. Related to hotfix v1.0.4.0 stashTab = TransferStashService.GetNumStashPages(GetTransferFile()); } var position = _dynamicPacker.Insert(pi.BaseRecord, (uint)pi.Seed); if (position == null) { _logger.Warn("Item insert canceled, no valid position found."); _setFeedback(GlobalSettings.Language.GetTag("iatag_deposit_stash_full")); return(false); } buffer.InsertRange(0, BitConverter.GetBytes(position.X * 32)); buffer.InsertRange(4, BitConverter.GetBytes(position.Y * 32)); buffer.InsertRange(0, BitConverter.GetBytes(stashTab)); using (NamedPipeClientStream pipeStream = new NamedPipeClientStream(".", "gdiahook", PipeDirection.InOut, PipeOptions.Asynchronous)) { // The connect function will indefinitely wait for the pipe to become available // If that is not acceptable specify a maximum waiting time (in ms) try { pipeStream.Connect(250); } catch (TimeoutException) { return(false); } pipeStream.Write(buffer.ToArray(), 0, buffer.Count); _logger.Debug("Wrote item to pipe"); _setFeedback(GlobalSettings.Language.GetTag("iatag_deposit_pipe_success")); } return(true); }
public ItemTransferController( CefBrowserHandler browser, Action <string> feedback, Action <string> setTooltip, SplitSearchWindow searchWindow, IPlayerItemDao playerItemDao, TransferStashService transferStashService, ItemStatService itemStatService, SettingsService settingsService ) { _browser = browser; _setFeedback = feedback; _setTooltip = setTooltip; _searchWindow = searchWindow; _dao = playerItemDao; _transferStashService = transferStashService; _itemStatService = itemStatService; _settingsService = settingsService; }
private bool StoreItemsToDatabase(ICollection <Item> items, string mod, bool isHardcore) { // Convert the items var playerItems = items.Select(item => TransferStashService.Map(item, mod, isHardcore)).ToList(); try { _playerItemDao.Save(playerItems); foreach (var item in playerItems) { var hash = ItemReplicaService.GetHash(item); _replicaItemDao.UpdatePlayerItemId(hash, item.Id); } } catch (Exception ex) { Logger.Warn(ex.Message); Logger.Warn(ex.StackTrace); return(false); } return(true); }
public SettingsWindow( CefBrowserHandler cefBrowserHandler, TooltipHelper tooltipHelper, Action itemViewUpdateTrigger, IPlayerItemDao playerItemDao, GDTransferFile[] modFilter, TransferStashService transferStashService, TransferStashService2 transferStashService2, LanguagePackPicker languagePackPicker, SettingsService settings, GrimDawnDetector grimDawnDetector, DarkMode darkModeToggler, AutomaticUpdateChecker automaticUpdateChecker) { InitializeComponent(); _controller = new SettingsController(settings); this._cefBrowserHandler = cefBrowserHandler; this._tooltipHelper = tooltipHelper; this._itemViewUpdateTrigger = itemViewUpdateTrigger; this._playerItemDao = playerItemDao; this._modFilter = modFilter; this._transferStashService = transferStashService; this._transferStashService2 = transferStashService2; _languagePackPicker = languagePackPicker; _settings = settings; _grimDawnDetector = grimDawnDetector; _darkModeToggler = darkModeToggler; _automaticUpdateChecker = automaticUpdateChecker; _controller.BindCheckbox(cbMinimizeToTray); _controller.BindCheckbox(cbTransferAnyMod); _controller.BindCheckbox(cbSecureTransfers); _controller.BindCheckbox(cbShowRecipesAsItems); _controller.BindCheckbox(cbHideSkills); _controller.LoadDefaults(); // TODO: Write out the settingscontroller and add logic for updating showskills config linkCheckForUpdates.Visible = Environment.Is64BitOperatingSystem; pbAutomaticUpdates.Visible = Environment.Is64BitOperatingSystem; }
private void MainWindow_Load(object sender, EventArgs e) { if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "UI"; } Logger.Debug("Starting UI initialization"); // Set version number var version = Assembly.GetExecutingAssembly().GetName().Version; DateTime buildDate = new DateTime(2000, 1, 1) .AddDays(version.Build) .AddSeconds(version.Revision * 2); statusLabel.Text = statusLabel.Text + $" - {version.Major}.{version.Minor}.{version.Build}.{version.Revision} from {buildDate.ToString("dd/MM/yyyy")}"; var settingsService = _serviceProvider.Get <SettingsService>(); ExceptionReporter.EnableLogUnhandledOnThread(); SizeChanged += OnMinimizeWindow; // Chicken and the egg.. search controller needs browser, browser needs search controllers var. var databaseItemDao = _serviceProvider.Get <IDatabaseItemDao>(); var searchController = _serviceProvider.Get <SearchController>(); searchController.JsIntegration.OnRequestSetItemAssociations += (s, evvv) => { (evvv as GetSetItemAssociationsEventArgs).Elements = databaseItemDao.GetItemSetAssociations(); }; _cefBrowserHandler.InitializeChromium(searchController.JsIntegration, Browser_IsBrowserInitializedChanged, tabControl1); searchController.Browser = _cefBrowserHandler; searchController.JsIntegration.OnClipboard += SetItemsClipboard; searchController.JsIntegration.OnRequestFeatureRecommendation += (o, args) => { var features = settingsService.GetPersistent().FeaturesNotShown; (args as FeatureSuggestionArgs).Feature = features.FirstOrDefault(); (args as FeatureSuggestionArgs).HasFeature = features.Count > 0; }; searchController.JsIntegration.OnSeenFeatureRecommendation += (o, args) => settingsService.GetPersistent().AddShownFeature((args as FeatureSuggestionArgs).Feature); var playerItemDao = _serviceProvider.Get <IPlayerItemDao>(); var cacher = _serviceProvider.Get <TransferStashServiceCache>(); _parsingService.OnParseComplete += (o, args) => cacher.Refresh(); var stashWriter = new SafeTransferStashWriter(settingsService, _cefBrowserHandler); var transferStashService = new TransferStashService(_serviceProvider.Get <IDatabaseItemStatDao>(), settingsService, stashWriter); var transferStashService2 = new TransferStashService2(playerItemDao, cacher, transferStashService, stashWriter, settingsService, _cefBrowserHandler); _serviceProvider.Add(transferStashService2); _transferStashWorker = new TransferStashWorker(transferStashService2, _userFeedbackService); _stashFileMonitor.OnStashModified += (_, __) => { StashEventArg args = __ as StashEventArg; _transferStashWorker.Queue(args?.Filename); // May not minimize, but _usageStatisticsReporter.ResetLastMinimized(); _automaticUpdateChecker.ResetLastMinimized(); }; 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"); _cefBrowserHandler.ShowHelp(HelpService.HelpType.CloudSavesEnabled); Logger.Warn("Shutting down IA, unable to monitor stash files."); if (!Debugger.IsAttached) { Close(); } } // Load the grim database var grimDawnDetector = _serviceProvider.Get <GrimDawnDetector>(); 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 buddyItemDao = _serviceProvider.Get <IBuddyItemDao>(); var buddySubscriptionDao = _serviceProvider.Get <IBuddySubscriptionDao>(); var databaseSettingDao = _serviceProvider.Get <IDatabaseSettingDao>(); _authService = new AuthService(_cefBrowserHandler, new AuthenticationProvider(settingsService), playerItemDao); var backupSettings = new BackupSettings(playerItemDao, settingsService, _cefBrowserHandler); UIHelper.AddAndShow(backupSettings, backupPanel); // TODO: buttonLogin.Visible = !BlockedLogsDetection.DreamcrashBlocked(); var onlineSettings = new OnlineSettings(playerItemDao, _authService, settingsService, _cefBrowserHandler, buddyItemDao, buddySubscriptionDao); UIHelper.AddAndShow(onlineSettings, onlinePanel); _cefBrowserHandler.OnAuthSuccess += (_, __) => onlineSettings.UpdateUi(); UIHelper.AddAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, playerItemDao, _parsingService, databaseSettingDao, grimDawnDetector, settingsService, _cefBrowserHandler), modsPanel); if (!BlockedLogsDetection.DreamcrashBlocked()) { UIHelper.AddAndShow(new LoggingWindow(), panelLogging); } var itemTagDao = _serviceProvider.Get <IItemTagDao>(); var backupService = new BackupService(_authService, playerItemDao, settingsService); _charBackupService = new CharacterBackupService(settingsService, _authService); _backupServiceWorker = new BackupServiceWorker(backupService, _charBackupService); searchController.JsIntegration.OnRequestBackedUpCharacterList += (_, args) => { RequestCharacterListEventArg a = args as RequestCharacterListEventArg; a.Characters = _charBackupService.ListBackedUpCharacters(); }; searchController.JsIntegration.OnRequestCharacterDownloadUrl += (_, args) => { RequestCharacterDownloadUrlEventArg a = args as RequestCharacterDownloadUrlEventArg; a.Url = _charBackupService.GetDownloadUrl(a.Character); }; backupService.OnUploadComplete += (o, args) => _searchWindow.UpdateListView(); searchController.OnSearch += (o, args) => backupService.OnSearch(); _searchWindow = new SplitSearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, playerItemDao, searchController, itemTagDao, settingsService); UIHelper.AddAndShow(_searchWindow, searchPanel); searchPanel.Height = searchPanel.Parent.Height; searchPanel.Width = searchPanel.Parent.Width; transferStashService2.OnUpdate += (_, __) => { _searchWindow.UpdateListView(); }; var languagePackPicker = new LanguagePackPicker(itemTagDao, playerItemDao, _parsingService, settingsService); var dm = new DarkMode(this); UIHelper.AddAndShow( new SettingsWindow( _cefBrowserHandler, _tooltipHelper, ListviewUpdateTrigger, playerItemDao, _searchWindow.ModSelectionHandler.GetAvailableModSelection(), transferStashService, transferStashService2, languagePackPicker, settingsService, grimDawnDetector, dm ), settingsPanel); #if !DEBUG if (!BlockedLogsDetection.DreamcrashBlocked()) // Uses dreamcrash server { ThreadPool.QueueUserWorkItem(m => ExceptionReporter.ReportUsage()); _automaticUpdateChecker.CheckForUpdates(); } #endif Shown += (_, __) => { StartInjector(); }; _buddyItemsService = new BuddyItemsService( buddyItemDao, 3 * 60 * 1000, settingsService, _authService, buddySubscriptionDao ); // Start the backup task _backupBackgroundTask = new BackgroundTask(new FileBackup(playerItemDao, settingsService)); LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language); new EasterEgg(settingsService).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 = TransferStashService.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(Debugger.IsAttached && false)); _messageProcessors.Add(new StashStatusHandler()); _messageProcessors.Add(new CloudDetectorProcessor(SetFeedback)); _messageProcessors.Add(new GenericErrorHandler()); RuntimeSettings.StashStatusChanged += GlobalSettings_StashStatusChanged; _transferController = new ItemTransferController( _cefBrowserHandler, SetFeedback, SetTooltipAtmouse, _searchWindow, playerItemDao, transferStashService, _serviceProvider.Get <ItemStatService>(), settingsService ); Application.AddMessageFilter(new MousewheelMessageFilter()); var titleTag = RuntimeSettings.Language.GetTag("iatag_ui_itemassistant"); if (!string.IsNullOrEmpty(titleTag)) { this.Text += $" - {titleTag}"; } // Popup login diag if (_authService.CheckAuthentication() == AuthService.AccessStatus.Unauthorized && !settingsService.GetLocal().OptOutOfBackups) { if (!BlockedLogsDetection.DreamcrashBlocked()) { // Backup login wont work var t = new System.Windows.Forms.Timer { Interval = 100 }; t.Tick += (o, args) => { if (_cefBrowserHandler.BrowserControl.CanExecuteJavascriptInMainFrame) { _authService.Authenticate(); t.Stop(); } }; t.Start(); } } searchController.JsIntegration.ItemTransferEvent += TransferItem; new WindowSizeManager(this, settingsService); // Suggest translation packs if available if (string.IsNullOrEmpty(settingsService.GetLocal().LocalizationFile) && !settingsService.GetLocal().HasSuggestedLanguageChange) { if (LocalizationLoader.HasSupportedTranslations(grimDawnDetector.GetGrimLocations())) { Logger.Debug("A new language pack has been detected, informing end user.."); new LanguagePackPicker(itemTagDao, playerItemDao, _parsingService, settingsService).Show(grimDawnDetector.GetGrimLocations()); settingsService.GetLocal().HasSuggestedLanguageChange = true; } } if (settingsService.GetPersistent().DarkMode) { dm.Activate(); // Needs a lot more work before its ready, for example custom components uses Draw and does not respect coloring. _cefBrowserHandler.SetDarkMode(settingsService.GetPersistent().DarkMode); } Logger.Debug("UI initialization complete"); }
// TODO: This creates another session instance, should be executed inside the ThreadExecuter public static void PrintStartupInfo(SessionFactory factory, SettingsService settings, SqlDialect dialect) { Logger.Info(settings.GetLocal().StashToLootFrom == 0 ? "IA is configured to loot from the last stash page" : $"IA is configured to loot from stash page #{settings.GetLocal().StashToLootFrom}"); Logger.Info(settings.GetLocal().StashToDepositTo == 0 ? "IA is configured to deposit to the second-to-last stash page" : $"IA is configured to deposit to stash page #{settings.GetLocal().StashToDepositTo}"); using (ISession session = factory.OpenSession()) { long numItemsStored = session.CreateCriteria <PlayerItem>() .SetProjection(NHibernate.Criterion.Projections.RowCountInt64()) .UniqueResult <long>(); if (numItemsStored == 0) { Logger.Warn($"There are {numItemsStored} items stored in the database. <---- Unless you just installed IA, this is bad. No items."); } else { Logger.Info($"There are {numItemsStored} items stored in the database."); } } Logger.Info(settings.GetPersistent().ShowRecipesAsItems ? "Show recipes as items is enabled" : "Show recipes as items is disabled"); Logger.Info("Transfer to any mod is " + (settings.GetPersistent().TransferAnyMod ? "enabled" : "disabled")); Logger.Info("Experimental updates is " + (settings.GetPersistent().SubscribeExperimentalUpdates ? "enabled" : "disabled")); Logger.Info("Delete duplicates is " + (settings.GetPersistent().DeleteDuplicates ? "enabled" : "disabled")); Logger.Info((new WindowsPrincipal(WindowsIdentity.GetCurrent())).IsInRole(WindowsBuiltInRole.Administrator) ? "Running as administrator" : "Not running with low privileges"); List <GDTransferFile> mods = GlobalPaths.GetTransferFiles(true); if (mods.Count == 0) { Logger.Warn("No transfer files has been found"); } else { Logger.Info("The following transfer files has been found:"); foreach (GDTransferFile mod in mods) { var stash = TransferStashService.GetStash(mod.Filename); if (stash?.Tabs.Count < 2) { Logger.Warn($"\"{mod.Filename}\": Mod: \"{mod.Mod}\", HC: {mod.IsHardcore}, Downgrade: {mod.Downgrade}, Tabs: {stash?.Tabs.Count} <======="); Logger.Warn("Stash file does not have enough tabs"); } else { Logger.Info($"\"{mod.Filename}\": Mod: \"{mod.Mod}\", HC: {mod.IsHardcore}, Downgrade: {mod.Downgrade}, Tabs: {stash?.Tabs.Count}"); } } } Logger.Info("There are items stored for the following mods:"); foreach (ModSelection entry in new PlayerItemDaoImpl(factory, new DatabaseItemStatDaoImpl(factory, dialect), dialect) .GetModSelection()) { Logger.Info($"Mod: \"{entry.Mod}\", HC: {entry.IsHardcore}"); } string gdPath = settings.GetLocal().CurrentGrimdawnLocation; Logger.Info(string.IsNullOrEmpty(gdPath) ? "The path to Grim Dawn is unknown (not great)" : $"The path to Grim Dawn is \"{gdPath}\""); Logger.Info($"Using IA on multiple PCs: {settings.GetPersistent().UsingDualComputer}"); Logger.Info($"Logged into online backups: {!string.IsNullOrEmpty(settings.GetPersistent().CloudUser)}"); Logger.Info($"Opted out of online backups: {settings.GetLocal().OptOutOfBackups}"); using (ISession session = factory.OpenSession()) { long num = session.CreateCriteria <DatabaseItem>() .SetProjection(NHibernate.Criterion.Projections.RowCountInt64()) .UniqueResult <long>(); var isGdParsed = num > 0; settings.GetLocal().IsGrimDawnParsed = isGdParsed; if (isGdParsed) { Logger.Info("The Grim Dawn database has been parsed"); } else { Logger.Warn("The Grim Dawn database has not been parsed"); } } Logger.Info("Startup data dump complete"); }
public void Add(PlayerItem item) { Add(TransferStashService.Map(item)); }
private void MainWindow_Load(object sender, EventArgs e) { if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "UI"; } Logger.Debug("Starting UI initialization"); ExceptionReporter.EnableLogUnhandledOnThread(); SizeChanged += OnMinimizeWindow; var cacher = new TransferStashServiceCache(_databaseItemDao); _parsingService.OnParseComplete += (o, args) => cacher.Refresh(); var stashWriter = new SafeTransferStashWriter(_settingsService); _transferStashService = new TransferStashService(_databaseItemStatDao, _settingsService, stashWriter); var transferStashService2 = new TransferStashService2(_playerItemDao, cacher, _transferStashService, stashWriter, _settingsService); _transferStashWorker = new TransferStashWorker(transferStashService2, _userFeedbackService); _stashFileMonitor.OnStashModified += (_, __) => { StashEventArg args = __ as StashEventArg; _transferStashWorker.Queue(args?.Filename); }; 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"); HelpService.ShowHelp(HelpService.HelpType.CloudSavesEnabled); Logger.Warn("Shutting down IA, unable to monitor stash files."); if (!Debugger.IsAttached) { Close(); } } // Chicken and the egg.. SearchController searchController = new SearchController( _databaseItemDao, _playerItemDao, _databaseItemStatDao, _itemSkillDao, _buddyItemDao, _augmentationItemRepo, _settingsService ); searchController.JsBind.SetItemSetAssociations(_databaseItemDao.GetItemSetAssociations()); _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, _settingsService ); addAndShow(_buddySettingsWindow, buddyPanel); _authAuthService = new AzureAuthService(_cefBrowserHandler, new AuthenticationProvider(_settingsService)); var backupSettings = new BackupSettings(_playerItemDao, _authAuthService, _settingsService); addAndShow(backupSettings, backupPanel); addAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, _playerItemDao, _parsingService, _databaseSettingDao, _grimDawnDetector, _settingsService), modsPanel); addAndShow(new HelpTab(), panelHelp); addAndShow(new LoggingWindow(), panelLogging); var backupService = new BackupService(_authAuthService, _playerItemDao, _azurePartitionDao, () => _settingsService.GetPersistent().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, _settingsService); addAndShow(_searchWindow, searchPanel); transferStashService2.OnUpdate += (_, __) => { _searchWindow.UpdateListView(); }; var languagePackPicker = new LanguagePackPicker(_itemTagDao, _playerItemDao, _parsingService, _settingsService); addAndShow( new SettingsWindow( _cefBrowserHandler, _tooltipHelper, ListviewUpdateTrigger, _playerItemDao, _searchWindow.ModSelectionHandler.GetAvailableModSelection(), _transferStashService, transferStashService2, languagePackPicker, _settingsService, _grimDawnDetector ), settingsPanel); #if !DEBUG ThreadPool.QueueUserWorkItem(m => ExceptionReporter.ReportUsage()); _automaticUpdateChecker.CheckForUpdates(); #endif Shown += (_, __) => { StartInjector(); }; //settingsController.Data.budd BuddySyncEnabled = _settingsService.GetPersistent().BuddySyncEnabled; // Start the backup task _backupBackgroundTask = new BackgroundTask(new FileBackup(_playerItemDao, _settingsService)); LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language); new EasterEgg(_settingsService).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 = TransferStashService.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(Debugger.IsAttached && false)); _messageProcessors.Add(new StashStatusHandler()); _messageProcessors.Add(new ItemSpawnedProcessor()); _messageProcessors.Add(new CloudDetectorProcessor(SetFeedback)); _messageProcessors.Add(new GenericErrorHandler()); //messageProcessors.Add(new LogMessageProcessor()); #if DEBUG _messageProcessors.Add(new DebugMessageProcessor()); #endif RuntimeSettings.StashStatusChanged += GlobalSettings_StashStatusChanged; _transferController = new ItemTransferController( _cefBrowserHandler, SetFeedback, SetTooltipAtmouse, _settingsController, _searchWindow, _dynamicPacker, _playerItemDao, _transferStashService, new ItemStatService(_databaseItemStatDao, _itemSkillDao, _settingsService) ); Application.AddMessageFilter(new MousewheelMessageFilter()); var titleTag = RuntimeSettings.Language.GetTag("iatag_ui_itemassistant"); if (!string.IsNullOrEmpty(titleTag)) { this.Text += $" - {titleTag}"; } // Popup login diag if (_authAuthService.CheckAuthentication() == AzureAuthService.AccessStatus.Unauthorized && !_settingsService.GetLocal().OptOutOfBackups) { 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, _settingsService); // Suggest translation packs if available if (!string.IsNullOrEmpty(_settingsService.GetLocal().LocalizationFile) && !_settingsService.GetLocal().HasSuggestedLanguageChange) { if (LocalizationLoader.HasSupportedTranslations(_grimDawnDetector.GetGrimLocations())) { Logger.Debug("A new language pack has been detected, informing end user.."); new LanguagePackPicker(_itemTagDao, _playerItemDao, _parsingService, _settingsService).Show(_grimDawnDetector.GetGrimLocations()); _settingsService.GetLocal().HasSuggestedLanguageChange = true; } } Logger.Debug("UI initialization complete"); }
/// <summary> /// Map of [mod][transfer file] /// </summary> public static List <GDTransferFile> GetTransferFiles(bool includeDowngradeFiles) { var transferFilesCache = new List <GDTransferFile>(); HashSet <string> parsedFiles = new HashSet <string>(); string documents = SavePath; var transferFilenames = new string[] { "transfer.gst", // Softcore "transfer.gsh", // Hardcore }; if (includeDowngradeFiles) { transferFilenames = new string[] { "transfer.gst", // Softcore "transfer.gsh", // Hardcore "transfer.bst", // Softcore Vanilla FG/AOM disabled (Vanilla only, owns expansions) "transfer.cst", // Softcore FG disabled (Vanilla+AOM) "transfer.csh", // Hardcore FG disabled (Vanilla+AOM) "transfer.bsh" // Hardcore FG/AOM disabled (Vanilla only, owns expansions) }; } if (!Directory.Exists(documents)) { Logger.Warn($"Could not locate the folder \"{documents}\""); return(transferFilesCache); } // Generate a list of the interesting files List <string> files = new List <string>(); // transfer.bst / transfer.cst / transfer.csh foreach (string filename in transferFilenames) { string vanilla = Path.Combine(documents, filename); if (File.Exists(vanilla) && !parsedFiles.Contains(vanilla)) { files.Add(vanilla); } foreach (var possibleMod in Directory.GetDirectories(documents)) { string mod = Path.Combine(possibleMod, filename); if (File.Exists(mod) && !parsedFiles.Contains(mod)) { files.Add(mod); } } } foreach (string potential in files) { if (TransferStashService.TryGetModLabel(potential, out var mod)) { parsedFiles.Add(potential); var lastAccess = File.GetLastWriteTime(potential); transferFilesCache.Add(new GDTransferFile { Filename = potential, Mod = mod, IsHardcore = IsHardcore(potential), LastAccess = lastAccess, Downgrade = GetDowngradeType(potential) }); } } if (transferFilesCache.Count == 0) { Logger.Warn($"No stash files detected in {documents}"); } return(transferFilesCache); }
public CostCalculationService(IPlayerItemDao playerItemDao, TransferStashService transferStashService) { _playerItemDao = playerItemDao; _transferStashService = transferStashService; }