Exemple #1
0
        public SettingsWindow(
            CefBrowserHandler cefBrowserHandler,
            IItemTagDao itemTagDao,
            TooltipHelper tooltipHelper,
            Action itemViewUpdateTrigger,
            IDatabaseSettingDao settingsDao,
            IPlayerItemDao playerItemDao,
            ArzParser parser,
            GDTransferFile[] modFilter,
            StashManager stashManager, ParsingService parsingService)
        {
            InitializeComponent();
            this._cefBrowserHandler     = cefBrowserHandler;
            this._tooltipHelper         = tooltipHelper;
            this._itemViewUpdateTrigger = itemViewUpdateTrigger;
            this._settingsDao           = settingsDao;
            this._playerItemDao         = playerItemDao;
            this._parser       = parser;
            this._modFilter    = modFilter;
            this._stashManager = stashManager;
            _parsingService    = parsingService;
            _itemTagDao        = itemTagDao;

            _controller.BindCheckbox(cbMinimizeToTray);

            _controller.BindCheckbox(cbMergeDuplicates);
            _controller.BindCheckbox(cbTransferAnyMod);
            _controller.BindCheckbox(cbSecureTransfers);
            _controller.BindCheckbox(cbShowRecipesAsItems);
            _controller.BindCheckbox(cbAutoUpdateModSettings);
            _controller.BindCheckbox(cbAutoSearch);
            _controller.BindCheckbox(cbDisplaySkills);
            _controller.LoadDefaults();
        }
Exemple #2
0
        public MainWindow(
            CefBrowserHandler browser,
            IDatabaseItemDao databaseItemDao,
            IDatabaseItemStatDao databaseItemStatDao,
            IPlayerItemDao playerItemDao,
            IDatabaseSettingDao databaseSettingDao,
            IBuddyItemDao buddyItemDao,
            IBuddySubscriptionDao buddySubscriptionDao,
            ArzParser arzParser,
            IRecipeItemDao recipeItemDao,
            IItemSkillDao itemSkillDao
            )
        {
            _cefBrowserHandler = browser;
            InitializeComponent();
            FormClosing += MainWindow_FormClosing;
            Instance     = this;

            _reportUsageStatistics = new Stopwatch();
            _reportUsageStatistics.Start();

            _dynamicPacker        = new DynamicPacker(databaseItemStatDao);
            _databaseItemDao      = databaseItemDao;
            _databaseItemStatDao  = databaseItemStatDao;
            _playerItemDao        = playerItemDao;
            _databaseSettingDao   = databaseSettingDao;
            _buddyItemDao         = buddyItemDao;
            _buddySubscriptionDao = buddySubscriptionDao;
            _arzParser            = arzParser;
            _recipeParser         = new RecipeParser(recipeItemDao);
            _itemSkillDao         = itemSkillDao;
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "Main/UI";
                ExceptionReporter.EnableLogUnhandledOnThread();
            }

            ExceptionReporter.UrlCrashreport = "http://ribbs.dreamcrash.org/gddamage/crashreport.php";
            ExceptionReporter.UrlStats       = "http://ribbs.dreamcrash.org/gddamage/stats.php";
            ExceptionReporter.LogExceptions  = true;
            ExceptionReporter.Uuid           = GetUuid();
#if !DEBUG
#endif
            var      version   = Assembly.GetExecutingAssembly().GetName().Version;
            DateTime buildDate = new DateTime(2000, 1, 1)
                                 .AddDays(version.Build)
                                 .AddSeconds(version.Revision * 2);

            Logger.InfoFormat("Running version {0}.{1}.{2}.{3} from {4:dd/MM/yyyy}", version.Major, version.Minor, version.Build, version.Revision, buildDate);

            Logger.Info("Anonymous usage statistics and crash reports will be collected.");
            Logger.Info("Statistics and crash reports can be found at http://ribbs.dreamcrash.org/gddamage/logs.html");

            if (!File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Hook.dll")))
            {
                MessageBox.Show("Error - It appears that hook.dll is missing\nMost likely this installation has been corrupted.", "Error");
                return;
            }


            string url = Properties.Settings.Default.DarkModeEnabled
                    ? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "content", "darkmode.html")
                    : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "content", "index.html");

            if (!File.Exists(url))
            {
                MessageBox.Show("Error - It appears the stat view is missing", "Error");
            }

            bool showDevtools = args != null && args.Any(m => m.Contains("-devtools"));
            using (var browser = new CefBrowserHandler()) {
                WebViewJsPojo jsPojo = new WebViewJsPojo();
                browser.InitializeChromium(url, jsPojo, null);
                Application.Run(new Form1(browser, GetSettings(), showDevtools));
            }
        }
Exemple #5
0
 public MainWindow(
     CefBrowserHandler browser,
     IDatabaseItemDao databaseItemDao,
     IDatabaseItemStatDao databaseItemStatDao,
     IPlayerItemDao playerItemDao,
     IAzurePartitionDao azurePartitionDao,
     IDatabaseSettingDao databaseSettingDao,
     IBuddyItemDao buddyItemDao,
     IBuddySubscriptionDao buddySubscriptionDao,
     IRecipeItemDao recipeItemDao,
     IItemSkillDao itemSkillDao,
     IItemTagDao itemTagDao,
     ParsingService parsingService,
     AugmentationItemRepo augmentationItemRepo,
     SettingsService settingsService,
     GrimDawnDetector grimDawnDetector,
     IItemCollectionDao itemCollectionRepo
     )
 {
     _cefBrowserHandler = browser;
     InitializeComponent();
     FormClosing            += MainWindow_FormClosing;
     _automaticUpdateChecker = new AutomaticUpdateChecker(settingsService);
     _settingsController     = new SettingsController(settingsService);
     _dynamicPacker          = new DynamicPacker(databaseItemStatDao);
     _databaseItemDao        = databaseItemDao;
     _databaseItemStatDao    = databaseItemStatDao;
     _playerItemDao          = playerItemDao;
     _azurePartitionDao      = azurePartitionDao;
     _databaseSettingDao     = databaseSettingDao;
     _buddyItemDao           = buddyItemDao;
     _buddySubscriptionDao   = buddySubscriptionDao;
     _recipeParser           = new RecipeParser(recipeItemDao);
     _itemSkillDao           = itemSkillDao;
     _itemTagDao             = itemTagDao;
     _parsingService         = parsingService;
     _augmentationItemRepo   = augmentationItemRepo;
     _userFeedbackService    = new UserFeedbackService(_cefBrowserHandler);
     _settingsService        = settingsService;
     _grimDawnDetector       = grimDawnDetector;
     _itemCollectionRepo     = itemCollectionRepo;
 }
Exemple #6
0
 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;
 }
Exemple #7
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "Main/UI";
            }

            var      version   = Assembly.GetExecutingAssembly().GetName().Version;
            DateTime buildDate = new DateTime(2000, 1, 1)
                                 .AddDays(version.Build)
                                 .AddSeconds(version.Revision * 2);

            Logger.InfoFormat("Running version {0}.{1}.{2}.{3} from {4:dd/MM/yyyy}", version.Major, version.Minor, version.Build, version.Revision, buildDate);

            if (!File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Hook.dll")))
            {
                MessageBox.Show("Error - It appears that hook.dll is missing\nMost likely this installation has been corrupted.", "Error");
                return;
            }

            string url = Properties.Settings.Default.DarkModeEnabled
                    ? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "content", "darkmode.html")
                    : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "content", "index.html");

            if (!File.Exists(url))
            {
                MessageBox.Show("Error - It appears the stat view is missing", "Error");
            }

            bool showDevtools = args != null && args.Any(m => m.Contains("-devtools"));

            using (var browser = new CefBrowserHandler())
            {
                WebViewJsPojo jsPojo = new WebViewJsPojo();
                browser.InitializeChromium(url, jsPojo, null);
                Application.Run(new Form1(browser, GetSettings(), showDevtools));
            }
        }
Exemple #8
0
        public MainWindow(
            CefBrowserHandler browser,
            IDatabaseItemDao databaseItemDao,
            IDatabaseItemStatDao databaseItemStatDao,
            IPlayerItemDao playerItemDao,
            IAzurePartitionDao azurePartitionDao,
            IDatabaseSettingDao databaseSettingDao,
            IBuddyItemDao buddyItemDao,
            IBuddySubscriptionDao buddySubscriptionDao,
            ArzParser arzParser,
            IRecipeItemDao recipeItemDao,
            IItemSkillDao itemSkillDao,
            IItemTagDao itemTagDao,
            ParsingService parsingService,
            bool requestedDevtools,
            AugmentationItemRepo augmentationItemRepo
            )
        {
            _cefBrowserHandler = browser;
            InitializeComponent();
            FormClosing += MainWindow_FormClosing;

            _reportUsageStatistics = new Stopwatch();
            _reportUsageStatistics.Start();

            _dynamicPacker          = new DynamicPacker(databaseItemStatDao);
            _databaseItemDao        = databaseItemDao;
            _databaseItemStatDao    = databaseItemStatDao;
            _playerItemDao          = playerItemDao;
            _azurePartitionDao      = azurePartitionDao;
            _databaseSettingDao     = databaseSettingDao;
            _buddyItemDao           = buddyItemDao;
            _buddySubscriptionDao   = buddySubscriptionDao;
            _arzParser              = arzParser;
            _recipeParser           = new RecipeParser(recipeItemDao);
            _itemSkillDao           = itemSkillDao;
            _itemTagDao             = itemTagDao;
            _parsingService         = parsingService;
            this._requestedDevtools = requestedDevtools;
            _augmentationItemRepo   = augmentationItemRepo;
        }
Exemple #9
0
        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;
        }
Exemple #10
0
 public ItemTransferController(
     CefBrowserHandler browser,
     Action <string> feedback,
     Action <string> setTooltip,
     ISettingsReadController settingsController,
     SearchWindow searchWindow,
     DynamicPacker dynamicPacker,
     IPlayerItemDao playerItemDao,
     StashManager stashManager,
     ItemStatService itemStatService
     )
 {
     this._browser            = browser;
     this._setFeedback        = feedback;
     this._setTooltip         = setTooltip;
     this._settingsController = settingsController;
     this._searchWindow       = searchWindow;
     this._dynamicPacker      = dynamicPacker;
     this._dao             = playerItemDao;
     this._stashManager    = stashManager;
     this._itemStatService = itemStatService;
 }
Exemple #11
0
        public MainWindow(
            ServiceProvider serviceProvider,
            CefBrowserHandler browser,
            ParsingService parsingService
            )
        {
            this._serviceProvider = serviceProvider;
            _cefBrowserHandler    = browser;
            InitializeComponent();
            FormClosing += MainWindow_FormClosing;

            _minimizeToTrayHandler = new MinimizeToTrayHandler(this, notifyIcon1, serviceProvider.Get <SettingsService>());

            var settingsService = _serviceProvider.Get <SettingsService>();

            _automaticUpdateChecker = new AutomaticUpdateChecker(settingsService);
            _settingsController     = new SettingsController(settingsService);
            _dynamicPacker          = new DynamicPacker(serviceProvider.Get <IDatabaseItemStatDao>());
            _recipeParser           = new RecipeParser(serviceProvider.Get <IRecipeItemDao>());
            _parsingService         = parsingService;
            _userFeedbackService    = new UserFeedbackService(_cefBrowserHandler);
        }
Exemple #12
0
        private static void Run(string[] args, ThreadExecuter threadExecuter)
        {
            var factory = new SessionFactory();

            // Settings should be upgraded early, it contains the language pack etc and some services depends on settings.
            var            settingsService = StartupService.LoadSettingsService();
            IPlayerItemDao playerItemDao   = new PlayerItemRepo(threadExecuter, factory);

            IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory);

            RuntimeSettings.InitializeLanguage(settingsService.GetLocal().LocalizationFile, databaseItemDao.GetTagDictionary());
            DumpTranslationTemplate();

            threadExecuter.Execute(() => new MigrationHandler(factory).Migrate());

            IDatabaseSettingDao databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory);

            LoadUuid(databaseSettingDao);
            var azurePartitionDao = new AzurePartitionRepo(threadExecuter, factory);
            IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory);
            IItemTagDao          itemTagDao          = new ItemTagRepo(threadExecuter, factory);


            IBuddyItemDao         buddyItemDao         = new BuddyItemRepo(threadExecuter, factory);
            IBuddySubscriptionDao buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory);
            IRecipeItemDao        recipeItemDao        = new RecipeItemRepo(threadExecuter, factory);
            IItemSkillDao         itemSkillDao         = new ItemSkillRepo(threadExecuter, factory);
            AugmentationItemRepo  augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory));
            var grimDawnDetector = new GrimDawnDetector(settingsService);

            Logger.Debug("Updating augment state..");
            augmentationItemRepo.UpdateState();

            // TODO: GD Path has to be an input param, as does potentially mods.
            ParsingService parsingService = new ParsingService(itemTagDao, null, databaseItemDao, databaseItemStatDao, itemSkillDao, settingsService.GetLocal().LocalizationFile);

            StartupService.PrintStartupInfo(factory, settingsService);



            if (RuntimeSettings.Language is EnglishLanguage language)
            {
                foreach (var tag in itemTagDao.GetClassItemTags())
                {
                    language.SetTagIfMissing(tag.Tag, tag.Name);
                }
            }

            if (args != null && args.Any(m => m.Contains("-logout")))
            {
                Logger.Info("Started with -logout specified, logging out of online backups.");
                settingsService.GetPersistent().AzureAuthToken = null;
            }

            using (CefBrowserHandler browser = new CefBrowserHandler())
            {
                _mw = new MainWindow(browser,
                                     databaseItemDao,
                                     databaseItemStatDao,
                                     playerItemDao,
                                     azurePartitionDao,
                                     databaseSettingDao,
                                     buddyItemDao,
                                     buddySubscriptionDao,
                                     recipeItemDao,
                                     itemSkillDao,
                                     itemTagDao,
                                     parsingService,
                                     augmentationItemRepo,
                                     settingsService,
                                     grimDawnDetector
                                     );

                Logger.Info("Checking for database updates..");

                StartupService.PerformIconCheck(databaseSettingDao, grimDawnDetector);
                playerItemDao.DeleteDuplidates();

                _mw.Visible = false;
                if (new DonateNagScreen(settingsService).CanNag)
                {
                    Application.Run(new DonateNagScreen(settingsService));
                }

                Logger.Info("Running the main application..");

                StartupService.PerformGrimUpdateCheck(settingsService);
                Application.Run(_mw);
            }

            Logger.Info("Application ended.");
        }
Exemple #13
0
        private static void Run(string[] args, ThreadExecuter threadExecuter)
        {
            var factory = new SessionFactory();

            // Settings should be upgraded early, it contains the language pack etc and some services depends on settings.
            IPlayerItemDao playerItemDao     = new PlayerItemRepo(threadExecuter, factory);
            var            statUpgradeNeeded = UpgradeSettings();

            // X
            IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory);

            GlobalSettings.InitializeLanguage(Properties.Settings.Default.LocalizationFile, databaseItemDao.GetTagDictionary());
            DumpTranslationTemplate();

            // Prohibited for now
            Properties.Settings.Default.InstaTransfer = false;
            Properties.Settings.Default.Save();
            threadExecuter.Execute(() => new MigrationHandler(factory).Migrate());

            IDatabaseSettingDao databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory);

            LoadUuid(databaseSettingDao);
            var azurePartitionDao = new AzurePartitionRepo(threadExecuter, factory);
            IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory);
            IItemTagDao          itemTagDao          = new ItemTagRepo(threadExecuter, factory);


#if !DEBUG
            if (statUpgradeNeeded)
            {
                // If we don't also update item stats, a lot of whining will ensue.
                // This accounts for most database updates (new fields added that needs to get populated etc)
                UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(playerItemDao);
                x.ShowDialog();
            }
#endif


            IBuddyItemDao         buddyItemDao         = new BuddyItemRepo(threadExecuter, factory);
            IBuddySubscriptionDao buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory);
            IRecipeItemDao        recipeItemDao        = new RecipeItemRepo(threadExecuter, factory);
            IItemSkillDao         itemSkillDao         = new ItemSkillRepo(threadExecuter, factory);
            ArzParser             arzParser            = new ArzParser(databaseSettingDao);
            AugmentationItemRepo  augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory));

            Logger.Debug("Updating augment state..");
            augmentationItemRepo.UpdateState();

            // TODO: GD Path has to be an input param, as does potentially mods.
            ParsingService parsingService = new ParsingService(itemTagDao, null, databaseItemDao, databaseItemStatDao, itemSkillDao, Properties.Settings.Default.LocalizationFile);

            PrintStartupInfo(factory);



            if (GlobalSettings.Language is EnglishLanguage language)
            {
                foreach (var tag in itemTagDao.GetClassItemTags())
                {
                    language.SetTagIfMissing(tag.Tag, tag.Name);
                }
            }

            if (args != null && args.Any(m => m.Contains("-logout")))
            {
                Logger.Info("Started with -logout specified, logging out of online backups.");
                Settings.Default.AzureAuthToken = null;
                Settings.Default.Save();
            }

            // TODO: Urgent, introduce DI and have MainWindow receive premade objects, not create them itself.
            using (CefBrowserHandler browser = new CefBrowserHandler())
            {
                _mw = new MainWindow(browser,
                                     databaseItemDao,
                                     databaseItemStatDao,
                                     playerItemDao,
                                     azurePartitionDao,
                                     databaseSettingDao,
                                     buddyItemDao,
                                     buddySubscriptionDao,
                                     arzParser,
                                     recipeItemDao,
                                     itemSkillDao,
                                     itemTagDao,
                                     parsingService,
                                     augmentationItemRepo
                                     );

                Logger.Info("Checking for database updates..");


                // Load the GD database (or mod, if any)
                string GDPath = databaseSettingDao.GetCurrentDatabasePath();
                if (string.IsNullOrEmpty(GDPath) || !Directory.Exists(GDPath))
                {
                    GDPath = GrimDawnDetector.GetGrimLocation();
                }

                if (!string.IsNullOrEmpty(GDPath) && Directory.Exists(GDPath))
                {
                    var numFiles         = Directory.GetFiles(GlobalPaths.StorageFolder).Length;
                    int numFilesExpected = 2100;
                    if (Directory.Exists(Path.Combine(GDPath, "gdx2")))
                    {
                        numFilesExpected += 580;
                    }
                    if (Directory.Exists(Path.Combine(GDPath, "gdx1")))
                    {
                        numFilesExpected += 890;
                    }

                    if (numFiles < numFilesExpected)
                    {
                        Logger.Debug($"Only found {numFiles} in storage, expected ~{numFilesExpected}+, parsing item icons.");
                        ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(GDPath));
                    }
                }
                else
                {
                    Logger.Warn("Could not find the Grim Dawn install location");
                }

                playerItemDao.UpdateHardcoreSettings();

                _mw.Visible = false;
                if (DonateNagScreen.CanNag)
                {
                    Application.Run(new DonateNagScreen());
                }

                Logger.Info("Running the main application..");


                Application.Run(_mw);
            }

            Logger.Info("Application ended.");
        }
Exemple #14
0
        private static void Run(string[] args, ThreadExecuter threadExecuter)
        {
            var dialect         = SqlDialect.Sqlite;
            var factory         = new SessionFactory(dialect);
            var serviceProvider = ServiceProvider.Initialize(threadExecuter, dialect);

            var settingsService      = serviceProvider.Get <SettingsService>();
            var databaseItemDao      = serviceProvider.Get <IDatabaseItemDao>();
            var augmentationItemRepo = serviceProvider.Get <IAugmentationItemDao>();

            RuntimeSettings.InitializeLanguage(settingsService.GetLocal().LocalizationFile, databaseItemDao.GetTagDictionary());
            DumpTranslationTemplate();

            Logger.Debug("Executing DB migrations..");
            threadExecuter.Execute(() => new MigrationHandler(factory).Migrate());

            Logger.Debug("Loading UUID");
            LoadUuid(settingsService);

            Logger.Debug("Updating augment state..");
            augmentationItemRepo.UpdateState();

            var            itemTagDao          = serviceProvider.Get <IItemTagDao>();
            var            databaseItemStatDao = serviceProvider.Get <IDatabaseItemStatDao>();
            var            itemSkillDao        = serviceProvider.Get <IItemSkillDao>();
            ParsingService parsingService      = new ParsingService(itemTagDao, null, databaseItemDao, databaseItemStatDao, itemSkillDao, settingsService.GetLocal().LocalizationFile);

            StartupService.PrintStartupInfo(factory, settingsService, dialect);


            // TODO: Offload to the new language loader
            if (RuntimeSettings.Language is EnglishLanguage language)
            {
                foreach (var tag in itemTagDao.GetClassItemTags())
                {
                    language.SetTagIfMissing(tag.Tag, tag.Name);
                }
            }

            using (CefBrowserHandler browser = new CefBrowserHandler(settingsService)) {
                _mw = new MainWindow(
                    serviceProvider,
                    browser,
                    parsingService
                    );

                Logger.Info("Checking for database updates..");

                var grimDawnDetector = serviceProvider.Get <GrimDawnDetector>();
                StartupService.PerformIconCheck(grimDawnDetector, settingsService);


                try {
                    var playerItemDao = serviceProvider.Get <IPlayerItemDao>();
                    playerItemDao.DeleteDuplicates();
                }
                catch (Exception ex) {
                    Logger.Warn("Something went terribly wrong trying to ensure no duplicate items are found, however we'll just ignore it instead of blocking you access to your items.. sigh..", ex);
                }

                _mw.Visible = false;
                if (new DonateNagScreen(settingsService).CanNag)
                {
                    Application.Run(new DonateNagScreen(settingsService));
                }

                Logger.Info("Running the main application..");

                StartupService.PerformGrimUpdateCheck(settingsService);
                Application.Run(_mw);
            }

            Logger.Info("Application ended.");
        }
Exemple #15
0
        private static void Run(string[] args, ThreadExecuter threadExecuter)
        {
            var factory = new SessionFactory();

            // Settings should be upgraded early, it contains the language pack etc and some services depends on settings.
            IPlayerItemDao playerItemDao = new PlayerItemRepo(threadExecuter, factory);

            UpgradeSettings(playerItemDao);

            // X
            IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory);

            GlobalSettings.InitializeLanguage(Properties.Settings.Default.LocalizationFile, databaseItemDao.GetTagDictionary());

            // Prohibited for now
            Properties.Settings.Default.InstaTransfer = false;
            Properties.Settings.Default.Save();
            threadExecuter.Execute(() => new MigrationHandler(factory).Migrate());

            IDatabaseSettingDao databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory);

            LoadUuid(databaseSettingDao);
            var azurePartitionDao = new AzurePartitionRepo(threadExecuter, factory);
            IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory);
            IItemTagDao          itemTagDao          = new ItemTagRepo(threadExecuter, factory);



            IBuddyItemDao         buddyItemDao         = new BuddyItemRepo(threadExecuter, factory);
            IBuddySubscriptionDao buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory);
            IRecipeItemDao        recipeItemDao        = new RecipeItemRepo(threadExecuter, factory);
            IItemSkillDao         itemSkillDao         = new ItemSkillRepo(threadExecuter, factory);
            ArzParser             arzParser            = new ArzParser(databaseSettingDao);
            AugmentationItemRepo  augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory));

            Logger.Debug("Updating augment state..");
            augmentationItemRepo.UpdateState();

            // TODO: GD Path has to be an input param, as does potentially mods.
            ParsingService parsingService = new ParsingService(itemTagDao, null, databaseItemDao, databaseItemStatDao, itemSkillDao, Properties.Settings.Default.LocalizationFile);

            PrintStartupInfo(factory);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Logger.Info("Visual styles enabled..");

            if (GlobalSettings.Language is EnglishLanguage language)
            {
                foreach (var tag in itemTagDao.GetClassItemTags())
                {
                    language.SetTagIfMissing(tag.Tag, tag.Name);
                }
            }


            bool showDevtools = args != null && args.Any(m => m.Contains("-devtools"));

            // TODO: Urgent, introduce DI and have MainWindow receive premade objects, not create them itself.
            using (CefBrowserHandler browser = new CefBrowserHandler()) {
                _mw = new MainWindow(browser,
                                     databaseItemDao,
                                     databaseItemStatDao,
                                     playerItemDao,
                                     azurePartitionDao,
                                     databaseSettingDao,
                                     buddyItemDao,
                                     buddySubscriptionDao,
                                     arzParser,
                                     recipeItemDao,
                                     itemSkillDao,
                                     itemTagDao,
                                     parsingService,
                                     showDevtools,
                                     augmentationItemRepo
                                     );

                Logger.Info("Checking for database updates..");


                // Load the GD database (or mod, if any)
                string GDPath = databaseSettingDao.GetCurrentDatabasePath();
                if (string.IsNullOrEmpty(GDPath) || !Directory.Exists(GDPath))
                {
                    GDPath = GrimDawnDetector.GetGrimLocation();
                }

                if (!string.IsNullOrEmpty(GDPath) && Directory.Exists(GDPath))
                {
                    var numFiles = Directory.GetFiles(GlobalPaths.StorageFolder).Length;
                    if (numFiles < 2000)
                    {
                        Logger.Debug($"Only found {numFiles} in storage, expected ~3200+, parsing item icons.");
                        ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(GDPath));
                    }
                }
                else
                {
                    Logger.Warn("Could not find the Grim Dawn install location");
                }

                playerItemDao.UpdateHardcoreSettings();

                _mw.Visible = false;
                if (DonateNagScreen.CanNag)
                {
                    Application.Run(new DonateNagScreen());
                }

                Logger.Info("Running the main application..");


                Application.Run(_mw);
            }

            Logger.Info("Application ended.");
        }
Exemple #16
0
 public WebView(CefBrowserHandler browser)
 {
     InitializeComponent();
     this._browser = browser;
 }
Exemple #17
0
        public Form1(CefBrowserHandler browser, AppSettings appSettings, bool showDevtools)
        {
            InitializeComponent();
            _browser             = browser;
            _appSettings         = appSettings;
            _generalStateService = new GeneralStateService(_appSettings);
            _showDevtools        = showDevtools;

            _messageProcessorCore           = new MessageProcessorCore(_damageParsingService, _positionTrackerService, _generalStateService, _appSettings);
            _statisticsService              = new StatisticsService(_damageParsingService);
            _browser.JsPojo.OnSave         += JsPojoOnOnSave;
            _browser.JsPojo.OnSetLightMode += (sender, args) => {
                bool isDarkMode = (args as LightModeArgument)?.IsDarkMode ?? false;
                Properties.Settings.Default.DarkModeEnabled = isDarkMode;
                Properties.Settings.Default.Save();
            };
            _browser.JsPojo.OnLog += (sender, args) => {
                string data = (args as SaveParseArgument)?.Data;
                Logger.Warn(data);
                ExceptionReporter.ReportIssue(data);
            };

            _nameSuggestionService         = new NameSuggestionService(GlobalSettings.BineroHost);
            _cSharpJsStateMapper           = new CSharpJsStateMapper(_browser, _statisticsService, _generalStateService, _positionTrackerService);
            _browser.JsPojo.OnRequestData += (sender, _args) => {
                RequestDataArgument args = _args as RequestDataArgument;
                long start;
                if (long.TryParse(args.TimestampStart, out start))
                {
                    long end;
                    if (long.TryParse(args.TimestampEnd, out end))
                    {
                        _cSharpJsStateMapper.RequestData(args.Type, start, end, args.EntityId, args.Callback);
                    }
                    else
                    {
                        Logger.Warn($"Could not parse timestamp {args.TimestampEnd} received for {args.Type}");
                    }
                }
                else
                {
                    Logger.Warn($"Could not parse timestamp {args.TimestampStart} received for {args.Type}");
                }
            };



#if !DEBUG
            webViewPanel.Parent.Controls.Remove(webViewPanel);
            Controls.Clear();
            if (_showDevtools)
            {
                Controls.Add(btnShowDevtools);
            }
            Controls.Add(webViewPanel);

            bool itemAssistantInstalled = Directory.Exists(GlobalSettings.ItemAssistantFolder) || new Random().Next(10) < 8;
            if (itemAssistantInstalled)
            {
                webViewPanel.Location = new Point {
                    X = 0, Y = 0
                };
                webViewPanel.Width  = this.ClientSize.Width;
                webViewPanel.Height = this.ClientSize.Height;
            }
            else
            {
                var labels = new[] {
                    "Is your stash full? Try Item Assistant!",
                    "Need a larger stash? Try Item Assistant!",
                    "Having trouble finding space for all your loot? Try Item Assistant!",
                    "Having trouble finding space for all your items? Try Item Assistant!",
                    "Need extra item storage? Try Item Assistant!",
                };
                var idx = new Random().Next(0, labels.Length);
                linkItemAssistant.Text = labels[idx];


                const int margin = 5;
                webViewPanel.Location = new Point {
                    X = 0, Y = linkItemAssistant.Height + margin * 2
                };
                webViewPanel.Width  = this.ClientSize.Width;
                webViewPanel.Height = this.ClientSize.Height - linkItemAssistant.Height - margin * 2;
                Controls.Add(linkItemAssistant);
            }
#else
            linkItemAssistant.Hide();
#endif



            _timerReportUsage = new System.Timers.Timer();
            _timerReportUsage.Start();
            _timerReportUsage.Elapsed += (a1, a2) => {
                if (Thread.CurrentThread.Name == null)
                {
                    Thread.CurrentThread.Name = "CleanupThread";
                }

                _damageParsingService.Cleanup();
            };
            _timerReportUsage.Interval  = 60 * 1000 * 5;
            _timerReportUsage.AutoReset = true;
            _timerReportUsage.Start();
        }
Exemple #18
0
        private static void Run(ThreadExecuter threadExecuter)
        {
            var factory = new SessionFactory();

            // Prohibited for now
            Properties.Settings.Default.InstaTransfer = false;
            Properties.Settings.Default.Save();

            new MigrationHandler(factory).Migrate();
            IDatabaseSettingDao databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory);

            LoadUuid(databaseSettingDao);
            IPlayerItemDao       playerItemDao       = new PlayerItemRepo(threadExecuter, factory);
            IDatabaseItemDao     databaseItemDao     = new DatabaseItemRepo(threadExecuter, factory);
            IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory);

            IBuddyItemDao         buddyItemDao         = new BuddyItemRepo(threadExecuter, factory);
            IBuddySubscriptionDao buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory);
            IRecipeItemDao        recipeItemDao        = new RecipeItemRepo(threadExecuter, factory);
            IItemSkillDao         itemSkillDao         = new ItemSkillRepo(threadExecuter, factory);
            ArzParser             arzParser            = new ArzParser(databaseItemDao, databaseItemStatDao, databaseSettingDao, itemSkillDao);

            PrintStartupInfo(factory);



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Logger.Info("Visual styles enabled..");
            UpgradeSettings(playerItemDao);

            var language = GlobalSettings.Language as StatTranslator.EnglishLanguage;

            if (language != null)
            {
                foreach (var tag in databaseItemDao.GetClassItemTags())
                {
                    language.SetTagIfMissing(tag.Tag, tag.Name);
                }
            }


            using (CefBrowserHandler browser = new CefBrowserHandler()) {
                _mw = new MainWindow(browser,
                                     databaseItemDao,
                                     databaseItemStatDao,
                                     playerItemDao,
                                     databaseSettingDao,
                                     buddyItemDao,
                                     buddySubscriptionDao,
                                     arzParser,
                                     recipeItemDao,
                                     itemSkillDao
                                     );

                Logger.Info("Checking for database updates..");


                // Load the GD database (or mod, if any)
                string GDPath = databaseSettingDao.GetCurrentDatabasePath();
                bool   isVanilla;
                if (string.IsNullOrEmpty(GDPath) || !Directory.Exists(GDPath))
                {
                    GDPath    = GrimDawnDetector.GetGrimLocation();
                    isVanilla = true;
                }
                else
                {
                    isVanilla = GDPath.Equals(GrimDawnDetector.GetGrimLocation());
                }

                if (!string.IsNullOrEmpty(GDPath) && Directory.Exists(GDPath))
                {
                    if (arzParser.NeedUpdate(GDPath))
                    {
                        ParsingDatabaseScreen parserUI = new ParsingDatabaseScreen(
                            databaseSettingDao,
                            arzParser,
                            GDPath,
                            Properties.Settings.Default.LocalizationFile,
                            false,
                            !isVanilla);
                        parserUI.ShowDialog();
                    }

                    if (playerItemDao.RequiresStatUpdate())
                    {
                        UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(playerItemDao);
                        x.ShowDialog();
                    }



                    var numFiles = Directory.GetFiles(GlobalPaths.StorageFolder).Length;
                    if (numFiles < 2000)
                    {
                        Logger.Debug($"Only found {numFiles} in storage, expected ~3200+, parsing item icons.");
                        ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(GDPath));
                    }
                }
                else
                {
                    Logger.Warn("Could not find the Grim Dawn install location");
                }

                playerItemDao.UpdateHardcoreSettings();

                _mw.Visible = false;
                if (DonateNagScreen.CanNag)
                {
                    Application.Run(new DonateNagScreen());
                }

                Logger.Info("Running the main application..");


                Application.Run(_mw);
            }

            Logger.Info("Application ended.");
        }